tllist: use __typeof__ instead of __typeof

This commit is contained in:
Daniel Eklöf 2018-12-15 11:45:57 +01:00
parent b4a3a09ae4
commit c67234e34f

View file

@ -40,7 +40,7 @@
/* Adds a new item to the back of the list */
#define tll_push_back(list, new_item) \
do { \
__typeof((list).head) __e = malloc(sizeof(*__e)); \
__typeof__((list).head) __e = malloc(sizeof(*__e)); \
__e->item = (new_item); \
__e->prev = (list).tail; \
__e->next = NULL; \
@ -56,7 +56,7 @@
/* Adds a new item to the front of the list */
#define tll_push_front(list, new_item) \
do { \
__typeof((list).head) __e = malloc(sizeof(*__e)); \
__typeof__((list).head) __e = malloc(sizeof(*__e)); \
__e->item = (new_item); \
__e->prev = NULL; \
__e->next = (list).head; \
@ -103,8 +103,8 @@
#define tll_remove(list, it) \
do { \
assert((list).length > 0); \
__typeof((list).head) __prev = it->prev; \
__typeof((list).head) __next = it->next; \
__typeof__((list).head) __prev = it->prev; \
__typeof__((list).head) __next = it->next; \
if (__prev != NULL) \
__prev->next = __next; \
else \
@ -129,16 +129,16 @@
* returns the *actual* item, not an iterator.
*/
#define tll_pop_front(list) \
({__typeof((list).head) it = (list).head; \
__typeof((list).head->item) __ret = it->item; \
({__typeof__((list).head) it = (list).head; \
__typeof__((list).head->item) __ret = it->item; \
tll_remove((list), it); \
__ret; \
})
/* Same as tll_pop_front(), but returns/removes the *last* element */
#define tll_pop_back(list) \
({__typeof((list).tail) it = (list).tail; \
__typeof((list).tail->item) __ret = it->item; \
({__typeof__((list).tail) it = (list).tail; \
__typeof__((list).tail->item) __ret = it->item; \
tll_remove((list), it); \
__ret; \
})