xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/int_util.h (revision 162ae9c834f6d9f9cb443bd62cceb23e0b5fef48)
1 //===-- int_util.h - internal utility functions ---------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is not part of the interface of this library.
10 //
11 // This file defines non-inline utilities which are available for use in the
12 // library. The function definitions themselves are all contained in int_util.c
13 // which will always be compiled into any compiler-rt library.
14 //
15 //===----------------------------------------------------------------------===//
16 
17 #ifndef INT_UTIL_H
18 #define INT_UTIL_H
19 
20 /// \brief Trigger a program abort (or panic for kernel code).
21 #define compilerrt_abort() __compilerrt_abort_impl(__FILE__, __LINE__, __func__)
22 
23 NORETURN void __compilerrt_abort_impl(const char *file, int line,
24                                       const char *function);
25 
26 #define COMPILE_TIME_ASSERT(expr) COMPILE_TIME_ASSERT1(expr, __COUNTER__)
27 #define COMPILE_TIME_ASSERT1(expr, cnt) COMPILE_TIME_ASSERT2(expr, cnt)
28 #define COMPILE_TIME_ASSERT2(expr, cnt)                                        \
29   typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
30 
31 #endif // INT_UTIL_H
32