user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] scripts: add syscall-list tool for development
@ 2021-06-18 21:44 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-06-18 21:44 UTC (permalink / raw)
  To: meta

We'll be supporting inotify directly as we do with epoll so so
Linux users won't have to deal with XS, extra DSOs or install
Linux::Inotify2 (and common::sense) modules.
---
 MANIFEST                   |  2 ++
 devel/README               |  1 +
 devel/syscall-list         | 49 ++++++++++++++++++++++++++++++++++++++
 lib/PublicInbox/Syscall.pm |  1 +
 4 files changed, 53 insertions(+)
 create mode 100644 devel/README
 create mode 100755 devel/syscall-list

diff --git a/MANIFEST b/MANIFEST
index d4b3e75d..146a32ab 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 00000000..8f9a0485
--- /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 00000000..b33401d9
--- /dev/null
+++ b/devel/syscall-list
@@ -0,0 +1,49 @@
+# Copyright 2021 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <http://www.gnu.org/licenses/agpl-3.0.txt>
+# 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 $/; <DATA> };
+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 <unistd.h>
+#include <sys/syscall.h>
+#include <stdio.h>
+
+#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 2599f8a3..a8a6f42a 100644
--- a/lib/PublicInbox/Syscall.pm
+++ b/lib/PublicInbox/Syscall.pm
@@ -197,6 +197,7 @@ if ($^O eq "linux") {
 }
 # 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-18 21:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 21:44 [PATCH] scripts: add syscall-list tool for development Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.mail.public-inbox.meta
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.mail.public-inbox.meta
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git