diff options
author | Joseph Huber <huberjn@outlook.com> | 2024-08-14 12:19:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-14 12:19:08 -0500 |
commit | 0eb1fc88680e2df430a5cb68be5e6a671b43c82d (patch) | |
tree | 3642df82449e3329bb93e956dc7f1bc5a6e8d6a5 /libcxx/src | |
parent | 5eb6330ef6de633e119a6679efce1f9018110eb1 (diff) | |
download | llvm-0eb1fc88680e2df430a5cb68be5e6a671b43c82d.zip llvm-0eb1fc88680e2df430a5cb68be5e6a671b43c82d.tar.gz llvm-0eb1fc88680e2df430a5cb68be5e6a671b43c82d.tar.bz2 |
[libcxx] Set `_LIBCPP_HAS_CLOCK_GETTIME` for GPU targets (#99243)
Summary:
I am attempting to get the GPU to build and support libc++. One issue
I've encountered is that it will look for `timeval` unless this macro is
set. We can support `CLOCK_MONOTONIC` on the GPU fairly easily as we
have access to a fixed-frequency clock via `__builtin_readsteadycounter`
intrinsics with a known frequency. This also requires `CLOCK_REALTIME`
which we can't support, but provide anyway from the GPU `libc` to make
this happy. It will return an error so at least that will be obvious.
I may need a more consistent configuration for this in the future, maybe
I should put a common macro in a different common header that's just
`__GPU__`? I don't know where I would put such a thing however.
Diffstat (limited to 'libcxx/src')
-rw-r--r-- | libcxx/src/chrono.cpp | 5 | ||||
-rw-r--r-- | libcxx/src/filesystem/filesystem_clock.cpp | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp index 83e8a64..986360d 100644 --- a/libcxx/src/chrono.cpp +++ b/libcxx/src/chrono.cpp @@ -31,9 +31,10 @@ # include <sys/time.h> // for gettimeofday and timeval #endif -// OpenBSD does not have a fully conformant suite of POSIX timers, but +// OpenBSD and GPU do not have a fully conformant suite of POSIX timers, but // it does have clock_gettime and CLOCK_MONOTONIC which is all we need. -#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) +#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || defined(__AMDGPU__) || \ + defined(__NVPTX__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) # define _LIBCPP_HAS_CLOCK_GETTIME #endif diff --git a/libcxx/src/filesystem/filesystem_clock.cpp b/libcxx/src/filesystem/filesystem_clock.cpp index e13b285..473a54a 100644 --- a/libcxx/src/filesystem/filesystem_clock.cpp +++ b/libcxx/src/filesystem/filesystem_clock.cpp @@ -29,7 +29,8 @@ # include <sys/time.h> // for gettimeofday and timeval #endif -#if defined(__APPLE__) || defined(__gnu_hurd__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) +#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__AMDGPU__) || defined(__NVPTX__) || \ + (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) # define _LIBCPP_HAS_CLOCK_GETTIME #endif |