switch from typeof to the more portable __typeof__
authorFelix Fietkau <nbd@nbd.name>
Sat, 7 Apr 2018 13:21:25 +0000 (15:21 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 7 Apr 2018 13:21:33 +0000 (15:21 +0200)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
avl.h
list.h
utils.h

diff --git a/avl.h b/avl.h
index c468597..1eb18ad 100644 (file)
--- a/avl.h
+++ b/avl.h
@@ -238,7 +238,7 @@ __avl_find_element(const struct avl_tree *tree, const void *key, size_t offset,
  *    NULL if no element was found
  */
 #define avl_find_element(tree, key, element, node_element) \
  *    NULL if no element was found
  */
 #define avl_find_element(tree, key, element, node_element) \
-  ((typeof(*(element)) *)__avl_find_element(tree, key, offsetof(typeof(*(element)), node_element), AVL_FIND_EQUAL))
+  ((__typeof__(*(element)) *)__avl_find_element(tree, key, offsetof(typeof(*(element)), node_element), AVL_FIND_EQUAL))
 
 /**
  * @param tree pointer to avl-tree
 
 /**
  * @param tree pointer to avl-tree
@@ -251,7 +251,7 @@ __avl_find_element(const struct avl_tree *tree, const void *key, size_t offset,
  *    NULL if no element was found
  */
 #define avl_find_le_element(tree, key, element, node_element) \
  *    NULL if no element was found
  */
 #define avl_find_le_element(tree, key, element, node_element) \
-  ((typeof(*(element)) *)__avl_find_element(tree, key, offsetof(typeof(*(element)), node_element), AVL_FIND_LESSEQUAL))
+  ((__typeof__(*(element)) *)__avl_find_element(tree, key, offsetof(typeof(*(element)), node_element), AVL_FIND_LESSEQUAL))
 
 /**
  * @param tree pointer to avl-tree
 
 /**
  * @param tree pointer to avl-tree
@@ -264,7 +264,7 @@ __avl_find_element(const struct avl_tree *tree, const void *key, size_t offset,
  *    NULL if no element was found
  */
 #define avl_find_ge_element(tree, key, element, node_element) \
  *    NULL if no element was found
  */
 #define avl_find_ge_element(tree, key, element, node_element) \
-  ((typeof(*(element)) *)__avl_find_element(tree, key, offsetof(typeof(*(element)), node_element), AVL_FIND_GREATEREQUAL))
+  ((__typeof__(*(element)) *)__avl_find_element(tree, key, offsetof(typeof(*(element)), node_element), AVL_FIND_GREATEREQUAL))
 
 /**
  * This function must not be called for an empty tree
 
 /**
  * This function must not be called for an empty tree
@@ -278,7 +278,7 @@ __avl_find_element(const struct avl_tree *tree, const void *key, size_t offset,
  *    (automatically converted to type 'element')
  */
 #define avl_first_element(tree, element, node_member) \
  *    (automatically converted to type 'element')
  */
 #define avl_first_element(tree, element, node_member) \
-  container_of((tree)->list_head.next, typeof(*(element)), node_member.list)
+  container_of((tree)->list_head.next, __typeof__(*(element)), node_member.list)
 
 /**
  * @param tree pointer to tree
 
 /**
  * @param tree pointer to tree
@@ -290,7 +290,7 @@ __avl_find_element(const struct avl_tree *tree, const void *key, size_t offset,
  *    (automatically converted to type 'element')
  */
 #define avl_last_element(tree, element, node_member) \
  *    (automatically converted to type 'element')
  */
 #define avl_last_element(tree, element, node_member) \
-  container_of((tree)->list_head.prev, typeof(*(element)), node_member.list)
+  container_of((tree)->list_head.prev, __typeof__(*(element)), node_member.list)
 
 /**
  * This function must not be called for the last element of
 
 /**
  * This function must not be called for the last element of
@@ -303,7 +303,7 @@ __avl_find_element(const struct avl_tree *tree, const void *key, size_t offset,
  *    (automatically converted to type 'element')
  */
 #define avl_next_element(element, node_member) \
  *    (automatically converted to type 'element')
  */
 #define avl_next_element(element, node_member) \
-  container_of((&(element)->node_member.list)->next, typeof(*(element)), node_member.list)
+  container_of((&(element)->node_member.list)->next, __typeof__(*(element)), node_member.list)
 
 /**
  * This function must not be called for the first element of
 
 /**
  * This function must not be called for the first element of
@@ -316,7 +316,7 @@ __avl_find_element(const struct avl_tree *tree, const void *key, size_t offset,
  *    (automatically converted to type 'element')
  */
 #define avl_prev_element(element, node_member) \
  *    (automatically converted to type 'element')
  */
 #define avl_prev_element(element, node_member) \
-  container_of((&(element)->node_member.list)->prev, typeof(*(element)), node_member.list)
+  container_of((&(element)->node_member.list)->prev, __typeof__(*(element)), node_member.list)
 
 /**
  * Loop over a block of elements of a tree, used similar to a for() command.
 
 /**
  * Loop over a block of elements of a tree, used similar to a for() command.
diff --git a/list.h b/list.h
index ab52acf..8e61e47 100644 (file)
--- a/list.h
+++ b/list.h
@@ -37,7 +37,7 @@
 #ifndef container_of
 #define container_of(ptr, type, member)                                        \
        ({                                                              \
 #ifndef container_of
 #define container_of(ptr, type, member)                                        \
        ({                                                              \
-               const typeof(((type *) NULL)->member) *__mptr = (ptr);  \
+               const __typeof__(((type *) NULL)->member) *__mptr = (ptr);      \
                (type *) ((char *) __mptr - offsetof(type, member));    \
        })
 #endif
                (type *) ((char *) __mptr - offsetof(type, member));    \
        })
 #endif
@@ -120,17 +120,17 @@ list_del_init(struct list_head *entry)
        for (p = (head)->next, n = p->next; p != (head); p = n, n = p->next)
 
 #define list_for_each_entry(p, h, field)                               \
        for (p = (head)->next, n = p->next; p != (head); p = n, n = p->next)
 
 #define list_for_each_entry(p, h, field)                               \
-       for (p = list_first_entry(h, typeof(*p), field); &p->field != (h); \
-           p = list_entry(p->field.next, typeof(*p), field))
+       for (p = list_first_entry(h, __typeof__(*p), field); &p->field != (h); \
+           p = list_entry(p->field.next, __typeof__(*p), field))
 
 #define list_for_each_entry_safe(p, n, h, field)                       \
 
 #define list_for_each_entry_safe(p, n, h, field)                       \
-       for (p = list_first_entry(h, typeof(*p), field),                \
-           n = list_entry(p->field.next, typeof(*p), field); &p->field != (h);\
-           p = n, n = list_entry(n->field.next, typeof(*n), field))
+       for (p = list_first_entry(h, __typeof__(*p), field),            \
+           n = list_entry(p->field.next, __typeof__(*p), field); &p->field != (h);\
+           p = n, n = list_entry(n->field.next, __typeof__(*n), field))
 
 #define        list_for_each_entry_reverse(p, h, field)                        \
 
 #define        list_for_each_entry_reverse(p, h, field)                        \
-       for (p = list_last_entry(h, typeof(*p), field); &p->field != (h); \
-           p = list_entry(p->field.prev, typeof(*p), field))
+       for (p = list_last_entry(h, __typeof__(*p), field); &p->field != (h); \
+           p = list_entry(p->field.prev, __typeof__(*p), field))
 
 #define        list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = p->prev)
 #define        list_for_each_prev_safe(p, n, h) for (p = (h)->prev, n = p->prev; p != (h); p = n, n = p->prev)
 
 #define        list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = p->prev)
 #define        list_for_each_prev_safe(p, n, h) for (p = (h)->prev, n = p->prev; p != (h); p = n, n = p->prev)
diff --git a/utils.h b/utils.h
index 6a53b3f..b64b400 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -125,7 +125,7 @@ int clock_gettime(int type, struct timespec *tv);
        (sizeof(int) == sizeof(*(1 ? ((void*)((long)(x) * 0l)) : (int*)1)))
 
 #define __eval_once(func, x)                                           \
        (sizeof(int) == sizeof(*(1 ? ((void*)((long)(x) * 0l)) : (int*)1)))
 
 #define __eval_once(func, x)                                           \
-       ({ typeof(x) __x = x; func(__x); })
+       ({ __typeof__(x) __x = x; func(__x); })
 
 #define __eval_safe(func, x)                                           \
        __builtin_choose_expr(__is_constant(x),                         \
 
 #define __eval_safe(func, x)                                           \
        __builtin_choose_expr(__is_constant(x),                         \