X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lib%2Fbitfield.h;h=7d5eaeaa068ddadb7631d9f88750453bc9aa47a2;hb=2459130397d7e7eecc44a5f06a39d65c78257eef;hp=ebbe7544cdd585bff9351416490dc43c5cb67718;hpb=3b06049560550ae0e8203bfd5f307bc7cc63fcca;p=lttng-modules.git diff --git a/lib/bitfield.h b/lib/bitfield.h index ebbe7544..7d5eaeaa 100644 --- a/lib/bitfield.h +++ b/lib/bitfield.h @@ -29,8 +29,10 @@ /* * _bt_is_signed_type() willingly generates comparison of unsigned * expression < 0, which is always false. Silence compiler warnings. + * GCC versions lower than 4.6.0 do not accept diagnostic pragma inside + * functions. */ -#ifdef __GNUC__ +#if defined(__GNUC__) && (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600 # define _BT_DIAG_PUSH _Pragma("GCC diagnostic push") # define _BT_DIAG_POP _Pragma("GCC diagnostic pop") @@ -53,8 +55,12 @@ * Produce a build-time error if the condition `cond` is non-zero. * Evaluates as a size_t expression. */ +#ifdef __cplusplus +#define _BT_BUILD_ASSERT(cond) ([]{static_assert((cond), "");}, 0) +#else #define _BT_BUILD_ASSERT(cond) \ sizeof(struct { int f:(2 * !!(cond) - 1); }) +#endif /* * Cast value `v` to an unsigned integer of the same size as `v`. @@ -360,7 +366,7 @@ do { \ do { \ __typeof__(*(vptr)) *_vptr = (vptr); \ __typeof__(*_vptr) _v; \ - type *_ptr = (void *) (ptr); \ + type *_ptr = (type *) (ptr); \ unsigned long _start = (start), _length = (length); \ type _mask, _cmask; \ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \