summaryrefslogtreecommitdiff
path: root/src/include/port/atomics/generic-gcc.h
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2024-07-04 13:25:31 +0200
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2024-07-04 13:25:31 +0200
commit3a9d0d774d90c41bd60a8fb85685092d3e0bc30f (patch)
tree1bfef85d36c37605087924b06ea9f30596d91a09 /src/include/port/atomics/generic-gcc.h
parent1c9acb14ae0c16dacb9d2823b59589e8f523d1a6 (diff)
Remove bogus assertion in pg_atomic_monotonic_advance_u64
This code wanted to ensure that the 'exchange' variable passed to pg_atomic_compare_exchange_u64 has correct alignment, but apparently platforms don't actually require anything that doesn't come naturally. While messing with pg_atomic_monotonic_advance_u64: instead of using Max() to determine the value to return, just use pg_atomic_compare_exchange_u64()'s return value to decide; also, use pg_atomic_compare_exchange_u64 instead of the _impl version; also remove the unnecessary underscore at the end of variable name "target". Backpatch to 17, where this code was introduced by commit bf3ff7bf83bc. Reported-by: Alexander Lakhin <exclusion@gmail.com> Discussion: https://postgr.es/m/36796438-a718-cf9b-2071-b2c1b947c1b5@gmail.com
Diffstat (limited to 'src/include/port/atomics/generic-gcc.h')
-rw-r--r--src/include/port/atomics/generic-gcc.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/include/port/atomics/generic-gcc.h b/src/include/port/atomics/generic-gcc.h
index 9d91370fa8c..872d2f02af4 100644
--- a/src/include/port/atomics/generic-gcc.h
+++ b/src/include/port/atomics/generic-gcc.h
@@ -240,6 +240,7 @@ static inline bool
pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr,
uint64 *expected, uint64 newval)
{
+ AssertPointerAlignment(expected, 8);
return __atomic_compare_exchange_n(&ptr->value, expected, newval, false,
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
}
@@ -253,6 +254,8 @@ pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr,
{
bool ret;
uint64 current;
+
+ AssertPointerAlignment(expected, 8);
current = __sync_val_compare_and_swap(&ptr->value, *expected, newval);
ret = current == *expected;
*expected = current;