]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/missing_syscalls.py
5 # We only generate numbers for a dozen or so syscalls
21 def wrap(*args
, **kwargs
):
22 return dict(f(*args
, **kwargs
))
23 return functools
.update_wrapper(wrap
, f
)
26 def parse_syscall_table(filename
):
27 print(f
'Reading {filename}…')
28 for line
in open(filename
):
31 yield items
[0], int(items
[1])
33 def parse_syscall_tables(filenames
):
34 return {filename
.split('-')[-1]: parse_syscall_table(filename
)
35 for filename
in filenames
}
38 #ifndef __IGNORE_{syscall}
39 # if defined(__aarch64__)
40 # define systemd_NR_{syscall} {nr_arm64}
41 # elif defined(__alpha__)
42 # define systemd_NR_{syscall} {nr_alpha}
43 # elif defined(__arc__) || defined(__tilegx__)
44 # define systemd_NR_{syscall} {nr_arc}
45 # elif defined(__arm__)
46 # define systemd_NR_{syscall} {nr_arm}
47 # elif defined(__i386__)
48 # define systemd_NR_{syscall} {nr_i386}
49 # elif defined(__ia64__)
50 # define systemd_NR_{syscall} {nr_ia64}
51 # elif defined(__m68k__)
52 # define systemd_NR_{syscall} {nr_m68k}
53 # elif defined(_MIPS_SIM)
54 # if _MIPS_SIM == _MIPS_SIM_ABI32
55 # define systemd_NR_{syscall} {nr_mipso32}
56 # elif _MIPS_SIM == _MIPS_SIM_NABI32
57 # define systemd_NR_{syscall} {nr_mips64n32}
58 # elif _MIPS_SIM == _MIPS_SIM_ABI64
59 # define systemd_NR_{syscall} {nr_mips64}
61 # error "Unknown MIPS ABI"
63 # elif defined(__powerpc__)
64 # define systemd_NR_{syscall} {nr_powerpc}
65 # elif defined(__s390__)
66 # define systemd_NR_{syscall} {nr_s390}
67 # elif defined(__sparc__)
68 # define systemd_NR_{syscall} {nr_sparc}
69 # elif defined(__x86_64__)
70 # if defined(__ILP32__)
71 # define systemd_NR_{syscall} ({nr_x86_64} | /* __X32_SYSCALL_BIT */ 0x40000000)
73 # define systemd_NR_{syscall} {nr_x86_64}
76 # warning "{syscall}() syscall number is unknown for your architecture"
79 /* may be (invalid) negative number due to libseccomp, see PR 13319 */
80 # if defined __NR_{syscall} && __NR_{syscall} >= 0
81 # if defined systemd_NR_{syscall}
82 assert_cc(__NR_{syscall} == systemd_NR_{syscall});
85 # if defined __NR_{syscall}
86 # undef __NR_{syscall}
88 # if defined systemd_NR_{syscall} && systemd_NR_{syscall} >= 0
89 # define __NR_{syscall} systemd_NR_{syscall}
95 def print_syscall_def(syscall
, tables
, out
):
96 mappings
= {f
'nr_{arch}':t
.get(syscall
, -1)
97 for arch
, t
in tables
.items()}
98 print(DEF_TEMPLATE
.format(syscall
=syscall
, **mappings
),
101 def print_syscall_defs(syscalls
, tables
, out
):
102 print('/* This file is generated. Do not edit! */\n', file=out
)
103 for syscall
in syscalls
:
104 print_syscall_def(syscall
, tables
, out
)
106 if __name__
== '__main__':
107 output_file
= sys
.argv
[1]
108 arch_files
= sys
.argv
[2:]
109 out
= open(output_file
, 'wt')
111 tables
= parse_syscall_tables(arch_files
)
112 print_syscall_defs(SYSCALLS
, tables
, out
)
114 print(f
'Wrote {output_file}')