summaryrefslogtreecommitdiff
path: root/libc/src/time/gpu/clock_gettime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/time/gpu/clock_gettime.cpp')
-rw-r--r--libc/src/time/gpu/clock_gettime.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/libc/src/time/gpu/clock_gettime.cpp b/libc/src/time/gpu/clock_gettime.cpp
index de7899a2a17c..81547ef7f1ca 100644
--- a/libc/src/time/gpu/clock_gettime.cpp
+++ b/libc/src/time/gpu/clock_gettime.cpp
@@ -10,23 +10,16 @@
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
-#include "time_utils.h"
+#include "src/__support/time/clock_gettime.h"
+#include "src/__support/time/gpu/time_utils.h"
namespace LIBC_NAMESPACE_DECL {
-constexpr uint64_t TICKS_PER_SEC = 1000000000UL;
-
LLVM_LIBC_FUNCTION(int, clock_gettime, (clockid_t clockid, timespec *ts)) {
- if (clockid != CLOCK_MONOTONIC || !ts)
- return -1;
-
- uint64_t ns_per_tick = TICKS_PER_SEC / GPU_CLOCKS_PER_SEC;
- uint64_t ticks = gpu::fixed_frequency_clock();
-
- ts->tv_nsec = (ticks * ns_per_tick) % TICKS_PER_SEC;
- ts->tv_sec = (ticks * ns_per_tick) / TICKS_PER_SEC;
-
- return 0;
+ ErrorOr<int> result = internal::clock_gettime(clockid, ts);
+ if (result)
+ return result.value();
+ return result.error();
}
} // namespace LIBC_NAMESPACE_DECL