[libc-commits] [libc] be9e982 - [libc] Fix mlock, mlock2, and munlock signatures (#224905)

via libc-commits libc-commits at lists.llvm.org
Sun Sep 20 13:45:44 PDT 2026


Author: Jeff Bailey
Date: 2026-09-20T21:45:38+01:00
New Revision: be9e98270a4948e43b6555c7a5908bc9644209f1

URL: https://github.com/llvm/llvm-project/commit/be9e98270a4948e43b6555c7a5908bc9644209f1
DIFF: https://github.com/llvm/llvm-project/commit/be9e98270a4948e43b6555c7a5908bc9644209f1.diff

LOG: [libc] Fix mlock, mlock2, and munlock signatures (#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.

Added: 
    

Modified: 
    libc/include/sys/mman.yaml
    libc/src/sys/mman/linux/mlock2.cpp
    libc/src/sys/mman/mlock2.h

Removed: 
    


################################################################################
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