X-Git-Url: http://git.liburcu.org/?p=lttng-modules.git;a=blobdiff_plain;f=lib%2Fbitfield.h;h=7d5eaeaa068ddadb7631d9f88750453bc9aa47a2;hp=a9e268b4153031d9eb10ccae39df17c5f310b7ed;hb=ff0d3a20659704a3762b0394844f42a89afbe246;hpb=1c88f269135ba48b0adb8a8a1f8b32e8b3c4cbb9 diff --git a/lib/bitfield.h b/lib/bitfield.h index a9e268b4..7d5eaeaa 100644 --- a/lib/bitfield.h +++ b/lib/bitfield.h @@ -55,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`. @@ -362,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 */ \