Skip to content

Commit 9fc398c

Browse files
yoneymeta-codesync[bot]
authored andcommitted
Use std::atomic_ref when available
Summary: Fixes broken builds where C++20 `std::atomic_ref` is not available. Reviewed By: jbower-fb Differential Revision: D94774027 fbshipit-source-id: 3ccdff4c7c1f5fb2e445a592c3868b131d7df2d8
1 parent fdb633f commit 9fc398c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

cinderx/Common/util.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,12 @@ class FrozenList {
488488
inline void setVectorcall(
489489
BorrowedRef<PyFunctionObject> func,
490490
vectorcallfunc entry) {
491+
#ifdef __cpp_lib_atomic_ref
492+
std::atomic_ref<vectorcallfunc>(func->vectorcall)
493+
.store(entry, std::memory_order_relaxed);
494+
#else
491495
__atomic_store_n(&func->vectorcall, entry, __ATOMIC_RELAXED);
496+
#endif
492497
}
493498

494499
using FuncVisitor = void (*)(BorrowedRef<PyFunctionObject>);

0 commit comments

Comments
 (0)