mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-24 13:43:28 +00:00
typecheck: import include/linux/typecheck.h from Linux 4.9
Copied from Linux 4.9. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
parent
a7b8176999
commit
ff90af6c73
1 changed files with 24 additions and 0 deletions
24
include/linux/typecheck.h
Normal file
24
include/linux/typecheck.h
Normal file
|
@ -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 */
|
Loading…
Reference in a new issue