bsd-user: Add syscall header generator for FreeBSD
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>
Warner Losh committed
Apr 13, 2026 at 08:20 UTC
771ab9c4d8ad9b4e8a7b1845b52f689481d0a251
2 files changed
+17
-2
bsd-user/freebsd/meson.build
+8
-2
@@ -1,6 +1,12 @@
1
+bsd_syscall_nr = custom_target('bsd-syscall-h',
2
+ output: '@BASENAME@_nr.h',
3
+ input: ['/usr/include/sys/syscall.h'],
4
+ command: [sh, meson.current_source_dir() / 'scripts/syscallhdr.sh', '@INPUT@', '@OUTPUT@', 'FREEBSD'])
5
+
6
bsd_user_ss.add(files(
7
'os-stat.c',
8
'os-proc.c',
9
'os-sys.c',
5
- 'os-syscall.c',
6
-))
10
+ 'os-syscall.c'),
11
+ bsd_syscall_nr
12
+)
bsd-user/freebsd/scripts/syscallhdr.sh
new
+9
@@ -0,0 +1,9 @@
1
+#!/bin/sh
2
+# Copyright (c) 2026 Warner Losh <imp@bsdimp.com>
3
+# SPDX-License-Identifier: GPL-2.0-or-later
4
+
5
+in="$1"
6
+out="$2"
7
+bsd="$3"
8
+
9
+awk -v bsd="$3" '{sub("SYS_", "TARGET_" bsd "_NR_", $0); print;}' < $in > $out