Fix some copyright lines in folly/lang/
[folly.git] / folly / lang / SafeAssert.cpp
1 /*
2  * Copyright 2013-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <folly/lang/SafeAssert.h>
18
19 #include <folly/Conv.h>
20 #include <folly/FileUtil.h>
21
22 namespace folly { namespace detail {
23
24 namespace {
25 void writeStderr(const char* s, size_t len) {
26   writeFull(STDERR_FILENO, s, len);
27 }
28 void writeStderr(const char* s) {
29   writeStderr(s, strlen(s));
30 }
31 } // namespace
32
33 void assertionFailure(const char* expr, const char* msg, const char* file,
34                       unsigned int line, const char* function) {
35   writeStderr("\n\nAssertion failure: ");
36   writeStderr(expr + 1, strlen(expr) - 2);
37   writeStderr("\nMessage: ");
38   writeStderr(msg);
39   writeStderr("\nFile: ");
40   writeStderr(file);
41   writeStderr("\nLine: ");
42   char buf[20];
43   uint32_t n = uint64ToBufferUnsafe(line, buf);
44   writeFull(STDERR_FILENO, buf, n);
45   writeStderr("\nFunction: ");
46   writeStderr(function);
47   writeStderr("\n");
48   fsyncNoInt(STDERR_FILENO);
49   abort();
50 }
51
52 } // namespace detail
53 } // namespace folly