use standard `__typeof__()` instead of GNU extension `typeof()`

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>
main
Eric Engestrom 2019-12-17 23:01:08 +00:00 committed by Dylan Baker
parent fa80f49df8
commit 63d06ad3c3
5 changed files with 16 additions and 16 deletions

View File

@ -96,19 +96,19 @@ typedef struct _drmMMListHead
(__item) = (__temp), (__temp) = (__item)->prev) (__item) = (__temp), (__temp) = (__item)->prev)
#define DRMLISTFOREACHENTRY(__item, __list, __head) \ #define DRMLISTFOREACHENTRY(__item, __list, __head) \
for ((__item) = DRMLISTENTRY(typeof(*__item), (__list)->next, __head); \ for ((__item) = DRMLISTENTRY(__typeof__(*__item), (__list)->next, __head); \
&(__item)->__head != (__list); \ &(__item)->__head != (__list); \
(__item) = DRMLISTENTRY(typeof(*__item), \ (__item) = DRMLISTENTRY(__typeof__(*__item), \
(__item)->__head.next, __head)) (__item)->__head.next, __head))
#define DRMLISTFOREACHENTRYSAFE(__item, __temp, __list, __head) \ #define DRMLISTFOREACHENTRYSAFE(__item, __temp, __list, __head) \
for ((__item) = DRMLISTENTRY(typeof(*__item), (__list)->next, __head), \ for ((__item) = DRMLISTENTRY(__typeof__(*__item), (__list)->next, __head), \
(__temp) = DRMLISTENTRY(typeof(*__item), \ (__temp) = DRMLISTENTRY(__typeof__(*__item), \
(__item)->__head.next, __head); \ (__item)->__head.next, __head); \
&(__item)->__head != (__list); \ &(__item)->__head != (__list); \
(__item) = (__temp), \ (__item) = (__temp), \
(__temp) = DRMLISTENTRY(typeof(*__item), \ (__temp) = DRMLISTENTRY(__typeof__(*__item), \
(__temp)->__head.next, __head)) (__temp)->__head.next, __head))
#define DRMLISTJOIN(__list, __join) if (!DRMLISTEMPTY(__list)) { \ #define DRMLISTJOIN(__list, __join) if (!DRMLISTEMPTY(__list)) { \
(__list)->next->prev = (__join); \ (__list)->next->prev = (__join); \

View File

@ -24,7 +24,7 @@ project(
version : '2.4.109', version : '2.4.109',
license : 'MIT', license : 'MIT',
meson_version : '>= 0.46', meson_version : '>= 0.46',
default_options : ['buildtype=debugoptimized', 'c_std=gnu99'], default_options : ['buildtype=debugoptimized', 'c_std=c99'],
) )
pkg = import('pkgconfig') pkg = import('pkgconfig')

View File

@ -305,7 +305,7 @@ static void amdgpu_secure_bounce(void)
/* Fill Alice with a pattern. /* Fill Alice with a pattern.
*/ */
for (pp = alice.bo->cpu_ptr; 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)) pp += sizeof(secure_pattern))
memcpy(pp, secure_pattern, 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. /* Verify the contents of Alice.
*/ */
for (pp = alice.bo->cpu_ptr; 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)) { pp += sizeof(secure_pattern)) {
res = memcmp(pp, secure_pattern, sizeof(secure_pattern)); res = memcmp(pp, secure_pattern, sizeof(secure_pattern));
if (res) { if (res) {

View File

@ -31,7 +31,7 @@
#include "xf86drm.h" #include "xf86drm.h"
#include "nouveau.h" #include "nouveau.h"
static typeof(ioctl) *old_ioctl; static __typeof__(ioctl) *old_ioctl;
static int failed; static int failed;
static int import_fd; static int import_fd;

View File

@ -110,7 +110,7 @@ static inline void list_delinit(struct list_head *item)
#ifndef container_of #ifndef container_of
#define container_of(ptr, sample, member) \ #define container_of(ptr, sample, member) \
(void *)((char *)(ptr) \ (void *)((char *)(ptr) \
- ((char *)&((typeof(sample))0)->member)) - ((char *)&((__typeof__(sample))0)->member))
#endif #endif
#define LIST_FOR_EACH_ENTRY(pos, head, member) \ #define LIST_FOR_EACH_ENTRY(pos, head, member) \