# This license differs from the rest of public-inbox
#
# This module is Copyright (c) 2005 Six Apart, Ltd.
-# Copyright (C) 2019-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
#
# All rights reserved.
#
EPOLLIN EPOLLOUT EPOLLET
EPOLL_CTL_ADD EPOLL_CTL_DEL EPOLL_CTL_MOD
EPOLLONESHOT EPOLLEXCLUSIVE
- signalfd $SFD_NONBLOCK);
+ signalfd);
our %EXPORT_TAGS = (epoll => [qw(epoll_ctl epoll_create epoll_wait
EPOLLIN EPOLLOUT
EPOLL_CTL_ADD EPOLL_CTL_DEL EPOLL_CTL_MOD
$clean->(); # don't trust modules before us
my $rv = eval { require 'syscall.ph'; 1 } || eval { require 'sys/syscall.ph'; 1 };
$clean->(); # don't require modules after us trust us
- return $rv;
+ $rv;
}
);
my $SFD_CLOEXEC = 02000000; # Perl does not expose O_CLOEXEC
-our $SFD_NONBLOCK = O_NONBLOCK;
our $no_deprecated = 0;
if ($^O eq "linux") {
*epoll_ctl = \&epoll_ctl_mod4;
}
}
-
-elsif ($^O eq "freebsd") {
- if ($ENV{FREEBSD_SENDFILE}) {
- # this is still buggy and in development
- }
-}
+# use Inline::C for *BSD-only or general POSIX stuff.
+# Linux guarantees stable syscall numbering, BSDs only offer a stable libc
+# use scripts/syscall-list on Linux to detect new syscall numbers
############################################################################
# epoll functions
############################################################################
-sub epoll_defined { return $SYS_epoll_create ? 1 : 0; }
+sub epoll_defined { $SYS_epoll_create ? 1 : 0; }
sub epoll_create {
- syscall($SYS_epoll_create, $no_deprecated ? 0 : ($_[0]||100)+0);
+ syscall($SYS_epoll_create, $no_deprecated ? 0 : 100);
}
# epoll_ctl wrapper
# epoll_wait wrapper
# ARGS: (epfd, maxevents, timeout (milliseconds), arrayref)
# arrayref: values modified to be [$fd, $event]
-our $epoll_wait_events;
+our $epoll_wait_events = '';
our $epoll_wait_size = 0;
sub epoll_wait_mod4 {
my ($epfd, $maxevents, $timeout_msec, $events) = @_;
}
}
-sub signalfd ($$$) {
- my ($fd, $signos, $flags) = @_;
+sub signalfd ($$) {
+ my ($signos, $nonblock) = @_;
if ($SYS_signalfd4) {
my $set = POSIX::SigSet->new(@$signos);
- syscall($SYS_signalfd4, $fd, "$$set",
+ syscall($SYS_signalfd4, -1, "$$set",
# $Config{sig_count} is NSIG, so this is NSIG/8:
int($Config{sig_count}/8),
- $flags|$SFD_CLOEXEC);
+ # SFD_NONBLOCK == O_NONBLOCK for every architecture
+ ($nonblock ? O_NONBLOCK : 0) |$SFD_CLOEXEC);
} else {
$! = ENOSYS;
undef;