X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=lib%2Fbitfield.h;h=36b6d644cbe8e10ad3d37e7d5eaa629ae5b6c85e;hb=1f611cf7fbc31c2b3c44a91c7c7ac8d647722fe3;hp=a9e268b4153031d9eb10ccae39df17c5f310b7ed;hpb=5f7779c5265d15bd087fde0b2694249e11ea9472;p=lttng-modules.git diff --git a/lib/bitfield.h b/lib/bitfield.h index a9e268b4..36b6d644 100644 --- a/lib/bitfield.h +++ b/lib/bitfield.h @@ -26,30 +26,7 @@ #error "bitfield.h requires the compiler representation of signed integers to be two's complement." #endif -/* - * _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. - */ -#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") - -# define _BT_DIAG_STRINGIFY_1(x) #x -# define _BT_DIAG_STRINGIFY(x) _BT_DIAG_STRINGIFY_1(x) - -# define _BT_DIAG_IGNORE(option) \ - _Pragma(_BT_DIAG_STRINGIFY(GCC diagnostic ignored option)) -# define _BT_DIAG_IGNORE_TYPE_LIMITS _BT_DIAG_IGNORE("-Wtype-limits") -#else -# define _BT_DIAG_PUSH -# define _BT_DIAG_POP -# define _BT_DIAG_IGNORE -# define _BT_DIAG_IGNORE_TYPE_LIMITS -#endif - -#define _bt_is_signed_type(type) ((type) -1 < (type) 0) +#define _bt_is_signed_type(type) ((type) -1 < (type) 1) /* * Produce a build-time error if the condition `cond` is non-zero. @@ -368,7 +345,6 @@ do { \ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \ unsigned long _start_unit, _end_unit, _this_unit; \ unsigned long _end, _cshift; /* _cshift is "complement shift" */ \ - bool _is_signed_type; \ \ if (!_length) { \ *_vptr = 0; \ @@ -380,11 +356,7 @@ do { \ _end_unit = (_end + (_ts - 1)) / _ts; \ \ _this_unit = _end_unit - 1; \ - _BT_DIAG_PUSH \ - _BT_DIAG_IGNORE_TYPE_LIMITS \ - _is_signed_type = _bt_is_signed_type(__typeof__(_v)); \ - _BT_DIAG_POP \ - if (_is_signed_type \ + if (_bt_is_signed_type(__typeof__(_v)) \ && (_ptr[_this_unit] & _bt_lshift((type) 1, (_end % _ts ? _end % _ts : _ts) - 1))) \ _v = ~(__typeof__(_v)) 0; \ else \ @@ -440,7 +412,6 @@ do { \ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \ unsigned long _start_unit, _end_unit, _this_unit; \ unsigned long _end, _cshift; /* _cshift is "complement shift" */ \ - bool _is_signed_type; \ \ if (!_length) { \ *_vptr = 0; \ @@ -452,11 +423,7 @@ do { \ _end_unit = (_end + (_ts - 1)) / _ts; \ \ _this_unit = _start_unit; \ - _BT_DIAG_PUSH \ - _BT_DIAG_IGNORE_TYPE_LIMITS \ - _is_signed_type = _bt_is_signed_type(__typeof__(_v)); \ - _BT_DIAG_POP \ - if (_is_signed_type \ + if (_bt_is_signed_type(__typeof__(_v)) \ && (_ptr[_this_unit] & _bt_lshift((type) 1, _ts - (_start % _ts) - 1))) \ _v = ~(__typeof__(_v)) 0; \ else \