Skip to content

Commit ce1305a

Browse files
[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).
1 parent ce41444 commit ce1305a

File tree

1 file changed

+4
-0
lines changed
  • libc/include/llvm-libc-types

1 file changed

+4
-0
lines changed

libc/include/llvm-libc-types/off_t.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#ifndef __LLVM_LIBC_TYPES_OFF_T_H__
1010
#define __LLVM_LIBC_TYPES_OFF_T_H__
1111

12+
#if defined(__LP64__) || defined(__riscv)
1213
typedef __INT64_TYPE__ off_t;
14+
#else
15+
typedef __INT32_TYPE__ off_t;
16+
#endif // __LP64__ || __riscv
1317

1418
#endif // __LLVM_LIBC_TYPES_OFF_T_H__

0 commit comments

Comments
 (0)