-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc][bazel] Add bazel for sys/mman and resource #161750
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
Depends on other cleanup patches: llvm#161748 llvm#161749
@llvm/pr-subscribers-libc Author: Michael Jones (michaelrj-google) ChangesDepends on other cleanup patches: Full diff: https://github.com/llvm/llvm-project/pull/161750.diff 3 Files Affected:
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 026664bd019f9..5e08ee9bd4b17 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -432,6 +432,11 @@ libc_support_library(
hdrs = ["hdr/types/struct_timeval.h"],
)
+libc_support_library(
+ name = "types_struct_rlimit",
+ hdrs = ["hdr/types/struct_rlimit.h"],
+)
+
libc_support_library(
name = "types_pid_t",
hdrs = ["hdr/types/pid_t.h"],
@@ -6753,6 +6758,230 @@ libc_function(
],
)
+############################### sys/mman targets ###############################
+
+libc_function(
+ name = "madvise",
+ srcs = ["src/sys/mman/linux/madvise.cpp"],
+ hdrs = ["src/sys/mman/madvise.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "mincore",
+ srcs = ["src/sys/mman/linux/mincore.cpp"],
+ hdrs = ["src/sys/mman/mincore.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "mlock",
+ srcs = ["src/sys/mman/linux/mlock.cpp"],
+ hdrs = ["src/sys/mman/mlock.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "mlock2",
+ srcs = ["src/sys/mman/linux/mlock2.cpp"],
+ hdrs = ["src/sys/mman/mlock2.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "mlockall",
+ srcs = ["src/sys/mman/linux/mlockall.cpp"],
+ hdrs = ["src/sys/mman/mlockall.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "mmap",
+ srcs = ["src/sys/mman/linux/mmap.cpp"],
+ hdrs = ["src/sys/mman/mmap.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "mprotect",
+ srcs = ["src/sys/mman/linux/mprotect.cpp"],
+ hdrs = ["src/sys/mman/mprotect.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "mremap",
+ srcs = ["src/sys/mman/linux/mremap.cpp"],
+ hdrs = ["src/sys/mman/mremap.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "msync",
+ srcs = ["src/sys/mman/linux/msync.cpp"],
+ hdrs = ["src/sys/mman/msync.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "munlock",
+ srcs = ["src/sys/mman/linux/munlock.cpp"],
+ hdrs = ["src/sys/mman/munlock.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "munlockall",
+ srcs = ["src/sys/mman/linux/munlockall.cpp"],
+ hdrs = ["src/sys/mman/munlockall.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "munmap",
+ srcs = ["src/sys/mman/linux/munmap.cpp"],
+ hdrs = ["src/sys/mman/munmap.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "posix_madvise",
+ srcs = ["src/sys/mman/linux/posix_madvise.cpp"],
+ hdrs = ["src/sys/mman/posix_madvise.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_function(
+ name = "remap_file_pages",
+ srcs = ["src/sys/mman/linux/remap_file_pages.cpp"],
+ hdrs = ["src/sys/mman/remap_file_pages.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ],
+)
+
+libc_support_library(
+ name = "shm_common",
+ hdrs = ["src/sys/mman/linux/shm_common.h"],
+ deps = [
+ ":__support_common",
+ ":__support_cpp_array",
+ ":__support_cpp_string_view",
+ ":__support_error_or",
+ ":__support_macros_config",
+ ":errno",
+ ":string_memory_utils",
+ ],
+)
+
+libc_function(
+ name = "shm_open",
+ srcs = ["src/sys/mman/linux/shm_open.cpp"],
+ hdrs = ["src/sys/mman/shm_open.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_fcntl",
+ ":errno",
+ ":hdr_fcntl_macros",
+ ":shm_common",
+ ":types_mode_t",
+ ],
+)
+
+libc_function(
+ name = "shm_unlink",
+ srcs = ["src/sys/mman/linux/shm_unlink.cpp"],
+ hdrs = ["src/sys/mman/shm_unlink.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ":hdr_fcntl_macros",
+ ":shm_common",
+ ":types_mode_t",
+ ],
+)
+
+############################# sys/resource targets #############################
+
+libc_function(
+ name = "getrlimit",
+ srcs = ["src/sys/resource/linux/getrlimit.cpp"],
+ hdrs = ["src/sys/resource/getrlimit.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ":types_struct_rlimit",
+ ],
+)
+
+libc_function(
+ name = "setrlimit",
+ srcs = ["src/sys/resource/linux/setrlimit.cpp"],
+ hdrs = ["src/sys/resource/setrlimit.h"],
+ deps = [
+ ":__support_common",
+ ":__support_osutil_syscall",
+ ":errno",
+ ":types_struct_rlimit",
+ ],
+)
+
############################### sys/stat targets ###############################
libc_function(
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/sys/mman/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/sys/mman/BUILD.bazel
new file mode 100644
index 0000000000000..e2c7f7a8bf60b
--- /dev/null
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/sys/mman/BUILD.bazel
@@ -0,0 +1,131 @@
+# This file is licensed 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
+
+# Tests for LLVM libc socket.h functions.
+
+load("//libc/test:libc_test_rules.bzl", "libc_test")
+
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"])
+
+libc_test(
+ name = "madvise_test",
+ srcs = ["linux/madvise_test.cpp"],
+ deps = [
+ "//libc:madvise",
+ "//libc:mmap",
+ "//libc:munmap",
+ ],
+)
+
+libc_test(
+ name = "mincore_test",
+ srcs = ["linux/mincore_test.cpp"],
+ deps = [
+ "//libc:madvise",
+ "//libc:mincore",
+ "//libc:mlock",
+ "//libc:mmap",
+ "//libc:munlock",
+ "//libc:munmap",
+ ],
+)
+
+libc_test(
+ name = "mlock_test",
+ srcs = ["linux/mlock_test.cpp"],
+ deps = [
+ "//libc:__support_osutil_syscall",
+ "//libc:getrlimit",
+ "//libc:madvise",
+ "//libc:mincore",
+ "//libc:mlock",
+ "//libc:mlock2",
+ "//libc:mlockall",
+ "//libc:mmap",
+ "//libc:munlock",
+ "//libc:munlockall",
+ "//libc:munmap",
+ ],
+)
+
+libc_test(
+ name = "mmap_test",
+ srcs = ["linux/mmap_test.cpp"],
+ deps = [
+ "//libc:mmap",
+ "//libc:munmap",
+ ],
+)
+
+libc_test(
+ name = "mprotect_test",
+ srcs = ["linux/mprotect_test.cpp"],
+ deps = [
+ "//libc:mmap",
+ "//libc:mprotect",
+ "//libc:munmap",
+ ],
+)
+
+libc_test(
+ name = "mremap_test",
+ srcs = ["linux/mremap_test.cpp"],
+ deps = [
+ "//libc:mmap",
+ "//libc:mremap",
+ "//libc:munmap",
+ ],
+)
+
+libc_test(
+ name = "msync_test",
+ srcs = ["linux/msync_test.cpp"],
+ deps = [
+ "//libc:mlock",
+ "//libc:mmap",
+ "//libc:msync",
+ "//libc:munlock",
+ "//libc:munmap",
+ ],
+)
+
+libc_test(
+ name = "posix_madvise_test",
+ srcs = ["linux/posix_madvise_test.cpp"],
+ deps = [
+ "//libc:mmap",
+ "//libc:munmap",
+ "//libc:posix_madvise",
+ ],
+)
+
+libc_test(
+ name = "remap_file_pages_test",
+ srcs = ["linux/remap_file_pages_test.cpp"],
+ deps = [
+ "//libc:close",
+ "//libc:mmap",
+ "//libc:munmap",
+ "//libc:open",
+ "//libc:remap_file_pages",
+ ],
+)
+
+libc_test(
+ name = "shm_test",
+ srcs = ["linux/shm_test.cpp"],
+ deps = [
+ "//libc:close",
+ "//libc:fcntl",
+ "//libc:ftruncate",
+ "//libc:hdr_fcntl_macros",
+ "//libc:mmap",
+ "//libc:munmap",
+ "//libc:open",
+ "//libc:shm_open",
+ "//libc:shm_unlink",
+ ],
+)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/sys/resource/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/sys/resource/BUILD.bazel
new file mode 100644
index 0000000000000..e90f908846f77
--- /dev/null
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/sys/resource/BUILD.bazel
@@ -0,0 +1,24 @@
+# This file is licensed 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
+
+# Tests for LLVM libc socket.h functions.
+
+load("//libc/test:libc_test_rules.bzl", "libc_test")
+
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"])
+
+libc_test(
+ name = "getrlimit_setrlimit_test",
+ srcs = ["getrlimit_setrlimit_test.cpp"],
+ deps = [
+ "//libc:__support_cpp_string_view",
+ "//libc:close",
+ "//libc:getrlimit",
+ "//libc:open",
+ "//libc:setrlimit",
+ "//libc:unlink",
+ ],
+)
|
vonosmas
approved these changes
Oct 6, 2025
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.
Depends on other cleanup patches:
#161748
#161749