Make UEFI boot-platform build again
[haiku.git] / headers / posix / assert.h
blob628cd4c843c24f410b8b8af24f2b2338cf740d1f
1 /*
2 * Copyright 2004-2015 Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
6 /* Include guards are only on part of the file, as assert.h is required
7 to support being included multiple times.
9 E.g. the following is required to be valid:
11 #undef NDEBUG
12 #include <assert.h>
14 assert(0); // this assertion will be triggered
16 #define NDEBUG
17 #include <assert.h>
19 assert(0); // this assertion will not be triggered
22 #undef assert
24 #ifndef NDEBUG
25 /* defining NDEBUG disables assert() functionality */
27 #ifndef _ASSERT_H_
28 #define _ASSERT_H_
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 extern void __assert_fail(const char *assertion, const char *file,
35 unsigned int line, const char *function)
36 __attribute__ ((noreturn));
38 extern void __assert_perror_fail(int error, const char *file,
39 unsigned int line, const char *function)
40 __attribute__ ((noreturn));
42 #ifdef __cplusplus
44 #endif
46 #endif /* !_ASSERT_H_ */
48 #define assert(assertion) \
49 ((assertion) ? (void)0 : __assert_fail(#assertion, __FILE__, __LINE__, __PRETTY_FUNCTION__))
51 #else /* NDEBUG */
52 # define assert(condition) ((void)0)
53 #endif