[libc-commits] [libc] 0ccc389 - [libc] Make RPC header work with GCC9

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Mon Nov 25 05:31:43 PST 2024


Author: Joseph Huber
Date: 2024-11-25T07:31:35-06:00
New Revision: 0ccc3895126aaa94ae3fe890fcca0ad69658bbab

URL: https://github.com/llvm/llvm-project/commit/0ccc3895126aaa94ae3fe890fcca0ad69658bbab
DIFF: https://github.com/llvm/llvm-project/commit/0ccc3895126aaa94ae3fe890fcca0ad69658bbab.diff

LOG: [libc] Make RPC header work with GCC9

Added: 
    

Modified: 
    libc/shared/rpc_util.h

Removed: 
    


################################################################################
diff  --git a/libc/shared/rpc_util.h b/libc/shared/rpc_util.h
index 502014d839ae94..bb0177c01b85ea 100644
--- a/libc/shared/rpc_util.h
+++ b/libc/shared/rpc_util.h
@@ -17,6 +17,11 @@
 #define RPC_TARGET_IS_GPU
 #endif
 
+// Workaround for missing __has_builtin in < GCC 10.
+#ifndef __has_builtin
+#define __has_builtin(x) 0
+#endif
+
 #ifndef RPC_INLINE
 #define RPC_INLINE inline
 #endif
@@ -141,17 +146,15 @@ template <typename T> class optional {
 
 /// Suspend the thread briefly to assist the thread scheduler during busy loops.
 RPC_INLINE void sleep_briefly() {
-#if defined(LIBC_TARGET_ARCH_IS_NVPTX)
+#if defined(__NVPTX__)
   if (__nvvm_reflect("__CUDA_ARCH") >= 700)
     asm("nanosleep.u32 64;" ::: "memory");
-#elif defined(LIBC_TARGET_ARCH_IS_AMDGPU)
+#elif defined(__AMDGPU__)
   __builtin_amdgcn_s_sleep(2);
-#elif defined(LIBC_TARGET_ARCH_IS_X86)
+#elif __has_builtin(__builtin_ia32_pause)
   __builtin_ia32_pause();
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) && __has_builtin(__builtin_arm_isb)
+#elif __has_builtin(__builtin_arm_isb)
   __builtin_arm_isb(0xf);
-#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
-  asm volatile("isb\n" ::: "memory");
 #else
   // Simply do nothing if sleeping isn't supported on this platform.
 #endif


        


More information about the libc-commits mailing list