public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob d33a8a78a86e00c4534259125fa2c380323d813c 1830 bytes (raw)
$ git show v1.8.0:devel/syscall-list	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 
# Copyright 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 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 $/; <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 <sys/syscall.h>
#include <sys/ioctl.h>
#include <linux/fs.h>
#include <unistd.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);
	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\n", sizeof(size_t), sizeof(off_t));
	return 0;
}

git clone https://public-inbox.org/public-inbox.git
git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git