Skip to content

Commit 00d7e67

Browse files
committed
[libc] Fix constant address space on global clock
Summary: I did this wrong in the first version, because `extern "C"` doesn't imply it's extern when used directly.
1 parent 9f62775 commit 00d7e67

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

libc/src/time/gpu/time_utils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ namespace LIBC_NAMESPACE {
1515
// insufficient.
1616
// TODO: Once we have another use-case for this we should put it in a common
1717
// device environment struct.
18-
extern "C" [[gnu::visibility("protected")]] uint64_t __llvm_libc_clock_freq =
19-
clock_freq;
18+
gpu::Constant<uint64_t> __llvm_libc_clock_freq = clock_freq;
2019
#endif
2120

2221
} // namespace LIBC_NAMESPACE

libc/src/time/gpu/time_utils.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ constexpr uint64_t clock_freq = 100000000UL;
2323

2424
// We provide an externally visible symbol such that the runtime can set
2525
// this to the correct value.
26-
extern "C" [[gnu::visibility("protected")]] uint64_t __llvm_libc_clock_freq;
26+
extern "C" {
27+
[[gnu::visibility("protected")]]
28+
extern gpu::Constant<uint64_t> __llvm_libc_clock_freq;
29+
}
2730
#define GPU_CLOCKS_PER_SEC static_cast<clock_t>(__llvm_libc_clock_freq)
2831

2932
#elif defined(LIBC_TARGET_ARCH_IS_NVPTX)

0 commit comments

Comments
 (0)