pkubaj commented on code in PR #3696:
URL: https://github.com/apache/brpc/pull/3696#discussion_r4443302031
##########
src/butil/atomicops_internals_gcc.h:
##########
@@ -99,6 +93,82 @@ inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
return *ptr;
}
+#ifdef ARCH_CPU_64_BITS
+
+inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
+ Atomic64 old_value,
+ Atomic64 new_value) {
+ return __sync_val_compare_and_swap(ptr, old_value, new_value);
+}
+
+inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
+ Atomic64 new_value) {
+ Atomic64 old_value;
+ do {
+ old_value = *ptr;
+ } while (!__sync_bool_compare_and_swap(ptr, old_value, new_value));
+ return old_value;
+}
+
+inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
+ Atomic64 increment) {
+ for (;;) {
+ Atomic64 old_value = *ptr;
+ Atomic64 new_value = old_value + increment;
+ if (__sync_bool_compare_and_swap(ptr, old_value, new_value)) {
Review Comment:
Fixed in dd5a5a5373de: both `Barrier_AtomicIncrement` overloads return
`__sync_add_and_fetch(ptr, increment)`. `atomicops_unittest.cc` built on
big-endian powerpc64 passes, including `IncrementBounds`; with
`-fsanitize=signed-integer-overflow` the previous header reports the overflow
at the 32-bit boundary and the new one runs clean.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]