![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 #ifndef TYPECHECK_H_INCLUDED 0003 #define TYPECHECK_H_INCLUDED 0004 0005 /* 0006 * Check at compile time that something is of a particular type. 0007 * Always evaluates to 1 so you may use it easily in comparisons. 0008 */ 0009 #define typecheck(type,x) \ 0010 ({ type __dummy; \ 0011 typeof(x) __dummy2; \ 0012 (void)(&__dummy == &__dummy2); \ 0013 1; \ 0014 }) 0015 0016 /* 0017 * Check at compile time that 'function' is a certain type, or is a pointer 0018 * to that type (needs to use typedef for the function type.) 0019 */ 0020 #define typecheck_fn(type,function) \ 0021 ({ typeof(type) __tmp = function; \ 0022 (void)__tmp; \ 0023 }) 0024 0025 /* 0026 * Check at compile time that something is a pointer type. 0027 */ 0028 #define typecheck_pointer(x) \ 0029 ({ typeof(x) __dummy; \ 0030 (void)sizeof(*__dummy); \ 0031 1; \ 0032 }) 0033 0034 #endif /* TYPECHECK_H_INCLUDED */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |