[libc-commits] [libc] 9ff0a44 - [libc] Fix setrlimit/getrlimit on 32-bit systems

Mikhail R. Gadelha via libc-commits libc-commits at lists.llvm.org
Thu Sep 7 12:05:13 PDT 2023


Author: Mikhail R. Gadelha
Date: 2023-09-07T16:02:32-03:00
New Revision: 9ff0a447d055a72ae4c758ef72ca2b64deefcfb7

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

LOG: [libc] Fix setrlimit/getrlimit on 32-bit systems

libc uses SYS_prlimit64 (which takes a struct rlimit64) to implement
setrlimt and getrlimit (which take a struct rlimit). In 64-bit bits
systems this is not an issue since the members of struct rlimit64 and
struct rlimit are 64 bits long, however, in 32-bit systems the members
of struct rlimit are only 32 bits long, causing wrong values being
passed to SYS_prlimit64.

This patch changes rlim_t to be __UINT64_TYPE__ (which also changes
rlimit as a side-effect), fixing the problem of mismatching types in
the syscall.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D159104

Added: 
    

Modified: 
    libc/include/llvm-libc-types/rlim_t.h

Removed: 
    


################################################################################
diff  --git a/libc/include/llvm-libc-types/rlim_t.h b/libc/include/llvm-libc-types/rlim_t.h
index 467a715c31df39f..4e5acfb24c1b5bb 100644
--- a/libc/include/llvm-libc-types/rlim_t.h
+++ b/libc/include/llvm-libc-types/rlim_t.h
@@ -9,6 +9,6 @@
 #ifndef __LLVM_LIBC_TYPES_RLIM_T_H__
 #define __LLVM_LIBC_TYPES_RLIM_T_H__
 
-typedef unsigned long rlim_t;
+typedef __UINT64_TYPE__ rlim_t;
 
 #endif // __LLVM_LIBC_TYPES_RLIM_T_H__


        


More information about the libc-commits mailing list