[libc-commits] [libc] ce1305a - [libc] make off_t 32b for 32b arm (#77350)
via libc-commits
libc-commits at lists.llvm.org
Mon Jan 8 13:10:03 PST 2024
Author: Nick Desaulniers
Date: 2024-01-08T13:09:58-08:00
New Revision: ce1305a3cea42dad8dd6ee5606dd4259e8632953
URL: https://github.com/llvm/llvm-project/commit/ce1305a3cea42dad8dd6ee5606dd4259e8632953
DIFF: https://github.com/llvm/llvm-project/commit/ce1305a3cea42dad8dd6ee5606dd4259e8632953.diff
LOG: [libc] make off_t 32b for 32b arm (#77350)
Fixes the following diagnostic:
llvm-project/libc/src/sys/mman/linux/mmap.cpp:44:59: error: implicit
conversion loses integer precision: 'off_t' (aka 'long long') to 'long'
[-Werror,-Wshorten-64-to-32]
size, prot, flags, fd, offset);
^~~~~~
It looks like off_t is a curious types on different platforms. FWICT,
it's 32b
on arm (at least for arm-linux-gnueabi) but 64b elsewhere (including 32b
riscv32-linux-gnu).
Added:
Modified:
libc/include/llvm-libc-types/off_t.h
Removed:
################################################################################
diff --git a/libc/include/llvm-libc-types/off_t.h b/libc/include/llvm-libc-types/off_t.h
index 111b29aa68d875..a0cbe992189d00 100644
--- a/libc/include/llvm-libc-types/off_t.h
+++ b/libc/include/llvm-libc-types/off_t.h
@@ -9,6 +9,10 @@
#ifndef __LLVM_LIBC_TYPES_OFF_T_H__
#define __LLVM_LIBC_TYPES_OFF_T_H__
+#if defined(__LP64__) || defined(__riscv)
typedef __INT64_TYPE__ off_t;
+#else
+typedef __INT32_TYPE__ off_t;
+#endif // __LP64__ || __riscv
#endif // __LLVM_LIBC_TYPES_OFF_T_H__
More information about the libc-commits
mailing list