basic: move basic/missing_syscall_defs.h -> include/override/sys/syscall.h

This also moves syscall tables and generators to the same directory.

Note, inclusion of asm/sgidefs.h is dropped, as it is already included
by unistd.h and sys/syscall.h.
This commit is contained in:
Yu Watanabe
2025-06-19 08:35:35 +09:00
parent 2b912d2066
commit da522c9921
28 changed files with 139 additions and 141 deletions

View File

@@ -121,9 +121,6 @@ sources += basic_sources
missing_audit_h = files('missing_audit.h')
missing_syscall_def_h = files('missing_syscall_def.h')
basic_sources += missing_syscall_def_h
generated_gperf_headers = []
foreach item : [
# name, source, struct name, prefix, headers
@@ -176,50 +173,6 @@ basic_sources += generated_gperf_headers
############################################################
arch_list = [
'alpha',
'arc',
'arm',
'arm64',
'i386',
'ia64',
'loongarch64',
'm68k',
'mips64',
'mips64n32',
'mipso32',
'parisc',
'powerpc',
'powerpc64',
'riscv32',
'riscv64',
's390',
's390x',
'sparc',
'x86_64'
]
run_target(
'update-syscall-tables',
command : [update_syscall_tables_sh, meson.current_source_dir()] + arch_list)
syscall_list_txt = files('syscall-list.txt')
syscall_lists = []
foreach arch: arch_list
syscall_lists += files('syscalls-@0@.txt'.format(arch))
endforeach
missing_syscalls_py = find_program('missing_syscalls.py')
run_target(
'update-syscall-header',
command : [missing_syscalls_py,
missing_syscall_def_h,
syscall_lists])
############################################################
filesystem_includes = files(
'../include/uapi/linux/magic.h',
'missing_magic.h',

View File

@@ -10,13 +10,8 @@
#include <sys/xattr.h>
#include <unistd.h>
#ifdef ARCH_MIPS
#include <asm/sgidefs.h>
#endif
#include "forward.h"
#include "missing_keyctl.h"
#include "missing_syscall_def.h"
/* ======================================================================= */

View File

@@ -1,5 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
subdir('override/sys')
# Source files that provides AF_XYZ
af_sources = files(
'override/sys/socket.h',

View File

@@ -33,6 +33,20 @@ def parse_syscall_tables(filenames):
return {filename.split('-')[-1][:-4]: parse_syscall_table(filename)
for filename in filenames}
HEADER = '''\
/* SPDX-License-Identifier: LGPL-2.1-or-later
* This file is generated by src/include/override/sys/generate-syscall.py. Do not edit!
*
* Use 'ninja -C build update-syscall-tables' to download new syscall tables,
* and 'ninja -C build update-syscall-header' to regenerate this file.
*/
#pragma once
#include_next <sys/syscall.h>
#include <assert.h>
'''
DEF_TEMPLATE_A = '''\
#ifndef __IGNORE_{syscall}
@@ -97,7 +111,7 @@ DEF_TEMPLATE_C = '''\
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_{syscall} && __NR_{syscall} >= 0
# if defined systemd_NR_{syscall}
_Static_assert(__NR_{syscall} == systemd_NR_{syscall}, "");
static_assert(__NR_{syscall} == systemd_NR_{syscall}, "");
# endif
# else
# if defined __NR_{syscall}
@@ -128,16 +142,7 @@ def print_syscall_def(syscall, tables, out):
file=out)
def print_syscall_defs(syscalls, tables, out):
print('''\
/* SPDX-License-Identifier: LGPL-2.1-or-later
* This file is generated by src/basic/missing_syscalls.py. Do not edit!
*
* Use 'ninja -C build update-syscall-tables' to download new syscall tables,
* and 'ninja -C build update-syscall-header' to regenerate this file.
*/
#pragma once
''',
file=out)
print(HEADER, file=out)
print(ARCH_CHECK, file=out)
for syscall in syscalls:
print_syscall_def(syscall, tables, out)

View File

@@ -0,0 +1,41 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
arch_list = [
'alpha',
'arc',
'arm',
'arm64',
'i386',
'ia64',
'loongarch64',
'm68k',
'mips64',
'mips64n32',
'mipso32',
'parisc',
'powerpc',
'powerpc64',
'riscv32',
'riscv64',
's390',
's390x',
'sparc',
'x86_64'
]
run_target(
'update-syscall-tables',
command : [update_syscall_tables_sh, meson.current_source_dir()] + arch_list)
syscall_list_txt = files('syscall-list.txt')
syscall_lists = []
foreach arch: arch_list
syscall_lists += files('syscalls-@0@.txt'.format(arch))
endforeach
generate_syscall_py = find_program('generate-syscall.py')
run_target(
'update-syscall-header',
command : [generate_syscall_py, files('syscall.h')] + syscall_lists)

View File

@@ -11,8 +11,6 @@
#include <sys/syscall.h>
#include <unistd.h>
#include "missing_syscall_def.h"
/* Since glibc-2.37 (774058d72942249f71d74e7f2b639f77184160a6), sys/mount.h includes linux/mount.h, and
* we can safely include both headers in the same source file. However, we cannot do that with older glibc.
* To avoid conflicts, let's not use glibc's sys/mount.h, and provide our own minimal implementation.

View File

@@ -1,11 +1,15 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later
* This file is generated by src/basic/missing_syscalls.py. Do not edit!
* This file is generated by src/include/override/sys/generate-syscall.py. Do not edit!
*
* Use 'ninja -C build update-syscall-tables' to download new syscall tables,
* and 'ninja -C build update-syscall-header' to regenerate this file.
*/
#pragma once
#include_next <sys/syscall.h>
#include <assert.h>
/* 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__)
@@ -98,7 +102,7 @@
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_close_range && __NR_close_range >= 0
# if defined systemd_NR_close_range
_Static_assert(__NR_close_range == systemd_NR_close_range, "");
static_assert(__NR_close_range == systemd_NR_close_range, "");
# endif
# else
# if defined __NR_close_range
@@ -166,7 +170,7 @@ _Static_assert(__NR_close_range == systemd_NR_close_range, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_fchmodat2 && __NR_fchmodat2 >= 0
# if defined systemd_NR_fchmodat2
_Static_assert(__NR_fchmodat2 == systemd_NR_fchmodat2, "");
static_assert(__NR_fchmodat2 == systemd_NR_fchmodat2, "");
# endif
# else
# if defined __NR_fchmodat2
@@ -234,7 +238,7 @@ _Static_assert(__NR_fchmodat2 == systemd_NR_fchmodat2, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_mount_setattr && __NR_mount_setattr >= 0
# if defined systemd_NR_mount_setattr
_Static_assert(__NR_mount_setattr == systemd_NR_mount_setattr, "");
static_assert(__NR_mount_setattr == systemd_NR_mount_setattr, "");
# endif
# else
# if defined __NR_mount_setattr
@@ -246,6 +250,74 @@ _Static_assert(__NR_mount_setattr == systemd_NR_mount_setattr, "");
# endif
#endif
#ifndef __IGNORE_open_tree_attr
# if defined(__aarch64__)
# define systemd_NR_open_tree_attr 467
# elif defined(__alpha__)
# define systemd_NR_open_tree_attr 577
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_open_tree_attr 467
# elif defined(__arm__)
# define systemd_NR_open_tree_attr 467
# elif defined(__i386__)
# define systemd_NR_open_tree_attr 467
# elif defined(__ia64__)
# define systemd_NR_open_tree_attr -1
# elif defined(__loongarch_lp64)
# define systemd_NR_open_tree_attr 467
# elif defined(__m68k__)
# define systemd_NR_open_tree_attr 467
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_open_tree_attr 4467
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_open_tree_attr 6467
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_open_tree_attr 5467
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_open_tree_attr 467
# elif defined(__powerpc__)
# define systemd_NR_open_tree_attr 467
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_open_tree_attr 467
# elif __riscv_xlen == 64
# define systemd_NR_open_tree_attr 467
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_open_tree_attr 467
# elif defined(__sparc__)
# define systemd_NR_open_tree_attr 467
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_open_tree_attr (467 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_open_tree_attr 467
# endif
# elif !defined(missing_arch_template)
# warning "open_tree_attr() syscall number is unknown for your architecture"
# endif
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_open_tree_attr && __NR_open_tree_attr >= 0
# if defined systemd_NR_open_tree_attr
static_assert(__NR_open_tree_attr == systemd_NR_open_tree_attr, "");
# endif
# else
# if defined __NR_open_tree_attr
# undef __NR_open_tree_attr
# endif
# if defined systemd_NR_open_tree_attr && systemd_NR_open_tree_attr >= 0
# define __NR_open_tree_attr systemd_NR_open_tree_attr
# endif
# endif
#endif
#ifndef __IGNORE_openat2
# if defined(__aarch64__)
# define systemd_NR_openat2 437
@@ -302,7 +374,7 @@ _Static_assert(__NR_mount_setattr == systemd_NR_mount_setattr, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_openat2 && __NR_openat2 >= 0
# if defined systemd_NR_openat2
_Static_assert(__NR_openat2 == systemd_NR_openat2, "");
static_assert(__NR_openat2 == systemd_NR_openat2, "");
# endif
# else
# if defined __NR_openat2
@@ -370,7 +442,7 @@ _Static_assert(__NR_openat2 == systemd_NR_openat2, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_quotactl_fd && __NR_quotactl_fd >= 0
# if defined systemd_NR_quotactl_fd
_Static_assert(__NR_quotactl_fd == systemd_NR_quotactl_fd, "");
static_assert(__NR_quotactl_fd == systemd_NR_quotactl_fd, "");
# endif
# else
# if defined __NR_quotactl_fd
@@ -438,7 +510,7 @@ _Static_assert(__NR_quotactl_fd == systemd_NR_quotactl_fd, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_removexattrat && __NR_removexattrat >= 0
# if defined systemd_NR_removexattrat
_Static_assert(__NR_removexattrat == systemd_NR_removexattrat, "");
static_assert(__NR_removexattrat == systemd_NR_removexattrat, "");
# endif
# else
# if defined __NR_removexattrat
@@ -506,7 +578,7 @@ _Static_assert(__NR_removexattrat == systemd_NR_removexattrat, "");
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_setxattrat && __NR_setxattrat >= 0
# if defined systemd_NR_setxattrat
_Static_assert(__NR_setxattrat == systemd_NR_setxattrat, "");
static_assert(__NR_setxattrat == systemd_NR_setxattrat, "");
# endif
# else
# if defined __NR_setxattrat
@@ -517,71 +589,3 @@ _Static_assert(__NR_setxattrat == systemd_NR_setxattrat, "");
# endif
# endif
#endif
#ifndef __IGNORE_open_tree_attr
# if defined(__aarch64__)
# define systemd_NR_open_tree_attr 467
# elif defined(__alpha__)
# define systemd_NR_open_tree_attr 577
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_open_tree_attr 467
# elif defined(__arm__)
# define systemd_NR_open_tree_attr 467
# elif defined(__i386__)
# define systemd_NR_open_tree_attr 467
# elif defined(__ia64__)
# define systemd_NR_open_tree_attr -1
# elif defined(__loongarch_lp64)
# define systemd_NR_open_tree_attr 467
# elif defined(__m68k__)
# define systemd_NR_open_tree_attr 467
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_open_tree_attr 4467
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_open_tree_attr 6467
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_open_tree_attr 5467
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_open_tree_attr 467
# elif defined(__powerpc__)
# define systemd_NR_open_tree_attr 467
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_open_tree_attr 467
# elif __riscv_xlen == 64
# define systemd_NR_open_tree_attr 467
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_open_tree_attr 467
# elif defined(__sparc__)
# define systemd_NR_open_tree_attr 467
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_open_tree_attr (467 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_open_tree_attr 467
# endif
# elif !defined(missing_arch_template)
# warning "open_tree_attr() syscall number is unknown for your architecture"
# endif
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_open_tree_attr && __NR_open_tree_attr >= 0
# if defined systemd_NR_open_tree_attr
_Static_assert(__NR_open_tree_attr == systemd_NR_open_tree_attr, "");
# endif
# else
# if defined __NR_open_tree_attr
# undef __NR_open_tree_attr
# endif
# if defined systemd_NR_open_tree_attr && systemd_NR_open_tree_attr >= 0
# define __NR_open_tree_attr systemd_NR_open_tree_attr
# endif
# endif
#endif