Better express platform requirements in s_lock.h.

Presently, s_lock.h insists that every platform provide TAS(), and
its header comment doesn't say which of the macros a new platform
actually needs to supply.  The real contract is that a platform
must provide either S_LOCK() or a TAS() for the default S_LOCK() to
be built on.

To better express that, this commit moves the "no spinlock support"
error to where the default S_LOCK() is defined, compiles s_lock()
only when the default S_LOCK() is in use, and provides a default
TAS_SPIN() only when there is a TAS() to base it on.  The direct
callers of s_lock() in the spinlock tests are adjusted to match.
The header comment is reworked accordingly, dropping the note about
pre-9.5 volatile requirements and the caution about TAS()
spuriously failing along the way.

Co-authored-by: Tom Lane <[email protected]>
Discussion: https://postgr.es/m/afkUeI7UhacZ5ZFm%40nathan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d9b5a63f49d9d372a6609243eb0e9417a0a35e6f

Modified Files
--------------
src/backend/storage/lmgr/s_lock.c |  4 +++-
src/include/storage/s_lock.h      | 46 +++++++++++++++++++--------------------
src/test/regress/regress.c        |  2 +-
3 files changed, 26 insertions(+), 26 deletions(-)

Reply via email to