Skip to content

Commit d06c9a6

Browse files
[libc][bazel] Add bazel for sys/mman and resource (#161750)
Depends on other cleanup patches: #161748 #161749
1 parent b4a95fe commit d06c9a6

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"],
@@ -6760,6 +6765,230 @@ libc_function(
67606765
],
67616766
)
67626767

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

67656994
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)