]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic: move basic/missing_syscall_defs.h -> include/override/sys/syscall.h
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 18 Jun 2025 23:35:35 +0000 (08:35 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 11 Jul 2025 04:05:46 +0000 (13:05 +0900)
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.

28 files changed:
src/basic/meson.build
src/basic/missing_syscall.h
src/include/meson.build
src/include/override/sys/generate-syscall.py [moved from src/basic/missing_syscalls.py with 94% similarity]
src/include/override/sys/meson.build [new file with mode: 0644]
src/include/override/sys/mount.h
src/include/override/sys/syscall-list.txt [moved from src/basic/syscall-list.txt with 100% similarity]
src/include/override/sys/syscall.h [moved from src/basic/missing_syscall_def.h with 96% similarity]
src/include/override/sys/syscalls-alpha.txt [moved from src/basic/syscalls-alpha.txt with 100% similarity]
src/include/override/sys/syscalls-arc.txt [moved from src/basic/syscalls-arc.txt with 100% similarity]
src/include/override/sys/syscalls-arm.txt [moved from src/basic/syscalls-arm.txt with 100% similarity]
src/include/override/sys/syscalls-arm64.txt [moved from src/basic/syscalls-arm64.txt with 100% similarity]
src/include/override/sys/syscalls-i386.txt [moved from src/basic/syscalls-i386.txt with 100% similarity]
src/include/override/sys/syscalls-ia64.txt [moved from src/basic/syscalls-ia64.txt with 100% similarity]
src/include/override/sys/syscalls-loongarch64.txt [moved from src/basic/syscalls-loongarch64.txt with 100% similarity]
src/include/override/sys/syscalls-m68k.txt [moved from src/basic/syscalls-m68k.txt with 100% similarity]
src/include/override/sys/syscalls-mips64.txt [moved from src/basic/syscalls-mips64.txt with 100% similarity]
src/include/override/sys/syscalls-mips64n32.txt [moved from src/basic/syscalls-mips64n32.txt with 100% similarity]
src/include/override/sys/syscalls-mipso32.txt [moved from src/basic/syscalls-mipso32.txt with 100% similarity]
src/include/override/sys/syscalls-parisc.txt [moved from src/basic/syscalls-parisc.txt with 100% similarity]
src/include/override/sys/syscalls-powerpc.txt [moved from src/basic/syscalls-powerpc.txt with 100% similarity]
src/include/override/sys/syscalls-powerpc64.txt [moved from src/basic/syscalls-powerpc64.txt with 100% similarity]
src/include/override/sys/syscalls-riscv32.txt [moved from src/basic/syscalls-riscv32.txt with 100% similarity]
src/include/override/sys/syscalls-riscv64.txt [moved from src/basic/syscalls-riscv64.txt with 100% similarity]
src/include/override/sys/syscalls-s390.txt [moved from src/basic/syscalls-s390.txt with 100% similarity]
src/include/override/sys/syscalls-s390x.txt [moved from src/basic/syscalls-s390x.txt with 100% similarity]
src/include/override/sys/syscalls-sparc.txt [moved from src/basic/syscalls-sparc.txt with 100% similarity]
src/include/override/sys/syscalls-x86_64.txt [moved from src/basic/syscalls-x86_64.txt with 100% similarity]

index b7b2253586a4e909efbc496a6175c2f8c968e6d8..ece4bf1e9227da6e8ce05c366b714f089d00cea9 100644 (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',
index 76074d1c0497dcb156c7480ce0f6203fa1e1e168..994bda9a3e3fdb73cc630ca5007b9574962588cd 100644 (file)
 #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"
 
 /* ======================================================================= */
 
index 74f4437df0481517ab036d3659df45da020f5eae..9786723b1b26ec3d07929f8151b0705cf0a85044 100644 (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',
similarity index 94%
rename from src/basic/missing_syscalls.py
rename to src/include/override/sys/generate-syscall.py
index dd26b76b4c93dc5ba4831c0d4344cab02b236f0a..b58f1d6bcf175eafb9ac3b3d3e075d04d168f10e 100644 (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)
diff --git a/src/include/override/sys/meson.build b/src/include/override/sys/meson.build
new file mode 100644 (file)
index 0000000..b66f9d0
--- /dev/null
@@ -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)
index 3c9cd8ef5bdbfe88196f897293679ba8a7d0b197..050c23cc6ab177144a55a3c79ed4afc727e495c8 100644 (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.
similarity index 96%
rename from src/basic/missing_syscall_def.h
rename to src/include/override/sys/syscall.h
index a34cb36f14d912d7f465b454c4b3b72952e25bfe..894394a76bba991f44a5ab3e1047d09ece7da636 100644 (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__)
 /* 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