pgsql: Better express platform requirements in s_lock.h.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Better express platform requirements in s_lock.h.
Date: 2026-09-28 18:53:00
Message-ID: E1xBGTE-00000001eFU-0Jju@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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 <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-09-28 23:28:44 pgsql: Fix crash in parallel autovacuum when no DSM segment can be crea
Previous Message Andrew Dunstan 2026-09-28 18:47:16 pgsql: Fire create_upper_paths_hook for UPPERREL_PARTIAL_GROUP_AGG