summaryrefslogtreecommitdiffstats
path: root/linux/syscall-table.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/syscall-table.c')
-rw-r--r--linux/syscall-table.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/linux/syscall-table.c b/linux/syscall-table.c
new file mode 100644
index 0000000..6bcd480
--- /dev/null
+++ b/linux/syscall-table.c
@@ -0,0 +1,58 @@
+/* See LICENSE file for copyright and license details. */
+#define REQUIRE_FLEXABLE_OR_NPARAMS
+#include "../common.h"
+
+
+#include "../generated/linux-syscall-table.h"
+#include "../generated/linux-syscalls.h"
+#include "syscalls.h"
+
+
+/* generated/linux-syscall-dedup.h removes references to duplicate symbols, then compiler optimisation removes them */
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wunused-const-variable"
+#elif defined(__GNUC__)
+# pragma GCC diagnostic ignored "-Wunused-const-variable"
+#endif
+
+
+#define MAKE_SYSCALL_WITHOUT_COMPAT(ARCH, NR, NAME, ACTUAL)\
+ static const struct libsyscalls_syscall linux_##ARCH##_syscall_##NAME = {\
+ .name = #NAME,\
+ .actual_syscall = &linux_syscall_##ACTUAL,\
+ .actual_compat_syscall = NULL\
+ }
+
+#define MAKE_SYSCALL_WITH_COMPAT(ARCH, NR, NAME, ACTUAL, COMPAT)\
+ static const struct libsyscalls_syscall linux_##ARCH##_syscall_##NAME = {\
+ .name = #NAME,\
+ .actual_syscall = &linux_syscall_##ACTUAL,\
+ .actual_compat_syscall = &linux_syscall_##COMPAT\
+ }
+
+
+#define X(ARCH)\
+ LIST_LINUX_SYSCALLS_FOR_##ARCH(MAKE_##ARCH##_SYSCALL_WITHOUT_COMPAT, MAKE_##ARCH##_SYSCALL_WITH_COMPAT, ;)
+LIST_LINUX_ARCHES(X, ;);
+#undef X
+
+#ifndef CREATING_DEDUP_TABLE
+# include "../generated/linux-syscall-dedup.h"
+#endif
+
+#define MAKE_SYSCALL_TABLE_ENTRY(ARCH, NR, NAME, ...)\
+ [NR] = &linux_##ARCH##_syscall_##NAME
+
+#define X(ARCH)\
+ static const struct libsyscalls_syscall *const linux_##ARCH##_syscalls_table[] = {\
+ LIST_LINUX_SYSCALLS_FOR_##ARCH(MAKE_##ARCH##_SYSCALL_TABLE_ENTRY, MAKE_##ARCH##_SYSCALL_TABLE_ENTRY, COMMA)\
+ }
+LIST_LINUX_ARCHES(X, ;);
+#undef X
+
+
+const struct libsyscalls_syscall *const *const libsyscalls_linux_syscalls_table_[] = {
+#define X(ARCH) [LIBSYSCALLS_ARCH_##ARCH] = linux_##ARCH##_syscalls_table
+ LIST_LINUX_ARCHES(X, COMMA)
+#undef X
+};