[libc-commits] [libc] [libc] Fix mlock, mlock2, and munlock signatures (PR #224905)
Jeff Bailey via libc-commits
libc-commits at lists.llvm.org
Sun Sep 20 03:21:35 PDT 2026
https://github.com/kaladron created https://github.com/llvm/llvm-project/pull/224905
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.
>From d599802487461517f72a6c1bf73064debc6ceb37 Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Sun, 20 Sep 2026 11:17:30 +0100
Subject: [PATCH] [libc] Fix mlock, mlock2, and munlock signatures
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.
---
libc/include/sys/mman.yaml | 6 +++---
libc/src/sys/mman/linux/mlock2.cpp | 3 ++-
libc/src/sys/mman/mlock2.h | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
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
More information about the libc-commits
mailing list