]> Sergey Matveev's repositories - public-inbox.git/blob - devel/syscall-list
xt/mem-imapd-tls: update aliases to DSdeflate subs
[public-inbox.git] / devel / syscall-list
1 # Copyright 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 v5.10.1;
13 use File::Temp 0.19;
14 use POSIX qw(uname);
15 say '$machine='.(POSIX::uname())[-1];
16 my $cc = $ENV{CC} // 'cc';
17 my @cflags = split(/\s+/, $ENV{CFLAGS} // '-Wall');
18 my $str = do { local $/; <DATA> };
19 my $tmp = File::Temp->newdir('syscall-list-XXXX', TMPDIR => 1);
20 my $f = "$tmp/sc.c";
21 my $x = "$tmp/sc";
22 open my $fh, '>', $f or die "open $f $!";
23 print $fh $str or die "print $f $!";
24 close $fh or die "close $f $!";
25 system($cc, '-o', $x, $f, @cflags) == 0 or die "cc failed \$?=$?";
26 exec($x);
27 __DATA__
28 #define _GNU_SOURCE
29 #include <sys/syscall.h>
30 #include <sys/ioctl.h>
31 #include <linux/fs.h>
32 #include <unistd.h>
33 #include <stdio.h>
34
35 #define D(x) printf("$" #x " = %ld;\n", (long)x)
36
37 int main(void)
38 {
39 #ifdef __linux__
40         D(SYS_epoll_create1);
41         D(SYS_epoll_ctl);
42 #ifdef SYS_epoll_wait
43         D(SYS_epoll_wait);
44 #endif
45         D(SYS_epoll_pwait);
46         D(SYS_signalfd4);
47         D(SYS_inotify_init1);
48         D(SYS_inotify_add_watch);
49         D(SYS_inotify_rm_watch);
50         D(SYS_prctl);
51         D(SYS_fstatfs);
52         D(SYS_sendmsg);
53         D(SYS_recvmsg);
54 #ifdef FS_IOC_GETFLAGS
55         printf("FS_IOC_GETFLAGS=%#lx\nFS_IOC_SETFLAGS=%#lx\n",
56                 (unsigned long)FS_IOC_GETFLAGS, (unsigned long)FS_IOC_SETFLAGS);
57 #endif
58
59 #ifdef SYS_renameat2
60         D(SYS_renameat2);
61 #endif
62 #endif /* Linux, any other OSes with stable syscalls? */
63         printf("size_t=%zu off_t=%zu\n", sizeof(size_t), sizeof(off_t));
64         return 0;
65 }