1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

Linux: Add epoll_pwait2 (BZ #27359)

It is similar to epoll_wait, with the difference the timeout has
nanosecond resoluting by using struct timespec instead of int.

Although Linux interface only provides 64 bit time_t support, old
32 bit interface is also provided (so keep in sync with current
practice and to no force opt-in on 64 bit time_t).

Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
This commit is contained in:
Adhemerval Zanella
2022-01-12 11:31:53 -03:00
parent ded3aeb202
commit 5f3a7ebc35
41 changed files with 349 additions and 1 deletions

3
NEWS
View File

@ -126,6 +126,9 @@ Major new features:
checks, this can help to ensure that proper diagnostics are printed if checks, this can help to ensure that proper diagnostics are printed if
the dynamic loader runs on an incompatible CPU. the dynamic loader runs on an incompatible CPU.
* On Linux, the epoll_pwait2 function has been added. It is similar to
epoll_wait with the difference the timeout has nanoseconds resolution.
Deprecated and removed features, and other changes affecting compatibility: Deprecated and removed features, and other changes affecting compatibility:
* On x86-64, the LD_PREFER_MAP_32BIT_EXEC environment variable support * On x86-64, the LD_PREFER_MAP_32BIT_EXEC environment variable support

View File

@ -4,6 +4,14 @@
# ifndef _ISOMAC # ifndef _ISOMAC
libc_hidden_proto (epoll_pwait) libc_hidden_proto (epoll_pwait)
#if __TIMESIZE == 64
# define __epoll_pwait2_time64 epoll_pwait2
#else
extern int __epoll_pwait2_time64 (int fd, struct epoll_event *ev, int maxev,
const struct __timespec64 *tmo,
const sigset_t *s);
libc_hidden_proto (__epoll_pwait2_time64)
#endif
# endif /* !_ISOMAC */ # endif /* !_ISOMAC */
#endif #endif

View File

@ -55,7 +55,7 @@ endif
ifeq ($(subdir),misc) ifeq ($(subdir),misc)
sysdep_routines += adjtimex clone umount umount2 readahead sysctl \ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
setfsuid setfsgid epoll_pwait signalfd \ setfsuid setfsgid epoll_pwait epoll_pwait2 signalfd \
eventfd eventfd_read eventfd_write prlimit prlimit64 \ eventfd eventfd_read eventfd_write prlimit prlimit64 \
personality epoll_wait tee vmsplice splice \ personality epoll_wait tee vmsplice splice \
open_by_handle_at mlock2 pkey_mprotect pkey_set pkey_get \ open_by_handle_at mlock2 pkey_mprotect pkey_set pkey_get \
@ -125,6 +125,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
tst-ntp_gettimex tst-sigtimedwait tst-misalign-clone \ tst-ntp_gettimex tst-sigtimedwait tst-misalign-clone \
tst-prctl \ tst-prctl \
tst-scm_rights \ tst-scm_rights \
tst-epoll \
# tests # tests
# Test for the symbol version of fcntl that was replaced in glibc 2.28. # Test for the symbol version of fcntl that was replaced in glibc 2.28.
@ -146,6 +147,7 @@ endif
tests-time64 += \ tests-time64 += \
tst-adjtimex-time64 \ tst-adjtimex-time64 \
tst-clock_adjtime-time64 \ tst-clock_adjtime-time64 \
tst-epoll-time64 \
tst-ntp_adjtime-time64 \ tst-ntp_adjtime-time64 \
tst-ntp_gettime-time64 \ tst-ntp_gettime-time64 \
tst-ntp_gettimex-time64 \ tst-ntp_gettimex-time64 \

View File

@ -293,6 +293,12 @@ libc {
%endif %endif
close_range; close_range;
} }
GLIBC_2.35 {
%ifdef TIME64_NON_DEFAULT
__epoll_pwait2_time64;
%endif
epoll_pwait2;
}
GLIBC_PRIVATE { GLIBC_PRIVATE {
# functions used in other libraries # functions used in other libraries
__syscall_rt_sigqueueinfo; __syscall_rt_sigqueueinfo;

View File

@ -2614,3 +2614,4 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F

View File

@ -2711,6 +2711,7 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F GLIBC_2.4 _IO_sprintf F

View File

@ -2375,3 +2375,4 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F

View File

@ -491,8 +491,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 _Exit F GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
GLIBC_2.4 _IO_2_1_stdin_ D 0xa0 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0

View File

@ -488,8 +488,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 _Exit F GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
GLIBC_2.4 _IO_2_1_stdin_ D 0xa0 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0

View File

@ -2647,5 +2647,7 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F

View File

@ -0,0 +1,44 @@
/* Implementation of epoll_pwait2 syscall wrapper.
Copyright (C) 2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <sys/epoll.h>
#include <sysdep.h>
int
__epoll_pwait2_time64 (int fd, struct epoll_event *ev, int maxev,
const struct __timespec64 *tmo, const sigset_t *s)
{
/* The syscall only supports 64-bit time_t. */
return SYSCALL_CANCEL (epoll_pwait2, fd, ev, maxev, tmo, s, __NSIG_BYTES);
}
#if __TIMESIZE != 64
libc_hidden_def (__epoll_pwait2_time64)
int
epoll_pwait2 (int fd, struct epoll_event *ev, int maxev,
const struct timespec *tmo, const sigset_t *s)
{
struct __timespec64 tmo64, *ptmo64 = NULL;
if (tmo != NULL)
{
tmo64 = valid_timespec_to_timespec64 (*tmo);
ptmo64 = &tmo64;
}
return __epoll_pwait2_time64 (fd, ev, maxev, ptmo64, s);
}
#endif

View File

@ -2596,8 +2596,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -2780,8 +2780,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -2549,6 +2549,7 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -492,8 +492,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 _Exit F GLIBC_2.4 _Exit F
GLIBC_2.4 _IO_2_1_stderr_ D 0x98 GLIBC_2.4 _IO_2_1_stderr_ D 0x98
GLIBC_2.4 _IO_2_1_stdin_ D 0x98 GLIBC_2.4 _IO_2_1_stdin_ D 0x98

View File

@ -2723,8 +2723,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -2696,5 +2696,7 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F

View File

@ -2693,5 +2693,7 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F

View File

@ -2688,8 +2688,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -2686,8 +2686,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -2694,8 +2694,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -2600,6 +2600,7 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -2735,5 +2735,7 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F

View File

@ -697,6 +697,7 @@ GLIBC_2.35 epoll_create F
GLIBC_2.35 epoll_create1 F GLIBC_2.35 epoll_create1 F
GLIBC_2.35 epoll_ctl F GLIBC_2.35 epoll_ctl F
GLIBC_2.35 epoll_pwait F GLIBC_2.35 epoll_pwait F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.35 epoll_wait F GLIBC_2.35 epoll_wait F
GLIBC_2.35 erand48 F GLIBC_2.35 erand48 F
GLIBC_2.35 erand48_r F GLIBC_2.35 erand48_r F

View File

@ -2750,8 +2750,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F GLIBC_2.4 _IO_sprintf F

View File

@ -2783,8 +2783,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F GLIBC_2.4 _IO_sprintf F

View File

@ -2508,6 +2508,7 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F GLIBC_2.4 _IO_sprintf F

View File

@ -2810,3 +2810,4 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F

View File

@ -2377,3 +2377,4 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F

View File

@ -2577,3 +2577,4 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F

View File

@ -2748,8 +2748,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F GLIBC_2.4 _IO_sprintf F

View File

@ -2545,6 +2545,7 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F GLIBC_2.4 _IO_sprintf F

View File

@ -2603,8 +2603,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -2600,8 +2600,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -2743,8 +2743,10 @@ GLIBC_2.34 tss_create F
GLIBC_2.34 tss_delete F GLIBC_2.34 tss_delete F
GLIBC_2.34 tss_get F GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __epoll_pwait2_time64 F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_fprintf F
GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_printf F
GLIBC_2.4 _IO_sprintf F GLIBC_2.4 _IO_sprintf F

View File

@ -2572,6 +2572,7 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -22,6 +22,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <bits/types/sigset_t.h> #include <bits/types/sigset_t.h>
#include <bits/types/struct_timespec.h>
/* Get the platform-dependent flags. */ /* Get the platform-dependent flags. */
#include <bits/epoll.h> #include <bits/epoll.h>
@ -133,6 +134,26 @@ extern int epoll_pwait (int __epfd, struct epoll_event *__events,
int __maxevents, int __timeout, int __maxevents, int __timeout,
const __sigset_t *__ss); const __sigset_t *__ss);
/* Same as epoll_pwait, but the timeout as a timespec.
This function is a cancellation point and therefore not marked with
__THROW. */
#ifndef __USE_TIME_BITS64
extern int epoll_pwait2 (int __epfd, struct epoll_event *__events,
int __maxevents, const struct timespec *__timeout,
const __sigset_t *__ss);
#else
# ifdef __REDIRECT
extern int __REDIRECT (epoll_pwait2, (int __epfd, struct epoll_event *__ev,
int __maxevs,
const struct timespec *__timeout,
const __sigset_t *__ss),
__epoll_pwait2_time64);
# else
# define epoll_pwait2 __epoll_pwait2_time64
# endif
#endif
__END_DECLS __END_DECLS
#endif /* sys/epoll.h */ #endif /* sys/epoll.h */

View File

@ -0,0 +1 @@
#include "tst-epoll.c"

View File

@ -0,0 +1,211 @@
/* Basic tests for Linux epoll_* wrappers.
Copyright (C) 2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <errno.h>
#include <intprops.h>
#include <support/check.h>
#include <support/support.h>
#include <support/xsignal.h>
#include <support/xunistd.h>
#include <support/xtime.h>
#include <stdlib.h>
#include <sys/epoll.h>
/* The test focus on checking if the timeout argument is correctly handled
by glibc wrappers. */
static void
handler (int sig)
{
}
typedef int (*epoll_wait_check_t) (int, struct epoll_event *, int,
int, const sigset_t *);
static void
test_epoll_basic (epoll_wait_check_t epoll_wait_check)
{
{
sigset_t ss_usr1;
sigemptyset (&ss_usr1);
sigaddset (&ss_usr1, SIGUSR1);
TEST_COMPARE (sigprocmask (SIG_BLOCK, &ss_usr1, NULL), 0);
}
int fds[2][2];
xpipe (fds[0]);
xpipe (fds[1]);
sigset_t ss;
TEST_COMPARE (sigprocmask (SIG_SETMASK, NULL, &ss), 0);
sigdelset (&ss, SIGUSR1);
int efd = epoll_create1 (0);
TEST_VERIFY_EXIT (efd != -1);
struct epoll_event event;
event.data.fd = fds[1][0];
event.events = EPOLLIN | EPOLLET;
TEST_COMPARE (epoll_ctl (efd, EPOLL_CTL_ADD, fds[1][0], &event), 0);
pid_t parent = getpid ();
pid_t p = xfork ();
if (p == 0)
{
xclose (fds[0][1]);
xclose (fds[1][0]);
event.data.fd = fds[0][0];
event.events = EPOLLIN | EPOLLET;
TEST_COMPARE (epoll_ctl (efd, EPOLL_CTL_ADD, fds[0][0], &event), 0);
int e;
do
{
if (getppid () != parent)
FAIL_EXIT1 ("getppid()=%d != parent=%d", getppid(), parent);
errno = 0;
e = epoll_wait_check (efd, &event, 1, 500, &ss);
}
while (e == 0);
TEST_COMPARE (e, -1);
TEST_COMPARE (errno, EINTR);
TEMP_FAILURE_RETRY (write (fds[1][1], "foo", 3));
exit (0);
}
xclose (fds[0][0]);
xclose (fds[1][1]);
/* Wait some time so child is blocked on the syscall. */
nanosleep (&(struct timespec) {0, 10000000}, NULL);
TEST_COMPARE (kill (p, SIGUSR1), 0);
int e = epoll_wait_check (efd, &event, 1, 500000000, &ss);
TEST_COMPARE (e, 1);
TEST_VERIFY (event.events & EPOLLIN);
xclose (fds[0][1]);
xclose (fds[1][0]);
xclose (efd);
}
static void
test_epoll_large_timeout (epoll_wait_check_t epoll_wait_check)
{
timer_t t = support_create_timer (0, 100000000, true, NULL);
int fds[2];
xpipe (fds);
fd_set rfds;
FD_ZERO (&rfds);
FD_SET (fds[0], &rfds);
sigset_t ss;
TEST_COMPARE (sigprocmask (SIG_SETMASK, NULL, &ss), 0);
sigdelset (&ss, SIGALRM);
int efd = epoll_create1 (0);
TEST_VERIFY_EXIT (efd != -1);
struct epoll_event event;
event.data.fd = fds[0];
event.events = EPOLLIN | EPOLLET;
TEST_COMPARE (epoll_ctl (efd, EPOLL_CTL_ADD, fds[0], &event), 0);
int tmo = TYPE_MAXIMUM (int);
TEST_COMPARE (epoll_wait_check (efd, &event, 1, tmo, &ss), -1);
TEST_VERIFY (errno == EINTR || errno == EOVERFLOW);
TEST_COMPARE (epoll_wait_check (efd, &event, 1, -1, &ss), -1);
TEST_VERIFY (errno == EINTR || errno == EOVERFLOW);
support_delete_timer (t);
xclose (fds[0]);
xclose (fds[1]);
xclose (efd);
}
static int
epoll_wait_check (int epfd, struct epoll_event *ev, int maxev, int tmo,
const sigset_t *ss)
{
sigset_t orig;
TEST_COMPARE (sigprocmask (SIG_SETMASK, ss, &orig), 0);
int r = epoll_wait (epfd, ev, maxev, tmo);
TEST_COMPARE (sigprocmask (SIG_SETMASK, &orig, NULL), 0);
return r;
}
static int
epoll_pwait_check (int epfd, struct epoll_event *ev, int maxev, int tmo,
const sigset_t *ss)
{
return epoll_pwait (epfd, ev, maxev, tmo, ss);
}
static int
epoll_pwait2_check (int epfd, struct epoll_event *ev, int maxev, int tmo,
const sigset_t *ss)
{
time_t s = tmo == -1 ? TYPE_MAXIMUM (time_t) : tmo / 1000;
long int ns = tmo == -1 ? 0 : (tmo % 1000) * 1000000;
return epoll_pwait2 (epfd, ev, maxev, &(struct timespec) { s, ns }, ss);
}
static int
do_test (void)
{
{
struct sigaction sa;
sa.sa_handler = handler;
sa.sa_flags = 0;
sigemptyset (&sa.sa_mask);
xsigaction (SIGUSR1, &sa, NULL);
sa.sa_handler = SIG_IGN;
xsigaction (SIGCHLD, &sa, NULL);
}
int r = epoll_pwait2 (-1, NULL, 0, NULL, NULL);
TEST_COMPARE (r, -1);
bool pwait2_supported = errno != ENOSYS;
test_epoll_basic (epoll_wait_check);
test_epoll_basic (epoll_pwait_check);
if (pwait2_supported)
test_epoll_basic (epoll_pwait2_check);
test_epoll_large_timeout (epoll_wait_check);
test_epoll_large_timeout (epoll_pwait_check);
if (pwait2_supported)
test_epoll_large_timeout (epoll_pwait2_check);
return 0;
}
#include <support/test-driver.c>

View File

@ -2523,6 +2523,7 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F
GLIBC_2.4 __confstr_chk F GLIBC_2.4 __confstr_chk F
GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_chk F
GLIBC_2.4 __fgets_unlocked_chk F GLIBC_2.4 __fgets_unlocked_chk F

View File

@ -2629,3 +2629,4 @@ GLIBC_2.34 tss_get F
GLIBC_2.34 tss_set F GLIBC_2.34 tss_set F
GLIBC_2.35 __memcmpeq F GLIBC_2.35 __memcmpeq F
GLIBC_2.35 _dl_find_object F GLIBC_2.35 _dl_find_object F
GLIBC_2.35 epoll_pwait2 F