use standard `__typeof__()` instead of GNU extension `typeof()`
authorEric Engestrom <eric.engestrom@intel.com>
Tue, 17 Dec 2019 23:01:08 +0000 (23:01 +0000)
committerDylan Baker <dylan@pnwbakers.com>
Thu, 20 Jan 2022 00:08:31 +0000 (16:08 -0800)
And switch to c_std=c99. This simplifies using libdrm as a meson
subproject for mesa.

v2: (dylan)
  - switch to c99 as the standard
  - Fix amdgpu security tests as well

Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Signed-off-by: Dylan Baker <dylan@pnwbakers.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Emma Anholt <emma@anholt.net>
libdrm_lists.h
meson.build
tests/amdgpu/security_tests.c
tests/nouveau/threaded.c
util_double_list.h

index 8926d8d..7f55fc0 100644 (file)
@@ -96,19 +96,19 @@ typedef struct _drmMMListHead
             (__item) = (__temp), (__temp) = (__item)->prev)
 
 #define DRMLISTFOREACHENTRY(__item, __list, __head)                            \
-       for ((__item) = DRMLISTENTRY(typeof(*__item), (__list)->next, __head); \
-            &(__item)->__head != (__list);                                    \
-            (__item) = DRMLISTENTRY(typeof(*__item),                          \
-                                    (__item)->__head.next, __head))
+       for ((__item) = DRMLISTENTRY(__typeof__(*__item), (__list)->next, __head); \
+            &(__item)->__head != (__list);                                        \
+            (__item) = DRMLISTENTRY(__typeof__(*__item),                          \
+                                    (__item)->__head.next, __head))
 
 #define DRMLISTFOREACHENTRYSAFE(__item, __temp, __list, __head)                \
-       for ((__item) = DRMLISTENTRY(typeof(*__item), (__list)->next, __head), \
-            (__temp) = DRMLISTENTRY(typeof(*__item),                          \
-                                    (__item)->__head.next, __head);           \
-            &(__item)->__head != (__list);                                    \
-            (__item) = (__temp),                                              \
-            (__temp) = DRMLISTENTRY(typeof(*__item),                          \
-                                    (__temp)->__head.next, __head))
+       for ((__item) = DRMLISTENTRY(__typeof__(*__item), (__list)->next, __head), \
+            (__temp) = DRMLISTENTRY(__typeof__(*__item),                          \
+                                    (__item)->__head.next, __head);               \
+            &(__item)->__head != (__list);                                        \
+            (__item) = (__temp),                                                  \
+            (__temp) = DRMLISTENTRY(__typeof__(*__item),                          \
+                                    (__temp)->__head.next, __head))
 
 #define DRMLISTJOIN(__list, __join) if (!DRMLISTEMPTY(__list)) {       \
        (__list)->next->prev = (__join);                                \
index f5704cf..5b87a22 100644 (file)
@@ -24,7 +24,7 @@ project(
   version : '2.4.109',
   license : 'MIT',
   meson_version : '>= 0.46',
-  default_options : ['buildtype=debugoptimized', 'c_std=gnu99'],
+  default_options : ['buildtype=debugoptimized', 'c_std=c99'],
 )
 
 pkg = import('pkgconfig')
index 280e862..e6c9f9a 100644 (file)
@@ -305,7 +305,7 @@ static void amdgpu_secure_bounce(void)
        /* Fill Alice with a pattern.
         */
        for (pp = alice.bo->cpu_ptr;
-            pp < (typeof(pp)) alice.bo->cpu_ptr + SECURE_BUFFER_SIZE;
+            pp < (__typeof__(pp)) alice.bo->cpu_ptr + SECURE_BUFFER_SIZE;
             pp += sizeof(secure_pattern))
                memcpy(pp, secure_pattern, sizeof(secure_pattern));
 
@@ -343,7 +343,7 @@ static void amdgpu_secure_bounce(void)
        /* Verify the contents of Alice.
         */
        for (pp = alice.bo->cpu_ptr;
-            pp < (typeof(pp)) alice.bo->cpu_ptr + SECURE_BUFFER_SIZE;
+            pp < (__typeof__(pp)) alice.bo->cpu_ptr + SECURE_BUFFER_SIZE;
             pp += sizeof(secure_pattern)) {
                res = memcmp(pp, secure_pattern, sizeof(secure_pattern));
                if (res) {
index ddbac74..eaa469e 100644 (file)
@@ -31,7 +31,7 @@
 #include "xf86drm.h"
 #include "nouveau.h"
 
-static typeof(ioctl) *old_ioctl;
+static __typeof__(ioctl) *old_ioctl;
 static int failed;
 
 static int import_fd;
index 7e48b26..9bdca13 100644 (file)
@@ -110,7 +110,7 @@ static inline void list_delinit(struct list_head *item)
 #ifndef container_of
 #define container_of(ptr, sample, member)                              \
     (void *)((char *)(ptr)                                             \
-            - ((char *)&((typeof(sample))0)->member))
+            - ((char *)&((__typeof__(sample))0)->member))
 #endif
 
 #define LIST_FOR_EACH_ENTRY(pos, head, member)                         \