Skip to content

Commit ecdbffe

Browse files
[libc] Support epoll_wait using epoll_pwait (#80224)
The epoll_wait syscall is equivalent to calling epoll_pwait with a null sigset. This is useful to support systems that have epoll_pwait but not epoll_wait.
1 parent 3913931 commit ecdbffe

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

libc/src/sys/epoll/linux/epoll_wait.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
1212
#include "src/__support/common.h"
13-
1413
#include "src/errno/libc_errno.h"
1514
#include <sys/syscall.h> // For syscall numbers.
1615

1716
// TODO: Use this include once the include headers are also using quotes.
17+
// #include "include/llvm-libc-types/sigset_t.h"
1818
// #include "include/llvm-libc-types/struct_epoll_event.h"
1919

2020
#include <sys/epoll.h>
@@ -24,9 +24,16 @@ namespace LIBC_NAMESPACE {
2424
LLVM_LIBC_FUNCTION(int, epoll_wait,
2525
(int epfd, struct epoll_event *events, int maxevents,
2626
int timeout)) {
27+
#ifdef SYS_epoll_wait
2728
int ret = LIBC_NAMESPACE::syscall_impl<int>(
2829
SYS_epoll_wait, epfd, reinterpret_cast<long>(events), maxevents, timeout);
29-
30+
#elif defined(SYS_epoll_pwait)
31+
int ret = LIBC_NAMESPACE::syscall_impl<int>(
32+
SYS_epoll_pwait, epfd, reinterpret_cast<long>(events), maxevents, timeout,
33+
reinterpret_cast<long>(nullptr), sizeof(sigset_t));
34+
#else
35+
#error "epoll_wait and epoll_pwait are unavailable. Unable to build epoll_wait."
36+
#endif
3037
// A negative return value indicates an error with the magnitude of the
3138
// value being the error code.
3239
if (ret < 0) {

0 commit comments

Comments
 (0)