summaryrefslogtreecommitdiffstats
path: root/src/basic/missing_syscalls.py
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-04-27 21:18:05 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-04-28 15:41:34 +0200
commit94dfd85b0cc8d2271b9d1aedeb75d43123a94e85 (patch)
treeeccd1072ff718ed7fde6bd740f21b81a64b65701 /src/basic/missing_syscalls.py
parentnetwork: neighbor: Always add neighbors with replace (diff)
downloadsystemd-94dfd85b0cc8d2271b9d1aedeb75d43123a94e85.tar.xz
systemd-94dfd85b0cc8d2271b9d1aedeb75d43123a94e85.zip
basic/missing-syscalls: only emit one warning about missing numbers
The ifdef pattern is the same for all syscalls, so most of the time, if one is not defined, all others will too. So let's reduce the noise a bit and emit one warning in case the support for the architecture is fully missing. (Current template was copied over from before when we added numbers for each syscall by hand and stopped making sense when we started generating the header from a table that is expected to have all syscall numbers.)
Diffstat (limited to 'src/basic/missing_syscalls.py')
-rw-r--r--src/basic/missing_syscalls.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/basic/missing_syscalls.py b/src/basic/missing_syscalls.py
index 550be48cf4..e83a17b59a 100644
--- a/src/basic/missing_syscalls.py
+++ b/src/basic/missing_syscalls.py
@@ -37,8 +37,12 @@ def parse_syscall_tables(filenames):
return {filename.split('-')[-1][:-4]: parse_syscall_table(filename)
for filename in filenames}
-DEF_TEMPLATE = '''
+DEF_TEMPLATE_A = '''\
+
#ifndef __IGNORE_{syscall}
+'''
+
+DEF_TEMPLATE_B = '''\
# if defined(__aarch64__)
# define systemd_NR_{syscall} {nr_arm64}
# elif defined(__alpha__)
@@ -75,9 +79,12 @@ DEF_TEMPLATE = '''
# else
# define systemd_NR_{syscall} {nr_x86_64}
# endif
-# else
-# warning "{syscall}() syscall number is unknown for your architecture"
+# elif !defined(missing_arch_template)
+%s
# endif
+'''
+
+DEF_TEMPLATE_C = '''\
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_{syscall} && __NR_{syscall} >= 0
@@ -92,20 +99,33 @@ assert_cc(__NR_{syscall} == systemd_NR_{syscall});
# define __NR_{syscall} systemd_NR_{syscall}
# endif
# endif
-#endif
-'''
+#endif'''
+
+DEF_TEMPLATE = (DEF_TEMPLATE_A +
+ DEF_TEMPLATE_B % '# warning "{syscall}() syscall number is unknown for your architecture"' +
+ DEF_TEMPLATE_C)
+
+ARCH_CHECK = '''\
+/* Note: if this code looks strange, this is because it is derived from the same
+ * template as the per-syscall blocks below. */
+''' + '\n'.join(line for line in DEF_TEMPLATE_B.splitlines()
+ if ' define ' not in line) % '''\
+# warning "Current architecture is missing from the template"
+# define missing_arch_template 1'''
def print_syscall_def(syscall, tables, out):
mappings = {f'nr_{arch}':t.get(syscall, -1)
for arch, t in tables.items()}
print(DEF_TEMPLATE.format(syscall=syscall, **mappings),
- file=out, end='')
+ file=out)
def print_syscall_defs(syscalls, tables, out):
print('''\
/* SPDX-License-Identifier: LGPL-2.1-or-later
* This file is generated. Do not edit! */
-''' , file=out, end='')
+''',
+ file=out)
+ print(ARCH_CHECK, file=out)
for syscall in syscalls:
print_syscall_def(syscall, tables, out)