From c131f122778c62f920a99bbf854ced4a37ee8b03 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 3 Dec 2023 19:23:35 +0100 Subject: First commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- linux/syscall-table.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 linux/syscall-table.c (limited to 'linux/syscall-table.c') 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 +}; -- cgit v1.2.3-70-g09d2