[libc-commits] [libc] [libc] Enable 'timespec_get' for the GPU build (PR #120304)

via libc-commits libc-commits at lists.llvm.org
Tue Dec 17 13:19:00 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Joseph Huber (jhuber6)

<details>
<summary>Changes</summary>

Summary:
Currently fails to build libc++ because this is missing.


---
Full diff: https://github.com/llvm/llvm-project/pull/120304.diff


4 Files Affected:

- (modified) libc/config/gpu/entrypoints.txt (+1) 
- (modified) libc/src/__support/time/gpu/time_utils.h (+2) 
- (modified) libc/src/time/gpu/nanosleep.cpp (-2) 
- (modified) libc/src/time/gpu/timespec_get.cpp (+1) 


``````````diff
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 {
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/120304


More information about the libc-commits mailing list