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,18 +96,18 @@ typedef struct _drmMMListHead
(__item) = (__temp), (__temp) = (__item)->prev)
#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) = DRMLISTENTRY(typeof(*__item), \
(__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), \
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) = DRMLISTENTRY(__typeof__(*__item), \
(__temp)->__head.next, __head))
#define DRMLISTJOIN(__list, __join) if (!DRMLISTEMPTY(__list)) { \

View 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')

View 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) {

View 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;

View 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) \