diff options
| author | lntue <lntue@google.com> | 2024-11-26 15:07:30 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-26 18:07:30 -0500 |
| commit | 3372303188df0f7f8ac26e7ab610cf8b0f716d42 (patch) | |
| tree | b2fefc7827d1a350008c57f01c1c6c1044d5570f | |
| parent | e1af76cad265694f1799d46de455f18c931ae2b7 (diff) | |
| download | llvm-3372303188df0f7f8ac26e7ab610cf8b0f716d42.zip llvm-3372303188df0f7f8ac26e7ab610cf8b0f716d42.tar.gz llvm-3372303188df0f7f8ac26e7ab610cf8b0f716d42.tar.bz2 | |
Revert "[libc] Implement process_mrelease." (#117807)
Reverts llvm/llvm-project#117503
| -rw-r--r-- | libc/config/linux/aarch64/entrypoints.txt | 1 | ||||
| -rw-r--r-- | libc/config/linux/riscv/entrypoints.txt | 1 | ||||
| -rw-r--r-- | libc/config/linux/x86_64/entrypoints.txt | 1 | ||||
| -rw-r--r-- | libc/include/sys/syscall.h.def | 7 | ||||
| -rw-r--r-- | libc/newhdrgen/yaml/sys/mman.yaml | 7 | ||||
| -rw-r--r-- | libc/spec/linux.td | 6 | ||||
| -rw-r--r-- | libc/src/sys/mman/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | libc/src/sys/mman/linux/CMakeLists.txt | 12 | ||||
| -rw-r--r-- | libc/src/sys/mman/linux/process_mrelease.cpp | 33 | ||||
| -rw-r--r-- | libc/src/sys/mman/process_mrelease.h | 21 | ||||
| -rw-r--r-- | libc/test/src/sys/mman/linux/CMakeLists.txt | 18 | ||||
| -rw-r--r-- | libc/test/src/sys/mman/linux/process_mrelease_test.cpp | 72 |
12 files changed, 1 insertions, 184 deletions
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index 08b5072..74ca374 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -252,7 +252,6 @@ set(TARGET_LIBC_ENTRYPOINTS libc.src.sys.mman.munlockall libc.src.sys.mman.munmap libc.src.sys.mman.remap_file_pages - libc.src.sys.mman.process_mrelease libc.src.sys.mman.posix_madvise libc.src.sys.mman.shm_open libc.src.sys.mman.shm_unlink diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index 4ea65f7..5419462 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -251,7 +251,6 @@ set(TARGET_LIBC_ENTRYPOINTS libc.src.sys.mman.munmap libc.src.sys.mman.remap_file_pages libc.src.sys.mman.posix_madvise - libc.src.sys.mman.process_mrelease libc.src.sys.mman.shm_open libc.src.sys.mman.shm_unlink diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index d0651c0..957e28b 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -252,7 +252,6 @@ set(TARGET_LIBC_ENTRYPOINTS libc.src.sys.mman.munmap libc.src.sys.mman.remap_file_pages libc.src.sys.mman.posix_madvise - libc.src.sys.mman.process_mrelease libc.src.sys.mman.shm_open libc.src.sys.mman.shm_unlink diff --git a/libc/include/sys/syscall.h.def b/libc/include/sys/syscall.h.def index 11758ea..03c19eb 100644 --- a/libc/include/sys/syscall.h.def +++ b/libc/include/sys/syscall.h.def @@ -2349,12 +2349,5 @@ #define SYS_writev __NR_writev #endif -#ifdef __NR_process_mrelease -#define SYS_process_mrelease __NR_process_mrelease -#endif - -#ifdef __NR_pidfd_open -#define SYS_pidfd_open __NR_pidfd_open -#endif #endif // LLVM_LIBC_SYS_SYSCALL_H diff --git a/libc/newhdrgen/yaml/sys/mman.yaml b/libc/newhdrgen/yaml/sys/mman.yaml index dd53eb6..962ca35 100644 --- a/libc/newhdrgen/yaml/sys/mman.yaml +++ b/libc/newhdrgen/yaml/sys/mman.yaml @@ -132,10 +132,3 @@ functions: return_type: int arguments: - type: const char * - - name: process_mrelease - standards: - - Linux - return_type: int - arguments: - - type: int - - type: unsigned int diff --git a/libc/spec/linux.td b/libc/spec/linux.td index 99e0949..9b5dc8e 100644 --- a/libc/spec/linux.td +++ b/libc/spec/linux.td @@ -112,12 +112,6 @@ def Linux : StandardSpec<"Linux"> { ArgSpec<IntType>, ArgSpec<SizeTType>, ArgSpec<IntType>, - FunctionSpec< - "process_mrelease", - RetValSpec<IntType>, - [ - ArgSpec<IntType>, - ArgSpec<UnsignedIntType> ] >, FunctionSpec< diff --git a/libc/src/sys/mman/CMakeLists.txt b/libc/src/sys/mman/CMakeLists.txt index 281efc0..4d4c2ad 100644 --- a/libc/src/sys/mman/CMakeLists.txt +++ b/libc/src/sys/mman/CMakeLists.txt @@ -113,9 +113,3 @@ add_entrypoint_object( DEPENDS .${LIBC_TARGET_OS}.mremap ) - -add_entrypoint_object( - process_mrelease - ALIAS - DEPENDS - .${LIBC_TARGET_OS}.process_mrelease) diff --git a/libc/src/sys/mman/linux/CMakeLists.txt b/libc/src/sys/mman/linux/CMakeLists.txt index aa2ca4b..89a0ad1 100644 --- a/libc/src/sys/mman/linux/CMakeLists.txt +++ b/libc/src/sys/mman/linux/CMakeLists.txt @@ -36,6 +36,7 @@ add_entrypoint_object( libc.src.__support.OSUtil.osutil libc.src.errno.errno ) + add_entrypoint_object( munmap SRCS @@ -213,14 +214,3 @@ add_entrypoint_object( libc.src.unistd.unlink .shm_common ) - -add_entrypoint_object( - process_mrelease - SRCS - process_mrelease.cpp - HDRS - ../process_mrelease.h - DEPENDS - libc.include.sys_syscall - libc.src.__support.OSUtil.osutil - libc.src.errno.errno) diff --git a/libc/src/sys/mman/linux/process_mrelease.cpp b/libc/src/sys/mman/linux/process_mrelease.cpp deleted file mode 100644 index e86bbec..0000000 --- a/libc/src/sys/mman/linux/process_mrelease.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//===---------- Linux implementation of the mrelease function -----------===// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#include "src/sys/mman/process_mrelease.h" - -#include "src/__support/OSUtil/syscall.h" // For internal syscall function. -#include "src/__support/common.h" - -#include "src/__support/macros/config.h" -#include "src/errno/libc_errno.h" -#include <linux/param.h> // For EXEC_PAGESIZE. -#include <sys/syscall.h> // For syscall numbers. - -namespace LIBC_NAMESPACE_DECL { - -LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) { - long ret = - LIBC_NAMESPACE::syscall_impl<int>(SYS_process_mrelease, pidfd, flags); - - if (ret < 0) { - libc_errno = static_cast<int>(-ret); - return -1; - } - - return 0; -} - -} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/sys/mman/process_mrelease.h b/libc/src/sys/mman/process_mrelease.h deleted file mode 100644 index ec4a6e4..0000000 --- a/libc/src/sys/mman/process_mrelease.h +++ /dev/null @@ -1,21 +0,0 @@ -//===-- Implementation header for process_mrelease function --------*- C++ -*-===// -// -// 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 -// -//===-------------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_SRC_SYS_MMAN_PROCESS_MRELEASE_H -#define LLVM_LIBC_SRC_SYS_MMAN_PROCESS_MRELEASE_H - -#include "src/__support/macros/config.h" -#include <sys/mman.h> // For size_t and off_t - -namespace LIBC_NAMESPACE_DECL { - -int process_mrelease(int pidfd, unsigned int flags); - -} // namespace LIBC_NAMESPACE_DECL - -#endif // LLVM_LIBC_SRC_SYS_MMAN_PROCESS_MRELEASE_H diff --git a/libc/test/src/sys/mman/linux/CMakeLists.txt b/libc/test/src/sys/mman/linux/CMakeLists.txt index 35dcf83..44ed11a 100644 --- a/libc/test/src/sys/mman/linux/CMakeLists.txt +++ b/libc/test/src/sys/mman/linux/CMakeLists.txt @@ -181,21 +181,3 @@ add_libc_unittest( libc.hdr.fcntl_macros libc.test.UnitTest.ErrnoSetterMatcher ) - -add_libc_unittest( - process_mrelease_test - SUITE - libc_sys_mman_unittests - SRCS - process_mrelease_test.cpp - DEPENDS - libc.include.sys_mman - libc.include.sys_syscall - libc.src.errno.errno - libc.src.sys.mman.process_mrelease - libc.src.unistd.close - libc.src.signal.kill - libc.include.signal - libc.src.stdlib.exit - libc.src.__support.OSUtil.osutil - libc.src.__support.threads.sleep) diff --git a/libc/test/src/sys/mman/linux/process_mrelease_test.cpp b/libc/test/src/sys/mman/linux/process_mrelease_test.cpp deleted file mode 100644 index 3349a5e..0000000 --- a/libc/test/src/sys/mman/linux/process_mrelease_test.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===-- Unittests for process_mrelease ------------------------------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#include "src/__support/OSUtil/syscall.h" // For internal syscall function. -#include "src/__support/threads/sleep.h" -#include "src/errno/libc_errno.h" -#include "src/signal/kill.h" -#include "src/stdlib/exit.h" -#include "src/sys/mman/process_mrelease.h" -#include "src/unistd/close.h" -#include "src/unistd/fork.h" -#include "test/UnitTest/LibcTest.h" - -#include <sys/syscall.h> - -int pidfd_open(pid_t pid, unsigned int flags) { - return LIBC_NAMESPACE::syscall_impl(SYS_pidfd_open, pid, flags); -} - -TEST(LlvmLibcMProcessMReleaseTest, NoError) { - pid_t child_pid = fork(); - EXPECT_GE(child_pid, 0); - - if (child_pid == 0) { - // Child process: wait a bit then exit gracefully. - LIBC_NAMESPACE::sleep_briefly(); - LIBC_NAMESPACE::exit(0); - } else { - // Parent process: wait a bit and then kill the child. - // Give child process some time to start. - LIBC_NAMESPACE::sleep_briefly(); - int pidfd = pidfd_open(child_pid, 0); - EXPECT_GE(pidfd, 0); - - // Send SIGKILL to child process - LIBC_NAMESPACE::kill(child_pid, SIGKILL); - - EXPECT_EQ(LIBC_NAMESPACE::process_mrelease(pidfd, 0), 0); - - LIBC_NAMESPACE::close(pidfd); - } -} - -TEST(LlvmLibcMProcessMReleaseTest, ErrorNotKilled) { - pid_t child_pid = fork(); - EXPECT_GE(child_pid, 0); - - if (child_pid == 0) { - // Child process: wait a bit then exit gracefully. - LIBC_NAMESPACE::sleep_briefly(); - LIBC_NAMESPACE::exit(0); - } else { - // Give child process some time to start. - LIBC_NAMESPACE::sleep_briefly(); - int pidfd = pidfd_open(child_pid, 0); - EXPECT_GE(pidfd, 0); - - ASSERT_EQ(LIBC_NAMESPACE::process_mrelease(pidfd, 0), EINVAL); - - LIBC_NAMESPACE::close(pidfd); - } -} - -TEST(LlvmLibcMProcessMReleaseTest, ErrorNonExistingPidfd) { - - ASSERT_EQ(LIBC_NAMESPACE::process_mrelease(-1, 0), EBADF); -} |
