diff options
author | Neal H. Walfield <neal@gnu.org> | 2009-01-19 23:25:55 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@gnu.org> | 2009-01-19 23:34:13 +0100 |
commit | a4f3c0f4d96733d81919e1a3c0164dbf56efceb6 (patch) | |
tree | a9d6199b3c9ee307b53760dfcee6697ddbad9d24 | |
parent | 6c4e52ff849c34ac9ae2fd97bf7e5e56396f6138 (diff) |
2009-01-19 Neal H. Walfield <neal@gnu.org>
* assert.h (build_assert): Use gnulib's version.
-rw-r--r-- | libc-parts/ChangeLog | 4 | ||||
-rw-r--r-- | libc-parts/assert.h | 20 |
2 files changed, 23 insertions, 1 deletions
diff --git a/libc-parts/ChangeLog b/libc-parts/ChangeLog index 8e646f6..b1813c0 100644 --- a/libc-parts/ChangeLog +++ b/libc-parts/ChangeLog @@ -1,3 +1,7 @@ +2009-01-19 Neal H. Walfield <neal@gnu.org> + + * assert.h (build_assert): Use gnulib's version. + 2009-01-18 Neal H. Walfield <neal@gnu.org> * inttypes.h: New file. diff --git a/libc-parts/assert.h b/libc-parts/assert.h index 90aa7a3..6e5d139 100644 --- a/libc-parts/assert.h +++ b/libc-parts/assert.h @@ -24,7 +24,25 @@ #include <hurd/stddef.h> -#define build_assert(__expr) (void) (sizeof (char[(__expr)? 1 : -1])) +/* The build assert functions are taken from gnulib's + http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=lib/verify.h + . */ +# ifdef __cplusplus +template <int w> + struct build_assert_type__ { unsigned int build_assert_error_if_negative_size__: w; }; +# define build_assert_true(R) \ + (!!sizeof (build_assert_type__<(R) ? 1 : -1>)) +# else +# define build_assert_true(R) \ + (!!sizeof \ + (struct { unsigned int build_assert_error_if_negative_size__ \ + : (R) ? 1 : -1; \ + })) +# endif + +# define build_assert(R) \ + extern int (* build_assert_function__ (void)) [build_assert_true (R)] + #if defined(_L4_TEST_ENVIRONMENT) || defined(_ENABLE_TESTS) # include_next <assert.h> |