[libc-commits] [libc] [libc] skip test and return ENOSYS when processm_release unavailable (PR #117951)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Wed Nov 27 17:42:32 PST 2024
https://github.com/SchrodingerZhu updated https://github.com/llvm/llvm-project/pull/117951
>From 0a36d863734511207a249a0f0cac91011942997a Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Wed, 27 Nov 2024 20:40:23 -0500
Subject: [PATCH] [libc] skip test and return ENOSYS when processm_release
unavailable
---
libc/src/sys/mman/linux/process_mrelease.cpp | 8 ++++++++
libc/test/src/sys/mman/linux/process_mrelease_test.cpp | 3 ++-
2 files changed, 10 insertions(+), 1 deletion(-)
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
More information about the libc-commits
mailing list