File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -150,14 +150,27 @@ template <typename T> struct Atomic {
150
150
};
151
151
152
152
// Issue a thread fence with the given memory ordering.
153
- LIBC_INLINE void atomic_thread_fence (MemoryOrder mem_ord) {
153
+ LIBC_INLINE void atomic_thread_fence ([[maybe_unused]] MemoryOrder mem_ord) {
154
154
// The NVPTX backend currently does not support atomic thread fences so we use a
155
155
// full system fence instead.
156
156
#ifdef LIBC_TARGET_ARCH_IS_NVPTX
157
- (void )mem_ord;
158
157
__nvvm_membar_sys ();
159
158
#else
160
- __atomic_thread_fence (int (mem_ord));
159
+ __atomic_thread_fence (static_cast <int >(mem_ord));
160
+ #endif
161
+ }
162
+
163
+ // Establishes memory synchronization ordering of non-atomic and relaxed atomic
164
+ // accesses, as instructed by order, between a thread and a signal handler
165
+ // executed on the same thread. This is equivalent to atomic_thread_fence,
166
+ // except no instructions for memory ordering are issued. Only reordering of
167
+ // the instructions by the compiler is suppressed as order instructs.
168
+ LIBC_INLINE void atomic_signal_fence ([[maybe_unused]] MemoryOrder mem_ord) {
169
+ #if __has_builtin(__atomic_signal_fence)
170
+ __atomic_signal_fence (static_cast <int >(mem_ord));
171
+ #else
172
+ // if the builtin is not ready, use asm as a full compiler barrier.
173
+ asm volatile (" " ::: " memory" );
161
174
#endif
162
175
}
163
176
You can’t perform that action at this time.
0 commit comments