mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
missing_syscall: add epoll_pwait2() wrapper
This commit is contained in:
parent
8b2620ea8c
commit
420297c9e1
@ -549,6 +549,7 @@ foreach ident : [
|
|||||||
['mallinfo', '''#include <malloc.h>'''],
|
['mallinfo', '''#include <malloc.h>'''],
|
||||||
['execveat', '''#include <unistd.h>'''],
|
['execveat', '''#include <unistd.h>'''],
|
||||||
['close_range', '''#include <unistd.h>'''],
|
['close_range', '''#include <unistd.h>'''],
|
||||||
|
['epoll_pwait2', '''#include <sys/epoll.h>'''],
|
||||||
]
|
]
|
||||||
|
|
||||||
have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
|
have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
|
||||||
@ -672,6 +673,7 @@ foreach header : ['crypt.h',
|
|||||||
'sys/auxv.h',
|
'sys/auxv.h',
|
||||||
'valgrind/memcheck.h',
|
'valgrind/memcheck.h',
|
||||||
'valgrind/valgrind.h',
|
'valgrind/valgrind.h',
|
||||||
|
'linux/time_types.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
conf.set10('HAVE_' + header.underscorify().to_upper(),
|
conf.set10('HAVE_' + header.underscorify().to_upper(),
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#if HAVE_LINUX_TIME_TYPES_H
|
||||||
|
/* This header defines __kernel_timespec for us, but is only available since Linux 5.1, hence conditionally
|
||||||
|
* include this. */
|
||||||
|
#include <linux/time_types.h>
|
||||||
|
#endif
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -382,3 +387,41 @@ static inline int missing_close_range(int first_fd, int end_fd, unsigned flags)
|
|||||||
|
|
||||||
# define close_range missing_close_range
|
# define close_range missing_close_range
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* ======================================================================= */
|
||||||
|
|
||||||
|
#if !HAVE_EPOLL_PWAIT2
|
||||||
|
|
||||||
|
/* Defined to be equivalent to the kernel's _NSIG_WORDS, i.e. the size of the array of longs that is
|
||||||
|
* encapsulated by sigset_t. */
|
||||||
|
#define KERNEL_NSIG_WORDS (64 / (sizeof(long) * 8))
|
||||||
|
#define KERNEL_NSIG_BYTES (KERNEL_NSIG_WORDS * sizeof(long))
|
||||||
|
|
||||||
|
struct epoll_event;
|
||||||
|
|
||||||
|
static inline int missing_epoll_pwait2(
|
||||||
|
int fd,
|
||||||
|
struct epoll_event *events,
|
||||||
|
int maxevents,
|
||||||
|
const struct timespec *timeout,
|
||||||
|
const sigset_t *sigset) {
|
||||||
|
|
||||||
|
# if defined(__NR_epoll_pwait2) && HAVE_LINUX_TIME_TYPES_H
|
||||||
|
if (timeout) {
|
||||||
|
/* Convert from userspace timespec to kernel timespec */
|
||||||
|
struct __kernel_timespec ts = {
|
||||||
|
.tv_sec = timeout->tv_sec,
|
||||||
|
.tv_nsec = timeout->tv_nsec,
|
||||||
|
};
|
||||||
|
|
||||||
|
return syscall(__NR_epoll_pwait2, fd, events, maxevents, &ts, sigset, sigset ? KERNEL_NSIG_BYTES : 0);
|
||||||
|
} else
|
||||||
|
return syscall(__NR_epoll_pwait2, fd, events, maxevents, NULL, sigset, sigset ? KERNEL_NSIG_BYTES : 0);
|
||||||
|
# else
|
||||||
|
errno = ENOSYS;
|
||||||
|
return -1;
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
# define epoll_pwait2 missing_epoll_pwait2
|
||||||
|
#endif
|
||||||
|
@ -673,3 +673,58 @@ assert_cc(__NR_statx == systemd_NR_statx);
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __IGNORE_epoll_pwait2
|
||||||
|
# if defined(__aarch64__)
|
||||||
|
# define systemd_NR_epoll_pwait2 441
|
||||||
|
# elif defined(__alpha__)
|
||||||
|
# define systemd_NR_epoll_pwait2 551
|
||||||
|
# elif defined(__arc__) || defined(__tilegx__)
|
||||||
|
# define systemd_NR_epoll_pwait2 441
|
||||||
|
# elif defined(__arm__)
|
||||||
|
# define systemd_NR_epoll_pwait2 441
|
||||||
|
# elif defined(__i386__)
|
||||||
|
# define systemd_NR_epoll_pwait2 441
|
||||||
|
# elif defined(__ia64__)
|
||||||
|
# define systemd_NR_epoll_pwait2 1465
|
||||||
|
# elif defined(__m68k__)
|
||||||
|
# define systemd_NR_epoll_pwait2 441
|
||||||
|
# elif defined(_MIPS_SIM)
|
||||||
|
# if _MIPS_SIM == _MIPS_SIM_ABI32
|
||||||
|
# define systemd_NR_epoll_pwait2 4441
|
||||||
|
# elif _MIPS_SIM == _MIPS_SIM_NABI32
|
||||||
|
# define systemd_NR_epoll_pwait2 6441
|
||||||
|
# elif _MIPS_SIM == _MIPS_SIM_ABI64
|
||||||
|
# define systemd_NR_epoll_pwait2 5441
|
||||||
|
# else
|
||||||
|
# error "Unknown MIPS ABI"
|
||||||
|
# endif
|
||||||
|
# elif defined(__powerpc__)
|
||||||
|
# define systemd_NR_epoll_pwait2 441
|
||||||
|
# elif defined(__s390__)
|
||||||
|
# define systemd_NR_epoll_pwait2 441
|
||||||
|
# elif defined(__sparc__)
|
||||||
|
# define systemd_NR_epoll_pwait2 441
|
||||||
|
# elif defined(__x86_64__)
|
||||||
|
# if defined(__ILP32__)
|
||||||
|
# define systemd_NR_epoll_pwait2 (441 | /* __X32_SYSCALL_BIT */ 0x40000000)
|
||||||
|
# else
|
||||||
|
# define systemd_NR_epoll_pwait2 441
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# warning "epoll_pwait2() syscall number is unknown for your architecture"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
|
||||||
|
# if defined __NR_epoll_pwait2 && __NR_epoll_pwait2 >= 0
|
||||||
|
# if defined systemd_NR_epoll_pwait2
|
||||||
|
assert_cc(__NR_epoll_pwait2 == systemd_NR_epoll_pwait2);
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# if defined __NR_epoll_pwait2
|
||||||
|
# undef __NR_epoll_pwait2
|
||||||
|
# endif
|
||||||
|
# if defined systemd_NR_epoll_pwait2 && systemd_NR_epoll_pwait2 >= 0
|
||||||
|
# define __NR_epoll_pwait2 systemd_NR_epoll_pwait2
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
@ -17,7 +17,8 @@ SYSCALLS = [
|
|||||||
'pkey_mprotect',
|
'pkey_mprotect',
|
||||||
'renameat2',
|
'renameat2',
|
||||||
'setns',
|
'setns',
|
||||||
'statx']
|
'statx',
|
||||||
|
'epoll_pwait2']
|
||||||
|
|
||||||
def dictify(f):
|
def dictify(f):
|
||||||
def wrap(*args, **kwargs):
|
def wrap(*args, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user