1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00

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.)
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-04-28 03:18:05 +08:00
parent 192a9d95ea
commit 94dfd85b0c
2 changed files with 68 additions and 20 deletions

View File

@ -1,6 +1,34 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later /* SPDX-License-Identifier: LGPL-2.1-or-later
* This file is generated. Do not edit! */ * This file is generated. Do not edit! */
/* Note: if this code looks strange, this is because it is derived from the same
* template as the per-syscall blocks below. */
# if defined(__aarch64__)
# elif defined(__alpha__)
# elif defined(__arc__) || defined(__tilegx__)
# elif defined(__arm__)
# elif defined(__i386__)
# elif defined(__ia64__)
# elif defined(__m68k__)
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__powerpc__)
# elif defined(__s390__)
# elif defined(__sparc__)
# elif defined(__x86_64__)
# if defined(__ILP32__)
# else
# endif
# elif !defined(missing_arch_template)
# warning "Current architecture is missing from the template"
# define missing_arch_template 1
# endif
#ifndef __IGNORE_bpf #ifndef __IGNORE_bpf
# if defined(__aarch64__) # if defined(__aarch64__)
# define systemd_NR_bpf 280 # define systemd_NR_bpf 280
@ -38,7 +66,7 @@
# else # else
# define systemd_NR_bpf 321 # define systemd_NR_bpf 321
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "bpf() syscall number is unknown for your architecture" # warning "bpf() syscall number is unknown for your architecture"
# endif # endif
@ -94,7 +122,7 @@ assert_cc(__NR_bpf == systemd_NR_bpf);
# else # else
# define systemd_NR_close_range 436 # define systemd_NR_close_range 436
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "close_range() syscall number is unknown for your architecture" # warning "close_range() syscall number is unknown for your architecture"
# endif # endif
@ -150,7 +178,7 @@ assert_cc(__NR_close_range == systemd_NR_close_range);
# else # else
# define systemd_NR_copy_file_range 326 # define systemd_NR_copy_file_range 326
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "copy_file_range() syscall number is unknown for your architecture" # warning "copy_file_range() syscall number is unknown for your architecture"
# endif # endif
@ -206,7 +234,7 @@ assert_cc(__NR_copy_file_range == systemd_NR_copy_file_range);
# else # else
# define systemd_NR_getrandom 318 # define systemd_NR_getrandom 318
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "getrandom() syscall number is unknown for your architecture" # warning "getrandom() syscall number is unknown for your architecture"
# endif # endif
@ -262,7 +290,7 @@ assert_cc(__NR_getrandom == systemd_NR_getrandom);
# else # else
# define systemd_NR_memfd_create 319 # define systemd_NR_memfd_create 319
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "memfd_create() syscall number is unknown for your architecture" # warning "memfd_create() syscall number is unknown for your architecture"
# endif # endif
@ -318,7 +346,7 @@ assert_cc(__NR_memfd_create == systemd_NR_memfd_create);
# else # else
# define systemd_NR_name_to_handle_at 303 # define systemd_NR_name_to_handle_at 303
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "name_to_handle_at() syscall number is unknown for your architecture" # warning "name_to_handle_at() syscall number is unknown for your architecture"
# endif # endif
@ -374,7 +402,7 @@ assert_cc(__NR_name_to_handle_at == systemd_NR_name_to_handle_at);
# else # else
# define systemd_NR_pidfd_open 434 # define systemd_NR_pidfd_open 434
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "pidfd_open() syscall number is unknown for your architecture" # warning "pidfd_open() syscall number is unknown for your architecture"
# endif # endif
@ -430,7 +458,7 @@ assert_cc(__NR_pidfd_open == systemd_NR_pidfd_open);
# else # else
# define systemd_NR_pidfd_send_signal 424 # define systemd_NR_pidfd_send_signal 424
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "pidfd_send_signal() syscall number is unknown for your architecture" # warning "pidfd_send_signal() syscall number is unknown for your architecture"
# endif # endif
@ -486,7 +514,7 @@ assert_cc(__NR_pidfd_send_signal == systemd_NR_pidfd_send_signal);
# else # else
# define systemd_NR_pkey_mprotect 329 # define systemd_NR_pkey_mprotect 329
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "pkey_mprotect() syscall number is unknown for your architecture" # warning "pkey_mprotect() syscall number is unknown for your architecture"
# endif # endif
@ -542,7 +570,7 @@ assert_cc(__NR_pkey_mprotect == systemd_NR_pkey_mprotect);
# else # else
# define systemd_NR_renameat2 316 # define systemd_NR_renameat2 316
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "renameat2() syscall number is unknown for your architecture" # warning "renameat2() syscall number is unknown for your architecture"
# endif # endif
@ -598,7 +626,7 @@ assert_cc(__NR_renameat2 == systemd_NR_renameat2);
# else # else
# define systemd_NR_setns 308 # define systemd_NR_setns 308
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "setns() syscall number is unknown for your architecture" # warning "setns() syscall number is unknown for your architecture"
# endif # endif
@ -654,7 +682,7 @@ assert_cc(__NR_setns == systemd_NR_setns);
# else # else
# define systemd_NR_statx 332 # define systemd_NR_statx 332
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "statx() syscall number is unknown for your architecture" # warning "statx() syscall number is unknown for your architecture"
# endif # endif
@ -710,7 +738,7 @@ assert_cc(__NR_statx == systemd_NR_statx);
# else # else
# define systemd_NR_epoll_pwait2 441 # define systemd_NR_epoll_pwait2 441
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "epoll_pwait2() syscall number is unknown for your architecture" # warning "epoll_pwait2() syscall number is unknown for your architecture"
# endif # endif

View File

@ -37,8 +37,12 @@ def parse_syscall_tables(filenames):
return {filename.split('-')[-1][:-4]: parse_syscall_table(filename) return {filename.split('-')[-1][:-4]: parse_syscall_table(filename)
for filename in filenames} for filename in filenames}
DEF_TEMPLATE = ''' DEF_TEMPLATE_A = '''\
#ifndef __IGNORE_{syscall} #ifndef __IGNORE_{syscall}
'''
DEF_TEMPLATE_B = '''\
# if defined(__aarch64__) # if defined(__aarch64__)
# define systemd_NR_{syscall} {nr_arm64} # define systemd_NR_{syscall} {nr_arm64}
# elif defined(__alpha__) # elif defined(__alpha__)
@ -75,9 +79,12 @@ DEF_TEMPLATE = '''
# else # else
# define systemd_NR_{syscall} {nr_x86_64} # define systemd_NR_{syscall} {nr_x86_64}
# endif # endif
# else # elif !defined(missing_arch_template)
# warning "{syscall}() syscall number is unknown for your architecture" %s
# endif # endif
'''
DEF_TEMPLATE_C = '''\
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */ /* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_{syscall} && __NR_{syscall} >= 0 # if defined __NR_{syscall} && __NR_{syscall} >= 0
@ -92,20 +99,33 @@ assert_cc(__NR_{syscall} == systemd_NR_{syscall});
# define __NR_{syscall} systemd_NR_{syscall} # define __NR_{syscall} systemd_NR_{syscall}
# endif # endif
# 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): def print_syscall_def(syscall, tables, out):
mappings = {f'nr_{arch}':t.get(syscall, -1) mappings = {f'nr_{arch}':t.get(syscall, -1)
for arch, t in tables.items()} for arch, t in tables.items()}
print(DEF_TEMPLATE.format(syscall=syscall, **mappings), print(DEF_TEMPLATE.format(syscall=syscall, **mappings),
file=out, end='') file=out)
def print_syscall_defs(syscalls, tables, out): def print_syscall_defs(syscalls, tables, out):
print('''\ print('''\
/* SPDX-License-Identifier: LGPL-2.1-or-later /* SPDX-License-Identifier: LGPL-2.1-or-later
* This file is generated. Do not edit! */ * This file is generated. Do not edit! */
''' , file=out, end='') ''',
file=out)
print(ARCH_CHECK, file=out)
for syscall in syscalls: for syscall in syscalls:
print_syscall_def(syscall, tables, out) print_syscall_def(syscall, tables, out)