From 56706d5d25de794539a974221d553f20f1e619ea Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 4 Sep 2023 10:36:01 +0000 Subject: update devel/syscall-list to devel/sysdefs-list We use it to dump SIGWINCH and _SC_NPROCESSORS_ONLN, so "sysdefs" is a more appropriate list for *BSD users. --- devel/syscall-list | 71 --------------------------------------------------- devel/sysdefs-list | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 71 deletions(-) delete mode 100755 devel/syscall-list create mode 100755 devel/sysdefs-list (limited to 'devel') diff --git a/devel/syscall-list b/devel/syscall-list deleted file mode 100755 index 0b36c0e2..00000000 --- a/devel/syscall-list +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright all contributors -# License: AGPL-3.0+ -# Dump syscall numbers under Linux and any other kernel which -# promises stable syscall numbers. This is to maintain -# PublicInbox::Syscall -# DO NOT USE this for *BSDs, none of the current BSD kernels -# we know about promise stable syscall numbers, we'll use -# Inline::C to support them. -eval 'exec perl -S $0 ${1+"$@"}' # no shebang - if 0; # running under some shell -use strict; -use v5.10.1; -use File::Temp 0.19; -use POSIX qw(uname); -say '$machine='.(POSIX::uname())[-1]; -my $cc = $ENV{CC} // 'cc'; -my @cflags = split(/\s+/, $ENV{CFLAGS} // '-Wall'); -my $str = do { local $/; }; -my $tmp = File::Temp->newdir('syscall-list-XXXX', TMPDIR => 1); -my $f = "$tmp/sc.c"; -my $x = "$tmp/sc"; -open my $fh, '>', $f or die "open $f $!"; -print $fh $str or die "print $f $!"; -close $fh or die "close $f $!"; -system($cc, '-o', $x, $f, @cflags) == 0 or die "cc failed \$?=$?"; -exec($x); -__DATA__ -#define _GNU_SOURCE -#include -#include -#include -#ifdef __linux__ -#include -#endif -#include -#include -#include - -#define D(x) printf("$" #x " = %ld;\n", (long)x) - -int main(void) -{ -#ifdef __linux__ - D(SYS_epoll_create1); - D(SYS_epoll_ctl); -#ifdef SYS_epoll_wait - D(SYS_epoll_wait); -#endif - D(SYS_epoll_pwait); - D(SYS_signalfd4); - D(SYS_inotify_init1); - D(SYS_inotify_add_watch); - D(SYS_inotify_rm_watch); - D(SYS_prctl); - D(SYS_fstatfs); - D(SYS_sendmsg); - D(SYS_recvmsg); -#ifdef FS_IOC_GETFLAGS - printf("FS_IOC_GETFLAGS=%#lx\nFS_IOC_SETFLAGS=%#lx\n", - (unsigned long)FS_IOC_GETFLAGS, (unsigned long)FS_IOC_SETFLAGS); -#endif - -#ifdef SYS_renameat2 - D(SYS_renameat2); -#endif -#endif /* Linux, any other OSes with stable syscalls? */ - printf("size_t=%zu off_t=%zu pid_t=%zu\n", - sizeof(size_t), sizeof(off_t), sizeof(pid_t)); - D(SIGWINCH); - return 0; -} diff --git a/devel/sysdefs-list b/devel/sysdefs-list new file mode 100755 index 00000000..9764cc29 --- /dev/null +++ b/devel/sysdefs-list @@ -0,0 +1,74 @@ +# Copyright all contributors +# 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 +use v5.12; +use File::Temp 0.19; +use POSIX qw(uname); +use Config; +say '$machine='.(POSIX::uname())[-1]; +my $cc = $ENV{CC} // $Config{cc} // 'cc'; +my @cflags = split(/\s+/, $ENV{CFLAGS} // $Config{ccflags} // '-Wall'); +my $str = do { local $/; }; +$str =~ s/^\s*MAYBE\s*(\w+)\s*$/ +#ifdef $1 + D($1); +#endif +/sgxm; +my $tmp = File::Temp->newdir('sysdefs-list-XXXX', TMPDIR => 1); +my $f = "$tmp/sysdefs.c"; +my $x = "$tmp/sysdefs"; +open my $fh, '>', $f or die "open $f $!"; +print $fh $str or die "print $f $!"; +close $fh or die "close $f $!"; +system($cc, '-o', $x, $f, @cflags) == 0 or die "$cc failed \$?=$?"; +exec($x); +__DATA__ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif +#include +#include +#include +#ifdef __linux__ +#include +#endif +#include +#include +#include + +#define D(x) printf("$" #x " = %ld;\n", (long)x) + +int main(void) +{ +#ifdef __linux__ + D(SYS_epoll_create1); + D(SYS_epoll_ctl); + MAYBE SYS_epoll_wait + D(SYS_epoll_pwait); + D(SYS_signalfd4); + D(SYS_inotify_init1); + D(SYS_inotify_add_watch); + D(SYS_inotify_rm_watch); + D(SYS_prctl); + D(SYS_fstatfs); + D(SYS_sendmsg); + D(SYS_recvmsg); +#ifdef FS_IOC_GETFLAGS + printf("FS_IOC_GETFLAGS=%#lx\nFS_IOC_SETFLAGS=%#lx\n", + (unsigned long)FS_IOC_GETFLAGS, (unsigned long)FS_IOC_SETFLAGS); +#endif + MAYBE SYS_renameat2 +#endif /* Linux, any other OSes with stable syscalls? */ + printf("size_t=%zu off_t=%zu pid_t=%zu\n", + sizeof(size_t), sizeof(off_t), sizeof(pid_t)); + D(SIGWINCH); + MAYBE _SC_NPROCESSORS_ONLN + + return 0; +} -- cgit v1.2.3-24-ge0c7