]> granicus.if.org Git - postgresql/commit
Use more of gcc's __sync_fetch_and_xxx builtin functions for atomic ops.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 6 Sep 2017 18:21:39 +0000 (14:21 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 6 Sep 2017 18:21:39 +0000 (14:21 -0400)
commite09db94c0a5f3b440d96c5c9e8e6c1638d1ec39f
tree54a8bd69f25e039e3575f742a7dd0fc9b4ec40f6
parente530be96859eb0a0e0bab98a79029268ddc98a1d
Use more of gcc's __sync_fetch_and_xxx builtin functions for atomic ops.

In addition to __sync_fetch_and_add, gcc offers __sync_fetch_and_sub,
__sync_fetch_and_and, and __sync_fetch_and_or, which correspond directly
to primitive atomic ops that we want.  Testing shows that in some cases
they generate better code than our generic implementations, so use them.

We've assumed that configure's test for __sync_val_compare_and_swap is
sufficient to allow assuming that __sync_fetch_and_add is available, so
make the same assumption for these functions.  Should that prove to be
wrong, we can add more configure tests.

Yura Sokolov, reviewed by Jesper Pedersen and myself

Discussion: https://postgr.es/m/7f65886daca545067f82bf2b463b218d@postgrespro.ru
src/include/port/atomics/generic-gcc.h