Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wK1Ao-000Uxf-32 for pgsql-hackers@arkaria.postgresql.org; Mon, 04 May 2026 21:49:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wK1Al-0092pP-3A for pgsql-hackers@arkaria.postgresql.org; Mon, 04 May 2026 21:49:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wK1Al-0092pG-1Y for pgsql-hackers@lists.postgresql.org; Mon, 04 May 2026 21:49:51 +0000 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wK1Ai-00000000D1S-3ZPr for pgsql-hackers@postgresql.org; Mon, 04 May 2026 21:49:50 +0000 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-479ef2b78f3so3461526b6e.2 for ; Mon, 04 May 2026 14:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777931388; x=1778536188; darn=postgresql.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=JRRgzlZqOozMG46TxtfYDJdx3mtx6VIeB3I0vBysmn0=; b=F2LEfqpNhmJQ+/sYzyffeKxMy9wFJ4RFt9kMsmNET0WbElVc1p8bMyteH6ozBW6Yjn JwQtuT+gANrDMv8NORcnDpR9ncnDOBSdE+71TuuvnB0x6vhbG8Q/R4T70lup5yKXKb1V oHLLLILSYUesBKzl/5voCX1Y4RKJNBLzgrNhyKDVMmhbt/JQ9tX8AbSRi+uhgNl5Fu8a Uxi3eyII1Nc5e/Op6PBdCJ/wi8xSP5fvWmhjheuZgXJUFs4jWXTGp4XFSspO7ByuzAQ3 tULJcAnBAPmdXIQTswHjcS3eIShCmHQQm5AnOaMvWN1NEf3gLuqpzK2vVzkvcVtEowOQ 1yVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777931388; x=1778536188; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JRRgzlZqOozMG46TxtfYDJdx3mtx6VIeB3I0vBysmn0=; b=CJ8MJgMqGTcqgKnc5V3LNGO/kz1JOpSG/3+9JeiSUyin/6iex7+qE8DIYamD8C2i8+ 2ylsGukXGzeZKeLA+TK5gWA4mzJ/55alftWOUBmFplB4UlZq6hjQ5h/FuRXBdKW/jr7a OC8+Fy462MRUHEtTTbFg8TL4VRbrZclty5ZLbI5oK8QTk/OFAck5FBw+Fhkacncn1UoN YtxFeQZV76OrekFoRBrBByP2BjNp+w9EsmQGd1J6SFYlWimKNAp04qWoVUbZW2B7RMYP s1i+6hk5w52LWzGX+mv3YTWcNH8JMTdGz4CA2SYBsh8nc5PenHMrE2HNuNasc3doHJTG 5Q4Q== X-Gm-Message-State: AOJu0YwLb8M9juKInzR7XxFnXfXlzdjq2MWkKlYPygx7WOKm9itut4pz MdadjnpiXhB5WAW21pYE82tOb9lnjkTG09y0IgLayXHD/U0qe3bRzVi2jFLfag== X-Gm-Gg: AeBDiesXqT1juxX1e9ADuI3+L35mHZc8+byf8WVFQ7PUU7XGaeEN8GIHxNATfIrRWIF QNjzoLoBJRYMGUcqRMtVlJ6w+y8ie6j5u83DeDmX225+oPBY041KLVt3sKm/cHu72J+y3Hh1cic iOR+5QX1v/CtAmDT4aIZnbMMn9Ik0bcsQe1z4Lwypg6llzzIF5o8TcSCoR0KKO0wxSp1hijO3no 40ltNZyWy6PdRXOZqI86f+6KIvfF9oPuDdL81Sq5jTAsLvBEzsUoUJNs2BzFicGX9ECx3iNLynP w50uFa6Yk50BbRAokKFoxtazLCT3L4w56BzxfYhn0/QoVPri96wlBuAcy3ukJo1LbZDTaFO5o/7 urE3d14CZ3q9Da6Bd+skgHQL1KQUH7cM96jB1qUKxzU4Xms09OnQiRhATx3C8xvqP770E874xFG Pa/Q65GDXh8ixjo2cuRcHoT5+sXxxhz6firdtoa4BmImiHOcilBL9F3xtOZk+U2dTdDckXHPRqf 0oKN7LFhrGmFtxE/0PCWjXGNxow/sxfDeQaJ64LSe0= X-Received: by 2002:a05:6808:3087:b0:46a:7ab9:c339 with SMTP id 5614622812f47-47c89016a18mr5156623b6e.14.1777931387862; Mon, 04 May 2026 14:49:47 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 5614622812f47-47c76986f9dsm7468267b6e.16.2026.05.04.14.49.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 14:49:46 -0700 (PDT) Date: Mon, 4 May 2026 16:49:44 -0500 From: Nathan Bossart To: pgsql-hackers@postgresql.org Subject: small cleanup for s_lock.h Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="T3UIK4uPypqlnd5v" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --T3UIK4uPypqlnd5v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I noticed that s_lock.h points to a default implementation of tas() in tas.s or s_lock.c, but AFAICT there hasn't been a tas() implementation in s_lock.c since commit 718aa43a4e, and commit 25f36066dd seems to have removed the last remaining tas.s files. So, I think this is dead code. I also noticed that HAS_TEST_AND_SET just means that TAS is defined, so I wrote a 0002 that removes it in favor of checking TAS directly. 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. -- nathan --T3UIK4uPypqlnd5v Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0001-Remove-fallback-declaration-for-tas.patch From a254cee054ccd22c6c11f876c5f8549f28f6499c Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Mon, 4 May 2026 16:04:04 -0500 Subject: [PATCH v1 1/2] Remove fallback declaration for tas(). The last definition of tas() in s_lock.c was removed in commit 718aa43a4e, and the last tas.s file was removed in commit 25f36066dd, so this is dead code. --- src/include/storage/s_lock.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index c9e52511990..dcfec8ce2af 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -697,13 +697,6 @@ extern void s_unlock(volatile slock_t *lock); #define SPIN_DELAY() ((void) 0) #endif /* SPIN_DELAY */ -#if !defined(TAS) -extern int tas(volatile slock_t *lock); /* in port/.../tas.s, or - * s_lock.c */ - -#define TAS(lock) tas(lock) -#endif /* TAS */ - #if !defined(TAS_SPIN) #define TAS_SPIN(lock) TAS(lock) #endif /* TAS_SPIN */ -- 2.50.1 (Apple Git-155) --T3UIK4uPypqlnd5v Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v1-0002-Remove-HAS_TEST_AND_SET.patch From 60d6d767fc8e318f303c72b5883e3a15656b9ff5 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Mon, 4 May 2026 16:24:30 -0500 Subject: [PATCH v1 2/2] Remove HAS_TEST_AND_SET. This is only set when TAS is defined, so we can just check whether TAS is defined directly instead. --- src/include/storage/s_lock.h | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index dcfec8ce2af..fb872edd2f0 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -124,7 +124,6 @@ #ifdef __i386__ /* 32-bit i386 */ -#define HAS_TEST_AND_SET typedef unsigned char slock_t; @@ -194,7 +193,6 @@ spin_delay(void) #ifdef __x86_64__ /* AMD Opteron, Intel EM64T */ -#define HAS_TEST_AND_SET typedef unsigned char slock_t; @@ -249,7 +247,6 @@ spin_delay(void) */ #if defined(__arm__) || defined(__arm) || defined(__aarch64__) #ifdef HAVE_GCC__SYNC_INT32_TAS -#define HAS_TEST_AND_SET #define TAS(lock) tas(lock) @@ -292,7 +289,6 @@ spin_delay(void) /* S/390 and S/390x Linux (32- and 64-bit zSeries) */ #if defined(__s390__) || defined(__s390x__) -#define HAS_TEST_AND_SET typedef unsigned int slock_t; @@ -321,7 +317,6 @@ tas(volatile slock_t *lock) * acquire/release semantics. The CPU will treat superfluous members as * NOPs, so it's just code space. */ -#define HAS_TEST_AND_SET typedef unsigned char slock_t; @@ -392,7 +387,6 @@ do \ /* PowerPC */ #if defined(__ppc__) || defined(__powerpc__) || defined(__ppc64__) || defined(__powerpc64__) -#define HAS_TEST_AND_SET typedef unsigned int slock_t; @@ -453,7 +447,6 @@ do \ #if defined(__mips__) && !defined(__sgi) /* non-SGI MIPS */ -#define HAS_TEST_AND_SET typedef unsigned int slock_t; @@ -531,10 +524,9 @@ do \ * grounds that that's known to be more likely to work in the ARM ecosystem. * (But we dealt with ARM above.) */ -#if !defined(HAS_TEST_AND_SET) +#if !defined(TAS) #if defined(HAVE_GCC__SYNC_INT32_TAS) -#define HAS_TEST_AND_SET #define TAS(lock) tas(lock) @@ -549,7 +541,6 @@ tas(volatile slock_t *lock) #define S_UNLOCK(lock) __sync_lock_release(lock) #elif defined(HAVE_GCC__SYNC_CHAR_TAS) -#define HAS_TEST_AND_SET #define TAS(lock) tas(lock) @@ -565,7 +556,7 @@ tas(volatile slock_t *lock) #endif /* HAVE_GCC__SYNC_INT32_TAS */ -#endif /* !defined(HAS_TEST_AND_SET) */ +#endif /* !defined(TAS) */ /* @@ -592,12 +583,11 @@ tas(volatile slock_t *lock) * --------------------------------------------------------------------- */ -#if !defined(HAS_TEST_AND_SET) /* We didn't trigger above, let's try here */ +#if !defined(TAS) /* We didn't trigger above, let's try here */ #ifdef _MSC_VER typedef LONG slock_t; -#define HAS_TEST_AND_SET #define TAS(lock) (InterlockedCompareExchange(lock, 1, 0)) #define SPIN_DELAY() spin_delay() @@ -649,11 +639,11 @@ spin_delay(void) #endif -#endif /* !defined(HAS_TEST_AND_SET) */ +#endif /* !defined(TAS) */ /* Blow up if we didn't have any way to do spinlocks */ -#ifndef HAS_TEST_AND_SET +#ifndef TAS #error PostgreSQL does not have spinlock support on this platform. Please report this to pgsql-bugs@lists.postgresql.org. #endif -- 2.50.1 (Apple Git-155) --T3UIK4uPypqlnd5v--