-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Andrew Morton
authored and
Linus Torvalds
committed
Jul 25, 2008
1 parent
5df439e
commit e0deaff
Showing
2 changed files
with
25 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef TYPECHECK_H_INCLUDED | ||
#define TYPECHECK_H_INCLUDED | ||
|
||
/* | ||
* 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; \ | ||
}) | ||
|
||
/* | ||
* Check at compile time that 'function' is a certain type, or is a pointer | ||
* to that type (needs to use typedef for the function type.) | ||
*/ | ||
#define typecheck_fn(type,function) \ | ||
({ typeof(type) __tmp = function; \ | ||
(void)__tmp; \ | ||
}) | ||
|
||
#endif /* TYPECHECK_H_INCLUDED */ |