[libc-commits] [libc] 958de20 - [libc] Enable 'timespec_get' for the GPU build (#120304)
via libc-commits
libc-commits at lists.llvm.org
Tue Dec 17 13:31:10 PST 2024
Author: Joseph Huber
Date: 2024-12-17T15:31:07-06:00
New Revision: 958de20b30e73d898cf538435da5bab42ffd4987
URL: https://github.com/llvm/llvm-project/commit/958de20b30e73d898cf538435da5bab42ffd4987
DIFF: https://github.com/llvm/llvm-project/commit/958de20b30e73d898cf538435da5bab42ffd4987.diff
LOG: [libc] Enable 'timespec_get' for the GPU build (#120304)
Summary:
Currently fails to build libc++ because this is missing.
Added:
Modified:
libc/config/gpu/entrypoints.txt
libc/src/__support/time/gpu/time_utils.h
libc/src/time/gpu/nanosleep.cpp
libc/src/time/gpu/timespec_get.cpp
Removed:
################################################################################
diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index e3ebd3ca472560..28317c656d4be4 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -257,6 +257,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# time.h entrypoints
libc.src.time.clock
libc.src.time.clock_gettime
+ libc.src.time.timespec_get
libc.src.time.nanosleep
# wchar.h entrypoints
diff --git a/libc/src/__support/time/gpu/time_utils.h b/libc/src/__support/time/gpu/time_utils.h
index c631a38d91ba2f..315506c897dcf2 100644
--- a/libc/src/__support/time/gpu/time_utils.h
+++ b/libc/src/__support/time/gpu/time_utils.h
@@ -38,6 +38,8 @@ extern gpu::Constant<uint64_t> __llvm_libc_clock_freq;
#error "Unsupported target"
#endif
+constexpr uint64_t TICKS_PER_SEC = 1000000000UL;
+
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC_TIME_GPU_TIME_UTILS_H
diff --git a/libc/src/time/gpu/nanosleep.cpp b/libc/src/time/gpu/nanosleep.cpp
index 25a22d5703fa78..a92f660f225cb1 100644
--- a/libc/src/time/gpu/nanosleep.cpp
+++ b/libc/src/time/gpu/nanosleep.cpp
@@ -13,8 +13,6 @@
namespace LIBC_NAMESPACE_DECL {
-constexpr uint64_t TICKS_PER_SEC = 1000000000UL;
-
LLVM_LIBC_FUNCTION(int, nanosleep,
(const struct timespec *req, struct timespec *rem)) {
if (!GPU_CLOCKS_PER_SEC || !req)
diff --git a/libc/src/time/gpu/timespec_get.cpp b/libc/src/time/gpu/timespec_get.cpp
index f4ef328a83122c..0dd128444aa8e4 100644
--- a/libc/src/time/gpu/timespec_get.cpp
+++ b/libc/src/time/gpu/timespec_get.cpp
@@ -10,6 +10,7 @@
#include "hdr/time_macros.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
+#include "src/__support/time/gpu/time_utils.h"
namespace LIBC_NAMESPACE_DECL {
More information about the libc-commits
mailing list