From 0a989e8abd36599abe13c36c2b30ab75232f9756 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 29 Jan 2024 21:23:19 +0000 Subject: syscall: use pure Perl sendmsg/recvmsg on *BSD While syscall symbols (e.g. SYS_*) have changed on us in FreeBSD during the history of Sys::Syscall and this project and did bite us in some cases; the actual numbers don't get recycled for new syscalls. We're also fortunate that sendmsg and recvmsg syscalls and associated msghdr and cmsg structs predate the BSD forks and are compatible across all the BSDs I've tried. OpenBSD routes Perl `syscall' through libc; while NetBSD + FreeBSD document procedures for maintaining backwards compatibility. It looks like Dragonfly follows FreeBSD, here. Tested on i386 OpenBSD, and amd64 {Free,Net,Open,Dragonfly}BSD This enables *BSD users to use lei, -cindex and future SCM_RIGHTS-only features without needing Inline::C. [1] https://cvsweb.openbsd.org/src/gnu/usr.bin/perl/gen_syscall_emulator.pl [2] https://www.netbsd.org/docs/internals/en/chap-processes.html#syscall_versioning [3] https://wiki.freebsd.org/AddingSyscalls#Backward_compatibily --- devel/sysdefs-list | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'devel') diff --git a/devel/sysdefs-list b/devel/sysdefs-list index 61532cf2..ba51de6c 100755 --- a/devel/sysdefs-list +++ b/devel/sysdefs-list @@ -2,8 +2,6 @@ # License: AGPL-3.0+ # Dump system-specific constant numbers this is to maintain # PublicInbox::Syscall and any other system-specific pieces. -# DO NOT USE syscall numbers for *BSDs, none of the current BSD kernels -# we know about promise stable syscall numbers (unlike Linux). # However, sysconf(3) constants are stable ABI on all safe to dump. eval 'exec perl -S $0 ${1+"$@"}' # no shebang if 0; # running under some shell @@ -179,5 +177,12 @@ int main(void) PR_NUM(cmsg_type); STRUCT_END; + { + struct cmsghdr cmsg; + uintptr_t cmsg_data_off; + cmsg_data_off = (uintptr_t)CMSG_DATA(&cmsg) - (uintptr_t)&cmsg; + D(cmsg_data_off); + } + return 0; } -- cgit v1.2.3-24-ge0c7