46 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/sys/epoll/epoll_pwait2.h"10 11#include "hdr/signal_macros.h" // for NSIG12#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/__support/libc_errno.h"18#include "src/__support/macros/config.h"19#include "src/__support/macros/sanitizer.h"20 21#include <sys/syscall.h> // For syscall numbers.22 23namespace LIBC_NAMESPACE_DECL {24 25LLVM_LIBC_FUNCTION(int, epoll_pwait2,26 (int epfd, struct epoll_event *events, int maxevents,27 const struct timespec *timeout, const sigset_t *sigmask)) {28 int ret = LIBC_NAMESPACE::syscall_impl<int>(29 SYS_epoll_pwait2, epfd, reinterpret_cast<long>(events), maxevents,30 reinterpret_cast<long>(timeout), reinterpret_cast<long>(sigmask),31 NSIG / 8);32 33 // A negative return value indicates an error with the magnitude of the34 // value being the error code.35 if (ret < 0) {36 libc_errno = -ret;37 return -1;38 }39 40 MSAN_UNPOISON(events, ret * sizeof(struct epoll_event));41 42 return ret;43}44 45} // namespace LIBC_NAMESPACE_DECL46