1//===---------- Linux implementation of the epoll_pwait function ----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "src/sys/epoll/epoll_pwait.h"
10
11#include "hdr/signal_macros.h" // for NSIG
12#include "hdr/types/sigset_t.h"
13#include "hdr/types/struct_epoll_event.h"
14#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
15#include "src/__support/common.h"
16#include "src/errno/libc_errno.h"
17
18#include <sys/syscall.h> // For syscall numbers.
19
20namespace LIBC_NAMESPACE {
21
22LLVM_LIBC_FUNCTION(int, epoll_pwait,
23 (int epfd, struct epoll_event *events, int maxevents,
24 int timeout, const sigset_t *sigmask)) {
25 int ret = LIBC_NAMESPACE::syscall_impl<int>(
26 SYS_epoll_pwait, ts: epfd, ts: reinterpret_cast<long>(events), ts: maxevents, ts: timeout,
27 ts: reinterpret_cast<long>(sigmask), NSIG / 8);
28
29 // A negative return value indicates an error with the magnitude of the
30 // value being the error code.
31 if (ret < 0) {
32 libc_errno = -ret;
33 return -1;
34 }
35
36 return ret;
37}
38
39} // namespace LIBC_NAMESPACE
40

source code of libc/src/sys/epoll/linux/epoll_pwait.cpp