Skip to content

Commit 9b95b29

Browse files
committed
[clang] [Basic] Define time64 macros for *t64 triples
Set the `-D_FILE_OFFSET_BITS=64` and `-D_TIME_BITS=64` defaults when clang is builting for one of the `*t64` triples that Gentoo is planning to use for 32-bit platforms migrated to 64-bit time_t.
1 parent df75eaa commit 9b95b29

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/lib/Basic/Targets/OSTargets.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public OSTargetInfo<Target> {
337337
Builder.defineMacro("_GNU_SOURCE");
338338
if (this->HasFloat128)
339339
Builder.defineMacro("__FLOAT128__");
340+
if (Triple.isTime64ABI()) {
341+
Builder.defineMacro("_FILE_OFFSET_BITS", "64");
342+
Builder.defineMacro("_TIME_BITS", "64");
343+
}
340344
}
341345

342346
public:

clang/test/Preprocessor/time64.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -E -dM -triple=i686-pc-linux-gnu /dev/null | FileCheck -match-full-lines -check-prefix TIME32 %s
2+
// RUN: %clang_cc1 -E -dM -triple=i686-pc-linux-gnut64 /dev/null | FileCheck -match-full-lines -check-prefix TIME64 %s
3+
// RUN: %clang_cc1 -E -dM -triple=armv5tel-softfloat-linux-gnueabi /dev/null | FileCheck -match-full-lines -check-prefix TIME32 %s
4+
// RUN: %clang_cc1 -E -dM -triple=armv5tel-softfloat-linux-gnueabit64 /dev/null | FileCheck -match-full-lines -check-prefix TIME64 %s
5+
// RUN: %clang_cc1 -E -dM -triple=armv7a-unknown-linux-gnueabihf /dev/null | FileCheck -match-full-lines -check-prefix TIME32 %s
6+
// RUN: %clang_cc1 -E -dM -triple=armv7a-unknown-linux-gnueabihft64 /dev/null | FileCheck -match-full-lines -check-prefix TIME64 %s
7+
//
8+
// TIME32-NOT:#define _FILE_OFFSET_BITS 64
9+
// TIME32-NOT:#define _TIME_BITS 64
10+
//
11+
// TIME64:#define _FILE_OFFSET_BITS 64
12+
// TIME64:#define _TIME_BITS 64

0 commit comments

Comments
 (0)