]> Sergey Matveev's repositories - public-inbox.git/blob - devel/syscall-list
b33401d98ce4e2bac487b6f710eeb788bcf09ba5
[public-inbox.git] / devel / syscall-list
1 # Copyright 2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <http://www.gnu.org/licenses/agpl-3.0.txt>
3 # Dump syscall numbers under Linux and any other kernel which
4 # promises stable syscall numbers.  This is to maintain
5 # PublicInbox::Syscall
6 # DO NOT USE this for *BSDs, none of the current BSD kernels
7 # we know about promise stable syscall numbers, we'll use
8 # Inline::C to support them.
9 eval 'exec perl -S $0 ${1+"$@"}' # no shebang
10         if 0; # running under some shell
11 use strict;
12 use File::Temp 0.19;
13 my $cc = $ENV{CC} // 'cc';
14 my @cflags = split(/\s+/, $ENV{CFLAGS} // '-Wall');
15 my $str = do { local $/; <DATA> };
16 my $tmp = File::Temp->newdir('syscall-list-XXXX', TMPDIR => 1);
17 my $f = "$tmp/sc.c";
18 my $x = "$tmp/sc";
19 open my $fh, '>', $f or die "open $f $!";
20 print $fh $str or die "print $f $!";
21 close $fh or die "close $f $!";
22 system($cc, '-o', $x, $f, @cflags) == 0 or die "cc failed \$?=$?";
23 exec($x);
24 __DATA__
25 #define _GNU_SOURCE
26 #include <unistd.h>
27 #include <sys/syscall.h>
28 #include <stdio.h>
29
30 #define D(x) printf("$" #x " = %ld;\n", (long)x)
31
32 int main(void)
33 {
34 #ifdef __linux__
35         D(SYS_epoll_create1);
36         D(SYS_epoll_ctl);
37 #ifdef SYS_epoll_wait
38         D(SYS_epoll_wait);
39 #endif
40         D(SYS_epoll_pwait);
41         D(SYS_signalfd4);
42         D(SYS_inotify_init1);
43         D(SYS_inotify_add_watch);
44         D(SYS_inotify_rm_watch);
45         D(SYS_prctl);
46 #endif /* Linux, any other OSes with stable syscalls? */
47         printf("size_t=%zu off_t=%zu\n", sizeof(size_t), sizeof(off_t));
48         return 0;
49 }