summaryrefslogtreecommitdiffstats
path: root/linux/syscall-table.c
blob: 6bcd4802d1341e7de1580e4c027bf37884d98573 (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
/* 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
};