]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Remove SpinLockFree() and S_LOCK_FREE().
authorNathan Bossart <nathan@postgresql.org>
Thu, 19 Feb 2026 22:19:41 +0000 (16:19 -0600)
committerNathan Bossart <nathan@postgresql.org>
Thu, 19 Feb 2026 22:19:41 +0000 (16:19 -0600)
S_LOCK_FREE() is used by the test program in s_lock.c, but nobody
has voiced concerns about losing some coverage there.
SpinLockFree() appears to have been unused since it was introduced
by commit 499abb0c0f.  There was agreement to remove these in 2020,
but it never happened.  Since we still have agreement for removal
in 2026, let's do that now.

Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/aZX2oUcKf7IzHnnK%40nathan
Discussion: https://postgr.es/m/20200608225338.m5zho424w6lpwb2d%40alap3.anarazel.de

src/backend/storage/lmgr/s_lock.c
src/include/storage/s_lock.h
src/include/storage/spin.h

index 5b79556bc9cc89214d36ca6d090184f63eaea3b1..6df568eccb35a90b692a353d8a179b9b27631c25 100644 (file)
@@ -262,12 +262,6 @@ main()
                return 1;
        }
 
-       if (!S_LOCK_FREE(&test_lock.lock))
-       {
-               printf("S_LOCK_TEST: failed, lock not initialized\n");
-               return 1;
-       }
-
        S_LOCK(&test_lock.lock);
 
        if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
@@ -276,12 +270,6 @@ main()
                return 1;
        }
 
-       if (S_LOCK_FREE(&test_lock.lock))
-       {
-               printf("S_LOCK_TEST: failed, lock not locked\n");
-               return 1;
-       }
-
        S_UNLOCK(&test_lock.lock);
 
        if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
@@ -290,12 +278,6 @@ main()
                return 1;
        }
 
-       if (!S_LOCK_FREE(&test_lock.lock))
-       {
-               printf("S_LOCK_TEST: failed, lock not unlocked\n");
-               return 1;
-       }
-
        S_LOCK(&test_lock.lock);
 
        if (test_lock.pad1 != 0x44 || test_lock.pad2 != 0x44)
@@ -304,12 +286,6 @@ main()
                return 1;
        }
 
-       if (S_LOCK_FREE(&test_lock.lock))
-       {
-               printf("S_LOCK_TEST: failed, lock not re-locked\n");
-               return 1;
-       }
-
        printf("S_LOCK_TEST: this will print %d stars and then\n", NUM_DELAYS);
        printf("             exit with a 'stuck spinlock' message\n");
        printf("             if S_LOCK() and TAS() are working.\n");
index 62364586d60b24297bc1a8d8c38c4ec18537f01d..c9e5251199005a79fbcfd9f00c6eaa77895cc236 100644 (file)
  *     void S_UNLOCK(slock_t *lock)
  *             Unlock a previously acquired lock.
  *
- *     bool S_LOCK_FREE(slock_t *lock)
- *             Tests if the lock is free. Returns true if free, false if locked.
- *             This does *not* change the state of the lock.
- *
  *     void SPIN_DELAY(void)
  *             Delay operation to occur inside spinlock wait loop.
  *
@@ -671,10 +667,6 @@ spin_delay(void)
        (TAS(lock) ? s_lock((lock), __FILE__, __LINE__, __func__) : 0)
 #endif  /* S_LOCK */
 
-#if !defined(S_LOCK_FREE)
-#define S_LOCK_FREE(lock)      (*(lock) == 0)
-#endif  /* S_LOCK_FREE */
-
 #if !defined(S_UNLOCK)
 /*
  * Our default implementation of S_UNLOCK is essentially *(lock) = 0.  This
index 0f160d0e395afa148132db66bf77c33e70361046..78c95ae538bc8542e959ba6114cf4ef1fd09ec73 100644 (file)
  *     void SpinLockRelease(volatile slock_t *lock)
  *             Unlock a previously acquired lock.
  *
- *     bool SpinLockFree(slock_t *lock)
- *             Tests if the lock is free. Returns true if free, false if locked.
- *             This does *not* change the state of the lock.
- *
  *     Callers must beware that the macro argument may be evaluated multiple
  *     times!
  *
@@ -60,6 +56,4 @@
 
 #define SpinLockRelease(lock) S_UNLOCK(lock)
 
-#define SpinLockFree(lock)     S_LOCK_FREE(lock)
-
 #endif                                                 /* SPIN_H */