32 lines
816 B
C
32 lines
816 B
C
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef _ASSERT_H
|
|
#define _ASSERT_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
void __assert_fail(const char *expr, const char *file, unsigned int line,
|
|
const char *func) __attribute__((noreturn));
|
|
|
|
#ifdef NDEBUG
|
|
# define assert(x) ((void)0)
|
|
#else
|
|
# define assert(x) ((x) ? (void)0 : \
|
|
__assert_fail(#x, __FILE__, __LINE__, __func__))
|
|
#endif
|
|
|
|
// C11 static_assert — clang implements `_Static_assert` as a keyword.
|
|
// The macro spelling allows portable code that uses `static_assert(...)`.
|
|
#ifndef __cplusplus
|
|
# define static_assert _Static_assert
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|