Skip to content

Commit 7adc9f0

Browse files
[libc][bazel] Add bazel for sys/mman and resource
Depends on other cleanup patches: #161748 #161749
1 parent b3e2d6d commit 7adc9f0

File tree

3 files changed

+384
-0
lines changed

3 files changed

+384
-0
lines changed

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,11 @@ libc_support_library(
432432
hdrs = ["hdr/types/struct_timeval.h"],
433433
)
434434

435+
libc_support_library(
436+
name = "types_struct_rlimit",
437+
hdrs = ["hdr/types/struct_rlimit.h"],
438+
)
439+
435440
libc_support_library(
436441
name = "types_pid_t",
437442
hdrs = ["hdr/types/pid_t.h"],
@@ -6753,6 +6758,230 @@ libc_function(
67536758
],
67546759
)
67556760

6761+
############################### sys/mman targets ###############################
6762+
6763+
libc_function(
6764+
name = "madvise",
6765+
srcs = ["src/sys/mman/linux/madvise.cpp"],
6766+
hdrs = ["src/sys/mman/madvise.h"],
6767+
deps = [
6768+
":__support_common",
6769+
":__support_osutil_syscall",
6770+
":errno",
6771+
],
6772+
)
6773+
6774+
libc_function(
6775+
name = "mincore",
6776+
srcs = ["src/sys/mman/linux/mincore.cpp"],
6777+
hdrs = ["src/sys/mman/mincore.h"],
6778+
deps = [
6779+
":__support_common",
6780+
":__support_osutil_syscall",
6781+
":errno",
6782+
],
6783+
)
6784+
6785+
libc_function(
6786+
name = "mlock",
6787+
srcs = ["src/sys/mman/linux/mlock.cpp"],
6788+
hdrs = ["src/sys/mman/mlock.h"],
6789+
deps = [
6790+
":__support_common",
6791+
":__support_osutil_syscall",
6792+
":errno",
6793+
],
6794+
)
6795+
6796+
libc_function(
6797+
name = "mlock2",
6798+
srcs = ["src/sys/mman/linux/mlock2.cpp"],
6799+
hdrs = ["src/sys/mman/mlock2.h"],
6800+
deps = [
6801+
":__support_common",
6802+
":__support_osutil_syscall",
6803+
":errno",
6804+
],
6805+
)
6806+
6807+
libc_function(
6808+
name = "mlockall",
6809+
srcs = ["src/sys/mman/linux/mlockall.cpp"],
6810+
hdrs = ["src/sys/mman/mlockall.h"],
6811+
deps = [
6812+
":__support_common",
6813+
":__support_osutil_syscall",
6814+
":errno",
6815+
],
6816+
)
6817+
6818+
libc_function(
6819+
name = "mmap",
6820+
srcs = ["src/sys/mman/linux/mmap.cpp"],
6821+
hdrs = ["src/sys/mman/mmap.h"],
6822+
deps = [
6823+
":__support_common",
6824+
":__support_osutil_syscall",
6825+
":errno",
6826+
],
6827+
)
6828+
6829+
libc_function(
6830+
name = "mprotect",
6831+
srcs = ["src/sys/mman/linux/mprotect.cpp"],
6832+
hdrs = ["src/sys/mman/mprotect.h"],
6833+
deps = [
6834+
":__support_common",
6835+
":__support_osutil_syscall",
6836+
":errno",
6837+
],
6838+
)
6839+
6840+
libc_function(
6841+
name = "mremap",
6842+
srcs = ["src/sys/mman/linux/mremap.cpp"],
6843+
hdrs = ["src/sys/mman/mremap.h"],
6844+
deps = [
6845+
":__support_common",
6846+
":__support_osutil_syscall",
6847+
":errno",
6848+
],
6849+
)
6850+
6851+
libc_function(
6852+
name = "msync",
6853+
srcs = ["src/sys/mman/linux/msync.cpp"],
6854+
hdrs = ["src/sys/mman/msync.h"],
6855+
deps = [
6856+
":__support_common",
6857+
":__support_osutil_syscall",
6858+
":errno",
6859+
],
6860+
)
6861+
6862+
libc_function(
6863+
name = "munlock",
6864+
srcs = ["src/sys/mman/linux/munlock.cpp"],
6865+
hdrs = ["src/sys/mman/munlock.h"],
6866+
deps = [
6867+
":__support_common",
6868+
":__support_osutil_syscall",
6869+
":errno",
6870+
],
6871+
)
6872+
6873+
libc_function(
6874+
name = "munlockall",
6875+
srcs = ["src/sys/mman/linux/munlockall.cpp"],
6876+
hdrs = ["src/sys/mman/munlockall.h"],
6877+
deps = [
6878+
":__support_common",
6879+
":__support_osutil_syscall",
6880+
":errno",
6881+
],
6882+
)
6883+
6884+
libc_function(
6885+
name = "munmap",
6886+
srcs = ["src/sys/mman/linux/munmap.cpp"],
6887+
hdrs = ["src/sys/mman/munmap.h"],
6888+
deps = [
6889+
":__support_common",
6890+
":__support_osutil_syscall",
6891+
":errno",
6892+
],
6893+
)
6894+
6895+
libc_function(
6896+
name = "posix_madvise",
6897+
srcs = ["src/sys/mman/linux/posix_madvise.cpp"],
6898+
hdrs = ["src/sys/mman/posix_madvise.h"],
6899+
deps = [
6900+
":__support_common",
6901+
":__support_osutil_syscall",
6902+
":errno",
6903+
],
6904+
)
6905+
6906+
libc_function(
6907+
name = "remap_file_pages",
6908+
srcs = ["src/sys/mman/linux/remap_file_pages.cpp"],
6909+
hdrs = ["src/sys/mman/remap_file_pages.h"],
6910+
deps = [
6911+
":__support_common",
6912+
":__support_osutil_syscall",
6913+
":errno",
6914+
],
6915+
)
6916+
6917+
libc_support_library(
6918+
name = "shm_common",
6919+
hdrs = ["src/sys/mman/linux/shm_common.h"],
6920+
deps = [
6921+
":__support_common",
6922+
":__support_cpp_array",
6923+
":__support_cpp_string_view",
6924+
":__support_error_or",
6925+
":__support_macros_config",
6926+
":errno",
6927+
":string_memory_utils",
6928+
],
6929+
)
6930+
6931+
libc_function(
6932+
name = "shm_open",
6933+
srcs = ["src/sys/mman/linux/shm_open.cpp"],
6934+
hdrs = ["src/sys/mman/shm_open.h"],
6935+
deps = [
6936+
":__support_common",
6937+
":__support_osutil_fcntl",
6938+
":errno",
6939+
":hdr_fcntl_macros",
6940+
":shm_common",
6941+
":types_mode_t",
6942+
],
6943+
)
6944+
6945+
libc_function(
6946+
name = "shm_unlink",
6947+
srcs = ["src/sys/mman/linux/shm_unlink.cpp"],
6948+
hdrs = ["src/sys/mman/shm_unlink.h"],
6949+
deps = [
6950+
":__support_common",
6951+
":__support_osutil_syscall",
6952+
":errno",
6953+
":hdr_fcntl_macros",
6954+
":shm_common",
6955+
":types_mode_t",
6956+
],
6957+
)
6958+
6959+
############################# sys/resource targets #############################
6960+
6961+
libc_function(
6962+
name = "getrlimit",
6963+
srcs = ["src/sys/resource/linux/getrlimit.cpp"],
6964+
hdrs = ["src/sys/resource/getrlimit.h"],
6965+
deps = [
6966+
":__support_common",
6967+
":__support_osutil_syscall",
6968+
":errno",
6969+
":types_struct_rlimit",
6970+
],
6971+
)
6972+
6973+
libc_function(
6974+
name = "setrlimit",
6975+
srcs = ["src/sys/resource/linux/setrlimit.cpp"],
6976+
hdrs = ["src/sys/resource/setrlimit.h"],
6977+
deps = [
6978+
":__support_common",
6979+
":__support_osutil_syscall",
6980+
":errno",
6981+
":types_struct_rlimit",
6982+
],
6983+
)
6984+
67566985
############################### sys/stat targets ###############################
67576986

67586987
libc_function(
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
# Tests for LLVM libc socket.h functions.
6+
7+
load("//libc/test:libc_test_rules.bzl", "libc_test")
8+
9+
package(default_visibility = ["//visibility:public"])
10+
11+
licenses(["notice"])
12+
13+
libc_test(
14+
name = "madvise_test",
15+
srcs = ["linux/madvise_test.cpp"],
16+
deps = [
17+
"//libc:madvise",
18+
"//libc:mmap",
19+
"//libc:munmap",
20+
],
21+
)
22+
23+
libc_test(
24+
name = "mincore_test",
25+
srcs = ["linux/mincore_test.cpp"],
26+
deps = [
27+
"//libc:madvise",
28+
"//libc:mincore",
29+
"//libc:mlock",
30+
"//libc:mmap",
31+
"//libc:munlock",
32+
"//libc:munmap",
33+
],
34+
)
35+
36+
libc_test(
37+
name = "mlock_test",
38+
srcs = ["linux/mlock_test.cpp"],
39+
deps = [
40+
"//libc:__support_osutil_syscall",
41+
"//libc:getrlimit",
42+
"//libc:madvise",
43+
"//libc:mincore",
44+
"//libc:mlock",
45+
"//libc:mlock2",
46+
"//libc:mlockall",
47+
"//libc:mmap",
48+
"//libc:munlock",
49+
"//libc:munlockall",
50+
"//libc:munmap",
51+
],
52+
)
53+
54+
libc_test(
55+
name = "mmap_test",
56+
srcs = ["linux/mmap_test.cpp"],
57+
deps = [
58+
"//libc:mmap",
59+
"//libc:munmap",
60+
],
61+
)
62+
63+
libc_test(
64+
name = "mprotect_test",
65+
srcs = ["linux/mprotect_test.cpp"],
66+
deps = [
67+
"//libc:mmap",
68+
"//libc:mprotect",
69+
"//libc:munmap",
70+
],
71+
)
72+
73+
libc_test(
74+
name = "mremap_test",
75+
srcs = ["linux/mremap_test.cpp"],
76+
deps = [
77+
"//libc:mmap",
78+
"//libc:mremap",
79+
"//libc:munmap",
80+
],
81+
)
82+
83+
libc_test(
84+
name = "msync_test",
85+
srcs = ["linux/msync_test.cpp"],
86+
deps = [
87+
"//libc:mlock",
88+
"//libc:mmap",
89+
"//libc:msync",
90+
"//libc:munlock",
91+
"//libc:munmap",
92+
],
93+
)
94+
95+
libc_test(
96+
name = "posix_madvise_test",
97+
srcs = ["linux/posix_madvise_test.cpp"],
98+
deps = [
99+
"//libc:mmap",
100+
"//libc:munmap",
101+
"//libc:posix_madvise",
102+
],
103+
)
104+
105+
libc_test(
106+
name = "remap_file_pages_test",
107+
srcs = ["linux/remap_file_pages_test.cpp"],
108+
deps = [
109+
"//libc:close",
110+
"//libc:mmap",
111+
"//libc:munmap",
112+
"//libc:open",
113+
"//libc:remap_file_pages",
114+
],
115+
)
116+
117+
libc_test(
118+
name = "shm_test",
119+
srcs = ["linux/shm_test.cpp"],
120+
deps = [
121+
"//libc:close",
122+
"//libc:fcntl",
123+
"//libc:ftruncate",
124+
"//libc:hdr_fcntl_macros",
125+
"//libc:mmap",
126+
"//libc:munmap",
127+
"//libc:open",
128+
"//libc:shm_open",
129+
"//libc:shm_unlink",
130+
],
131+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
# Tests for LLVM libc socket.h functions.
6+
7+
load("//libc/test:libc_test_rules.bzl", "libc_test")
8+
9+
package(default_visibility = ["//visibility:public"])
10+
11+
licenses(["notice"])
12+
13+
libc_test(
14+
name = "getrlimit_setrlimit_test",
15+
srcs = ["getrlimit_setrlimit_test.cpp"],
16+
deps = [
17+
"//libc:__support_cpp_string_view",
18+
"//libc:close",
19+
"//libc:getrlimit",
20+
"//libc:open",
21+
"//libc:setrlimit",
22+
"//libc:unlink",
23+
],
24+
)

0 commit comments

Comments
 (0)