Skip to content

Commit 0ccc389

Browse files
committed
[libc] Make RPC header work with GCC9
1 parent b4d49fb commit 0ccc389

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

libc/shared/rpc_util.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#define RPC_TARGET_IS_GPU
1818
#endif
1919

20+
// Workaround for missing __has_builtin in < GCC 10.
21+
#ifndef __has_builtin
22+
#define __has_builtin(x) 0
23+
#endif
24+
2025
#ifndef RPC_INLINE
2126
#define RPC_INLINE inline
2227
#endif
@@ -141,17 +146,15 @@ template <typename T> class optional {
141146

142147
/// Suspend the thread briefly to assist the thread scheduler during busy loops.
143148
RPC_INLINE void sleep_briefly() {
144-
#if defined(LIBC_TARGET_ARCH_IS_NVPTX)
149+
#if defined(__NVPTX__)
145150
if (__nvvm_reflect("__CUDA_ARCH") >= 700)
146151
asm("nanosleep.u32 64;" ::: "memory");
147-
#elif defined(LIBC_TARGET_ARCH_IS_AMDGPU)
152+
#elif defined(__AMDGPU__)
148153
__builtin_amdgcn_s_sleep(2);
149-
#elif defined(LIBC_TARGET_ARCH_IS_X86)
154+
#elif __has_builtin(__builtin_ia32_pause)
150155
__builtin_ia32_pause();
151-
#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) && __has_builtin(__builtin_arm_isb)
156+
#elif __has_builtin(__builtin_arm_isb)
152157
__builtin_arm_isb(0xf);
153-
#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
154-
asm volatile("isb\n" ::: "memory");
155158
#else
156159
// Simply do nothing if sleeping isn't supported on this platform.
157160
#endif

0 commit comments

Comments
 (0)