]>
Commit | Line | Data |
---|---|---|
3dc31f14 RS |
1 | /* Allow this file to be included multiple times |
2 | with different settings of NDEBUG. */ | |
3 | #undef assert | |
4 | #undef __assert | |
5 | ||
6 | #ifdef NDEBUG | |
7 | #define assert(ignore) ((void) 0) | |
8 | #else | |
9 | ||
10 | #ifndef __GNUC__ | |
11 | ||
12 | #define assert(expression) \ | |
13 | ((void) ((expression) ? 0 : __assert (expression, __FILE__, __LINE__))) | |
14 | ||
15 | #define __assert(expression, file, lineno) \ | |
252043ee | 16 | (printf ("%s:%u: failed assertion\n", file, lineno), \ |
3dc31f14 RS |
17 | abort (), 0) |
18 | ||
19 | #else | |
3dc31f14 | 20 | |
b076a285 | 21 | #if defined(__STDC__) || defined (__cplusplus) |
3dc31f14 | 22 | |
5faca127 | 23 | /* Defined in libgcc.a */ |
b076a285 RS |
24 | #ifdef __cplusplus |
25 | extern "C" { | |
19ac2770 RK |
26 | extern void __eprintf (const char *, const char *, unsigned, const char *) |
27 | __attribute__ ((noreturn)); | |
b076a285 RS |
28 | } |
29 | #else | |
19ac2770 RK |
30 | extern void __eprintf (const char *, const char *, unsigned, const char *) |
31 | __attribute__ ((noreturn)); | |
b076a285 | 32 | #endif |
e071c188 | 33 | |
3dc31f14 RS |
34 | #define assert(expression) \ |
35 | ((void) ((expression) ? 0 : __assert (#expression, __FILE__, __LINE__))) | |
36 | ||
37 | #define __assert(expression, file, line) \ | |
252043ee | 38 | (__eprintf ("%s:%u: failed assertion `%s'\n", \ |
3dc31f14 RS |
39 | file, line, expression), 0) |
40 | ||
b076a285 | 41 | #else /* no __STDC__ and not C++; i.e. -traditional. */ |
3dc31f14 | 42 | |
19ac2770 | 43 | extern void __eprintf () __attribute__ ((noreturn)); /* Defined in libgcc.a */ |
e071c188 | 44 | |
3dc31f14 RS |
45 | #define assert(expression) \ |
46 | ((void) ((expression) ? 0 : __assert (expression, __FILE__, __LINE__))) | |
47 | ||
48 | #define __assert(expression, file, lineno) \ | |
252043ee | 49 | (__eprintf ("%s:%u: failed assertion `%s'\n", \ |
3dc31f14 RS |
50 | file, lineno, "expression"), 0) |
51 | ||
b076a285 | 52 | #endif /* no __STDC__ and not C++; i.e. -traditional. */ |
3dc31f14 RS |
53 | #endif /* no __GNU__; i.e., /bin/cc. */ |
54 | #endif |