-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Revert "[libc] implement ioctl" #88226
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
Conversation
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
This reverts commit 289a2c3.
@llvm/pr-subscribers-libc Author: None (lntue) ChangesReverts llvm/llvm-project#85890 This fails in full build mode: Full diff: https://github.com/llvm/llvm-project/pull/88226.diff 12 Files Affected:
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 5649e3ca29f91f..f5f5c437685a21 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -204,9 +204,6 @@ set(TARGET_LIBC_ENTRYPOINTS
#libc.src.stdio.scanf
#libc.src.stdio.fscanf
- # sys/ioctl.h entrypoints
- libc.src.sys.ioctl.ioctl
-
# sys/mman.h entrypoints
libc.src.sys.mman.madvise
libc.src.sys.mman.mmap
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 6c719320b0847a..71289789158f4b 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -209,9 +209,6 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdio.scanf
libc.src.stdio.fscanf
- # sys/ioctl.h entrypoints
- libc.src.sys.ioctl.ioctl
-
# sys/mman.h entrypoints
libc.src.sys.mman.madvise
libc.src.sys.mman.mmap
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 5880ad55b71cee..6bb53cb76220fc 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -221,9 +221,6 @@ set(TARGET_LIBC_ENTRYPOINTS
# https://github.com/llvm/llvm-project/issues/80060
# libc.src.sys.epoll.epoll_pwait2
- # sys/ioctl.h entrypoints
- libc.src.sys.ioctl.ioctl
-
# sys/mman.h entrypoints
libc.src.sys.mman.madvise
libc.src.sys.mman.mmap
diff --git a/libc/spec/linux.td b/libc/spec/linux.td
index 6e9b64f5a6b4af..f91f55ddac7846 100644
--- a/libc/spec/linux.td
+++ b/libc/spec/linux.td
@@ -79,24 +79,6 @@ def Linux : StandardSpec<"Linux"> {
[] // Functions
>;
- HeaderSpec SysIoctl = HeaderSpec<
- "sys/ioctl.h",
- [Macro<"MAP_ANONYMOUS">],
- [], // Types
- [], // Enumerations
- [
- FunctionSpec<
- "ioctl",
- RetValSpec<IntType>,
- [
- ArgSpec<IntType>,
- ArgSpec<UnsignedLongType>,
- ArgSpec<VoidPtr>,
- ]
- >,
- ] // Functions
- >;
-
HeaderSpec SysMMan = HeaderSpec<
"sys/mman.h",
[Macro<"MAP_ANONYMOUS">],
diff --git a/libc/src/sys/CMakeLists.txt b/libc/src/sys/CMakeLists.txt
index ac54df35284a7b..adc666b94202f7 100644
--- a/libc/src/sys/CMakeLists.txt
+++ b/libc/src/sys/CMakeLists.txt
@@ -1,6 +1,5 @@
add_subdirectory(auxv)
add_subdirectory(epoll)
-add_subdirectory(ioctl)
add_subdirectory(mman)
add_subdirectory(random)
add_subdirectory(resource)
diff --git a/libc/src/sys/ioctl/CMakeLists.txt b/libc/src/sys/ioctl/CMakeLists.txt
deleted file mode 100644
index 4b50c278c7871a..00000000000000
--- a/libc/src/sys/ioctl/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
- add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
-endif()
-
-add_entrypoint_object(
- ioctl
- ALIAS
- DEPENDS
- .${LIBC_TARGET_OS}.ioctl
-)
-
-
diff --git a/libc/src/sys/ioctl/ioctl.h b/libc/src/sys/ioctl/ioctl.h
deleted file mode 100644
index 8365678276a428..00000000000000
--- a/libc/src/sys/ioctl/ioctl.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//===-- Implementation header for mmap 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_IOCTL_IOCTL_H
-#define LLVM_LIBC_SRC_SYS_IOCTL_IOCTL_H
-namespace LIBC_NAMESPACE {
-
-int ioctl(int fd, unsigned long request, ...);
-
-} // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_SRC_SYS_IOCTL_IOCTL_H
diff --git a/libc/src/sys/ioctl/linux/CMakeLists.txt b/libc/src/sys/ioctl/linux/CMakeLists.txt
deleted file mode 100644
index 8a23505d4e9d19..00000000000000
--- a/libc/src/sys/ioctl/linux/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-add_entrypoint_object(
- ioctl
- SRCS
- ioctl.cpp
- HDRS
- ../ioctl.h
- DEPENDS
- libc.include.sys_ioctl
- libc.include.sys_syscall
- libc.src.__support.OSUtil.osutil
- libc.src.errno.errno
-)
-
diff --git a/libc/src/sys/ioctl/linux/ioctl.cpp b/libc/src/sys/ioctl/linux/ioctl.cpp
deleted file mode 100644
index 6c8ff54dc2aeef..00000000000000
--- a/libc/src/sys/ioctl/linux/ioctl.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-//===---------- Linux implementation of the POSIX ioctl 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/ioctl/ioctl.h"
-
-#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
-#include "src/__support/common.h"
-#include "src/errno/libc_errno.h"
-#include <stdarg.h>
-#include <sys/syscall.h> // For syscall numbers.
-
-namespace LIBC_NAMESPACE {
-
-// This function is currently linux only. It has to be refactored suitably if
-// madvise is to be supported on non-linux operating systems also.
-LLVM_LIBC_FUNCTION(int, ioctl, (int fd, unsigned long request, ...)) {
- va_list ptr_to_memory;
- va_start(ptr_to_memory, 1);
- va_arg(ptr_to_memory, void *) int ret =
- LIBC_NAMESPACE::syscall_impl<int>(SYS_ioctl, fd, request, ptr_to_memory);
- va_end(ptr_to_memory);
-
- // A negative return value indicates an error with the magnitude of the
- // value being the error code.
- if (ret < 0) {
- libc_errno = -ret;
- return -1;
- }
-
- return 0;
-}
-
-} // namespace LIBC_NAMESPACE
diff --git a/libc/test/src/sys/ioctl/CMakeLists.txt b/libc/test/src/sys/ioctl/CMakeLists.txt
deleted file mode 100644
index b4bbe81c92ff2e..00000000000000
--- a/libc/test/src/sys/ioctl/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
- add_subdirectory(${LIBC_TARGET_OS})
-endif()
diff --git a/libc/test/src/sys/ioctl/linux/CMakeLists.txt b/libc/test/src/sys/ioctl/linux/CMakeLists.txt
deleted file mode 100644
index 93e68975c4e1e2..00000000000000
--- a/libc/test/src/sys/ioctl/linux/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-add_custom_target(libc_sys_ioctl_unittests)
-
-add_libc_unittest(
- ioctl_test
- SUITE
- libc_sys_ioctl_unittests
- SRCS
- ioctl_test.cpp
- DEPENDS
- libc.include.sys_ioctl
- libc.src.errno.errno
- libc.test.errno_setter_matcher
-)
-
diff --git a/libc/test/src/sys/ioctl/linux/ioctl_test.cpp b/libc/test/src/sys/ioctl/linux/ioctl_test.cpp
deleted file mode 100644
index 3de3eff3e8d4c8..00000000000000
--- a/libc/test/src/sys/ioctl/linux/ioctl_test.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===-- Unittests for ioctl -----------------------------------------------===//
-//
-// 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/errno/libc_errno.h"
-#include "src/sys/ioctl/ioctl.h"
-#include "test/UnitTest/ErrnoSetterMatcher.h"
-#include "test/UnitTest/LibcTest.h"
-#include "test/UnitTest/Test.h"
-
-#include <sys/syscall.h>
-#include <unistd.h>
-
-using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
-using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
-
-TEST(LlvmLibcIoctlTest, InvalidFileDescriptor) {
- int fd = 10;
- unsigned long request = 10;
- int res = LIBC_NAMESPACE::ioctl(fd, 10, NULL);
- EXPECT_THAT(res, Fails(EBADF, -1));
-}
|
changkhothuychung
added a commit
to changkhothuychung/llvm-project
that referenced
this pull request
Apr 27, 2024
This reverts commit 3c2feab.
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.
Reverts #85890
This fails in full build mode:
https://lab.llvm.org/buildbot/#/builders/163/builds/54478/steps/4/logs/stdio