]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
bsd-user: Add syscall header generator for FreeBSD
authorWarner Losh <imp@bsdimp.com>
Mon, 13 Apr 2026 14:20:40 +0000 (08:20 -0600)
committerWarner Losh <imp@bsdimp.com>
Thu, 7 May 2026 02:10:40 +0000 (20:10 -0600)
Generate the syscall numbers from the installed header that has them.
Ideally, we'd use FreeBSD's lua infra for this, but that requires that
we have those files installed, and they aren't quite the same across
supported versions yet, so use this simple, but effective hack. Add to
meson build, but unused.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
bsd-user/freebsd/meson.build
bsd-user/freebsd/scripts/syscallhdr.sh [new file with mode: 0644]

index 8fd6c7cfb8216fb05c9710b492e54bf2f30e0641..38f2debf7e566757718e351ec9ae797fa3c554fa 100644 (file)
@@ -1,6 +1,12 @@
+bsd_syscall_nr = custom_target('bsd-syscall-h',
+    output: '@BASENAME@_nr.h',
+    input: ['/usr/include/sys/syscall.h'],
+    command: [sh, meson.current_source_dir() / 'scripts/syscallhdr.sh', '@INPUT@', '@OUTPUT@', 'FREEBSD'])
+
 bsd_user_ss.add(files(
   'os-stat.c',
   'os-proc.c',
   'os-sys.c',
-  'os-syscall.c',
-))
+  'os-syscall.c'),
+  bsd_syscall_nr
+)
diff --git a/bsd-user/freebsd/scripts/syscallhdr.sh b/bsd-user/freebsd/scripts/syscallhdr.sh
new file mode 100644 (file)
index 0000000..fa38500
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Copyright (c) 2026 Warner Losh <imp@bsdimp.com>
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+in="$1"
+out="$2"
+bsd="$3"
+
+awk -v bsd="$3" '{sub("SYS_", "TARGET_" bsd "_NR_", $0); print;}' < $in > $out