Skip to content

Commit 0a36d86

Browse files
[libc] skip test and return ENOSYS when processm_release unavailable
1 parent 63c5a42 commit 0a36d86

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

libc/src/sys/mman/linux/process_mrelease.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
namespace LIBC_NAMESPACE_DECL {
2020

2121
LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
22+
#ifdef SYS_process_mrelease
2223
long ret =
2324
LIBC_NAMESPACE::syscall_impl<int>(SYS_process_mrelease, pidfd, flags);
2425

@@ -28,6 +29,13 @@ LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
2829
}
2930

3031
return 0;
32+
#else
33+
// The system call is not available.
34+
(void)pidfd;
35+
(void)flags;
36+
libc_errno = ENOSYS;
37+
return -1;
38+
#endif
3139
}
3240

3341
} // namespace LIBC_NAMESPACE_DECL

libc/test/src/sys/mman/linux/process_mrelease_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "test/UnitTest/LibcTest.h"
1919

2020
#include <sys/syscall.h>
21-
21+
#if defined(SYS_process_mrelease) && defined(SYS_pidfd_open)
2222
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
2323

2424
int pidfd_open(pid_t pid, unsigned int flags) {
@@ -72,3 +72,4 @@ TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
7272
TEST(LlvmLibcProcessMReleaseTest, ErrorNonExistingPidfd) {
7373
EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(-1, 0), Fails(EBADF));
7474
}
75+
#endif

0 commit comments

Comments
 (0)