blob: 846393081d83ae58d300e51f7f3edee0d19f0ceb [file] [log] [blame]
Daniel Dunbar401f6932011-11-16 01:19:19 +00001/* ===-- int_util.h - internal utility functions ----------------------------===
2 *
Chandler Carruth7a739a02019-01-19 10:56:40 +00003 * 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
Daniel Dunbar401f6932011-11-16 01:19:19 +00006 *
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
18#ifndef INT_UTIL_H
19#define INT_UTIL_H
20
21/** \brief Trigger a program abort (or panic for kernel code). */
Richard Smith6b0b63e2018-09-08 00:17:37 +000022#define compilerrt_abort() __compilerrt_abort_impl(__FILE__, __LINE__, __func__)
Nick Kledzik1f4f7b52012-02-03 23:10:55 +000023
Richard Smith6b0b63e2018-09-08 00:17:37 +000024NORETURN void __compilerrt_abort_impl(const char *file, int line,
25 const char *function);
Daniel Dunbar401f6932011-11-16 01:19:19 +000026
Chih-Hung Hsiehf475acf2015-08-31 17:14:07 +000027#define COMPILE_TIME_ASSERT(expr) COMPILE_TIME_ASSERT1(expr, __COUNTER__)
28#define COMPILE_TIME_ASSERT1(expr, cnt) COMPILE_TIME_ASSERT2(expr, cnt)
Saleem Abdulrasool08b610e2015-10-06 04:33:05 +000029#define COMPILE_TIME_ASSERT2(expr, cnt) \
30 typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
Chih-Hung Hsiehf475acf2015-08-31 17:14:07 +000031
Daniel Dunbar401f6932011-11-16 01:19:19 +000032#endif /* INT_UTIL_H */