[libc-commits] [libc] [libc] use LIBC_HAS_BUILTIN instead __has_builtin (PR #82377)

via libc-commits libc-commits at lists.llvm.org
Tue Feb 20 08:27:32 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

<details>
<summary>Changes</summary>

fix the issue that `__has_builtin` is undefined on GPU targets.

---
Full diff: https://github.com/llvm/llvm-project/pull/82377.diff


1 Files Affected:

- (modified) libc/src/__support/CPP/atomic.h (+1-1) 


``````````diff
diff --git a/libc/src/__support/CPP/atomic.h b/libc/src/__support/CPP/atomic.h
index c10d06c04bccad..b74cb5981dbaf8 100644
--- a/libc/src/__support/CPP/atomic.h
+++ b/libc/src/__support/CPP/atomic.h
@@ -166,7 +166,7 @@ LIBC_INLINE void atomic_thread_fence([[maybe_unused]] MemoryOrder mem_ord) {
 // except no instructions for memory ordering are issued. Only reordering of
 // the instructions by the compiler is suppressed as order instructs.
 LIBC_INLINE void atomic_signal_fence([[maybe_unused]] MemoryOrder mem_ord) {
-#if __has_builtin(__atomic_signal_fence)
+#if LIBC_HAS_BUILTIN(__atomic_signal_fence)
   __atomic_signal_fence(static_cast<int>(mem_ord));
 #else
   // if the builtin is not ready, use asm as a full compiler barrier.

``````````

</details>


https://github.com/llvm/llvm-project/pull/82377


More information about the libc-commits mailing list