diff options
author | davidcunado-arm <david.cunado@arm.com> | 2017-04-21 09:37:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-21 09:37:36 +0100 |
commit | 2edf64827f2fc807c54b9cf79fba3d112885a890 (patch) | |
tree | a3f11c9ec580209e36e6d2508fd703ed17bc7297 /include/lib/stdlib/assert.h | |
parent | 85aa186ba11f49efef8e859cf5cab737c3ade26b (diff) | |
parent | aa61368eb554e9910c503f78560153805a2d6859 (diff) |
Merge pull request #906 from antonio-nino-diaz-arm/an/asserts-release
Add `ENABLE_ASSERTIONS` build option
Diffstat (limited to 'include/lib/stdlib/assert.h')
-rw-r--r-- | include/lib/stdlib/assert.h | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/include/lib/stdlib/assert.h b/include/lib/stdlib/assert.h index 5621f8ca..1bcd1ead 100644 --- a/include/lib/stdlib/assert.h +++ b/include/lib/stdlib/assert.h @@ -34,30 +34,27 @@ * @(#)assert.h 8.2 (Berkeley) 1/21/94 * $FreeBSD$ */ - -#include <sys/cdefs.h> - /* - * Unlike other ANSI header files, <assert.h> may usefully be included - * multiple times, with and without NDEBUG defined. + * Portions copyright (c) 2017, ARM Limited and Contributors. + * All rights reserved. */ -#undef assert -#undef _assert +#ifndef _ASSERT_H_ +#define _ASSERT_H_ -#ifdef NDEBUG -#define assert(e) ((void)0) -#define _assert(e) ((void)0) -#else -#define _assert(e) assert(e) +#include <sys/cdefs.h> +#if ENABLE_ASSERTIONS +#define _assert(e) assert(e) #define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \ __LINE__, #e)) -#endif /* NDEBUG */ +#else +#define assert(e) ((void)0) +#define _assert(e) ((void)0) +#endif /* ENABLE_ASSERTIONS */ -#ifndef _ASSERT_H_ -#define _ASSERT_H_ __BEGIN_DECLS void __assert(const char *, const char *, int, const char *) __dead2; __END_DECLS + #endif /* !_ASSERT_H_ */ |