X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu%2Fcompiler.h;h=974885a73f36c08e322bb6606bb3cd0e8e964ddd;hp=f977b95fdc60f73b6ef6c9ab2b96c4c30a884de2;hb=bdffa73aa208ad5f1e5b3a3cb6cbf86ac6996559;hpb=a0b7f7ea3fc3339a1c42caffd53ce9f056e5b901 diff --git a/urcu/compiler.h b/urcu/compiler.h index f977b95..974885a 100644 --- a/urcu/compiler.h +++ b/urcu/compiler.h @@ -8,14 +8,15 @@ * * Copyright (c) 2009 Mathieu Desnoyers * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED - * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * Permission is hereby granted to use or copy this program - * for any purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is granted, - * provided the above notices are retained, and a notice that the code was - * modified is included with the above copyright notice. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. */ #include /* for offsetof */ @@ -37,7 +38,7 @@ * use is to mediate communication between process-level code and irq/NMI * handlers, all running on the same CPU. */ -#define CMM_ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) +#define CMM_ACCESS_ONCE(x) (*(volatile __typeof__(x) *)&(x)) #ifndef caa_max #define caa_max(a,b) ((a)>(b)?(a):(b)) @@ -64,7 +65,7 @@ */ #define caa_container_of(ptr, type, member) \ ({ \ - const typeof(((type *) NULL)->member) * __ptr = (ptr); \ + const __typeof__(((type *) NULL)->member) * __ptr = (ptr); \ (type *)((char *)__ptr - offsetof(type, member)); \ }) @@ -85,4 +86,9 @@ #define URCU_FORCE_CAST(type, arg) ((type) (arg)) #endif +#define caa_is_signed_type(type) (((type) (-1)) < 0) + +#define caa_cast_long_keep_sign(v) \ + (caa_is_signed_type(__typeof__(v)) ? (long) (v) : (unsigned long) (v)) + #endif /* _URCU_COMPILER_H */