From: Mathieu Desnoyers Date: Mon, 11 Jun 2012 14:16:35 +0000 (-0400) Subject: Fix c99 compatibility: use __typeof__ instead of typeof in public headers X-Git-Tag: v0.7.4~13 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bdffa73aa208ad5f1e5b3a3cb6cbf86ac6996559;p=urcu.git Fix c99 compatibility: use __typeof__ instead of typeof in public headers Reported-by: John Steele Scott Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-bp.h b/urcu-bp.h index 5e42312..833688f 100644 --- a/urcu-bp.h +++ b/urcu-bp.h @@ -93,7 +93,7 @@ extern void rcu_read_unlock(void); extern void *rcu_dereference_sym_bp(void *p); #define rcu_dereference_bp(p) \ ({ \ - typeof(p) _________p1 = URCU_FORCE_CAST(typeof(p), \ + __typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p), \ rcu_dereference_sym_bp(URCU_FORCE_CAST(void *, p))); \ (_________p1); \ }) @@ -101,10 +101,10 @@ 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) \ ({ \ - typeof(*(p)) _________pold = (old); \ - typeof(*(p)) _________pnew = (_new); \ - typeof(*(p)) _________p1 = URCU_FORCE_CAST(typeof(*(p)), \ - rcu_cmpxchg_pointer_sym_bp(URCU_FORCE_CAST(void **, p),\ + __typeof__(*(p)) _________pold = (old); \ + __typeof__(*(p)) _________pnew = (_new); \ + __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \ + rcu_cmpxchg_pointer_sym_bp(URCU_FORCE_CAST(void **, p), \ _________pold, \ _________pnew)); \ (_________p1); \ @@ -113,8 +113,8 @@ 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) \ ({ \ - typeof(*(p)) _________pv = (v); \ - typeof(*(p)) _________p1 = URCU_FORCE_CAST(typeof(*(p)), \ + __typeof__(*(p)) _________pv = (v); \ + __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)),\ rcu_xchg_pointer_sym_bp(URCU_FORCE_CAST(void **, p), \ _________pv)); \ (_________p1); \ @@ -123,8 +123,8 @@ 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) \ ({ \ - typeof(*(p)) _________pv = (v); \ - typeof(*(p)) _________p1 = URCU_FORCE_CAST(typeof(*(p)), \ + __typeof__(*(p)) _________pv = (v); \ + __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \ rcu_set_pointer_sym_bp(URCU_FORCE_CAST(void **, p), \ _________pv)); \ (_________p1); \ diff --git a/urcu-pointer.h b/urcu-pointer.h index 1e1e6bf..03bfe79 100644 --- a/urcu-pointer.h +++ b/urcu-pointer.h @@ -67,7 +67,7 @@ extern "C" { extern void *rcu_dereference_sym(void *p); #define rcu_dereference(p) \ ({ \ - typeof(p) _________p1 = URCU_FORCE_CAST(typeof(p), \ + __typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p), \ rcu_dereference_sym(URCU_FORCE_CAST(void *, p))); \ (_________p1); \ }) @@ -75,10 +75,10 @@ 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) \ ({ \ - typeof(*(p)) _________pold = (old); \ - typeof(*(p)) _________pnew = (_new); \ - typeof(*(p)) _________p1 = URCU_FORCE_CAST(typeof(*(p)), \ - rcu_cmpxchg_pointer_sym(URCU_FORCE_CAST(void **, p),\ + __typeof__(*(p)) _________pold = (old); \ + __typeof__(*(p)) _________pnew = (_new); \ + __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \ + rcu_cmpxchg_pointer_sym(URCU_FORCE_CAST(void **, p), \ _________pold, \ _________pnew)); \ (_________p1); \ @@ -87,8 +87,8 @@ 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) \ ({ \ - typeof(*(p)) _________pv = (v); \ - typeof(*(p)) _________p1 = URCU_FORCE_CAST(typeof(*(p)), \ + __typeof__(*(p)) _________pv = (v); \ + __typeof__(*(p)) _________p1 = URCU_FORCE_CAST(__typeof__(*(p)), \ rcu_xchg_pointer_sym(URCU_FORCE_CAST(void **, p), \ _________pv)); \ (_________p1); \ @@ -103,7 +103,7 @@ extern void *rcu_xchg_pointer_sym(void **p, void *v); extern void *rcu_set_pointer_sym(void **p, void *v); #define rcu_set_pointer(p, v) \ do { \ - typeof(*(p)) _________pv = (v); \ + __typeof__(*(p)) _________pv = (v); \ (void) rcu_set_pointer_sym(URCU_FORCE_CAST(void **, p), \ _________pv); \ } while (0) diff --git a/urcu/compiler.h b/urcu/compiler.h index fc2425c..974885a 100644 --- a/urcu/compiler.h +++ b/urcu/compiler.h @@ -38,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)) @@ -65,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)); \ }) diff --git a/urcu/hlist.h b/urcu/hlist.h index 82015b3..d7d5c87 100644 --- a/urcu/hlist.h +++ b/urcu/hlist.h @@ -62,16 +62,16 @@ static inline void cds_hlist_del (struct cds_hlist_node *elem) #define cds_hlist_for_each_entry(entry, pos, head, member) \ for (pos = (head)->next, \ - entry = cds_hlist_entry(pos, typeof(*entry), member); \ + entry = cds_hlist_entry(pos, __typeof__(*entry), member); \ pos != NULL; \ pos = pos->next, \ - entry = cds_hlist_entry(pos, typeof(*entry), member)) + entry = cds_hlist_entry(pos, __typeof__(*entry), member)) #define cds_hlist_for_each_entry_safe(entry, pos, p, head, member) \ for (pos = (head)->next, \ - entry = cds_hlist_entry(pos, typeof(*entry), member); \ + entry = cds_hlist_entry(pos, __typeof__(*entry), member); \ (pos != NULL) && ({ p = pos->next; 1;}); \ pos = p, \ - entry = cds_hlist_entry(pos, typeof(*entry), member)) + entry = cds_hlist_entry(pos, __typeof__(*entry), member)) #endif /* _KCOMPAT_HLIST_H */ diff --git a/urcu/list.h b/urcu/list.h index 04dad80..f27ff7b 100644 --- a/urcu/list.h +++ b/urcu/list.h @@ -154,20 +154,20 @@ cds_list_splice (struct cds_list_head *add, struct cds_list_head *head) pos = p, p = pos->prev) #define cds_list_for_each_entry(pos, head, member) \ - for (pos = cds_list_entry((head)->next, typeof(*pos), member); \ + for (pos = cds_list_entry((head)->next, __typeof__(*pos), member); \ &pos->member != (head); \ - pos = cds_list_entry(pos->member.next, typeof(*pos), member)) + pos = cds_list_entry(pos->member.next, __typeof__(*pos), member)) #define cds_list_for_each_entry_reverse(pos, head, member) \ - for (pos = cds_list_entry((head)->prev, typeof(*pos), member); \ + for (pos = cds_list_entry((head)->prev, __typeof__(*pos), member); \ &pos->member != (head); \ - pos = cds_list_entry(pos->member.prev, typeof(*pos), member)) + pos = cds_list_entry(pos->member.prev, __typeof__(*pos), member)) #define cds_list_for_each_entry_safe(pos, p, head, member) \ - for (pos = cds_list_entry((head)->next, typeof(*pos), member), \ - p = cds_list_entry(pos->member.next,typeof(*pos), member); \ + for (pos = cds_list_entry((head)->next, __typeof__(*pos), member), \ + p = cds_list_entry(pos->member.next, __typeof__(*pos), member); \ &pos->member != (head); \ - pos = p, p = cds_list_entry(pos->member.next, typeof(*pos), member)) + pos = p, p = cds_list_entry(pos->member.next, __typeof__(*pos), member)) static inline int cds_list_empty(struct cds_list_head *head) { diff --git a/urcu/rcuhlist.h b/urcu/rcuhlist.h index 83b1363..8549550 100644 --- a/urcu/rcuhlist.h +++ b/urcu/rcuhlist.h @@ -57,9 +57,9 @@ static inline void cds_hlist_del_rcu(struct cds_hlist_node *elem) #define cds_hlist_for_each_entry_rcu(entry, pos, head, member) \ for (pos = rcu_dereference((head)->next), \ - entry = cds_hlist_entry(pos, typeof(*entry), member); \ + entry = cds_hlist_entry(pos, __typeof__(*entry), member); \ pos != NULL; \ pos = rcu_dereference(pos->next), \ - entry = cds_hlist_entry(pos, typeof(*entry), member)) + entry = cds_hlist_entry(pos, __typeof__(*entry), member)) #endif /* _URCU_RCUHLIST_H */ diff --git a/urcu/rculfhash.h b/urcu/rculfhash.h index 2938e5e..03ce593 100644 --- a/urcu/rculfhash.h +++ b/urcu/rculfhash.h @@ -450,21 +450,21 @@ void cds_lfht_resize(struct cds_lfht *ht, unsigned long new_size); #define cds_lfht_for_each_entry(ht, iter, pos, member) \ for (cds_lfht_first(ht, iter), \ pos = caa_container_of(cds_lfht_iter_get_node(iter), \ - typeof(*(pos)), member); \ + __typeof__(*(pos)), member); \ &(pos)->member != NULL; \ cds_lfht_next(ht, iter), \ pos = caa_container_of(cds_lfht_iter_get_node(iter), \ - typeof(*(pos)), member)) + __typeof__(*(pos)), member)) #define cds_lfht_for_each_entry_duplicate(ht, hash, match, key, \ iter, pos, member) \ for (cds_lfht_lookup(ht, hash, match, key, iter), \ pos = caa_container_of(cds_lfht_iter_get_node(iter), \ - typeof(*(pos)), member); \ + __typeof__(*(pos)), member); \ &(pos)->member != NULL; \ cds_lfht_next_duplicate(ht, match, key, iter), \ pos = caa_container_of(cds_lfht_iter_get_node(iter), \ - typeof(*(pos)), member)) + __typeof__(*(pos)), member)) #ifdef __cplusplus } diff --git a/urcu/rculist.h b/urcu/rculist.h index 575e1fb..3604a96 100644 --- a/urcu/rculist.h +++ b/urcu/rculist.h @@ -71,8 +71,8 @@ static inline void cds_list_del_rcu(struct cds_list_head *elem) /* Iterate through elements of the list. */ #define cds_list_for_each_entry_rcu(pos, head, member) \ - for (pos = cds_list_entry(rcu_dereference((head)->next), typeof(*pos), member); \ + for (pos = cds_list_entry(rcu_dereference((head)->next), __typeof__(*pos), member); \ &pos->member != (head); \ - pos = cds_list_entry(rcu_dereference(pos->member.next), typeof(*pos), member)) + pos = cds_list_entry(rcu_dereference(pos->member.next), __typeof__(*pos), member)) #endif /* _URCU_RCULIST_H */ diff --git a/urcu/static/urcu-pointer.h b/urcu/static/urcu-pointer.h index 906caa0..48dc5bf 100644 --- a/urcu/static/urcu-pointer.h +++ b/urcu/static/urcu-pointer.h @@ -62,7 +62,7 @@ extern "C" { */ #define _rcu_dereference(p) ({ \ - typeof(p) _________p1 = CMM_LOAD_SHARED(p); \ + __typeof__(p) _________p1 = CMM_LOAD_SHARED(p); \ cmm_smp_read_barrier_depends(); \ (_________p1); \ }) @@ -77,8 +77,8 @@ extern "C" { #define _rcu_cmpxchg_pointer(p, old, _new) \ ({ \ - typeof(*p) _________pold = (old); \ - typeof(*p) _________pnew = (_new); \ + __typeof__(*p) _________pold = (old); \ + __typeof__(*p) _________pnew = (_new); \ if (!__builtin_constant_p(_new) || \ ((_new) != NULL)) \ cmm_wmb(); \ @@ -93,7 +93,7 @@ extern "C" { #define _rcu_xchg_pointer(p, v) \ ({ \ - typeof(*p) _________pv = (v); \ + __typeof__(*p) _________pv = (v); \ if (!__builtin_constant_p(v) || \ ((v) != NULL)) \ cmm_wmb(); \ @@ -103,7 +103,7 @@ extern "C" { #define _rcu_set_pointer(p, v) \ do { \ - typeof(*p) _________pv = (v); \ + __typeof__(*p) _________pv = (v); \ if (!__builtin_constant_p(v) || \ ((v) != NULL)) \ cmm_wmb(); \ diff --git a/urcu/system.h b/urcu/system.h index acce7e9..2a45f22 100644 --- a/urcu/system.h +++ b/urcu/system.h @@ -49,7 +49,7 @@ */ #define CMM_STORE_SHARED(x, v) \ ({ \ - typeof(x) _v = _CMM_STORE_SHARED(x, v); \ + __typeof__(x) _v = _CMM_STORE_SHARED(x, v); \ cmm_smp_wmc(); \ _v; \ })