Remove bogus assertion in pg_atomic_monotonic_advance_u64
authorAlvaro Herrera <[email protected]>
Thu, 4 Jul 2024 11:25:31 +0000 (13:25 +0200)
committerAlvaro Herrera <[email protected]>
Thu, 4 Jul 2024 11:25:31 +0000 (13:25 +0200)
commit3a9d0d774d90c41bd60a8fb85685092d3e0bc30f
tree1bfef85d36c37605087924b06ea9f30596d91a09
parent1c9acb14ae0c16dacb9d2823b59589e8f523d1a6
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 <[email protected]>
Discussion: https://postgr.es/m/36796438-a718-cf9b-2071-b2c1b947c1b5@gmail.com
src/include/port/atomics.h
src/include/port/atomics/arch-ppc.h
src/include/port/atomics/arch-x86.h
src/include/port/atomics/generic-gcc.h
src/include/port/atomics/generic-sunpro.h