[libc-commits] [libc] [libc] Fix mlock, mlock2, and munlock signatures (PR #224905)
via libc-commits
libc-commits at lists.llvm.org
Sun Sep 20 03:49:13 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Jeff Bailey (kaladron)
<details>
<summary>Changes</summary>
Updated libc/include/sys/mman.yaml so the first parameter of mlock, mlock2, and munlock is const void * rather than void *.
Updated libc/src/sys/mman/mlock2.h and
libc/src/sys/mman/linux/mlock2.cpp so the flags parameter is unsigned int rather than int.
Assisted-by: Automated tooling, human reviewed.
---
Full diff: https://github.com/llvm/llvm-project/pull/224905.diff
3 Files Affected:
- (modified) libc/include/sys/mman.yaml (+3-3)
- (modified) libc/src/sys/mman/linux/mlock2.cpp (+2-1)
- (modified) libc/src/sys/mman/mlock2.h (+1-1)
``````````diff
diff --git a/libc/include/sys/mman.yaml b/libc/include/sys/mman.yaml
index bbd3ebaf72d46..8e58a3e0496f9 100644
--- a/libc/include/sys/mman.yaml
+++ b/libc/include/sys/mman.yaml
@@ -41,14 +41,14 @@ functions:
- posix
return_type: int
arguments:
- - type: void *
+ - type: const void *
- type: size_t
- name: mlock2
standards:
- linux
return_type: int
arguments:
- - type: void *
+ - type: const void *
- type: size_t
- type: unsigned int
- name: mlockall
@@ -99,7 +99,7 @@ functions:
- posix
return_type: int
arguments:
- - type: void *
+ - type: const void *
- type: size_t
- name: munlockall
standards:
diff --git a/libc/src/sys/mman/linux/mlock2.cpp b/libc/src/sys/mman/linux/mlock2.cpp
index 955cfe128de74..ca7c0df9b0e78 100644
--- a/libc/src/sys/mman/linux/mlock2.cpp
+++ b/libc/src/sys/mman/linux/mlock2.cpp
@@ -16,7 +16,8 @@
namespace LIBC_NAMESPACE_DECL {
#ifdef SYS_mlock2
-LLVM_LIBC_FUNCTION(int, mlock2, (const void *addr, size_t len, int flags)) {
+LLVM_LIBC_FUNCTION(int, mlock2,
+ (const void *addr, size_t len, unsigned int flags)) {
long ret = syscall_impl(SYS_mlock2, cpp::bit_cast<long>(addr), len, flags);
if (ret < 0) {
libc_errno = static_cast<int>(-ret);
diff --git a/libc/src/sys/mman/mlock2.h b/libc/src/sys/mman/mlock2.h
index 65dc0aa85a32f..ead8d9adc4814 100644
--- a/libc/src/sys/mman/mlock2.h
+++ b/libc/src/sys/mman/mlock2.h
@@ -17,7 +17,7 @@
namespace LIBC_NAMESPACE_DECL {
#ifdef SYS_mlock2
-int mlock2(const void *addr, size_t len, int flags);
+int mlock2(const void *addr, size_t len, unsigned int flags);
#endif
} // namespace LIBC_NAMESPACE_DECL
``````````
</details>
https://github.com/llvm/llvm-project/pull/224905
More information about the libc-commits
mailing list