summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2003-12-23 03:31:30 +0000
committerBruce Momjian2003-12-23 03:31:30 +0000
commit69f2e9b0fc46e50525990fbc9ea049e2c91840bf (patch)
tree6a8935c019067fe15286e2d5eba6c1b34ea084e6
parentdcae5781d11d0c0c0f2405d5e9b7d5ba91336e07 (diff)
Move slock_t typdefs into s_lock.h from include/port files for
centralization and easier maintanence.
-rw-r--r--src/backend/port/dynloader/netbsd.c2
-rw-r--r--src/backend/port/dynloader/openbsd.c2
-rw-r--r--src/backend/storage/lmgr/s_lock.c6
-rw-r--r--src/backend/storage/lmgr/spin.c3
-rw-r--r--src/include/port/aix.h3
-rw-r--r--src/include/port/beos.h4
-rw-r--r--src/include/port/bsdi.h12
-rw-r--r--src/include/port/cygwin.h5
-rw-r--r--src/include/port/darwin.h12
-rw-r--r--src/include/port/freebsd.h51
-rw-r--r--src/include/port/hpux.h9
-rw-r--r--src/include/port/irix5.h3
-rw-r--r--src/include/port/linux.h51
-rw-r--r--src/include/port/netbsd.h51
-rw-r--r--src/include/port/nextstep.h1
-rw-r--r--src/include/port/openbsd.h51
-rw-r--r--src/include/port/osf.h5
-rw-r--r--src/include/port/qnx4.h4
-rw-r--r--src/include/port/sco.h9
-rw-r--r--src/include/port/solaris.h5
-rw-r--r--src/include/port/sunos4.h3
-rw-r--r--src/include/port/svr4.h8
-rw-r--r--src/include/port/univel.h7
-rw-r--r--src/include/port/unixware.h7
-rw-r--r--src/include/storage/s_lock.h226
25 files changed, 158 insertions, 382 deletions
diff --git a/src/backend/port/dynloader/netbsd.c b/src/backend/port/dynloader/netbsd.c
index 33d2571b493..4b77049b3ba 100644
--- a/src/backend/port/dynloader/netbsd.c
+++ b/src/backend/port/dynloader/netbsd.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
diff --git a/src/backend/port/dynloader/openbsd.c b/src/backend/port/dynloader/openbsd.c
index 33d2571b493..4b77049b3ba 100644
--- a/src/backend/port/dynloader/openbsd.c
+++ b/src/backend/port/dynloader/openbsd.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
diff --git a/src/backend/storage/lmgr/s_lock.c b/src/backend/storage/lmgr/s_lock.c
index df1c5a53e96..3f13baaa60e 100644
--- a/src/backend/storage/lmgr/s_lock.c
+++ b/src/backend/storage/lmgr/s_lock.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.19 2003/12/23 00:32:06 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.20 2003/12/23 03:31:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,7 +17,6 @@
#include <sys/time.h>
#include <unistd.h>
-
#include "storage/s_lock.h"
@@ -118,6 +117,9 @@ s_lock(volatile slock_t *lock, const char *file, int line)
* Various TAS implementations that cannot live in s_lock.h as no inline
* definition exists (yet).
* In the future, get rid of tas.[cso] and fold it into this file.
+ *
+ * If you change something here, you have to modify s_lock.h because
+ * the definitions for these is split between this file and s_lock.h.
*/
diff --git a/src/backend/storage/lmgr/spin.c b/src/backend/storage/lmgr/spin.c
index b2d371e25e3..62bb4f4ad3e 100644
--- a/src/backend/storage/lmgr/spin.c
+++ b/src/backend/storage/lmgr/spin.c
@@ -16,7 +16,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/spin.c,v 1.12 2003/11/29 19:51:57 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/spin.c,v 1.13 2003/12/23 03:31:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -25,6 +25,7 @@
#include "storage/lwlock.h"
#include "storage/pg_sema.h"
#include "storage/spin.h"
+#include "storage/s_lock.h"
#ifdef HAS_TEST_AND_SET
diff --git a/src/include/port/aix.h b/src/include/port/aix.h
index d68b261afb3..0fde5763b87 100644
--- a/src/include/port/aix.h
+++ b/src/include/port/aix.h
@@ -1,8 +1,5 @@
#define CLASS_CONFLICT
#define DISABLE_XOPEN_NLS
-#define HAS_TEST_AND_SET
-
-typedef unsigned int slock_t;
#include <sys/machine.h> /* ENDIAN definitions for network
* communication */
diff --git a/src/include/port/beos.h b/src/include/port/beos.h
index 1ca198a96f0..9c71f80f568 100644
--- a/src/include/port/beos.h
+++ b/src/include/port/beos.h
@@ -2,10 +2,6 @@
#include <kernel/image.h>
#include <sys/ioctl.h>
-#define HAS_TEST_AND_SET
-
-typedef unsigned char slock_t;
-
#define AF_UNIX 10 /* no domain sockets on BeOS */
/* Beos doesn't have all the required getrusage fields */
diff --git a/src/include/port/bsdi.h b/src/include/port/bsdi.h
index 2b19bf9482b..e69de29bb2d 100644
--- a/src/include/port/bsdi.h
+++ b/src/include/port/bsdi.h
@@ -1,12 +0,0 @@
-#if defined(__i386__) || defined(__x86_64__)
-typedef unsigned char slock_t;
-#endif
-#if defined(__ia64)
-typedef unsigned int slock_t;
-#endif
-#if defined(__sparc__)
-typedef unsigned char slock_t;
-#endif
-
-#define HAS_TEST_AND_SET
-
diff --git a/src/include/port/cygwin.h b/src/include/port/cygwin.h
index 66bb9acc5d0..1a1be83b8f4 100644
--- a/src/include/port/cygwin.h
+++ b/src/include/port/cygwin.h
@@ -1,7 +1,4 @@
-/* $PostgreSQL: pgsql/src/include/port/cygwin.h,v 1.5 2003/11/29 19:52:08 pgsql Exp $ */
-
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
+/* $PostgreSQL: pgsql/src/include/port/cygwin.h,v 1.6 2003/12/23 03:31:30 momjian Exp $ */
#include <cygwin/version.h>
diff --git a/src/include/port/darwin.h b/src/include/port/darwin.h
index 0d35a8a2f49..06c559d2ba8 100644
--- a/src/include/port/darwin.h
+++ b/src/include/port/darwin.h
@@ -1,13 +1 @@
#define __darwin__ 1
-
-#if defined(__ppc__)
-#define HAS_TEST_AND_SET
-#endif
-
-#if defined(__ppc__)
-typedef unsigned int slock_t;
-
-#else
-typedef unsigned char slock_t;
-
-#endif
diff --git a/src/include/port/freebsd.h b/src/include/port/freebsd.h
index ae36a5cd4e2..e69de29bb2d 100644
--- a/src/include/port/freebsd.h
+++ b/src/include/port/freebsd.h
@@ -1,51 +0,0 @@
-#if defined(__i386__) || defined(__x86_64__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__ia64)
-#define HAS_TEST_AND_SET
-typedef unsigned int slock_t;
-#endif
-
-#if defined(__sparc__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__vax__)
-#define NEED_VAX_TAS_ASM
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__ns32k__)
-#define NEED_NS32K_TAS_ASM
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__m68k__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__arm__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__mips__)
-/* # undef HAS_TEST_AND_SET */
-#endif
-
-#if defined(__alpha__)
-#define HAS_TEST_AND_SET
-typedef unsigned long slock_t;
-#endif
-
-#if defined(__powerpc__)
-#define HAS_TEST_AND_SET
-typedef unsigned int slock_t;
-
-#endif
diff --git a/src/include/port/hpux.h b/src/include/port/hpux.h
index 28883ad4b10..a1d5afa3aec 100644
--- a/src/include/port/hpux.h
+++ b/src/include/port/hpux.h
@@ -10,21 +10,12 @@
#if defined(__hppa)
-#define HAS_TEST_AND_SET
-typedef struct
-{
- int sema[4];
-} slock_t;
-
#ifndef BYTE_ORDER
#define BYTE_ORDER BIG_ENDIAN
#endif
#elif defined(__ia64)
-#define HAS_TEST_AND_SET
-typedef unsigned int slock_t;
-
#ifndef BYTE_ORDER
#define BYTE_ORDER LITTLE_ENDIAN
#endif
diff --git a/src/include/port/irix5.h b/src/include/port/irix5.h
index aec62c87c25..e69de29bb2d 100644
--- a/src/include/port/irix5.h
+++ b/src/include/port/irix5.h
@@ -1,3 +0,0 @@
-#define HAS_TEST_AND_SET
-
-typedef unsigned long slock_t;
diff --git a/src/include/port/linux.h b/src/include/port/linux.h
index 159db3194f1..e69de29bb2d 100644
--- a/src/include/port/linux.h
+++ b/src/include/port/linux.h
@@ -1,51 +0,0 @@
-#if defined(__i386__) || defined(__x86_64__)
-typedef unsigned char slock_t;
-
-#define HAS_TEST_AND_SET
-
-#elif defined(__sparc__)
-typedef unsigned char slock_t;
-
-#define HAS_TEST_AND_SET
-
-#elif defined(__powerpc64__)
-typedef unsigned long slock_t;
-
-#define HAS_TEST_AND_SET
-
-#elif defined(__powerpc__)
-typedef unsigned int slock_t;
-
-#define HAS_TEST_AND_SET
-
-#elif defined(__alpha__)
-typedef long int slock_t;
-
-#define HAS_TEST_AND_SET
-
-#elif defined(__mips__)
-typedef unsigned int slock_t;
-
-#define HAS_TEST_AND_SET
-
-#elif defined(__arm__)
-typedef unsigned char slock_t;
-
-#define HAS_TEST_AND_SET
-
-#elif defined(__ia64__)
-typedef unsigned int slock_t;
-
-#define HAS_TEST_AND_SET
-
-#elif defined(__s390__) || defined(__s390x__)
-typedef unsigned int slock_t;
-
-#define HAS_TEST_AND_SET
-
-#elif defined(__mc68000__)
-typedef unsigned char slock_t;
-
-#define HAS_TEST_AND_SET
-
-#endif
diff --git a/src/include/port/netbsd.h b/src/include/port/netbsd.h
index ae36a5cd4e2..e69de29bb2d 100644
--- a/src/include/port/netbsd.h
+++ b/src/include/port/netbsd.h
@@ -1,51 +0,0 @@
-#if defined(__i386__) || defined(__x86_64__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__ia64)
-#define HAS_TEST_AND_SET
-typedef unsigned int slock_t;
-#endif
-
-#if defined(__sparc__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__vax__)
-#define NEED_VAX_TAS_ASM
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__ns32k__)
-#define NEED_NS32K_TAS_ASM
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__m68k__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__arm__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__mips__)
-/* # undef HAS_TEST_AND_SET */
-#endif
-
-#if defined(__alpha__)
-#define HAS_TEST_AND_SET
-typedef unsigned long slock_t;
-#endif
-
-#if defined(__powerpc__)
-#define HAS_TEST_AND_SET
-typedef unsigned int slock_t;
-
-#endif
diff --git a/src/include/port/nextstep.h b/src/include/port/nextstep.h
index c21594dcadb..12ce8912379 100644
--- a/src/include/port/nextstep.h
+++ b/src/include/port/nextstep.h
@@ -15,4 +15,3 @@ typedef int sigset_t;
#endif
#define NO_WAITPID
-typedef struct mutex slock_t;
diff --git a/src/include/port/openbsd.h b/src/include/port/openbsd.h
index ae36a5cd4e2..e69de29bb2d 100644
--- a/src/include/port/openbsd.h
+++ b/src/include/port/openbsd.h
@@ -1,51 +0,0 @@
-#if defined(__i386__) || defined(__x86_64__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__ia64)
-#define HAS_TEST_AND_SET
-typedef unsigned int slock_t;
-#endif
-
-#if defined(__sparc__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__vax__)
-#define NEED_VAX_TAS_ASM
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__ns32k__)
-#define NEED_NS32K_TAS_ASM
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__m68k__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__arm__)
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-#endif
-
-#if defined(__mips__)
-/* # undef HAS_TEST_AND_SET */
-#endif
-
-#if defined(__alpha__)
-#define HAS_TEST_AND_SET
-typedef unsigned long slock_t;
-#endif
-
-#if defined(__powerpc__)
-#define HAS_TEST_AND_SET
-typedef unsigned int slock_t;
-
-#endif
diff --git a/src/include/port/osf.h b/src/include/port/osf.h
index 6dfe3ea9b82..2368f3b5930 100644
--- a/src/include/port/osf.h
+++ b/src/include/port/osf.h
@@ -1,7 +1,2 @@
#define NOFIXADE
#define DISABLE_XOPEN_NLS
-#define HAS_TEST_AND_SET
- /* #include <sys/mman.h> */ /* for msemaphore */
-/*typedef msemaphore slock_t;*/
-#include <alpha/builtins.h>
-typedef volatile long slock_t;
diff --git a/src/include/port/qnx4.h b/src/include/port/qnx4.h
index 291abed0de7..585bee010c3 100644
--- a/src/include/port/qnx4.h
+++ b/src/include/port/qnx4.h
@@ -5,8 +5,6 @@
#include <unix.h>
#include <sys/select.h> /* for select */
-#define HAS_TEST_AND_SET
-
#undef HAVE_GETRUSAGE
#define strncasecmp strnicmp
@@ -22,8 +20,6 @@ extern unsigned char __nan[8];
typedef u_short ushort;
-typedef unsigned char slock_t;
-
extern int isnan(double dsrc);
extern long random(void);
diff --git a/src/include/port/sco.h b/src/include/port/sco.h
index 861f5ada2fe..b4e975c89d0 100644
--- a/src/include/port/sco.h
+++ b/src/include/port/sco.h
@@ -1,17 +1,8 @@
/* see src/backend/libpq/pqcomm.c */
#define SCO_ACCEPT_BUG
-#define HAS_TEST_AND_SET
-
#define USE_UNIVEL_CC
-#if defined(__ia64)
-typedef unsigned int slock_t;
-#else
-typedef unsigned char slock_t;
-#endif
-
-
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321
#endif
diff --git a/src/include/port/solaris.h b/src/include/port/solaris.h
index 6a234265bc1..8476fe362c8 100644
--- a/src/include/port/solaris.h
+++ b/src/include/port/solaris.h
@@ -1,7 +1,4 @@
-/* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.9 2003/11/29 19:52:08 pgsql Exp $ */
-
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
+/* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.10 2003/12/23 03:31:30 momjian Exp $ */
/*
* Sort this out for all operating systems some time. The __xxx
diff --git a/src/include/port/sunos4.h b/src/include/port/sunos4.h
index 5d7e911cf34..f7545fc6fae 100644
--- a/src/include/port/sunos4.h
+++ b/src/include/port/sunos4.h
@@ -1,6 +1,3 @@
-#define HAS_TEST_AND_SET
-typedef unsigned char slock_t;
-
/* sprintf() returns char *, not int, on SunOS 4.1.x */
#define SPRINTF_CHAR
diff --git a/src/include/port/svr4.h b/src/include/port/svr4.h
index 2c6e2b4e713..96d70623da6 100644
--- a/src/include/port/svr4.h
+++ b/src/include/port/svr4.h
@@ -3,11 +3,3 @@
#define BYTE_ORDER BIG_ENDIAN
#endif
#endif
-
-#ifdef sinix
-#define HAS_TEST_AND_SET
-
-#include "abi_mutex.h"
-typedef abilock_t slock_t;
-
-#endif
diff --git a/src/include/port/univel.h b/src/include/port/univel.h
index 83dd6cc03f9..100b9973d9a 100644
--- a/src/include/port/univel.h
+++ b/src/include/port/univel.h
@@ -6,13 +6,6 @@
***************************************/
#define USE_UNIVEL_CC
-#if defined(__ia64)
-typedef unsigned int slock_t;
-#else
-typedef unsigned char slock_t;
-#endif
-
-
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321
#endif
diff --git a/src/include/port/unixware.h b/src/include/port/unixware.h
index b4818fa20c4..600b7cd4f86 100644
--- a/src/include/port/unixware.h
+++ b/src/include/port/unixware.h
@@ -9,13 +9,6 @@
***************************************/
#define USE_UNIVEL_CC
-#if defined(__ia64)
-typedef unsigned int slock_t;
-#else
-typedef unsigned char slock_t;
-#endif
-
-
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321
#endif
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 2456d573b5b..52bbfbebab9 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -63,7 +63,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.119 2003/12/23 00:32:06 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/s_lock.h,v 1.120 2003/12/23 03:31:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -73,12 +73,11 @@
#include "storage/pg_sema.h"
-#if defined(HAS_TEST_AND_SET)
-
-
#if defined(__GNUC__) || defined(__ICC)
/*************************************************************************
* All the gcc inlines
+ * Gcc consistently defines the CPU as __cpu__.
+ * Other compilers use __cpu or __cpu__ so we test for both in those cases.
*/
/*
@@ -95,6 +94,9 @@
#if defined(__i386__) || defined(__x86_64__) /* AMD Opteron */
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
+
#define TAS(lock) tas(lock)
static __inline__ int
@@ -114,7 +116,10 @@ tas(volatile slock_t *lock)
/* Intel Itanium */
-#if defined(__ia64__) || defined(__ia64)
+#if defined(__ia64__) || defined(__ia64) /* __ia64 is used by ICC the compiler? */
+typedef unsigned int slock_t;
+#define HAS_TEST_AND_SET
+
#define TAS(lock) tas(lock)
static __inline__ int
@@ -135,6 +140,9 @@ tas(volatile slock_t *lock)
#if defined(__arm__) || defined(__arm)
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
+
#define TAS(lock) tas(lock)
static __inline__ int
@@ -153,9 +161,10 @@ tas(volatile slock_t *lock)
#if defined(__s390__) && !defined(__s390x__)
-/*
- * S/390 Linux
- */
+typedef unsigned int slock_t;
+#define HAS_TEST_AND_SET
+
+/* S/390 Linux */
#define TAS(lock) tas(lock)
static __inline__ int
@@ -179,9 +188,9 @@ tas(volatile slock_t *lock)
#endif /* __s390__ */
#if defined(__s390x__)
-/*
- * S/390x Linux (64-bit zSeries)
- */
+typedef unsigned int slock_t;
+#define HAS_TEST_AND_SET
+/* S/390x Linux (64-bit zSeries) */
#define TAS(lock) tas(lock)
static __inline__ int
@@ -206,6 +215,8 @@ tas(volatile slock_t *lock)
#if defined(__sparc__)
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
#define TAS(lock) tas(lock)
static __inline__ int
@@ -223,6 +234,14 @@ tas(volatile slock_t *lock)
#endif /* __sparc__ */
#if defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
+/* Is this correct? */
+#ifndef defined(__powerpc64__)
+typedef unsigned int slock_t;
+#else
+typedef unsigned long slock_t;
+#endif
+#define HAS_TEST_AND_SET
+
#define TAS(lock) tas(lock)
/*
* NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002,
@@ -255,10 +274,22 @@ tas(volatile slock_t *lock)
return _res;
}
+/*
+ * PowerPC S_UNLOCK is almost standard but requires a "sync" instruction.
+ */
+#define S_UNLOCK(lock) \
+do \
+{\
+ __asm__ __volatile__ (" sync \n"); \
+ *((volatile slock_t *) (lock)) = 0; \
+} while (0)
+
#endif /* powerpc */
#if defined(__mc68000__) && defined(__linux__)
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
#define TAS(lock) tas(lock)
static __inline__ int
@@ -280,25 +311,13 @@ tas(volatile slock_t *lock)
#endif /* defined(__mc68000__) && defined(__linux__) */
-#if defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__)
-/*
- * PowerPC S_UNLOCK is almost standard but requires a "sync" instruction.
- */
-#define S_UNLOCK(lock) \
-do \
-{\
- __asm__ __volatile__ (" sync \n"); \
- *((volatile slock_t *) (lock)) = 0; \
-} while (0)
-
-#endif /* powerpc */
-
-
-#if defined(NEED_VAX_TAS_ASM)
+#if defined(__vax__)
/*
* VAXen -- even multiprocessor ones
* (thanks to Tom Ivar Helbekkmo)
*/
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
#define TAS(lock) tas(lock)
static __inline__ int
@@ -317,10 +336,12 @@ tas(volatile slock_t *lock)
return _res;
}
-#endif /* NEED_VAX_TAS_ASM */
+#endif /* __vax__ */
-#if defined(NEED_NS32K_TAS_ASM)
+#if defined(__ns32k__)
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
#define TAS(lock) tas(lock)
static __inline__ int
@@ -335,54 +356,18 @@ tas(volatile slock_t *lock)
return _res;
}
-#endif /* NEED_NS32K_TAS_ASM */
-
-
-
-#else /* !__GNUC__ */
-
-/***************************************************************************
- * All non-gcc inlines
- */
-
-#if defined(USE_UNIVEL_CC)
-#define TAS(lock) tas(lock)
-
-asm int
-tas(volatile slock_t *s_lock)
-{
-/* UNIVEL wants %mem in column 1, so we don't pg_indent this file */
-%mem s_lock
- pushl %ebx
- movl s_lock, %ebx
- movl $255, %eax
- lock
- xchgb %al, (%ebx)
- popl %ebx
-}
-
-#endif /* defined(USE_UNIVEL_CC) */
-
-#endif /* defined(__GNUC__) */
-
-
-
-/*************************************************************************
- * These are the platforms that have only one compiler, or do not use inline
- * assembler (and hence have common code for gcc and non-gcc compilers,
- * if both are available).
- */
+#endif /* __ns32k__ */
#if defined(__alpha) || defined(__alpha__)
-
/*
* Correct multi-processor locking methods are explained in section 5.5.3
* of the Alpha AXP Architecture Handbook, which at this writing can be
* found at ftp://ftp.netbsd.org/pub/NetBSD/misc/dec-docs/index.html.
* For gcc we implement the handbook's code directly with inline assembler.
*/
-#if defined(__GNUC__)
+typedef unsigned long slock_t;
+#define HAS_TEST_AND_SET
#define TAS(lock) tas(lock)
#define S_UNLOCK(lock) \
@@ -416,8 +401,69 @@ tas(volatile slock_t *lock)
return (int) _res;
}
-#else /* !defined(__GNUC__) */
+#endif /* __alpha || __alpha__ */
+
+
+/* These live in s_lock.c, but only for gcc */
+
+#if defined(__m68k__)
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
+#endif
+
+#ifdef sinix /* This symbol is not protected with __, for SvR4 port */
+#include "abi_mutex.h"
+typedef abilock_t slock_t;
+#define HAS_TEST_AND_SET
+#endif
+
+
+/* These are in s_lock.c */
+
+#if defined(__m68k__)
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
+#endif
+
+#if defined(__mips__) && !defined(__sgi)
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
+#endif
+
+#endif /* __GNUC__ */
+
+
+
+/***************************************************************************
+ * Uses non-gcc inline assembly:
+ */
+
+#if !defined(HAS_TEST_AND_SET)
+
+#if defined(USE_UNIVEL_CC)
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
+#define TAS(lock) tas(lock)
+
+asm int
+tas(volatile slock_t *s_lock)
+{
+/* UNIVEL wants %mem in column 1, so we don't pg_indent this file */
+%mem s_lock
+ pushl %ebx
+ movl s_lock, %ebx
+ movl $255, %eax
+ lock
+ xchgb %al, (%ebx)
+ popl %ebx
+}
+
+#endif /* defined(USE_UNIVEL_CC) */
+
+#if defined(__alpha) || defined(__alpha__)
+typedef volatile long slock_t;
+#define HAS_TEST_AND_SET
/*
* The Tru64 compiler doesn't support gcc-style inline asm, but it does
* have some builtin functions that accomplish much the same results.
@@ -428,17 +474,19 @@ tas(volatile slock_t *lock)
*/
#include <alpha/builtins.h>
-
#define S_INIT_LOCK(lock) (*(lock) = 0)
#define TAS(lock) (__LOCK_LONG_RETRY((lock), 1) == 0)
#define S_UNLOCK(lock) __UNLOCK_LONG(lock)
-#endif /* defined(__GNUC__) */
-
#endif /* __alpha || __alpha__ */
#if defined(__hppa)
+typedef struct
+{
+ int sema[4];
+} slock_t;
+#define HAS_TEST_AND_SET
/*
* HP's PA-RISC
*
@@ -462,7 +510,10 @@ tas(volatile slock_t *lock)
#endif /* __hppa */
+
#if defined(__QNX__) && defined(__WATCOMC__)
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
/*
* QNX 4 using WATCOM C
*/
@@ -490,6 +541,8 @@ extern slock_t wc_tas(volatile slock_t *lock);
* assembly from his NECEWS SVR4 port, but we probably ought to retain this
* for the R3000 chips out there.
*/
+typedef unsigned long slock_t;
+#define HAS_TEST_AND_SET
#include "mutex.h"
#define TAS(lock) (test_and_set(lock,1))
#define S_UNLOCK(lock) (test_then_and(lock,0))
@@ -497,6 +550,7 @@ extern slock_t wc_tas(volatile slock_t *lock);
#define S_LOCK_FREE(lock) (test_then_add(lock,0) == 0)
#endif /* __sgi */
+
#if defined(sinix)
/*
* SINIX / Reliant UNIX
@@ -504,6 +558,7 @@ extern slock_t wc_tas(volatile slock_t *lock);
* member. (Basically same as SGI)
*
*/
+#define HAS_TEST_AND_SET
#define TAS(lock) (!acquire_lock(lock))
#define S_UNLOCK(lock) release_lock(lock)
#define S_INIT_LOCK(lock) init_lock(lock)
@@ -517,16 +572,15 @@ extern slock_t wc_tas(volatile slock_t *lock);
*
* Note that slock_t on POWER/POWER2/PowerPC is int instead of char
*/
+#define HAS_TEST_AND_SET
#define TAS(lock) _check_lock(lock, 0, 1)
#define S_UNLOCK(lock) _clear_lock(lock, 0)
#endif /* _AIX */
#if defined (nextstep)
-/*
- * NEXTSTEP (mach)
- * slock_t is defined as a struct mutex.
- */
+typedef struct mutex slock_t;
+#define HAS_TEST_AND_SET
#define S_LOCK(lock) mutex_lock(lock)
#define S_UNLOCK(lock) mutex_unlock(lock)
@@ -535,13 +589,28 @@ extern slock_t wc_tas(volatile slock_t *lock);
#define S_LOCK_FREE(alock) ((alock)->lock == 0)
#endif /* nextstep */
+/* These are in s_lock.c */
+#if defined(sun3)
+typedef unsigned char slock_t;
+#define HAS_TEST_AND_SET
+#endif
+
+#if defined(__sparc__) || defined(__sparc)
+#define HAS_TEST_AND_SET
+typedef unsigned char slock_t;
+#endif
+
+
+#endif /* !defined(HAS_TEST_AND_SET */
-#else /* HAS_TEST_AND_SET */
+
+#ifndef HAS_TEST_AND_SET
#ifdef HAVE_SPINLOCKS
#error PostgreSQL does not have native spinlock support on this platform. To continue the compilation, rerun configure using --disable-spinlocks. However, performance will be poor. Please report this to [email protected].
-#endif
+
+#else
/*
* Fake spinlock implementation using semaphores --- slow and prone
@@ -560,7 +629,8 @@ extern int tas_sema(volatile slock_t *lock);
#define S_INIT_LOCK(lock) s_init_lock_sema(lock)
#define TAS(lock) tas_sema(lock)
-#endif /* HAS_TEST_AND_SET */
+#endif /* HAVE_SPINLOCKS */
+#endif /* HAS_TEST_AND_SET */