repo init
[linux-rt-nao.git] / include / linux / pickop.h
blob3e1edad61ae3d258d473994b733e9b4e24328654
1 #ifndef _LINUX_PICKOP_H
2 #define _LINUX_PICKOP_H
4 #undef PICK_TYPE_EQUAL
5 #define PICK_TYPE_EQUAL(var, type) \
6 __builtin_types_compatible_p(typeof(var), type)
8 extern int __bad_func_type(void);
10 #define PICK_FUNCTION(type1, type2, func1, func2, arg0, ...) \
11 do { \
12 if (PICK_TYPE_EQUAL((arg0), type1)) \
13 func1((type1)(arg0), ##__VA_ARGS__); \
14 else if (PICK_TYPE_EQUAL((arg0), type2)) \
15 func2((type2)(arg0), ##__VA_ARGS__); \
16 else __bad_func_type(); \
17 } while (0)
19 #define PICK_FUNCTION_RET(type1, type2, func1, func2, arg0, ...) \
20 ({ \
21 unsigned long __ret; \
23 if (PICK_TYPE_EQUAL((arg0), type1)) \
24 __ret = func1((type1)(arg0), ##__VA_ARGS__); \
25 else if (PICK_TYPE_EQUAL((arg0), type2)) \
26 __ret = func2((type2)(arg0), ##__VA_ARGS__); \
27 else __ret = __bad_func_type(); \
29 __ret; \
32 #endif /* _LINUX_PICKOP_H */