diff options
author | Joseph Huber <huberjn@outlook.com> | 2024-07-16 16:17:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-16 16:17:34 -0500 |
commit | 8393ea5d1dd8e8b56a87a6edbca31fb8722cee48 (patch) | |
tree | 8390fc5204af66e30b5ce513f409c3a9117d8dd8 /libc/include | |
parent | f7cee44ef2a2bf62f3c939d5686c45c71f3b14bc (diff) | |
download | llvm-8393ea5d1dd8e8b56a87a6edbca31fb8722cee48.zip llvm-8393ea5d1dd8e8b56a87a6edbca31fb8722cee48.tar.gz llvm-8393ea5d1dd8e8b56a87a6edbca31fb8722cee48.tar.bz2 |
[libc] Implement `clock_gettime` for the monotonic clock on the GPU (#99067)
Summary:
This patch implements `clock_gettime` using the monotonic clock. This
allows users to get time elapsed at nanosecond resolution. This is
primarily to facilitate compiling the `chrono` library from `libc++`.
For this reason we provide both `CLOCK_MONOTONIC`, which we can
implement
with the GPU's global fixed-frequency clock, and `CLOCK_REALTIME` which
we cannot. The latter is provided just to make people who use this
header happy and it will always return failure.
Diffstat (limited to 'libc/include')
-rw-r--r-- | libc/include/llvm-libc-macros/gpu/time-macros.h | 3 | ||||
-rw-r--r-- | libc/include/time.h.def | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/libc/include/llvm-libc-macros/gpu/time-macros.h b/libc/include/llvm-libc-macros/gpu/time-macros.h index c3dc812..7142a3e 100644 --- a/libc/include/llvm-libc-macros/gpu/time-macros.h +++ b/libc/include/llvm-libc-macros/gpu/time-macros.h @@ -9,6 +9,9 @@ #ifndef LLVM_LIBC_MACROS_GPU_TIME_MACROS_H #define LLVM_LIBC_MACROS_GPU_TIME_MACROS_H +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 1 + #define CLOCKS_PER_SEC 1000000 #endif // LLVM_LIBC_MACROS_GPU_TIME_MACROS_H diff --git a/libc/include/time.h.def b/libc/include/time.h.def index 2355e88..3776dfc 100644 --- a/libc/include/time.h.def +++ b/libc/include/time.h.def @@ -11,6 +11,8 @@ #include "__llvm-libc-common.h" #include "llvm-libc-macros/time-macros.h" +#include "llvm-libc-types/clock_t.h" +#include "llvm-libc-types/clockid_t.h" %%public_api() |