btrfs-progs: kerncompat: add build-time assertion support
authorDavid Sterba <dsterba@suse.com>
Tue, 4 Oct 2016 20:14:12 +0000 (22:14 +0200)
committerDavid Sterba <dsterba@suse.com>
Wed, 5 Oct 2016 10:39:01 +0000 (12:39 +0200)
Macro to verify compile-time conditions, like sie of structures or
types.

Signed-off-by: David Sterba <dsterba@suse.com>
kerncompat.h

index 0cd85dc..ea04ef3 100644 (file)
 #define ULONG_MAX       (~0UL)
 #endif
 
+#define __token_glue(a,b,c)    ___token_glue(a,b,c)
+#define ___token_glue(a,b,c)   a ## b ## c
+#define BUILD_ASSERT(x)                extern int __token_glue(compile_time_assert_,__LINE__,__COUNTER__)[1-2*!(x)] __attribute__((unused))
+
 #ifndef BTRFS_DISABLE_BACKTRACE
 #define MAX_BACKTRACE  16
 static inline void print_trace(void)