[libc] [llvm] [libc] add remaining epoll functions, pipe (PR #84587)

Nick Desaulniers via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 21 13:06:37 PDT 2024


================
@@ -5,16 +5,45 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+#include "include/llvm-libc-macros/linux/sys-epoll-macros.h"
+#include "include/llvm-libc-types/struct_epoll_event.h"
 #include "src/errno/libc_errno.h"
+#include "src/sys/epoll/epoll_create1.h"
+#include "src/sys/epoll/epoll_ctl.h"
 #include "src/sys/epoll/epoll_pwait.h"
+#include "src/unistd/close.h"
+#include "src/unistd/pipe.h"
 #include "test/UnitTest/ErrnoSetterMatcher.h"
 #include "test/UnitTest/Test.h"
 
 using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
 
-TEST(LlvmLibcEpollWaitTest, Basic) {
-  EXPECT_THAT(LIBC_NAMESPACE::epoll_pwait(-1, nullptr, 0, 0, nullptr),
-              returns(EQ(-1ul)).with_errno(EQ(EINVAL)));
-}
+TEST(LlvmLibcEpollPwaitTest, Basic) {
+  int epfd = LIBC_NAMESPACE::epoll_create1(0);
+  ASSERT_GT(epfd, 0);
+  ASSERT_ERRNO_SUCCESS();
+
+  int pipefd[2];
+
+  ASSERT_THAT(LIBC_NAMESPACE::pipe(pipefd), Succeeds());
+
+  epoll_event event{.events = EPOLLOUT, .data = {.fd = pipefd[0]}};
----------------
nickdesaulniers wrote:

Orthogonal to the other issues we're hitting, this statement produces the following diagnostics:
```
[5/7] Building CXX object projects/libc/test/src/sys/epoll...inux.epoll_pwait_test.__build__.dir/epoll_pwait_test.cpp.o
/android0/llvm-project/libc/test/src/sys/epoll/linux/epoll_pwait_test.cpp:33:50: warning: designated initializers are a C++20 extension [-Wc++20-designator]
   33 |   epoll_event event{.events = EPOLLOUT, .data = {.fd = pipefd[0]}};
      |                                                  ^
/android0/llvm-project/libc/test/src/sys/epoll/linux/epoll_pwait_test.cpp:33:21: warning: designated initializers are a C++20 extension [-Wc++20-designator]
   33 |   epoll_event event{.events = EPOLLOUT, .data = {.fd = pipefd[0]}};
      |                     ^
```
as much as I love designated initializers, and am glad they were added to C++, they only did so for C++20.  Consider building this test in `-std=c++20`.

https://github.com/llvm/llvm-project/pull/84587


More information about the llvm-commits mailing list