Add a typecheck for the endianness conversions
Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/compiler/compiler.h b/compiler/compiler.h
index 0a0213b..e1afcb4 100644
--- a/compiler/compiler.h
+++ b/compiler/compiler.h
@@ -22,4 +22,15 @@
#define fio_unlikely(x) __builtin_expect(!!(x), 0)
+/*
+ * Check at compile time that something is of a particular type.
+ * Always evaluates to 1 so you may use it easily in comparisons.
+ */
+#define typecheck(type,x) \
+({ type __dummy; \
+ typeof(x) __dummy2; \
+ (void)(&__dummy == &__dummy2); \
+ 1; \
+})
+
#endif