Commit e0deaff470900a4c3222ca7139f6c9639e26a2f5

Authored by Andrew Morton
Committed by Linus Torvalds
1 parent 5df439ef06

split the typecheck macros out of include/linux/kernel.h

Needed to fix up a recursive include snafu in
locking-add-typecheck-on-irqsave-and-friends-for-correct-flags.patch

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 25 additions and 20 deletions Side-by-side Diff

include/linux/kernel.h
... ... @@ -14,6 +14,7 @@
14 14 #include <linux/compiler.h>
15 15 #include <linux/bitops.h>
16 16 #include <linux/log2.h>
  17 +#include <linux/typecheck.h>
17 18 #include <asm/byteorder.h>
18 19 #include <asm/bug.h>
19 20  
... ... @@ -440,26 +441,6 @@
440 441 #define container_of(ptr, type, member) ({ \
441 442 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
442 443 (type *)( (char *)__mptr - offsetof(type,member) );})
443   -
444   -/*
445   - * Check at compile time that something is of a particular type.
446   - * Always evaluates to 1 so you may use it easily in comparisons.
447   - */
448   -#define typecheck(type,x) \
449   -({ type __dummy; \
450   - typeof(x) __dummy2; \
451   - (void)(&__dummy == &__dummy2); \
452   - 1; \
453   -})
454   -
455   -/*
456   - * Check at compile time that 'function' is a certain type, or is a pointer
457   - * to that type (needs to use typedef for the function type.)
458   - */
459   -#define typecheck_fn(type,function) \
460   -({ typeof(type) __tmp = function; \
461   - (void)__tmp; \
462   -})
463 444  
464 445 struct sysinfo;
465 446 extern int do_sysinfo(struct sysinfo *info);
include/linux/typecheck.h
  1 +#ifndef TYPECHECK_H_INCLUDED
  2 +#define TYPECHECK_H_INCLUDED
  3 +
  4 +/*
  5 + * Check at compile time that something is of a particular type.
  6 + * Always evaluates to 1 so you may use it easily in comparisons.
  7 + */
  8 +#define typecheck(type,x) \
  9 +({ type __dummy; \
  10 + typeof(x) __dummy2; \
  11 + (void)(&__dummy == &__dummy2); \
  12 + 1; \
  13 +})
  14 +
  15 +/*
  16 + * Check at compile time that 'function' is a certain type, or is a pointer
  17 + * to that type (needs to use typedef for the function type.)
  18 + */
  19 +#define typecheck_fn(type,function) \
  20 +({ typeof(type) __tmp = function; \
  21 + (void)__tmp; \
  22 +})
  23 +
  24 +#endif /* TYPECHECK_H_INCLUDED */