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>
This commit is contained in:
Warner Losh
2026-04-13 08:20:40 -06:00
parent acdb0de9be
commit 771ab9c4d8
2 changed files with 17 additions and 2 deletions

View 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
)

View File

@@ -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