summaryrefslogtreecommitdiffstats
path: root/linux/syscall-table.c
blob: 0b1e0a0558c3891de2f01c7cd28b973a8ea78aad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* 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"

#if defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-variable" /* unused = not available on any architecutre the library is being compiled for */
#endif

#include "syscalls.h"

#if defined(__GNUC__)
# pragma GCC diagnostic pop
#endif



/* 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_WITHOUT_ENDIANS(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_WITHOUT_ENDIANS(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
};