Skip to content

[libc] skip test and return ENOSYS when processm_release unavailable #117951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 28, 2024

Conversation

SchrodingerZhu
Copy link
Contributor

No description provided.

@llvmbot llvmbot added the libc label Nov 28, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 28, 2024

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/117951.diff

2 Files Affected:

  • (modified) libc/src/sys/mman/linux/process_mrelease.cpp (+8)
  • (modified) libc/test/src/sys/mman/linux/process_mrelease_test.cpp (+2-1)
diff --git a/libc/src/sys/mman/linux/process_mrelease.cpp b/libc/src/sys/mman/linux/process_mrelease.cpp
index e86bbec1b1b661..7660f1e23ece2a 100644
--- a/libc/src/sys/mman/linux/process_mrelease.cpp
+++ b/libc/src/sys/mman/linux/process_mrelease.cpp
@@ -19,6 +19,7 @@
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
+#ifdef SYS_process_mrelease
   long ret =
       LIBC_NAMESPACE::syscall_impl<int>(SYS_process_mrelease, pidfd, flags);
 
@@ -28,6 +29,13 @@ LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
   }
 
   return 0;
+#else
+  // The system call is not available.
+  (void)pidfd;
+  (void)flags;
+  libc_errno = ENOSYS;
+  return -1;
+#endif
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/sys/mman/linux/process_mrelease_test.cpp b/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
index 56a7d66ee7a5ac..5328ce9f282d9a 100644
--- a/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
+++ b/libc/test/src/sys/mman/linux/process_mrelease_test.cpp
@@ -18,7 +18,7 @@
 #include "test/UnitTest/LibcTest.h"
 
 #include <sys/syscall.h>
-
+#if defined(SYS_process_mrelease) && defined(SYS_pidfd_open)
 using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
 
 int pidfd_open(pid_t pid, unsigned int flags) {
@@ -72,3 +72,4 @@ TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
 TEST(LlvmLibcProcessMReleaseTest, ErrorNonExistingPidfd) {
   EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(-1, 0), Fails(EBADF));
 }
+#endif

@SchrodingerZhu SchrodingerZhu requested a review from lntue November 28, 2024 01:44
@SchrodingerZhu
Copy link
Contributor Author

merge this to fix CI error

@SchrodingerZhu SchrodingerZhu merged commit 819b155 into llvm:main Nov 28, 2024
5 of 6 checks passed
@SchrodingerZhu SchrodingerZhu deleted the libc/mrelease-fix branch November 28, 2024 02:01
SchrodingerZhu added a commit to SchrodingerZhu/llvm-project that referenced this pull request Dec 4, 2024
SchrodingerZhu added a commit to SchrodingerZhu/llvm-project that referenced this pull request Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants