diff options
author | Michael Forney <mforney@mforney.org> | 2019-08-11 05:15:37 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-08-16 05:42:03 (GMT) |
commit | 24e5b315a55f8388cf1045b1573587d29712f253 (patch) | |
tree | 2d3794fd97d98210dab45ba14e7809f045417545 | |
parent | 849140d3fd3d3a242c3d1793c6e2ea4bc66e5991 (diff) | |
download | libnl-24e5b315a55f8388cf1045b1573587d29712f253.zip libnl-24e5b315a55f8388cf1045b1573587d29712f253.tar.gz libnl-24e5b315a55f8388cf1045b1573587d29712f253.tar.bz2 |
all: Use __typeof__ instead of typeof
This allows libnl to be built with -std=c99, which prevents the compiler
from using non-reserved identifiers for extensions.
-rw-r--r-- | include/netlink-private/netlink.h | 8 | ||||
-rw-r--r-- | include/netlink-private/utils.h | 12 | ||||
-rw-r--r-- | include/netlink/list.h | 12 | ||||
-rw-r--r-- | python/netlink/utils.h | 2 |
4 files changed, 17 insertions, 17 deletions
diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h index 8240bb2..48def74 100644 --- a/include/netlink-private/netlink.h +++ b/include/netlink-private/netlink.h @@ -160,14 +160,14 @@ static inline int nl_cb_call(struct nl_cb *cb, enum nl_cb_type type, struct nl_m #define __deprecated __attribute__ ((deprecated)) #define min(x,y) ({ \ - typeof(x) _x = (x); \ - typeof(y) _y = (y); \ + __typeof__(x) _x = (x); \ + __typeof__(y) _y = (y); \ (void) (&_x == &_y); \ _x < _y ? _x : _y; }) #define max(x,y) ({ \ - typeof(x) _x = (x); \ - typeof(y) _y = (y); \ + __typeof__(x) _x = (x); \ + __typeof__(y) _y = (y); \ (void) (&_x == &_y); \ _x > _y ? _x : _y; }) diff --git a/include/netlink-private/utils.h b/include/netlink-private/utils.h index a71dc63..f33a2f8 100644 --- a/include/netlink-private/utils.h +++ b/include/netlink-private/utils.h @@ -108,8 +108,8 @@ extern const char *nl_strerror_l(int err); #define _nl_clear_pointer(pp, destroy) \ ({ \ - typeof (*(pp)) *_pp = (pp); \ - typeof (*_pp) _p; \ + __typeof__ (*(pp)) *_pp = (pp); \ + __typeof__ (*_pp) _p; \ int _changed = 0; \ \ if ( _pp \ @@ -129,8 +129,8 @@ extern const char *nl_strerror_l(int err); #define _nl_steal_pointer(pp) \ ({ \ - typeof (*(pp)) *const _pp = (pp); \ - typeof (*_pp) _p = NULL; \ + __typeof__ (*(pp)) *const _pp = (pp); \ + __typeof__ (*_pp) _p = NULL; \ \ if ( _pp \ && (_p = *_pp)) { \ @@ -145,8 +145,8 @@ extern const char *nl_strerror_l(int err); #define _nl_malloc_maybe_a(alloca_maxlen, bytes, to_free) \ ({ \ const size_t _bytes = (bytes); \ - typeof (to_free) _to_free = (to_free); \ - typeof (*_to_free) _ptr; \ + __typeof__ (to_free) _to_free = (to_free); \ + __typeof__ (*_to_free) _ptr; \ \ _NL_STATIC_ASSERT ((alloca_maxlen) <= 500); \ _nl_assert (_to_free && !*_to_free); \ diff --git a/include/netlink/list.h b/include/netlink/list.h index fcfb826..2f20634 100644 --- a/include/netlink/list.h +++ b/include/netlink/list.h @@ -60,7 +60,7 @@ static inline int nl_list_empty(struct nl_list_head *head) } #define nl_container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + const __typeof__( ((type *)0)->member ) *__mptr = (ptr);\ (type *)( (char *)__mptr - (offsetof(type, member)));}) #define nl_list_entry(ptr, type, member) \ @@ -79,15 +79,15 @@ static inline int nl_list_empty(struct nl_list_head *head) nl_list_entry((head)->next, type, member) #define nl_list_for_each_entry(pos, head, member) \ - for (pos = nl_list_entry((head)->next, typeof(*pos), member); \ + for (pos = nl_list_entry((head)->next, __typeof__(*pos), member); \ &(pos)->member != (head); \ - (pos) = nl_list_entry((pos)->member.next, typeof(*(pos)), member)) + (pos) = nl_list_entry((pos)->member.next, __typeof__(*(pos)), member)) #define nl_list_for_each_entry_safe(pos, n, head, member) \ - for (pos = nl_list_entry((head)->next, typeof(*pos), member), \ - n = nl_list_entry(pos->member.next, typeof(*pos), member); \ + for (pos = nl_list_entry((head)->next, __typeof__(*pos), member), \ + n = nl_list_entry(pos->member.next, __typeof__(*pos), member); \ &(pos)->member != (head); \ - pos = n, n = nl_list_entry(n->member.next, typeof(*n), member)) + pos = n, n = nl_list_entry(n->member.next, __typeof__(*n), member)) #define nl_init_list_head(head) \ do { (head)->next = (head); (head)->prev = (head); } while (0) diff --git a/python/netlink/utils.h b/python/netlink/utils.h index 7836c30..3ec2fb5 100644 --- a/python/netlink/utils.h +++ b/python/netlink/utils.h @@ -30,7 +30,7 @@ static inline void list_del(struct list_head *entry, struct list_head *prev) #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + const __typeof__( ((type *)0)->member ) *__mptr = (ptr);\ (type *)( (char *)__mptr - offsetof(type,member) );}) #ifdef DEBUG |