1//===---------- Linux implementation of the epoll_pwait2 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_pwait2.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 "hdr/types/struct_timespec.h"
15#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
16#include "src/__support/common.h"
17#include "src/errno/libc_errno.h"
18
19#include <sys/syscall.h> // For syscall numbers.
20
21namespace LIBC_NAMESPACE {
22
23LLVM_LIBC_FUNCTION(int, epoll_pwait2,
24 (int epfd, struct epoll_event *events, int maxevents,
25 const struct timespec *timeout, const sigset_t *sigmask)) {
26 int ret = LIBC_NAMESPACE::syscall_impl<int>(
27 SYS_epoll_pwait2, ts: epfd, ts: reinterpret_cast<long>(events), ts: maxevents,
28 ts: reinterpret_cast<long>(timeout), ts: reinterpret_cast<long>(sigmask),
29 NSIG / 8);
30
31 // A negative return value indicates an error with the magnitude of the
32 // value being the error code.
33 if (ret < 0) {
34 libc_errno = -ret;
35 return -1;
36 }
37
38 return ret;
39}
40
41} // namespace LIBC_NAMESPACE
42

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