From: Kefu Chai Date: Wed, 25 Jul 2018 14:02:09 +0000 (+0800) Subject: replace typeof with __typeof__ X-Git-Tag: fio-3.9~56^2 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=3376ecf43b2bdd3952c6291d8b469bdf49d3a273 replace typeof with __typeof__ so we are able to extend fio with C++ . Signed-off-by: Kefu Chai --- diff --git a/compiler/compiler.h b/compiler/compiler.h index dacb7379..ddfbcc12 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -28,7 +28,7 @@ */ #define typecheck(type,x) \ ({ type __dummy; \ - typeof(x) __dummy2; \ + __typeof__(x) __dummy2; \ (void)(&__dummy == &__dummy2); \ 1; \ }) @@ -70,7 +70,7 @@ #ifdef FIO_INTERNAL #define ARRAY_SIZE(x) (sizeof((x)) / (sizeof((x)[0]))) -#define FIELD_SIZE(s, f) (sizeof(((typeof(s))0)->f)) +#define FIELD_SIZE(s, f) (sizeof(((__typeof__(s))0)->f)) #endif #endif diff --git a/flist.h b/flist.h index 2ca3d777..5437cd80 100644 --- a/flist.h +++ b/flist.h @@ -4,8 +4,8 @@ #include #include -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ +#define container_of(ptr, type, member) ({ \ + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) /* diff --git a/minmax.h b/minmax.h index afc78f02..ec0848c0 100644 --- a/minmax.h +++ b/minmax.h @@ -3,23 +3,23 @@ #ifndef min #define min(x,y) ({ \ - typeof(x) _x = (x); \ - typeof(y) _y = (y); \ + __typeof__(x) _x = (x); \ + __typeof__(y) _y = (y); \ (void) (&_x == &_y); \ _x < _y ? _x : _y; }) #endif #ifndef max #define max(x,y) ({ \ - typeof(x) _x = (x); \ - typeof(y) _y = (y); \ + __typeof__(x) _x = (x); \ + __typeof__(y) _y = (y); \ (void) (&_x == &_y); \ _x > _y ? _x : _y; }) #endif #define min_not_zero(x, y) ({ \ - typeof(x) __x = (x); \ - typeof(y) __y = (y); \ + __typeof__(x) __x = (x); \ + __typeof__(y) __y = (y); \ __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) #endif diff --git a/oslib/libmtd_common.h b/oslib/libmtd_common.h index 87f93b61..4ed9f0ba 100644 --- a/oslib/libmtd_common.h +++ b/oslib/libmtd_common.h @@ -49,18 +49,18 @@ extern "C" { #define min(a, b) MIN(a, b) /* glue for linux kernel source */ #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) -#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) +#define ALIGN(x,a) __ALIGN_MASK(x,(__typeof__(x))(a)-1) #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) #define min_t(t,x,y) ({ \ - typeof((x)) _x = (x); \ - typeof((y)) _y = (y); \ + __typeof__((x)) _x = (x); \ + __typeof__((y)) _y = (y); \ (_x < _y) ? _x : _y; \ }) #define max_t(t,x,y) ({ \ - typeof((x)) _x = (x); \ - typeof((y)) _y = (y); \ + __typeof__((x)) _x = (x); \ + __typeof__((y)) _y = (y); \ (_x > _y) ? _x : _y; \ }) diff --git a/verify.c b/verify.c index 40d484b5..1bb67519 100644 --- a/verify.c +++ b/verify.c @@ -1517,7 +1517,7 @@ int paste_blockoff(char *buf, unsigned int len, void *priv) struct io_u *io = priv; unsigned long long off; - typecheck(typeof(off), io->offset); + typecheck(__typeof__(off), io->offset); off = cpu_to_le64((uint64_t)io->offset); len = min(len, (unsigned int)sizeof(off)); memcpy(buf, &off, len);