Commit 07fe6e00 authored by Al Viro's avatar Al Viro

get rid of duplicate logics in __SC_....[1-6] definitions

All those guys have the same form - "take a list of type/name pairs,
apply some macro to each of them".  Abstract that part away, convert
all __SC_FOO##x(__VA_ARGS__) to __MAP(x,__SC_FOO,__VA_ARGS__).
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 6dbe51c2
...@@ -27,12 +27,6 @@ ...@@ -27,12 +27,6 @@
#define __SC_DELOUSE(t,v) ((t)(unsigned long)(v)) #define __SC_DELOUSE(t,v) ((t)(unsigned long)(v))
#endif #endif
#define __SC_CCAST1(t1, a1) __SC_DELOUSE(t1,a1)
#define __SC_CCAST2(t2, a2, ...) __SC_DELOUSE(t2,a2), __SC_CCAST1(__VA_ARGS__)
#define __SC_CCAST3(t3, a3, ...) __SC_DELOUSE(t3,a3), __SC_CCAST2(__VA_ARGS__)
#define __SC_CCAST4(t4, a4, ...) __SC_DELOUSE(t4,a4), __SC_CCAST3(__VA_ARGS__)
#define __SC_CCAST5(t5, a5, ...) __SC_DELOUSE(t5,a5), __SC_CCAST4(__VA_ARGS__)
#define __SC_CCAST6(t6, a6, ...) __SC_DELOUSE(t6,a6), __SC_CCAST5(__VA_ARGS__)
#define COMPAT_SYSCALL_DEFINE1(name, ...) \ #define COMPAT_SYSCALL_DEFINE1(name, ...) \
COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__) COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
#define COMPAT_SYSCALL_DEFINE2(name, ...) \ #define COMPAT_SYSCALL_DEFINE2(name, ...) \
...@@ -49,19 +43,19 @@ ...@@ -49,19 +43,19 @@
#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
asmlinkage long compat_sys##name(__SC_DECL##x(__VA_ARGS__)); \ asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
static inline long C_SYSC##name(__SC_DECL##x(__VA_ARGS__)); \ static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
asmlinkage long compat_SyS##name(__SC_LONG##x(__VA_ARGS__)) \ asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\
{ \ { \
return (long) C_SYSC##name(__SC_CCAST##x(__VA_ARGS__)); \ return C_SYSC##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \
} \ } \
SYSCALL_ALIAS(compat_sys##name, compat_SyS##name); \ SYSCALL_ALIAS(compat_sys##name, compat_SyS##name); \
static inline long C_SYSC##name(__SC_DECL##x(__VA_ARGS__)) static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */ #else /* CONFIG_HAVE_SYSCALL_WRAPPERS */
#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
asmlinkage long compat_sys##name(__SC_DECL##x(__VA_ARGS__)) asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
#endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */ #endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */
......
...@@ -78,49 +78,31 @@ struct sigaltstack; ...@@ -78,49 +78,31 @@ struct sigaltstack;
#include <linux/key.h> #include <linux/key.h>
#include <trace/syscall.h> #include <trace/syscall.h>
#define __SC_DECL1(t1, a1) t1 a1 /*
#define __SC_DECL2(t2, a2, ...) t2 a2, __SC_DECL1(__VA_ARGS__) * __MAP - apply a macro to syscall arguments
#define __SC_DECL3(t3, a3, ...) t3 a3, __SC_DECL2(__VA_ARGS__) * __MAP(n, m, t1, a1, t2, a2, ..., tn, an) will expand to
#define __SC_DECL4(t4, a4, ...) t4 a4, __SC_DECL3(__VA_ARGS__) * m(t1, a1), m(t2, a2), ..., m(tn, an)
#define __SC_DECL5(t5, a5, ...) t5 a5, __SC_DECL4(__VA_ARGS__) * The first argument must be equal to the amount of type/name
#define __SC_DECL6(t6, a6, ...) t6 a6, __SC_DECL5(__VA_ARGS__) * pairs given. Note that this list of pairs (i.e. the arguments
* of __MAP starting at the third one) is in the same format as
#define __SC_LONG1(t1, a1) long a1 * for SYSCALL_DEFINE<n>/COMPAT_SYSCALL_DEFINE<n>
#define __SC_LONG2(t2, a2, ...) long a2, __SC_LONG1(__VA_ARGS__) */
#define __SC_LONG3(t3, a3, ...) long a3, __SC_LONG2(__VA_ARGS__) #define __MAP1(m,t,a) m(t,a)
#define __SC_LONG4(t4, a4, ...) long a4, __SC_LONG3(__VA_ARGS__) #define __MAP2(m,t,a,...) m(t,a), __MAP1(m,__VA_ARGS__)
#define __SC_LONG5(t5, a5, ...) long a5, __SC_LONG4(__VA_ARGS__) #define __MAP3(m,t,a,...) m(t,a), __MAP2(m,__VA_ARGS__)
#define __SC_LONG6(t6, a6, ...) long a6, __SC_LONG5(__VA_ARGS__) #define __MAP4(m,t,a,...) m(t,a), __MAP3(m,__VA_ARGS__)
#define __MAP5(m,t,a,...) m(t,a), __MAP4(m,__VA_ARGS__)
#define __SC_CAST1(t1, a1) (t1) a1 #define __MAP6(m,t,a,...) m(t,a), __MAP5(m,__VA_ARGS__)
#define __SC_CAST2(t2, a2, ...) (t2) a2, __SC_CAST1(__VA_ARGS__) #define __MAP(n,...) __MAP##n(__VA_ARGS__)
#define __SC_CAST3(t3, a3, ...) (t3) a3, __SC_CAST2(__VA_ARGS__)
#define __SC_CAST4(t4, a4, ...) (t4) a4, __SC_CAST3(__VA_ARGS__) #define __SC_DECL(t, a) t a
#define __SC_CAST5(t5, a5, ...) (t5) a5, __SC_CAST4(__VA_ARGS__) #define __SC_LONG(t, a) long a
#define __SC_CAST6(t6, a6, ...) (t6) a6, __SC_CAST5(__VA_ARGS__) #define __SC_CAST(t, a) (t) a
#define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(sizeof(type) > sizeof(long))
#define __SC_TEST(type) BUILD_BUG_ON(sizeof(type) > sizeof(long))
#define __SC_TEST1(t1, a1) __SC_TEST(t1)
#define __SC_TEST2(t2, a2, ...) __SC_TEST(t2); __SC_TEST1(__VA_ARGS__)
#define __SC_TEST3(t3, a3, ...) __SC_TEST(t3); __SC_TEST2(__VA_ARGS__)
#define __SC_TEST4(t4, a4, ...) __SC_TEST(t4); __SC_TEST3(__VA_ARGS__)
#define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__)
#define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__)
#ifdef CONFIG_FTRACE_SYSCALLS #ifdef CONFIG_FTRACE_SYSCALLS
#define __SC_STR_ADECL1(t, a) #a #define __SC_STR_ADECL(t, a) #a
#define __SC_STR_ADECL2(t, a, ...) #a, __SC_STR_ADECL1(__VA_ARGS__) #define __SC_STR_TDECL(t, a) #t
#define __SC_STR_ADECL3(t, a, ...) #a, __SC_STR_ADECL2(__VA_ARGS__)
#define __SC_STR_ADECL4(t, a, ...) #a, __SC_STR_ADECL3(__VA_ARGS__)
#define __SC_STR_ADECL5(t, a, ...) #a, __SC_STR_ADECL4(__VA_ARGS__)
#define __SC_STR_ADECL6(t, a, ...) #a, __SC_STR_ADECL5(__VA_ARGS__)
#define __SC_STR_TDECL1(t, a) #t
#define __SC_STR_TDECL2(t, a, ...) #t, __SC_STR_TDECL1(__VA_ARGS__)
#define __SC_STR_TDECL3(t, a, ...) #t, __SC_STR_TDECL2(__VA_ARGS__)
#define __SC_STR_TDECL4(t, a, ...) #t, __SC_STR_TDECL3(__VA_ARGS__)
#define __SC_STR_TDECL5(t, a, ...) #t, __SC_STR_TDECL4(__VA_ARGS__)
#define __SC_STR_TDECL6(t, a, ...) #t, __SC_STR_TDECL5(__VA_ARGS__)
extern struct ftrace_event_class event_class_syscall_enter; extern struct ftrace_event_class event_class_syscall_enter;
extern struct ftrace_event_class event_class_syscall_exit; extern struct ftrace_event_class event_class_syscall_exit;
...@@ -217,10 +199,10 @@ extern struct trace_event_functions exit_syscall_print_funcs; ...@@ -217,10 +199,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
#ifdef CONFIG_FTRACE_SYSCALLS #ifdef CONFIG_FTRACE_SYSCALLS
#define SYSCALL_DEFINEx(x, sname, ...) \ #define SYSCALL_DEFINEx(x, sname, ...) \
static const char *types_##sname[] = { \ static const char *types_##sname[] = { \
__SC_STR_TDECL##x(__VA_ARGS__) \ __MAP(x,__SC_STR_TDECL,__VA_ARGS__) \
}; \ }; \
static const char *args_##sname[] = { \ static const char *args_##sname[] = { \
__SC_STR_ADECL##x(__VA_ARGS__) \ __MAP(x,__SC_STR_ADECL,__VA_ARGS__) \
}; \ }; \
SYSCALL_METADATA(sname, x); \ SYSCALL_METADATA(sname, x); \
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__) __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
...@@ -234,21 +216,21 @@ extern struct trace_event_functions exit_syscall_print_funcs; ...@@ -234,21 +216,21 @@ extern struct trace_event_functions exit_syscall_print_funcs;
#define SYSCALL_DEFINE(name) static inline long SYSC_##name #define SYSCALL_DEFINE(name) static inline long SYSC_##name
#define __SYSCALL_DEFINEx(x, name, ...) \ #define __SYSCALL_DEFINEx(x, name, ...) \
asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)); \ asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)); \ static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__)) \ asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
{ \ { \
__SC_TEST##x(__VA_ARGS__); \ __MAP(x,__SC_TEST,__VA_ARGS__); \
return (long) SYSC##name(__SC_CAST##x(__VA_ARGS__)); \ return SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \
} \ } \
SYSCALL_ALIAS(sys##name, SyS##name); \ SYSCALL_ALIAS(sys##name, SyS##name); \
static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)) static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */ #else /* CONFIG_HAVE_SYSCALL_WRAPPERS */
#define SYSCALL_DEFINE(name) asmlinkage long sys_##name #define SYSCALL_DEFINE(name) asmlinkage long sys_##name
#define __SYSCALL_DEFINEx(x, name, ...) \ #define __SYSCALL_DEFINEx(x, name, ...) \
asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)) asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
#endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */ #endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment