Skip to content

Commit f265353

Browse files
[libc] Clean up sys/resource (#161749)
Needed to support sys/resource in bazel
1 parent 3491738 commit f265353

File tree

8 files changed

+44
-12
lines changed

8 files changed

+44
-12
lines changed

libc/hdr/types/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_proxy_header_library(
2-
char8_t
2+
char8_t
33
HDRS
44
char8_t.h
55
DEPENDS
@@ -10,7 +10,7 @@ add_proxy_header_library(
1010
)
1111

1212
add_proxy_header_library(
13-
char32_t
13+
char32_t
1414
HDRS
1515
char32_t.h
1616
DEPENDS
@@ -470,3 +470,12 @@ add_proxy_header_library(
470470
libc.include.llvm-libc-types.dl_info
471471
libc.include.dlfcn
472472
)
473+
474+
add_proxy_header_library(
475+
struct_rlimit
476+
HDRS
477+
struct_rlimit.h
478+
FULL_BUILD_DEPENDS
479+
libc.include.llvm-libc-types.struct_rlimit
480+
libc.include.sys_resource
481+
)

libc/hdr/types/struct_rlimit.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Proxy for struct rlimit -------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_HDR_TYPES_STRUCT_RLIMIT_H
10+
#define LLVM_LIBC_HDR_TYPES_STRUCT_RLIMIT_H
11+
12+
#ifdef LIBC_FULL_BUILD
13+
14+
#include "include/llvm-libc-types/struct_rlimit.h"
15+
16+
#else // Overlay mode
17+
18+
#include <sys/resource.h>
19+
20+
#endif // LLVM_LIBC_FULL_BUILD
21+
22+
#endif // LLVM_LIBC_HDR_TYPES_STRUCT_RLIMIT_H

libc/src/sys/resource/linux/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ add_entrypoint_object(
55
HDRS
66
../getrlimit.h
77
DEPENDS
8+
libc.hdr.types.struct_rlimit
89
libc.include.sys_resource
910
libc.include.sys_syscall
1011
libc.src.__support.OSUtil.osutil
@@ -18,6 +19,7 @@ add_entrypoint_object(
1819
HDRS
1920
../setrlimit.h
2021
DEPENDS
22+
libc.hdr.types.struct_rlimit
2123
libc.include.sys_resource
2224
libc.include.sys_syscall
2325
libc.src.__support.OSUtil.osutil

libc/src/sys/resource/linux/getrlimit.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88

99
#include "src/sys/resource/getrlimit.h"
1010

11+
#include "hdr/types/struct_rlimit.h"
1112
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
1213
#include "src/__support/common.h"
13-
1414
#include "src/__support/libc_errno.h"
1515
#include "src/__support/macros/config.h"
16-
#include <sys/resource.h> // For struct rlimit
17-
#include <sys/syscall.h> // For syscall numbers.
16+
#include <sys/syscall.h> // For syscall numbers.
1817

1918
namespace LIBC_NAMESPACE_DECL {
2019

libc/src/sys/resource/linux/setrlimit.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88

99
#include "src/sys/resource/setrlimit.h"
1010

11+
#include "hdr/types/struct_rlimit.h"
1112
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
1213
#include "src/__support/common.h"
13-
1414
#include "src/__support/libc_errno.h"
1515
#include "src/__support/macros/config.h"
16-
#include <sys/resource.h> // For struct rlimit
17-
#include <sys/syscall.h> // For syscall numbers.
16+
#include <sys/syscall.h> // For syscall numbers.
1817

1918
namespace LIBC_NAMESPACE_DECL {
2019

libc/test/src/sys/resource/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
add_custom_target(libc_sys_resource_unittests)
22

3-
add_subdirectory(testdata)
4-
53
add_libc_unittest(
64
getrlimit_setrlimit_test
75
SUITE

libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ TEST_F(LlvmLibcResourceLimitsTest, SetNoFileLimit) {
2727
// successfully. Next, close the files and set the file descriptor limit
2828
// to 4. This will allow us to open one of those file but not the other.
2929

30-
constexpr const char *TEST_FILE1 = "testdata/resource_limits1.test";
31-
constexpr const char *TEST_FILE2 = "testdata/resource_limits2.test";
30+
constexpr const char *TEST_FILE1_NAME = "resource_limits1.test";
31+
constexpr const char *TEST_FILE2_NAME = "resource_limits2.test";
32+
33+
auto TEST_FILE1 = libc_make_test_file_path(TEST_FILE1_NAME);
34+
auto TEST_FILE2 = libc_make_test_file_path(TEST_FILE2_NAME);
3235

3336
int fd1 = LIBC_NAMESPACE::open(TEST_FILE1, O_CREAT | O_WRONLY, S_IRWXU);
3437
ASSERT_GT(fd1, 0);

libc/test/src/sys/resource/testdata/CMakeLists.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)