From 771ab9c4d8ad9b4e8a7b1845b52f689481d0a251 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Mon, 13 Apr 2026 08:20:40 -0600 Subject: [PATCH] bsd-user: Add syscall header generator for FreeBSD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é Reviewed-by: Pierrick Bouvier Signed-off-by: Warner Losh --- bsd-user/freebsd/meson.build | 10 ++++++++-- bsd-user/freebsd/scripts/syscallhdr.sh | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 bsd-user/freebsd/scripts/syscallhdr.sh diff --git a/bsd-user/freebsd/meson.build b/bsd-user/freebsd/meson.build index 8fd6c7cfb8..38f2debf7e 100644 --- a/bsd-user/freebsd/meson.build +++ b/bsd-user/freebsd/meson.build @@ -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 index 0000000000..fa38500775 --- /dev/null +++ b/bsd-user/freebsd/scripts/syscallhdr.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Copyright (c) 2026 Warner Losh +# 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