[libc-commits] [libc] [libc] Enable 'timespec_get' for the GPU build (PR #120304)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Tue Dec 17 13:18:22 PST 2024
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/120304
Summary:
Currently fails to build libc++ because this is missing.
>From 9ccda7bd4f4267c447a85cd47f2bdc1888030207 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Tue, 17 Dec 2024 15:17:05 -0600
Subject: [PATCH] [libc] Enable 'timespec_get' for the GPU build
Summary:
Currently fails to build libc++ because this is missing.
---
libc/config/gpu/entrypoints.txt | 1 +
libc/src/__support/time/gpu/time_utils.h | 2 ++
libc/src/time/gpu/nanosleep.cpp | 2 --
libc/src/time/gpu/timespec_get.cpp | 1 +
4 files changed, 4 insertions(+), 2 deletions(-)
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