Repository navigation
Conversation
This PR move posix_madvise behind the centralized syscall wrappers, following libc/docs/dev/syscall_wrapper_refactor.md.
|
@llvm/pr-subscribers-libc Author: Connector Switch (c8ef) ChangesThis PR move posix_madvise behind the centralized syscall wrappers, following libc/docs/dev/syscall_wrapper_refactor.md. Full diff: https://github.com/llvm/llvm-project/pull/240073.diff 3 Files Affected:
diff --git a/libc/src/sys/mman/linux/CMakeLists.txt b/libc/src/sys/mman/linux/CMakeLists.txt
index d8426921f85dac..c13d482e50600e 100644
--- a/libc/src/sys/mman/linux/CMakeLists.txt
+++ b/libc/src/sys/mman/linux/CMakeLists.txt
@@ -94,8 +94,9 @@ add_entrypoint_object(
DEPENDS
libc.hdr.sys_mman_macros
libc.hdr.types.size_t
- libc.include.sys_syscall
- libc.src.__support.OSUtil.osutil
+ libc.src.__support.OSUtil.linux.syscall_wrappers.madvise
+ libc.src.__support.common
+ libc.src.__support.macros.config
)
add_entrypoint_object(
diff --git a/libc/src/sys/mman/linux/posix_madvise.cpp b/libc/src/sys/mman/linux/posix_madvise.cpp
index 18427e25911fd5..265ef8400f4a06 100644
--- a/libc/src/sys/mman/linux/posix_madvise.cpp
+++ b/libc/src/sys/mman/linux/posix_madvise.cpp
@@ -1,19 +1,22 @@
-//===---------- Linux implementation of the POSIX posix_madvise function --===//
+//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Linux implementation of posix_madvise.
+///
+//===----------------------------------------------------------------------===//
#include "src/sys/mman/posix_madvise.h"
-#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/OSUtil/linux/syscall_wrappers/madvise.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
-#include <sys/syscall.h> // For syscall numbers.
-
#include "hdr/sys_mman_macros.h" // For POSIX_MADV_DONTNEED.
namespace LIBC_NAMESPACE_DECL {
@@ -26,9 +29,8 @@ LLVM_LIBC_FUNCTION(int, posix_madvise, (void *addr, size_t size, int advice)) {
if (advice == POSIX_MADV_DONTNEED) {
return 0;
}
- int ret = LIBC_NAMESPACE::syscall_impl<int>(
- SYS_madvise, reinterpret_cast<long>(addr), size, advice);
- return ret < 0 ? -ret : 0;
+ auto result = linux_syscalls::madvise(addr, size, advice);
+ return result ? 0 : result.error();
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 89c312fa4fe87b..c50e9193ac4248 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -19998,7 +19998,7 @@ libc_function(
deps = [
":__support_common",
":__support_macros_config",
- ":__support_osutil_syscall",
+ ":__support_osutil_linux_syscall_wrappers_madvise",
":hdr_sys_mman_macros",
":types_size_t",
],
|
This branch has not been deployed
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
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.
This PR move posix_madvise behind the centralized syscall wrappers, following libc/docs/dev/syscall_wrapper_refactor.md.