X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=urcu%2Fcompiler.h;h=0032b60cf67b64ee9bb349efdfaf17e8c34aba3a;hb=b683af4b537b63551775239242744d0d367377ff;hp=cd4a49d19dc6e82f454027bfba76dc2f8eb14bf5;hpb=bf65ba4ee8bf2fb7ac164824c27576ef24a61e6c;p=urcu.git diff --git a/urcu/compiler.h b/urcu/compiler.h index cd4a49d..0032b60 100644 --- a/urcu/compiler.h +++ b/urcu/compiler.h @@ -86,9 +86,14 @@ #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)) +/* + * Sign-extend to long if needed, and output type is unsigned long. + */ +#define caa_cast_long_keep_sign(v) \ + (caa_is_signed_type(__typeof__(v)) ? \ + (unsigned long) (long) (v) : \ + (unsigned long) (v)) #endif /* _URCU_COMPILER_H */