[libc-commits] [libc] [libc] Implement ppoll in poll (PR #225767)

Aman Maurya via libc-commits libc-commits at lists.llvm.org
Thu Sep 24 03:02:20 PDT 2026


================
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Unittests for ppoll.
+///
+//===----------------------------------------------------------------------===//
+
+#include "hdr/limits_macros.h"
+#include "hdr/poll_macros.h"
+#include "hdr/types/sigset_t.h"
+#include "hdr/types/struct_pollfd.h"
+#include "hdr/types/struct_timespec.h"
+#include "src/__support/CPP/scope.h"
+#include "src/poll/ppoll.h"
+#include "src/unistd/close.h"
+#include "src/unistd/pipe.h"
+#include "src/unistd/read.h"
+#include "src/unistd/write.h"
+#include "test/UnitTest/ErrnoCheckingTest.h"
+#include "test/UnitTest/Test.h"
+
+using LlvmLibcPPollTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
+
+TEST_F(LlvmLibcPPollTest, SmokeTest) {
+  timespec ts{0, 0};
+  int ret = LIBC_NAMESPACE::ppoll(nullptr, 0, &ts, nullptr);
+  ASSERT_ERRNO_SUCCESS();
+  ASSERT_EQ(0, ret);
+}
+
+TEST_F(LlvmLibcPPollTest, SmokeFailureTest) {
+  int ret = LIBC_NAMESPACE::ppoll(nullptr, UINT_MAX, nullptr, nullptr);
+  ASSERT_ERRNO_EQ(EINVAL);
+  ASSERT_EQ(-1, ret);
+}
+
+TEST_F(LlvmLibcPPollTest, TimeoutNotMutated) {
+  const timespec orig_ts{0, 0};
+  timespec ts = orig_ts;
+  int ret = LIBC_NAMESPACE::ppoll(nullptr, 0, &ts, nullptr);
+  ASSERT_ERRNO_SUCCESS();
+  ASSERT_EQ(0, ret);
+  ASSERT_EQ(ts.tv_sec, orig_ts.tv_sec);
+  ASSERT_EQ(ts.tv_nsec, orig_ts.tv_nsec);
+}
+
+TEST_F(LlvmLibcPPollTest, WithSigmask) {
+  timespec ts{0, 0};
+  sigset_t mask{};
+  int ret = LIBC_NAMESPACE::ppoll(nullptr, 0, &ts, &mask);
----------------
amanmaurya92 wrote:

done 👍 

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


More information about the libc-commits mailing list