mirror of
https://github.com/postgres/postgres.git
synced 2025-06-01 00:01:20 -04:00
Move slock_t typdefs into s_lock.h from include/port files for
centralization and easier maintanence.
This commit is contained in:
parent
dcae5781d1
commit
69f2e9b0fc
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -1,3 +0,0 @@
|
||||
#define HAS_TEST_AND_SET
|
||||
|
||||
typedef unsigned long slock_t;
|
@ -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
|
@ -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
|
@ -15,4 +15,3 @@ typedef int sigset_t;
|
||||
#endif
|
||||
|
||||
#define NO_WAITPID
|
||||
typedef struct mutex slock_t;
|
||||
|
@ -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
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
#else /* HAS_TEST_AND_SET */
|
||||
#endif /* !defined(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 pgsql-bugs@postgresql.org.
|
||||
#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 */
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user