From a93f397423076b2c2670bc4d3beedbe3a421f5b3 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Sat, 18 Jul 1998 14:51:10 +0000
Subject: [PATCH] On architectures where we don't have any special inline code
 for GCC, the inner "#if defined(__GNUC__)" can just be omitted in that
 architecture's block.

The existing arrangement with an outer "#if defined(__GNUC__)"
doesn't have any obvious benefit, and it encourages missed cases
like this one.


BTW, I'd suggest making the definition of clear_lock for HPUX be

static const slock_t clear_lock = {{-1, -1, -1, -1}};

The extra braces are needed to suppress warnings from gcc, and
declaring it const just seems like good practice.

			regards, tom lane
---
 src/include/storage/s_lock.h | 35 ++++++++++++++++-------------------
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index b628438f62b..b82d713b0a2 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.37 1998/07/18 14:38:12 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.38 1998/07/18 14:51:10 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -230,24 +230,6 @@ tas(volatile slock_t *lock)
 
 
 
-#if defined(__hpux)
-/*
- * HP-UX (PA-RISC)
- *
- * Note that slock_t on PA-RISC is a structure instead of char
- * (see storage/ipc.h).
- *
- * a "set" slock_t has a single word cleared.  a "clear" slock_t has
- * all words set to non-zero. tas() in tas.s
- */
-static slock_t clear_lock =
-{-1, -1, -1, -1};
-
-#define S_UNLOCK(lock)	(*(lock) = clear_lock)	/* struct assignment */
-#define S_LOCK_FREE(lock)	( *(int *) (((long) (lock) + 15) & ~15) != 0)
-#endif /* __hpux */
-
-
 
 #if defined(NEED_I386_TAS_ASM)
 /* non gcc i386 based things */
@@ -277,7 +259,22 @@ tas(slock_t *s_lock)
 
 #endif /* else defined(__GNUC__) */
 
+#if defined(__hpux)
+/*
+ * HP-UX (PA-RISC)
+ *
+ * Note that slock_t on PA-RISC is a structure instead of char
+ * (see storage/ipc.h).
+ *
+ * a "set" slock_t has a single word cleared.  a "clear" slock_t has
+ * all words set to non-zero. tas() in tas.s
+ */
+static const slock_t clear_lock =
+{{-1, -1, -1, -1}};
 
+#define S_UNLOCK(lock)	(*(lock) = clear_lock)	/* struct assignment */
+#define S_LOCK_FREE(lock)	( *(int *) (((long) (lock) + 15) & ~15) != 0)
+#endif /* __hpux */
 
 
 /****************************************************************************
-- 
GitLab