]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Allow use of __sync_lock_test_and_set for spinlocks on any machine.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 2 Nov 2022 21:37:26 +0000 (17:37 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 2 Nov 2022 21:37:26 +0000 (17:37 -0400)
commita0f9be1f9266e4080dd31bb37fea91b5d5e3b15f
tree6115a659c4a28635eab4d29d3c5c573cafc4e721
parent36abd1fb51df7c94ddfc26b0d08be7feb5f40241
Allow use of __sync_lock_test_and_set for spinlocks on any machine.

If we have no special-case code in s_lock.h for the current platform,
but the compiler has __sync_lock_test_and_set, use that instead of
failing.  It's unlikely that anybody's __sync_lock_test_and_set
would be so awful as to be worse than our semaphore-based fallback,
but if it is, they can (continue to) use --disable-spinlocks.

This allows removal of the RISC-V special case installed by commit
c32fcac56, which generated exactly the same code but only on that
platform.  Usefully, the RISC-V buildfarm animals should now test
at least the int variant of this patch.

I've manually tested both variants on ARM by dint of removing the
ARM-specific stanza.  We don't want to drop that, because it already
has some special knowledge and is likely to grow more over time.
Likewise, this is not meant to preclude installing special cases
for other arches if that proves worthwhile.

Per discussion of a request to install the same code for loongarch64.
Like the previous patch, we might as well back-patch to supported
branches.

Discussion: https://postgr.es/m/761ac43d44b84d679ba803c2bd947cc0@HSMAILSVR04.hs.handsome.com.cn
src/include/storage/s_lock.h