]> git.hungrycats.org Git - linux/commitdiff
[KERNEL]: Add typecheck macro for verifying types at compile time.
authorDavid S. Miller <davem@nuts.ninka.net>
Wed, 5 Mar 2003 13:22:16 +0000 (05:22 -0800)
committerLinus Torvalds <torvalds@home.transmeta.com>
Wed, 5 Mar 2003 13:22:16 +0000 (05:22 -0800)
include/linux/kernel.h

index 5cd1d8dc77f788863e3e2b835738304fb0032f54..f7f83f129d9fc3c5eec08f227aac13e5d2ae7467 100644 (file)
@@ -188,6 +188,17 @@ extern void dump_stack(void);
         const typeof( ((type *)0)->member ) *__mptr = (ptr);   \
         (type *)( (char *)__mptr - offsetof(type,member) );})
 
+/*
+ * Check at compile time that something is of a particular type.
+ * Always evaluates to 1 so you may use it easily in conparisons.
+ */
+#define typecheck(type,x) \
+({     type __dummy; \
+       typeof(x) __dummy2; \
+       (void)(&__dummy == &__dummy2); \
+       1; \
+})
+
 #endif /* __KERNEL__ */
 
 #define SI_LOAD_SHIFT  16