X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=urcu%2Fcompiler.h;h=e7817dbd019f8803abea56cd54fd749ebe6279d6;hb=6488f70bcf96976bfda4d1836e0cab5ef6f599ff;hp=0c6ece252ca0e8bee2a480ab45588bb8ccd15bcd;hpb=e51500edbd9919cee53bc85cbb4b22cd4786fc42;p=urcu.git diff --git a/urcu/compiler.h b/urcu/compiler.h index 0c6ece2..e7817db 100644 --- a/urcu/compiler.h +++ b/urcu/compiler.h @@ -70,7 +70,7 @@ }) #define CAA_BUILD_BUG_ON_ZERO(cond) (sizeof(struct { int:-!!(cond); })) -#define CAA_BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond)) +#define CAA_BUILD_BUG_ON(cond) ((void)CAA_BUILD_BUG_ON_ZERO(cond)) /* * __rcu is an annotation that documents RCU pointer accesses that need @@ -86,9 +86,32 @@ #define URCU_FORCE_CAST(type, arg) ((type) (arg)) #endif -#define caa_is_signed_type(type) (((type) (-1)) < 0) +#define caa_is_signed_type(type) ((type) -1 < (type) 0) -#define caa_cast_long_keep_sign(v) \ - (caa_is_signed_type(__typeof__(v)) ? (long) (v) : (unsigned long) (v)) +/* + * Cast to unsigned long, sign-extending if @v is signed. + * Note: casting to a larger type or to same type size keeps the sign of + * the expression being cast (see C99 6.3.1.3). + */ +#define caa_cast_long_keep_sign(v) ((unsigned long) (v)) + +/* + * Don't allow compiling with buggy compiler. + */ + +#ifdef __GNUC__ +# define URCU_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +/* + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58854 + */ +# ifdef __ARMEL__ +# if URCU_GCC_VERSION >= 40800 && URCU_GCC_VERSION <= 40802 +# error Your gcc version produces clobbered frame accesses +# endif +# endif +#endif #endif /* _URCU_COMPILER_H */