syscalls.h: slightly reduce the jungles of macros
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 5 Mar 2013 20:36:40 +0000 (15:36 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 5 Mar 2013 20:36:40 +0000 (15:36 -0500)
a) teach __MAP(num, m, <list of type/name pairs>) to take empty
list (with num being 0, of course)
b) fold types__... and args__... declaration and initialization into
SYSCALL_METADATA(num, ...), making their use conditional on num != 0.
That allows to use the SYSCALL_METADATA instead of its near-duplicate
in SYSCALL_DEFINE0.
c) make SYSCALL_METADATA expand to nothing in case if CONFIG_FTRACE_SYSCALLS
is not defined; that allows to make SYSCALL_DEFINE0 and SYSCALL_DEFINEx
definitions independent from CONFIG_FTRACE_SYSCALLS.
d) kill SYSCALL_DEFINE - no users left (SYSCALL_DEFINE[0-6] is, of course,
still alive and well).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
include/linux/syscalls.h

index 65c001f..4147d70 100644 (file)
@@ -87,6 +87,7 @@ struct sigaltstack;
  * of __MAP starting at the third one) is in the same format as
  * for SYSCALL_DEFINE<n>/COMPAT_SYSCALL_DEFINE<n>
  */
+#define __MAP0(m,...)
 #define __MAP1(m,t,a) m(t,a)
 #define __MAP2(m,t,a,...) m(t,a), __MAP1(m,__VA_ARGS__)
 #define __MAP3(m,t,a,...) m(t,a), __MAP2(m,__VA_ARGS__)
@@ -139,7 +140,13 @@ extern struct trace_event_functions exit_syscall_print_funcs;
          __attribute__((section("_ftrace_events")))                    \
        *__event_exit_##sname = &event_exit_##sname;
 
-#define SYSCALL_METADATA(sname, nb)                            \
+#define SYSCALL_METADATA(sname, nb, ...)                       \
+       static const char *types_##sname[] = {                  \
+               __MAP(nb,__SC_STR_TDECL,__VA_ARGS__)            \
+       };                                                      \
+       static const char *args_##sname[] = {                   \
+               __MAP(nb,__SC_STR_ADECL,__VA_ARGS__)            \
+       };                                                      \
        SYSCALL_TRACE_ENTER_EVENT(sname);                       \
        SYSCALL_TRACE_EXIT_EVENT(sname);                        \
        static struct syscall_metadata __used                   \
@@ -147,8 +154,8 @@ extern struct trace_event_functions exit_syscall_print_funcs;
                .name           = "sys"#sname,                  \
                .syscall_nr     = -1,   /* Filled in at boot */ \
                .nb_args        = nb,                           \
-               .types          = types_##sname,                \
-               .args           = args_##sname,                 \
+               .types          = nb ? types_##sname : NULL,    \
+               .args           = nb ? args_##sname : NULL,     \
                .enter_event    = &event_enter_##sname,         \
                .exit_event     = &event_exit_##sname,          \
                .enter_fields   = LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \
@@ -156,26 +163,13 @@ extern struct trace_event_functions exit_syscall_print_funcs;
        static struct syscall_metadata __used                   \
          __attribute__((section("__syscalls_metadata")))       \
         *__p_syscall_meta_##sname = &__syscall_meta_##sname;
+#else
+#define SYSCALL_METADATA(sname, nb, ...)
+#endif
 
 #define SYSCALL_DEFINE0(sname)                                 \
-       SYSCALL_TRACE_ENTER_EVENT(_##sname);                    \
-       SYSCALL_TRACE_EXIT_EVENT(_##sname);                     \
-       static struct syscall_metadata __used                   \
-         __syscall_meta__##sname = {                           \
-               .name           = "sys_"#sname,                 \
-               .syscall_nr     = -1,   /* Filled in at boot */ \
-               .nb_args        = 0,                            \
-               .enter_event    = &event_enter__##sname,        \
-               .exit_event     = &event_exit__##sname,         \
-               .enter_fields   = LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \
-       };                                                      \
-       static struct syscall_metadata __used                   \
-         __attribute__((section("__syscalls_metadata")))       \
-        *__p_syscall_meta_##sname = &__syscall_meta__##sname;  \
+       SYSCALL_METADATA(_##sname, 0);                          \
        asmlinkage long sys_##sname(void)
-#else
-#define SYSCALL_DEFINE0(name)     asmlinkage long sys_##name(void)
-#endif
 
 #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
 #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
@@ -184,22 +178,9 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
 #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
 
-#ifdef CONFIG_FTRACE_SYSCALLS
 #define SYSCALL_DEFINEx(x, sname, ...)                         \
-       static const char *types_##sname[] = {                  \
-               __MAP(x,__SC_STR_TDECL,__VA_ARGS__)             \
-       };                                                      \
-       static const char *args_##sname[] = {                   \
-               __MAP(x,__SC_STR_ADECL,__VA_ARGS__)             \
-       };                                                      \
-       SYSCALL_METADATA(sname, x);                             \
+       SYSCALL_METADATA(sname, x, __VA_ARGS__)                 \
        __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
-#else
-#define SYSCALL_DEFINEx(x, sname, ...)                         \
-       __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
-#endif
-
-#define SYSCALL_DEFINE(name) static inline long SYSC_##name
 
 #define __PROTECT(...) asmlinkage_protect(__VA_ARGS__)
 #define __SYSCALL_DEFINEx(x, name, ...)                                        \