[libc] Fix epoll_create behavior when only epoll_create1 is available#149713
Merged
mikhailramalho merged 1 commit intollvm:mainfrom Jul 20, 2025
Merged
[libc] Fix epoll_create behavior when only epoll_create1 is available#149713mikhailramalho merged 1 commit intollvm:mainfrom
mikhailramalho merged 1 commit intollvm:mainfrom
Conversation
In PR llvm#99785 I disabled a epoll_create test that should fail for systems where only epoll_create1 was available, because epoll_create1 couldn't fail the same way epoll_create did. Calling epoll_create(0) should fail with an EINVAL error, so when only epoll_create1 is available, we should just check if the arg is zero and return the error accordingly.
Member
|
@llvm/pr-subscribers-libc Author: Mikhail R. Gadelha (mikhailramalho) ChangesIn PR #99785, I disabled a test for Specifically, calling Full diff: https://github.com/llvm/llvm-project/pull/149713.diff 2 Files Affected:
diff --git a/libc/src/sys/epoll/linux/epoll_create.cpp b/libc/src/sys/epoll/linux/epoll_create.cpp
index 2e44e883ddf0a..dcd082b56f9ad 100644
--- a/libc/src/sys/epoll/linux/epoll_create.cpp
+++ b/libc/src/sys/epoll/linux/epoll_create.cpp
@@ -20,6 +20,11 @@ LLVM_LIBC_FUNCTION(int, epoll_create, ([[maybe_unused]] int size)) {
#ifdef SYS_epoll_create
int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_epoll_create, size);
#elif defined(SYS_epoll_create1)
+ if (size == 0) {
+ libc_errno = EINVAL;
+ return -1;
+ }
+
int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_epoll_create1, 0);
#else
#error \
diff --git a/libc/test/src/sys/epoll/linux/epoll_create_test.cpp b/libc/test/src/sys/epoll/linux/epoll_create_test.cpp
index 06c17c6cf29e6..2bbfe4fbe81ff 100644
--- a/libc/test/src/sys/epoll/linux/epoll_create_test.cpp
+++ b/libc/test/src/sys/epoll/linux/epoll_create_test.cpp
@@ -10,7 +10,6 @@
#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/ErrnoSetterMatcher.h"
#include "test/UnitTest/Test.h"
-#include <sys/syscall.h> // For syscall numbers.
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
using LlvmLibcEpollCreateTest = LIBC_NAMESPACE::testing::ErrnoCheckingTest;
@@ -23,8 +22,6 @@ TEST_F(LlvmLibcEpollCreateTest, Basic) {
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds());
}
-#ifdef SYS_epoll_create
TEST_F(LlvmLibcEpollCreateTest, Fails) {
ASSERT_THAT(LIBC_NAMESPACE::epoll_create(0), Fails(EINVAL));
}
-#endif
|
lntue
approved these changes
Jul 20, 2025
This was referenced Jul 23, 2025
mahesh-attarde
pushed a commit
to mahesh-attarde/llvm-project
that referenced
this pull request
Jul 28, 2025
…llvm#149713) In PR llvm#99785, I disabled a test for `epoll_create` that was intended to fail on systems where only `epoll_create1` is available. This is because `epoll_create1` cannot fail in the same way that `epoll_create` does. Specifically, calling `epoll_create(0)` should result in an EINVAL error. So, when only `epoll_create1` is available, we should simply check if the argument is zero and return the error accordingly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In PR #99785, I disabled a test for
epoll_createthat was intended to fail on systems where onlyepoll_create1is available. This is becauseepoll_create1cannot fail in the same way thatepoll_createdoes.Specifically, calling
epoll_create(0)should result in an EINVAL error. So, when onlyepoll_create1is available, we should simply check if the argument is zero and return the error accordingly.