From a10693c80a733511a722209ffe4488cdcef9ae50 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Mon, 8 Jan 2024 10:26:00 -0800 Subject: [PATCH 1/2] [libc] fix -Wshorten-64-to-32 for 32b arm mmap 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 riscv-linux-gnu). --- libc/include/llvm-libc-types/off_t.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc/include/llvm-libc-types/off_t.h b/libc/include/llvm-libc-types/off_t.h index 111b29aa68d87..f1c38d6bb5ad4 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__ From 6cf4d541de5a4094856e88b5aa6aed9b349aa385 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Mon, 8 Jan 2024 10:37:34 -0800 Subject: [PATCH 2/2] git clang-format HEAD~ --- libc/include/llvm-libc-types/off_t.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/include/llvm-libc-types/off_t.h b/libc/include/llvm-libc-types/off_t.h index f1c38d6bb5ad4..a0cbe992189d0 100644 --- a/libc/include/llvm-libc-types/off_t.h +++ b/libc/include/llvm-libc-types/off_t.h @@ -9,7 +9,7 @@ #ifndef __LLVM_LIBC_TYPES_OFF_T_H__ #define __LLVM_LIBC_TYPES_OFF_T_H__ -#if defined(__LP64__) || defined (__riscv) +#if defined(__LP64__) || defined(__riscv) typedef __INT64_TYPE__ off_t; #else typedef __INT32_TYPE__ off_t;