-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc] Clean up sys/resource #161749
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
michaelrj-google
merged 1 commit into
llvm:main
from
michaelrj-google:libcCleanupResource
Oct 6, 2025
Merged
[libc] Clean up sys/resource #161749
michaelrj-google
merged 1 commit into
llvm:main
from
michaelrj-google:libcCleanupResource
Oct 6, 2025
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
Needed to support sys/resource in bazel
@llvm/pr-subscribers-libc Author: Michael Jones (michaelrj-google) ChangesNeeded to support sys/resource in bazel Full diff: https://github.com/llvm/llvm-project/pull/161749.diff 8 Files Affected:
diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt
index 21971a4004760..225843924c243 100644
--- a/libc/hdr/types/CMakeLists.txt
+++ b/libc/hdr/types/CMakeLists.txt
@@ -1,5 +1,5 @@
add_proxy_header_library(
- char8_t
+ char8_t
HDRS
char8_t.h
DEPENDS
@@ -10,7 +10,7 @@ add_proxy_header_library(
)
add_proxy_header_library(
- char32_t
+ char32_t
HDRS
char32_t.h
DEPENDS
@@ -470,3 +470,12 @@ add_proxy_header_library(
libc.include.llvm-libc-types.dl_info
libc.include.dlfcn
)
+
+add_proxy_header_library(
+ struct_rlimit
+ HDRS
+ struct_rlimit.h
+ FULL_BUILD_DEPENDS
+ libc.include.llvm-libc-types.struct_rlimit
+ libc.include.sys_resource
+)
diff --git a/libc/hdr/types/struct_rlimit.h b/libc/hdr/types/struct_rlimit.h
new file mode 100644
index 0000000000000..a09dd53ef76e9
--- /dev/null
+++ b/libc/hdr/types/struct_rlimit.h
@@ -0,0 +1,22 @@
+//===-- Proxy for struct rlimit -------------------------------------------===//
+//
+// 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_HDR_TYPES_STRUCT_RLIMIT_H
+#define LLVM_LIBC_HDR_TYPES_STRUCT_RLIMIT_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-types/struct_rlimit.h"
+
+#else // Overlay mode
+
+#include <sys/resource.h>
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_TYPES_STRUCT_RLIMIT_H
diff --git a/libc/src/sys/resource/linux/CMakeLists.txt b/libc/src/sys/resource/linux/CMakeLists.txt
index 19f3901c98a29..9f0fdad3b0fdf 100644
--- a/libc/src/sys/resource/linux/CMakeLists.txt
+++ b/libc/src/sys/resource/linux/CMakeLists.txt
@@ -5,6 +5,7 @@ add_entrypoint_object(
HDRS
../getrlimit.h
DEPENDS
+ libc.hdr.types.struct_rlimit
libc.include.sys_resource
libc.include.sys_syscall
libc.src.__support.OSUtil.osutil
@@ -18,6 +19,7 @@ add_entrypoint_object(
HDRS
../setrlimit.h
DEPENDS
+ libc.hdr.types.struct_rlimit
libc.include.sys_resource
libc.include.sys_syscall
libc.src.__support.OSUtil.osutil
diff --git a/libc/src/sys/resource/linux/getrlimit.cpp b/libc/src/sys/resource/linux/getrlimit.cpp
index d272134194949..a3234ebf4f90b 100644
--- a/libc/src/sys/resource/linux/getrlimit.cpp
+++ b/libc/src/sys/resource/linux/getrlimit.cpp
@@ -8,13 +8,12 @@
#include "src/sys/resource/getrlimit.h"
+#include "hdr/types/struct_rlimit.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-
#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include <sys/resource.h> // For struct rlimit
-#include <sys/syscall.h> // For syscall numbers.
+#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/sys/resource/linux/setrlimit.cpp b/libc/src/sys/resource/linux/setrlimit.cpp
index 300bad75baa63..e2c2b379e7087 100644
--- a/libc/src/sys/resource/linux/setrlimit.cpp
+++ b/libc/src/sys/resource/linux/setrlimit.cpp
@@ -8,13 +8,12 @@
#include "src/sys/resource/setrlimit.h"
+#include "hdr/types/struct_rlimit.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
-
#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
-#include <sys/resource.h> // For struct rlimit
-#include <sys/syscall.h> // For syscall numbers.
+#include <sys/syscall.h> // For syscall numbers.
namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/test/src/sys/resource/CMakeLists.txt b/libc/test/src/sys/resource/CMakeLists.txt
index 2870f2ca05b5c..2097a2c501fbd 100644
--- a/libc/test/src/sys/resource/CMakeLists.txt
+++ b/libc/test/src/sys/resource/CMakeLists.txt
@@ -1,7 +1,5 @@
add_custom_target(libc_sys_resource_unittests)
-add_subdirectory(testdata)
-
add_libc_unittest(
getrlimit_setrlimit_test
SUITE
diff --git a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
index d6e1490e3a101..4e0a3c7d10b5f 100644
--- a/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
+++ b/libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
@@ -27,8 +27,11 @@ TEST_F(LlvmLibcResourceLimitsTest, SetNoFileLimit) {
// successfully. Next, close the files and set the file descriptor limit
// to 4. This will allow us to open one of those file but not the other.
- constexpr const char *TEST_FILE1 = "testdata/resource_limits1.test";
- constexpr const char *TEST_FILE2 = "testdata/resource_limits2.test";
+ constexpr const char *TEST_FILE1_NAME = "resource_limits1.test";
+ constexpr const char *TEST_FILE2_NAME = "resource_limits2.test";
+
+ auto TEST_FILE1 = libc_make_test_file_path(TEST_FILE1_NAME);
+ auto TEST_FILE2 = libc_make_test_file_path(TEST_FILE2_NAME);
int fd1 = LIBC_NAMESPACE::open(TEST_FILE1, O_CREAT | O_WRONLY, S_IRWXU);
ASSERT_GT(fd1, 0);
diff --git a/libc/test/src/sys/resource/testdata/CMakeLists.txt b/libc/test/src/sys/resource/testdata/CMakeLists.txt
deleted file mode 100644
index e69de29bb2d1d..0000000000000
|
michaelrj-google
added a commit
to michaelrj-google/llvm-project
that referenced
this pull request
Oct 2, 2025
Depends on other cleanup patches: llvm#161748 llvm#161749
vonosmas
approved these changes
Oct 6, 2025
michaelrj-google
added a commit
that referenced
this pull request
Oct 6, 2025
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
Oct 6, 2025
Depends on other cleanup patches: llvm/llvm-project#161748 llvm/llvm-project#161749
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.
Needed to support sys/resource in bazel