MANIFEST | 2 ++
devel/README | 1 +
devel/syscall-list | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
lib/PublicInbox/Syscall.pm | 1 +
diff --git a/MANIFEST b/MANIFEST
index d4b3e75df9e0bea3e6ee77a053c15372577c1521..146a32abed239653ba7bf0613a8fa493ae565e9a 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -97,6 +97,8 @@ contrib/css/216light.css
contrib/css/README
contrib/selinux/el7/publicinbox.fc
contrib/selinux/el7/publicinbox.te
+devel/README
+devel/syscall-list
examples/README
examples/README.unsubscribe
examples/apache2_cgi.conf
diff --git a/devel/README b/devel/README
new file mode 100644
index 0000000000000000000000000000000000000000..8f9a0485ec3f4eb08b3821777dc7bba6c2eaa444
--- /dev/null
+++ b/devel/README
@@ -0,0 +1 @@
+scripts use for public-inbox development that don't belong in t/
diff --git a/devel/syscall-list b/devel/syscall-list
new file mode 100755
index 0000000000000000000000000000000000000000..b33401d98ce4e2bac487b6f710eeb788bcf09ba5
--- /dev/null
+++ b/devel/syscall-list
@@ -0,0 +1,49 @@
+# Copyright 2021 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 File::Temp 0.19;
+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
+
+#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);
+#endif /* Linux, any other OSes with stable syscalls? */
+ printf("size_t=%zu off_t=%zu\n", sizeof(size_t), sizeof(off_t));
+ return 0;
+}
diff --git a/lib/PublicInbox/Syscall.pm b/lib/PublicInbox/Syscall.pm
index 2599f8a3d57b55eecf1bd27deef59e358741a9f9..a8a6f42a2e2dcc447bf1e16a36e9f35efb4de1fb 100644
--- a/lib/PublicInbox/Syscall.pm
+++ b/lib/PublicInbox/Syscall.pm
@@ -197,6 +197,7 @@ }
}
# use Inline::C for *BSD-only or general POSIX stuff.
# Linux guarantees stable syscall numbering, BSDs only offer a stable libc
+# use scripts/syscall-list on Linux to detect new syscall numbers
############################################################################
# epoll functions