summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKefu Chai <tchaikov@gmail.com>2018-07-25 22:02:09 +0800
committerKefu Chai <tchaikov@gmail.com>2018-07-25 22:02:14 +0800
commit3376ecf43b2bdd3952c6291d8b469bdf49d3a273 (patch)
tree17598a53bd296e3e55427c1dcae5f96697f1396a
parent540e235dcd276e63c57ca4bd35f70a0651e2d00e (diff)
replace typeof with __typeof__
so we are able to extend fio with C++ . Signed-off-by: Kefu Chai <tchaikov@gmail.com>
-rw-r--r--compiler/compiler.h4
-rw-r--r--flist.h4
-rw-r--r--minmax.h12
-rw-r--r--oslib/libmtd_common.h10
-rw-r--r--verify.c2
5 files changed, 16 insertions, 16 deletions
diff --git a/compiler/compiler.h b/compiler/compiler.h
index dacb737..ddfbcc1 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 2ca3d77..5437cd8 100644
--- a/flist.h
+++ b/flist.h
@@ -4,8 +4,8 @@
#include <stdlib.h>
#include <stddef.h>
-#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 afc78f0..ec0848c 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 87f93b6..4ed9f0b 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 40d484b..1bb6751 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);