From: Luca Boccassi Date: Wed, 25 Mar 2015 19:39:00 +0000 (+0000) Subject: Mark braced-groups within expressions with __extension__ X-Git-Tag: v0.7.14~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=20da51e457e3e6a70141ccb40c911d44815f7f63;p=urcu.git Mark braced-groups within expressions with __extension__ Braced-groups within expressions are not valid ISO C, so if a macro uses them and it's included in a project built with -pedantic, the build will fail. GCC and CLANG do support them as extension, so marking them as such allows the build to complete even with -pedantic. Signed-off-by: Luca Boccassi Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-bp.h b/urcu-bp.h index 833688f..1a1545f 100644 --- a/urcu-bp.h +++ b/urcu-bp.h @@ -92,6 +92,7 @@ extern void rcu_read_unlock(void); extern void *rcu_dereference_sym_bp(void *p); #define rcu_dereference_bp(p) \ + __extension__ \ ({ \ __typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p), \ rcu_dereference_sym_bp(URCU_FORCE_CAST(void *, p))); \ @@ -100,6 +101,7 @@ extern void *rcu_dereference_sym_bp(void *p); extern void *rcu_cmpxchg_pointer_sym_bp(void **p, void *old, void *_new); #define rcu_cmpxchg_pointer_bp(p, old, _new) \ + __extension__ \ ({ \ __typeof__(*(p)) _________pold = (old); \ __typeof__(*(p)) _________pnew = (_new); \ @@ -112,6 +114,7 @@ extern void *rcu_cmpxchg_pointer_sym_bp(void **p, void *old, void *_new); extern void *rcu_xchg_pointer_sym_bp(void **p, void *v); #define rcu_xchg_pointer_bp(p, v) \ + __extension__ \ ({ \ __typeof__(*(p)) _________pv = (v); \ __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)),\ @@ -122,6 +125,7 @@ extern void *rcu_xchg_pointer_sym_bp(void **p, void *v); extern void *rcu_set_pointer_sym_bp(void **p, void *v); #define rcu_set_pointer_bp(p, v) \ + __extension__ \ ({ \ __typeof__(*(p)) _________pv = (v); \ __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \ diff --git a/urcu-pointer.h b/urcu-pointer.h index 03bfe79..9a5f94a 100644 --- a/urcu-pointer.h +++ b/urcu-pointer.h @@ -66,6 +66,7 @@ extern "C" { extern void *rcu_dereference_sym(void *p); #define rcu_dereference(p) \ + __extension__ \ ({ \ __typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p), \ rcu_dereference_sym(URCU_FORCE_CAST(void *, p))); \ @@ -74,6 +75,7 @@ extern void *rcu_dereference_sym(void *p); extern void *rcu_cmpxchg_pointer_sym(void **p, void *old, void *_new); #define rcu_cmpxchg_pointer(p, old, _new) \ + __extension__ \ ({ \ __typeof__(*(p)) _________pold = (old); \ __typeof__(*(p)) _________pnew = (_new); \ @@ -86,6 +88,7 @@ extern void *rcu_cmpxchg_pointer_sym(void **p, void *old, void *_new); extern void *rcu_xchg_pointer_sym(void **p, void *v); #define rcu_xchg_pointer(p, v) \ + __extension__ \ ({ \ __typeof__(*(p)) _________pv = (v); \ __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \ diff --git a/urcu/arch/ppc.h b/urcu/arch/ppc.h index 95393ea..1068b28 100644 --- a/urcu/arch/ppc.h +++ b/urcu/arch/ppc.h @@ -58,6 +58,7 @@ extern "C" { #define cmm_smp_wmb() __asm__ __volatile__ (LWSYNC_OPCODE:::"memory") #define mftbl() \ + __extension__ \ ({ \ unsigned long rval; \ __asm__ __volatile__ ("mftbl %0" : "=r" (rval)); \ @@ -65,6 +66,7 @@ extern "C" { }) #define mftbu() \ + __extension__ \ ({ \ unsigned long rval; \ __asm__ __volatile__ ("mftbu %0" : "=r" (rval)); \ @@ -72,6 +74,7 @@ extern "C" { }) #define mftb() \ + __extension__ \ ({ \ unsigned long long rval; \ __asm__ __volatile__ ("mftb %0" : "=r" (rval)); \ diff --git a/urcu/compiler.h b/urcu/compiler.h index e7817db..378f0ea 100644 --- a/urcu/compiler.h +++ b/urcu/compiler.h @@ -64,6 +64,7 @@ * @member: name of the field within the object. */ #define caa_container_of(ptr, type, member) \ + __extension__ \ ({ \ const __typeof__(((type *) NULL)->member) * __ptr = (ptr); \ (type *)((char *)__ptr - offsetof(type, member)); \ diff --git a/urcu/static/urcu-pointer.h b/urcu/static/urcu-pointer.h index a5b3e4b..06371e3 100644 --- a/urcu/static/urcu-pointer.h +++ b/urcu/static/urcu-pointer.h @@ -64,7 +64,9 @@ extern "C" { * meets the 10-line criterion in LGPL, allowing this function to be * expanded directly in non-LGPL code. */ -#define _rcu_dereference(p) ({ \ +#define _rcu_dereference(p) \ + __extension__ \ + ({ \ __typeof__(p) _________p1 = CMM_LOAD_SHARED(p); \ cmm_smp_read_barrier_depends(); \ (_________p1); \ @@ -82,6 +84,7 @@ extern "C" { * expanded directly in non-LGPL code. */ #define _rcu_cmpxchg_pointer(p, old, _new) \ + __extension__ \ ({ \ __typeof__(*p) _________pold = (old); \ __typeof__(*p) _________pnew = (_new); \ @@ -101,6 +104,7 @@ extern "C" { * expanded directly in non-LGPL code. */ #define _rcu_xchg_pointer(p, v) \ + __extension__ \ ({ \ __typeof__(*p) _________pv = (v); \ if (!__builtin_constant_p(v) || \ diff --git a/urcu/system.h b/urcu/system.h index 6f31459..faae390 100644 --- a/urcu/system.h +++ b/urcu/system.h @@ -32,6 +32,7 @@ * Load a data from shared memory, doing a cache flush if required. */ #define CMM_LOAD_SHARED(p) \ + __extension__ \ ({ \ cmm_smp_rmc(); \ _CMM_LOAD_SHARED(p); \ @@ -41,13 +42,14 @@ * Identify a shared store. A cmm_smp_wmc() or cmm_smp_mc() should * follow the store. */ -#define _CMM_STORE_SHARED(x, v) ({ CMM_ACCESS_ONCE(x) = (v); }) +#define _CMM_STORE_SHARED(x, v) __extension__ ({ CMM_ACCESS_ONCE(x) = (v); }) /* * Store v into x, where x is located in shared memory. Performs the * required cache flush after writing. Returns v. */ #define CMM_STORE_SHARED(x, v) \ + __extension__ \ ({ \ __typeof__(x) _v = _CMM_STORE_SHARED(x, v); \ cmm_smp_wmc(); \