]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/missing_syscalls.py
2 # SPDX-License-Identifier: LGPL-2.1-or-later
7 # We only generate numbers for a dozen or so syscalls
23 def wrap(*args
, **kwargs
):
24 return dict(f(*args
, **kwargs
))
25 return functools
.update_wrapper(wrap
, f
)
28 def parse_syscall_table(filename
):
29 print(f
'Reading {filename}…')
30 for line
in open(filename
):
33 yield items
[0], int(items
[1])
35 def parse_syscall_tables(filenames
):
36 return {filename
.split('-')[-1][:-4]: parse_syscall_table(filename
)
37 for filename
in filenames
}
40 #ifndef __IGNORE_{syscall}
41 # if defined(__aarch64__)
42 # define systemd_NR_{syscall} {nr_arm64}
43 # elif defined(__alpha__)
44 # define systemd_NR_{syscall} {nr_alpha}
45 # elif defined(__arc__) || defined(__tilegx__)
46 # define systemd_NR_{syscall} {nr_arc}
47 # elif defined(__arm__)
48 # define systemd_NR_{syscall} {nr_arm}
49 # elif defined(__i386__)
50 # define systemd_NR_{syscall} {nr_i386}
51 # elif defined(__ia64__)
52 # define systemd_NR_{syscall} {nr_ia64}
53 # elif defined(__m68k__)
54 # define systemd_NR_{syscall} {nr_m68k}
55 # elif defined(_MIPS_SIM)
56 # if _MIPS_SIM == _MIPS_SIM_ABI32
57 # define systemd_NR_{syscall} {nr_mipso32}
58 # elif _MIPS_SIM == _MIPS_SIM_NABI32
59 # define systemd_NR_{syscall} {nr_mips64n32}
60 # elif _MIPS_SIM == _MIPS_SIM_ABI64
61 # define systemd_NR_{syscall} {nr_mips64}
63 # error "Unknown MIPS ABI"
65 # elif defined(__powerpc__)
66 # define systemd_NR_{syscall} {nr_powerpc}
67 # elif defined(__s390__)
68 # define systemd_NR_{syscall} {nr_s390}
69 # elif defined(__sparc__)
70 # define systemd_NR_{syscall} {nr_sparc}
71 # elif defined(__x86_64__)
72 # if defined(__ILP32__)
73 # define systemd_NR_{syscall} ({nr_x86_64} | /* __X32_SYSCALL_BIT */ 0x40000000)
75 # define systemd_NR_{syscall} {nr_x86_64}
78 # warning "{syscall}() syscall number is unknown for your architecture"
81 /* may be an (invalid) negative number due to libseccomp, see PR 13319 */
82 # if defined __NR_{syscall} && __NR_{syscall} >= 0
83 # if defined systemd_NR_{syscall}
84 assert_cc(__NR_{syscall} == systemd_NR_{syscall});
87 # if defined __NR_{syscall}
88 # undef __NR_{syscall}
90 # if defined systemd_NR_{syscall} && systemd_NR_{syscall} >= 0
91 # define __NR_{syscall} systemd_NR_{syscall}
97 def print_syscall_def(syscall
, tables
, out
):
98 mappings
= {f
'nr_{arch}':t
.get(syscall
, -1)
99 for arch
, t
in tables
.items()}
100 print(DEF_TEMPLATE
.format(syscall
=syscall
, **mappings
),
103 def print_syscall_defs(syscalls
, tables
, out
):
105 /* SPDX-License-Identifier: LGPL-2.1-or-later
106 * This file is generated. Do not edit! */
108 for syscall
in syscalls
:
109 print_syscall_def(syscall
, tables
, out
)
111 if __name__
== '__main__':
112 output_file
= sys
.argv
[1]
113 arch_files
= sys
.argv
[2:]
114 out
= open(output_file
, 'wt')
116 tables
= parse_syscall_tables(arch_files
)
117 print_syscall_defs(SYSCALLS
, tables
, out
)
119 print(f
'Wrote {output_file}')