]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Syscall.pm
index: support --compact / -c on command-line
[public-inbox.git] / lib / PublicInbox / Syscall.pm
index 487013d5247879b9d3482599191ce9222e2830e2..ce6b0f3afd5f832669614d3c13c5e08e9c5b1805 100644 (file)
@@ -5,7 +5,7 @@
 # This license differs from the rest of public-inbox
 #
 # This module is Copyright (c) 2005 Six Apart, Ltd.
-# Copyright (C) 2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2019-2020 all contributors <meta@public-inbox.org>
 #
 # All rights reserved.
 #
 # License or the Artistic License, as specified in the Perl README file.
 package PublicInbox::Syscall;
 use strict;
+use parent qw(Exporter);
 use POSIX qw(ENOSYS SEEK_CUR);
 use Config;
 
-require Exporter;
-use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS $VERSION);
-
-$VERSION     = "0.25";
-@ISA         = qw(Exporter);
-@EXPORT_OK   = qw(epoll_ctl epoll_create epoll_wait
+# $VERSION = '0.25'; # Sys::Syscall version
+our @EXPORT_OK = qw(epoll_ctl epoll_create epoll_wait
                   EPOLLIN EPOLLOUT EPOLLET
                   EPOLL_CTL_ADD EPOLL_CTL_DEL EPOLL_CTL_MOD
                   EPOLLONESHOT EPOLLEXCLUSIVE
                   signalfd SFD_NONBLOCK);
-%EXPORT_TAGS = (epoll => [qw(epoll_ctl epoll_create epoll_wait
+our %EXPORT_TAGS = (epoll => [qw(epoll_ctl epoll_create epoll_wait
                              EPOLLIN EPOLLOUT
                              EPOLL_CTL_ADD EPOLL_CTL_DEL EPOLL_CTL_MOD
                              EPOLLONESHOT EPOLLEXCLUSIVE)],
                 );
 
-use constant EPOLLIN       => 1;
-use constant EPOLLOUT      => 4;
-# use constant EPOLLERR      => 8;
-# use constant EPOLLHUP      => 16;
-# use constant EPOLLRDBAND   => 128;
-use constant EPOLLEXCLUSIVE => (1 << 28);
-use constant EPOLLONESHOT => (1 << 30);
-use constant EPOLLET => (1 << 31);
-use constant EPOLL_CTL_ADD => 1;
-use constant EPOLL_CTL_DEL => 2;
-use constant EPOLL_CTL_MOD => 3;
 use constant {
+       EPOLLIN => 1,
+       EPOLLOUT => 4,
+       # EPOLLERR => 8,
+       # EPOLLHUP => 16,
+       # EPOLLRDBAND => 128,
+       EPOLLEXCLUSIVE => (1 << 28),
+       EPOLLONESHOT => (1 << 30),
+       EPOLLET => (1 << 31),
+       EPOLL_CTL_ADD => 1,
+       EPOLL_CTL_DEL => 2,
+       EPOLL_CTL_MOD => 3,
+
        SFD_CLOEXEC => 02000000,
        SFD_NONBLOCK => 00004000,
 };
 
-
 our $loaded_syscall = 0;
 
 sub _load_syscall {
@@ -81,9 +78,9 @@ if ($^O eq "linux") {
     my $u64_mod_8 = 0;
 
     # if we're running on an x86_64 kernel, but a 32-bit process,
-    # we need to use the i386 syscall numbers.
+    # we need to use the x32 or i386 syscall numbers.
     if ($machine eq "x86_64" && $Config{ptrsize} == 4) {
-        $machine = "i386";
+        $machine = $Config{cppsymbols} =~ /\b__ILP32__=1\b/ ? 'x32' : 'i386';
     }
 
     # Similarly for mips64 vs mips
@@ -101,6 +98,11 @@ if ($^O eq "linux") {
         $SYS_epoll_ctl    = 233;
         $SYS_epoll_wait   = 232;
         $SYS_signalfd4 = 289;
+    } elsif ($machine eq 'x32') {
+        $SYS_epoll_create = 1073742037;
+        $SYS_epoll_ctl = 1073742057;
+        $SYS_epoll_wait = 1073742056;
+        $SYS_signalfd4 = 1073742113;
     } elsif ($machine =~ m/^parisc/) {
         $SYS_epoll_create = 224;
         $SYS_epoll_ctl    = 225;