diff options
author | YamaArashi <shadow962@live.com> | 2016-01-06 01:47:28 -0800 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2016-01-06 01:47:28 -0800 |
commit | be8b04496302184c6e8f04d6179f9c3afc50aeb6 (patch) | |
tree | 726e2468c0c07add773c0dbd86ab6386844259ae /gcc/assert.h |
initial commit
Diffstat (limited to 'gcc/assert.h')
-rwxr-xr-x | gcc/assert.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/gcc/assert.h b/gcc/assert.h new file mode 100755 index 0000000..ecc02ee --- /dev/null +++ b/gcc/assert.h @@ -0,0 +1,54 @@ +/* Allow this file to be included multiple times + with different settings of NDEBUG. */ +#undef assert +#undef __assert + +#ifdef NDEBUG +#define assert(ignore) ((void) 0) +#else + +#ifndef __GNUC__ + +#define assert(expression) \ + ((void) ((expression) ? 0 : __assert (expression, __FILE__, __LINE__))) + +#define __assert(expression, file, lineno) \ + (printf ("%s:%u: failed assertion\n", file, lineno), \ + abort (), 0) + +#else + +#if defined(__STDC__) || defined (__cplusplus) + +/* Defined in libgcc.a */ +#ifdef __cplusplus +extern "C" { +extern void __eprintf (const char *, const char *, unsigned, const char *) + __attribute__ ((noreturn)); +} +#else +extern void __eprintf (const char *, const char *, unsigned, const char *) + __attribute__ ((noreturn)); +#endif + +#define assert(expression) \ + ((void) ((expression) ? 0 : __assert (#expression, __FILE__, __LINE__))) + +#define __assert(expression, file, line) \ + (__eprintf ("%s:%u: failed assertion `%s'\n", \ + file, line, expression), 0) + +#else /* no __STDC__ and not C++; i.e. -traditional. */ + +extern void __eprintf () __attribute__ ((noreturn)); /* Defined in libgcc.a */ + +#define assert(expression) \ + ((void) ((expression) ? 0 : __assert (expression, __FILE__, __LINE__))) + +#define __assert(expression, file, lineno) \ + (__eprintf ("%s:%u: failed assertion `%s'\n", \ + file, lineno, "expression"), 0) + +#endif /* no __STDC__ and not C++; i.e. -traditional. */ +#endif /* no __GNU__; i.e., /bin/cc. */ +#endif |