Re: small cleanup for s_lock.h - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: small cleanup for s_lock.h
Date
Msg-id afoRiqyHl0HxhzCB@nathan
Whole thread
In response to Re: small cleanup for s_lock.h  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Mon, May 04, 2026 at 06:16:47PM -0400, Tom Lane wrote:
> Nathan Bossart <nathandbossart@gmail.com> writes:
>> I'd like to rewrite the comment at the top of the file, too, but haven't
>> gotten to that yet.  I find it a little misleading, especially because
>> we #error if TAS isn't defined.
> 
> No objection in principle to improving that comment, but what did you
> have in mind exactly?

I think the way the comment presents the macros gives a potentially
misleading impression about what you typically need to do to get a new
platform working, and you basically need to read through the whole file to
make sense of what's going on.  Some of the macros it mentions have a
default implementation that we use everywhere (e.g., S_INIT_LOCK), and if
you're using gcc, you may be able to just use the __sync_lock_test_and_set
versions.  If you _did_ need to add a new section for a new platform, you'd
probably be more interested in defining slock_t, HAS_TEST_AND_TEST/TAS,
S_UNLOCK, SPIN_DELAY, and maybe TAS_SPIN.  In fact, you _must_ ensure TAS
is defined or else we'll fail to compile.

Although as I write this e-mail and think about how exactly I'd rewrite the
comment, I grow less confident about doing so...

-- 
nathan



pgsql-hackers by date:

Previous
From: Ayush Tiwari
Date:
Subject: Re: Changing the state of data checksums in a running cluster
Next
From: "Tristan Partin"
Date:
Subject: Re: Cleanup: Replace sscanf with strtol/strtoul in snapmgr