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
$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;
--- /dev/null
+use strict;
+use Test::More;
+use IO::Handle;
+use PublicInbox::Syscall qw(:epoll);
+plan skip_all => 'not Linux' if $^O ne 'linux';
+my $epfd = epoll_create();
+ok($epfd >= 0, 'epoll_create');
+my $hnd = IO::Handle->new_from_fd($epfd, 'r+'); # close on exit
+
+pipe(my ($r, $w)) or die "pipe: $!";
+is(epoll_ctl($epfd, EPOLL_CTL_ADD, fileno($w), EPOLLOUT), 0,
+ 'epoll_ctl socket EPOLLOUT');
+
+my @events;
+is(epoll_wait($epfd, 100, 10000, \@events), 1, 'epoll_wait returns');
+is_deeply(\@events, [ [ fileno($w), EPOLLOUT ] ], 'got expected events');
+close $w;
+is(epoll_wait($epfd, 100, 0, \@events), 0, 'epoll_wait timeout');
+
+done_testing;