[libc-commits] [libc] [libc] Disable epoll_pwait2 for now. (PR #99967)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Mon Jul 22 15:06:32 PDT 2024


https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/99967

This patch reverts #99781 and part of #99771 since `epoll_pwait2` is not
in fact available on all supported systems. It is my opinion that we
shouldn't provide a version of a function that doesn't perform as
expected, which is why this revert needs to happen.

The `epoll_pwait2` function can be reenabled when we have a way to check
if it is available on the target system, tracking bug for that is #80060


>From 33bb9d2272561971d01c8c19ce158947e52ca18d Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Mon, 22 Jul 2024 15:02:27 -0700
Subject: [PATCH] [libc] Disable epoll_pwait2 for now.

This patch reverts #99781 and part of #99771 since `epoll_pwait2` is not
in fact available on all supported systems. It is my opinion that we
shouldn't provide a version of a function that doesn't perform as
expected, which is why this revert needs to happen.

The `epoll_pwait2` function can be reenabled when we have a way to check
if it is available on the target system, tracking bug for that is #80060
---
 libc/config/linux/riscv/entrypoints.txt   |  4 +++-
 libc/config/linux/x86_64/entrypoints.txt  |  4 +++-
 libc/src/sys/epoll/linux/epoll_pwait2.cpp | 12 ------------
 3 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index ea08957f4ee89..6ab90771802fd 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -228,7 +228,9 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.sys.epoll.epoll_ctl
     libc.src.sys.epoll.epoll_pwait
     libc.src.sys.epoll.epoll_wait
-    libc.src.sys.epoll.epoll_pwait2
+    # TODO: Need to check if pwait2 is available before providing.
+    # https://github.com/llvm/llvm-project/issues/80060
+    # libc.src.sys.epoll.epoll_pwait2
 
     # sys/mman.h entrypoints
     libc.src.sys.mman.madvise
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 7c422bad9f01d..f7813fc16ff7c 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -228,7 +228,9 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.sys.epoll.epoll_ctl
     libc.src.sys.epoll.epoll_pwait
     libc.src.sys.epoll.epoll_wait
-    libc.src.sys.epoll.epoll_pwait2
+    # TODO: Need to check if pwait2 is available before providing.
+    # https://github.com/llvm/llvm-project/issues/80060
+    # libc.src.sys.epoll.epoll_pwait2
 
     # sys/mman.h entrypoints
     libc.src.sys.mman.madvise
diff --git a/libc/src/sys/epoll/linux/epoll_pwait2.cpp b/libc/src/sys/epoll/linux/epoll_pwait2.cpp
index 4123157d29fff..14b419399fe9b 100644
--- a/libc/src/sys/epoll/linux/epoll_pwait2.cpp
+++ b/libc/src/sys/epoll/linux/epoll_pwait2.cpp
@@ -25,22 +25,10 @@ namespace LIBC_NAMESPACE_DECL {
 LLVM_LIBC_FUNCTION(int, epoll_pwait2,
                    (int epfd, struct epoll_event *events, int maxevents,
                     const struct timespec *timeout, const sigset_t *sigmask)) {
-#ifdef SYS_epoll_pwait2
   int ret = LIBC_NAMESPACE::syscall_impl<int>(
       SYS_epoll_pwait2, epfd, reinterpret_cast<long>(events), maxevents,
       reinterpret_cast<long>(timeout), reinterpret_cast<long>(sigmask),
       NSIG / 8);
-#elif defined(SYS_epoll_pwait)
-  // Convert nanoseconds to milliseconds, rounding up if there are remaining
-  // nanoseconds
-  long timeout_ms = static_cast<long>(timeout->tv_sec * 1000 +
-                                      (timeout->tv_nsec + 999999) / 1000000);
-  int ret = LIBC_NAMESPACE::syscall_impl<int>(
-      SYS_epoll_pwait, epfd, reinterpret_cast<long>(events), maxevents,
-      timeout_ms, reinterpret_cast<long>(sigmask), NSIG / 8);
-#else
-#error "epoll_pwait and epoll_pwait2 syscalls not available."
-#endif
 
   // A negative return value indicates an error with the magnitude of the
   // value being the error code.



More information about the libc-commits mailing list