Commit 69f2e9b0 authored by Bruce Momjian's avatar Bruce Momjian

Move slock_t typdefs into s_lock.h from include/port files for

centralization and easier maintanence.
parent dcae5781
/*- /*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1990 The Regents of the University of California. * Portions Copyright (c) 1990 The Regents of the University of California.
* All rights reserved. * All rights reserved.
......
/*- /*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1990 The Regents of the University of California. * Portions Copyright (c) 1990 The Regents of the University of California.
* All rights reserved. * All rights reserved.
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * 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 @@ ...@@ -17,7 +17,6 @@
#include <sys/time.h> #include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#include "storage/s_lock.h" #include "storage/s_lock.h"
...@@ -118,6 +117,9 @@ s_lock(volatile slock_t *lock, const char *file, int line) ...@@ -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 * Various TAS implementations that cannot live in s_lock.h as no inline
* definition exists (yet). * definition exists (yet).
* In the future, get rid of tas.[cso] and fold it into this file. * 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.
*/ */
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* *
* IDENTIFICATION * 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 @@ ...@@ -25,6 +25,7 @@
#include "storage/lwlock.h" #include "storage/lwlock.h"
#include "storage/pg_sema.h" #include "storage/pg_sema.h"
#include "storage/spin.h" #include "storage/spin.h"
#include "storage/s_lock.h"
#ifdef HAS_TEST_AND_SET #ifdef HAS_TEST_AND_SET
......
#define CLASS_CONFLICT #define CLASS_CONFLICT
#define DISABLE_XOPEN_NLS #define DISABLE_XOPEN_NLS
#define HAS_TEST_AND_SET
typedef unsigned int slock_t;
#include <sys/machine.h> /* ENDIAN definitions for network #include <sys/machine.h> /* ENDIAN definitions for network
* communication */ * communication */
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
#include <kernel/image.h> #include <kernel/image.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
#define AF_UNIX 10 /* no domain sockets on BeOS */ #define AF_UNIX 10 /* no domain sockets on BeOS */
/* Beos doesn't have all the required getrusage fields */ /* Beos doesn't have all the required getrusage fields */
......
#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
/* $PostgreSQL: pgsql/src/include/port/cygwin.h,v 1.5 2003/11/29 19:52:08 pgsql Exp $ */ /* $PostgreSQL: pgsql/src/include/port/cygwin.h,v 1.6 2003/12/23 03:31:30 momjian Exp $ */
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
#include <cygwin/version.h> #include <cygwin/version.h>
......
#define __darwin__ 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
#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
...@@ -10,21 +10,12 @@ ...@@ -10,21 +10,12 @@
#if defined(__hppa) #if defined(__hppa)
#define HAS_TEST_AND_SET
typedef struct
{
int sema[4];
} slock_t;
#ifndef BYTE_ORDER #ifndef BYTE_ORDER
#define BYTE_ORDER BIG_ENDIAN #define BYTE_ORDER BIG_ENDIAN
#endif #endif
#elif defined(__ia64) #elif defined(__ia64)
#define HAS_TEST_AND_SET
typedef unsigned int slock_t;
#ifndef BYTE_ORDER #ifndef BYTE_ORDER
#define BYTE_ORDER LITTLE_ENDIAN #define BYTE_ORDER LITTLE_ENDIAN
#endif #endif
......
#define HAS_TEST_AND_SET
typedef unsigned long slock_t;
#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
#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
...@@ -15,4 +15,3 @@ typedef int sigset_t; ...@@ -15,4 +15,3 @@ typedef int sigset_t;
#endif #endif
#define NO_WAITPID #define NO_WAITPID
typedef struct mutex slock_t;
#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
#define NOFIXADE #define NOFIXADE
#define DISABLE_XOPEN_NLS #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;
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#include <unix.h> #include <unix.h>
#include <sys/select.h> /* for select */ #include <sys/select.h> /* for select */
#define HAS_TEST_AND_SET
#undef HAVE_GETRUSAGE #undef HAVE_GETRUSAGE
#define strncasecmp strnicmp #define strncasecmp strnicmp
...@@ -22,8 +20,6 @@ extern unsigned char __nan[8]; ...@@ -22,8 +20,6 @@ extern unsigned char __nan[8];
typedef u_short ushort; typedef u_short ushort;
typedef unsigned char slock_t;
extern int isnan(double dsrc); extern int isnan(double dsrc);
extern long random(void); extern long random(void);
......
/* see src/backend/libpq/pqcomm.c */ /* see src/backend/libpq/pqcomm.c */
#define SCO_ACCEPT_BUG #define SCO_ACCEPT_BUG
#define HAS_TEST_AND_SET
#define USE_UNIVEL_CC #define USE_UNIVEL_CC
#if defined(__ia64)
typedef unsigned int slock_t;
#else
typedef unsigned char slock_t;
#endif
#ifndef BIG_ENDIAN #ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321 #define BIG_ENDIAN 4321
#endif #endif
......
/* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.9 2003/11/29 19:52:08 pgsql Exp $ */ /* $PostgreSQL: pgsql/src/include/port/solaris.h,v 1.10 2003/12/23 03:31:30 momjian Exp $ */
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
/* /*
* Sort this out for all operating systems some time. The __xxx * Sort this out for all operating systems some time. The __xxx
......
#define HAS_TEST_AND_SET
typedef unsigned char slock_t;
/* sprintf() returns char *, not int, on SunOS 4.1.x */ /* sprintf() returns char *, not int, on SunOS 4.1.x */
#define SPRINTF_CHAR #define SPRINTF_CHAR
......
...@@ -3,11 +3,3 @@ ...@@ -3,11 +3,3 @@
#define BYTE_ORDER BIG_ENDIAN #define BYTE_ORDER BIG_ENDIAN
#endif #endif
#endif #endif
#ifdef sinix
#define HAS_TEST_AND_SET
#include "abi_mutex.h"
typedef abilock_t slock_t;
#endif
...@@ -6,13 +6,6 @@ ...@@ -6,13 +6,6 @@
***************************************/ ***************************************/
#define USE_UNIVEL_CC #define USE_UNIVEL_CC
#if defined(__ia64)
typedef unsigned int slock_t;
#else
typedef unsigned char slock_t;
#endif
#ifndef BIG_ENDIAN #ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321 #define BIG_ENDIAN 4321
#endif #endif
......
...@@ -9,13 +9,6 @@ ...@@ -9,13 +9,6 @@
***************************************/ ***************************************/
#define USE_UNIVEL_CC #define USE_UNIVEL_CC
#if defined(__ia64)
typedef unsigned int slock_t;
#else
typedef unsigned char slock_t;
#endif
#ifndef BIG_ENDIAN #ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321 #define BIG_ENDIAN 4321
#endif #endif
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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 @@ ...@@ -73,12 +73,11 @@
#include "storage/pg_sema.h" #include "storage/pg_sema.h"
#if defined(HAS_TEST_AND_SET)
#if defined(__GNUC__) || defined(__ICC) #if defined(__GNUC__) || defined(__ICC)
/************************************************************************* /*************************************************************************
* All the gcc inlines * 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 @@ ...@@ -95,6 +94,9 @@
#if defined(__i386__) || defined(__x86_64__) /* AMD Opteron */ #if defined(__i386__) || defined(__x86_64__) /* AMD Opteron */
typedef unsigned char slock_t;
#define HAS_TEST_AND_SET
#define TAS(lock) tas(lock) #define TAS(lock) tas(lock)
static __inline__ int static __inline__ int
...@@ -114,7 +116,10 @@ tas(volatile slock_t *lock) ...@@ -114,7 +116,10 @@ tas(volatile slock_t *lock)
/* Intel Itanium */ /* 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) #define TAS(lock) tas(lock)
static __inline__ int static __inline__ int
...@@ -135,6 +140,9 @@ tas(volatile slock_t *lock) ...@@ -135,6 +140,9 @@ tas(volatile slock_t *lock)
#if defined(__arm__) || defined(__arm) #if defined(__arm__) || defined(__arm)
typedef unsigned char slock_t;
#define HAS_TEST_AND_SET
#define TAS(lock) tas(lock) #define TAS(lock) tas(lock)
static __inline__ int static __inline__ int
...@@ -153,9 +161,10 @@ tas(volatile slock_t *lock) ...@@ -153,9 +161,10 @@ tas(volatile slock_t *lock)
#if defined(__s390__) && !defined(__s390x__) #if defined(__s390__) && !defined(__s390x__)
/* typedef unsigned int slock_t;
* S/390 Linux #define HAS_TEST_AND_SET
*/
/* S/390 Linux */
#define TAS(lock) tas(lock) #define TAS(lock) tas(lock)
static __inline__ int static __inline__ int
...@@ -179,9 +188,9 @@ tas(volatile slock_t *lock) ...@@ -179,9 +188,9 @@ tas(volatile slock_t *lock)
#endif /* __s390__ */ #endif /* __s390__ */
#if defined(__s390x__) #if defined(__s390x__)
/* typedef unsigned int slock_t;
* S/390x Linux (64-bit zSeries) #define HAS_TEST_AND_SET
*/ /* S/390x Linux (64-bit zSeries) */
#define TAS(lock) tas(lock) #define TAS(lock) tas(lock)
static __inline__ int static __inline__ int
...@@ -206,6 +215,8 @@ tas(volatile slock_t *lock) ...@@ -206,6 +215,8 @@ tas(volatile slock_t *lock)
#if defined(__sparc__) #if defined(__sparc__)
typedef unsigned char slock_t;
#define HAS_TEST_AND_SET
#define TAS(lock) tas(lock) #define TAS(lock) tas(lock)
static __inline__ int static __inline__ int
...@@ -223,6 +234,14 @@ tas(volatile slock_t *lock) ...@@ -223,6 +234,14 @@ tas(volatile slock_t *lock)
#endif /* __sparc__ */ #endif /* __sparc__ */
#if defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__) #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) #define TAS(lock) tas(lock)
/* /*
* NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002, * NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002,
...@@ -255,10 +274,22 @@ tas(volatile slock_t *lock) ...@@ -255,10 +274,22 @@ tas(volatile slock_t *lock)
return _res; 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 */ #endif /* powerpc */
#if defined(__mc68000__) && defined(__linux__) #if defined(__mc68000__) && defined(__linux__)
typedef unsigned char slock_t;
#define HAS_TEST_AND_SET
#define TAS(lock) tas(lock) #define TAS(lock) tas(lock)
static __inline__ int static __inline__ int
...@@ -280,25 +311,13 @@ tas(volatile slock_t *lock) ...@@ -280,25 +311,13 @@ tas(volatile slock_t *lock)
#endif /* defined(__mc68000__) && defined(__linux__) */ #endif /* defined(__mc68000__) && defined(__linux__) */
#if defined(__ppc__) || defined(__powerpc__) || defined(__powerpc64__) #if defined(__vax__)
/*
* 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)
/* /*
* VAXen -- even multiprocessor ones * VAXen -- even multiprocessor ones
* (thanks to Tom Ivar Helbekkmo) * (thanks to Tom Ivar Helbekkmo)
*/ */
typedef unsigned char slock_t;
#define HAS_TEST_AND_SET
#define TAS(lock) tas(lock) #define TAS(lock) tas(lock)
static __inline__ int static __inline__ int
...@@ -317,10 +336,12 @@ tas(volatile slock_t *lock) ...@@ -317,10 +336,12 @@ tas(volatile slock_t *lock)
return _res; 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) #define TAS(lock) tas(lock)
static __inline__ int static __inline__ int
...@@ -335,54 +356,18 @@ tas(volatile slock_t *lock) ...@@ -335,54 +356,18 @@ tas(volatile slock_t *lock)
return _res; return _res;
} }
#endif /* NEED_NS32K_TAS_ASM */ #endif /* __ns32k__ */
#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).
*/
#if defined(__alpha) || defined(__alpha__) #if defined(__alpha) || defined(__alpha__)
/* /*
* Correct multi-processor locking methods are explained in section 5.5.3 * Correct multi-processor locking methods are explained in section 5.5.3
* of the Alpha AXP Architecture Handbook, which at this writing can be * 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. * 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. * 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 TAS(lock) tas(lock)
#define S_UNLOCK(lock) \ #define S_UNLOCK(lock) \
...@@ -416,8 +401,69 @@ tas(volatile slock_t *lock) ...@@ -416,8 +401,69 @@ tas(volatile slock_t *lock)
return (int) _res; 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 * The Tru64 compiler doesn't support gcc-style inline asm, but it does
* have some builtin functions that accomplish much the same results. * have some builtin functions that accomplish much the same results.
...@@ -428,17 +474,19 @@ tas(volatile slock_t *lock) ...@@ -428,17 +474,19 @@ tas(volatile slock_t *lock)
*/ */
#include <alpha/builtins.h> #include <alpha/builtins.h>
#define S_INIT_LOCK(lock) (*(lock) = 0) #define S_INIT_LOCK(lock) (*(lock) = 0)
#define TAS(lock) (__LOCK_LONG_RETRY((lock), 1) == 0) #define TAS(lock) (__LOCK_LONG_RETRY((lock), 1) == 0)
#define S_UNLOCK(lock) __UNLOCK_LONG(lock) #define S_UNLOCK(lock) __UNLOCK_LONG(lock)
#endif /* defined(__GNUC__) */
#endif /* __alpha || __alpha__ */ #endif /* __alpha || __alpha__ */
#if defined(__hppa) #if defined(__hppa)
typedef struct
{
int sema[4];
} slock_t;
#define HAS_TEST_AND_SET
/* /*
* HP's PA-RISC * HP's PA-RISC
* *
...@@ -462,7 +510,10 @@ tas(volatile slock_t *lock) ...@@ -462,7 +510,10 @@ tas(volatile slock_t *lock)
#endif /* __hppa */ #endif /* __hppa */
#if defined(__QNX__) && defined(__WATCOMC__) #if defined(__QNX__) && defined(__WATCOMC__)
typedef unsigned char slock_t;
#define HAS_TEST_AND_SET
/* /*
* QNX 4 using WATCOM C * QNX 4 using WATCOM C
*/ */
...@@ -490,6 +541,8 @@ extern slock_t wc_tas(volatile slock_t *lock); ...@@ -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 * assembly from his NECEWS SVR4 port, but we probably ought to retain this
* for the R3000 chips out there. * for the R3000 chips out there.
*/ */
typedef unsigned long slock_t;
#define HAS_TEST_AND_SET
#include "mutex.h" #include "mutex.h"
#define TAS(lock) (test_and_set(lock,1)) #define TAS(lock) (test_and_set(lock,1))
#define S_UNLOCK(lock) (test_then_and(lock,0)) #define S_UNLOCK(lock) (test_then_and(lock,0))
...@@ -497,6 +550,7 @@ extern slock_t wc_tas(volatile slock_t *lock); ...@@ -497,6 +550,7 @@ extern slock_t wc_tas(volatile slock_t *lock);
#define S_LOCK_FREE(lock) (test_then_add(lock,0) == 0) #define S_LOCK_FREE(lock) (test_then_add(lock,0) == 0)
#endif /* __sgi */ #endif /* __sgi */
#if defined(sinix) #if defined(sinix)
/* /*
* SINIX / Reliant UNIX * SINIX / Reliant UNIX
...@@ -504,6 +558,7 @@ extern slock_t wc_tas(volatile slock_t *lock); ...@@ -504,6 +558,7 @@ extern slock_t wc_tas(volatile slock_t *lock);
* member. (Basically same as SGI) * member. (Basically same as SGI)
* *
*/ */
#define HAS_TEST_AND_SET
#define TAS(lock) (!acquire_lock(lock)) #define TAS(lock) (!acquire_lock(lock))
#define S_UNLOCK(lock) release_lock(lock) #define S_UNLOCK(lock) release_lock(lock)
#define S_INIT_LOCK(lock) init_lock(lock) #define S_INIT_LOCK(lock) init_lock(lock)
...@@ -517,16 +572,15 @@ extern slock_t wc_tas(volatile slock_t *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 * 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 TAS(lock) _check_lock(lock, 0, 1)
#define S_UNLOCK(lock) _clear_lock(lock, 0) #define S_UNLOCK(lock) _clear_lock(lock, 0)
#endif /* _AIX */ #endif /* _AIX */
#if defined (nextstep) #if defined (nextstep)
/* typedef struct mutex slock_t;
* NEXTSTEP (mach) #define HAS_TEST_AND_SET
* slock_t is defined as a struct mutex.
*/
#define S_LOCK(lock) mutex_lock(lock) #define S_LOCK(lock) mutex_lock(lock)
#define S_UNLOCK(lock) mutex_unlock(lock) #define S_UNLOCK(lock) mutex_unlock(lock)
...@@ -535,13 +589,28 @@ extern slock_t wc_tas(volatile slock_t *lock); ...@@ -535,13 +589,28 @@ extern slock_t wc_tas(volatile slock_t *lock);
#define S_LOCK_FREE(alock) ((alock)->lock == 0) #define S_LOCK_FREE(alock) ((alock)->lock == 0)
#endif /* nextstep */ #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 #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 pgsql-bugs@postgresql.org. #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 pgsql-bugs@postgresql.org.
#endif
#else
/* /*
* Fake spinlock implementation using semaphores --- slow and prone * Fake spinlock implementation using semaphores --- slow and prone
...@@ -560,7 +629,8 @@ extern int tas_sema(volatile slock_t *lock); ...@@ -560,7 +629,8 @@ extern int tas_sema(volatile slock_t *lock);
#define S_INIT_LOCK(lock) s_init_lock_sema(lock) #define S_INIT_LOCK(lock) s_init_lock_sema(lock)
#define TAS(lock) tas_sema(lock) #define TAS(lock) tas_sema(lock)
#endif /* HAS_TEST_AND_SET */ #endif /* HAVE_SPINLOCKS */
#endif /* HAS_TEST_AND_SET */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment