Commit a7ea9f46 authored by Tom Lane's avatar Tom Lane

Still further tweaking of s_lock assembler: do not assume that leading

whitespace is unimportant in assembly code.  Also, move VAX definition
of typedef slock_t to port header files to be like all the other ports.
Note that netbsd.h and openbsd.h are now identical, and I rather think
that freebsd.h is broken in the places where it doesn't agree --- but
I'll leave it to the freebsders to look at that.
parent 58f40285
...@@ -14,6 +14,7 @@ typedef long int slock_t; ...@@ -14,6 +14,7 @@ typedef long int slock_t;
#endif #endif
#if defined(__vax__) #if defined(__vax__)
typedef unsigned char slock_t;
#define NEED_VAX_TAS_ASM #define NEED_VAX_TAS_ASM
#define HAS_TEST_AND_SET #define HAS_TEST_AND_SET
#endif #endif
......
#if defined(__i386__) #if defined(__i386__)
#define NEED_I386_TAS_ASM #define NEED_I386_TAS_ASM
#define HAS_TEST_AND_SET #define HAS_TEST_AND_SET
typedef unsigned char slock_t;
#endif #endif
#if defined(__sparc__) #if defined(__sparc__)
#define NEED_SPARC_TAS_ASM #define NEED_SPARC_TAS_ASM
#define HAS_TEST_AND_SET #define HAS_TEST_AND_SET
typedef unsigned char slock_t;
#endif #endif
#if defined(__vax__) #if defined(__vax__)
#define NEED_VAX_TAS_ASM #define NEED_VAX_TAS_ASM
#define HAS_TEST_AND_SET #define HAS_TEST_AND_SET
typedef unsigned char slock_t;
#endif #endif
#if defined(__ns32k__) #if defined(__ns32k__)
#define NEED_NS32K_TAS_ASM #define NEED_NS32K_TAS_ASM
#define HAS_TEST_AND_SET #define HAS_TEST_AND_SET
typedef unsigned char slock_t;
#endif #endif
#if defined(__m68k__) #if defined(__m68k__)
#define HAS_TEST_AND_SET #define HAS_TEST_AND_SET
typedef unsigned char slock_t;
#endif #endif
#if defined(__arm__) #if defined(__arm__)
#define HAS_TEST_AND_SET #define HAS_TEST_AND_SET
typedef unsigned char slock_t;
#endif #endif
#if defined(__mips__) #if defined(__mips__)
/* # undef HAS_TEST_AND_SET */ /* # undef HAS_TEST_AND_SET */
#endif #endif
#if defined(__powerpc__) #if defined(__alpha__)
#define HAS_TEST_AND_SET #define HAS_TEST_AND_SET
typedef unsigned long slock_t;
#endif #endif
#if defined(__powerpc__) #if defined(__powerpc__)
#define HAS_TEST_AND_SET
typedef unsigned int slock_t; typedef unsigned int slock_t;
#else
typedef unsigned char slock_t;
#endif #endif
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.84 2001/01/19 21:09:57 momjian Exp $ * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.85 2001/01/20 00:03:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -100,12 +100,12 @@ extern void s_lock_sleep(unsigned spins, int microsec, ...@@ -100,12 +100,12 @@ extern void s_lock_sleep(unsigned spins, int microsec,
*/ */
/* /*
* Standard _asm format: * Standard gcc asm format:
* *
* __asm__ __volatile__( __asm__ __volatile__(
"command \n" " command \n"
"command \n" " command \n"
"command \n" " command \n"
: "=r"(_res) return value, in register : "=r"(_res) return value, in register
: "r"(lock) argument, 'lock pointer', in register : "r"(lock) argument, 'lock pointer', in register
: "r0"); inline code uses this register : "r0"); inline code uses this register
...@@ -121,8 +121,8 @@ tas(volatile slock_t *lock) ...@@ -121,8 +121,8 @@ tas(volatile slock_t *lock)
register slock_t _res = 1; register slock_t _res = 1;
__asm__ __volatile__( __asm__ __volatile__(
"lock \n" " lock \n"
"xchgb %0,%1 \n" " xchgb %0,%1 \n"
: "=q"(_res), "=m"(*lock) : "=q"(_res), "=m"(*lock)
: "0"(_res)); : "0"(_res));
return (int) _res; return (int) _res;
...@@ -140,7 +140,7 @@ tas(volatile slock_t *lock) ...@@ -140,7 +140,7 @@ tas(volatile slock_t *lock)
long int ret; long int ret;
__asm__ __volatile__( __asm__ __volatile__(
"xchg4 %0=%1,%2 \n" " xchg4 %0=%1,%2 \n"
: "=r"(ret), "=m"(*lock) : "=r"(ret), "=m"(*lock)
: "r"(1), "1"(*lock) : "r"(1), "1"(*lock)
: "memory"); : "memory");
...@@ -160,7 +160,7 @@ tas(volatile slock_t *lock) ...@@ -160,7 +160,7 @@ tas(volatile slock_t *lock)
register slock_t _res = 1; register slock_t _res = 1;
__asm__ __volatile__( __asm__ __volatile__(
"swpb %0, %0, [%3] \n" " swpb %0, %0, [%3] \n"
: "=r"(_res), "=m"(*lock) : "=r"(_res), "=m"(*lock)
: "0"(_res), "r"(lock)); : "0"(_res), "r"(lock));
return (int) _res; return (int) _res;
...@@ -180,11 +180,11 @@ tas(volatile slock_t *lock) ...@@ -180,11 +180,11 @@ tas(volatile slock_t *lock)
int _res; int _res;
__asm__ __volatile__( __asm__ __volatile__(
"la 1,1 \n" " la 1,1 \n"
"l 2,%2 \n" " l 2,%2 \n"
"slr 0,0 \n" " slr 0,0 \n"
"cs 0,1,0(2)\n" " cs 0,1,0(2) \n"
"lr %1,0 \n" " lr %1,0 \n"
: "=m"(lock), "=d"(_res) : "=m"(lock), "=d"(_res)
: "m"(lock) : "m"(lock)
: "0", "1", "2"); : "0", "1", "2");
...@@ -204,7 +204,7 @@ tas(volatile slock_t *lock) ...@@ -204,7 +204,7 @@ tas(volatile slock_t *lock)
register slock_t _res = 1; register slock_t _res = 1;
__asm__ __volatile__( __asm__ __volatile__(
"ldstub [%2], %0 \n" " ldstub [%2], %0 \n"
: "=r"(_res), "=m"(*lock) : "=r"(_res), "=m"(*lock)
: "r"(lock)); : "r"(lock));
return (int) _res; return (int) _res;
...@@ -222,8 +222,8 @@ tas(volatile slock_t *lock) ...@@ -222,8 +222,8 @@ tas(volatile slock_t *lock)
register int rv; register int rv;
__asm__ __volatile__( __asm__ __volatile__(
"tas %1 \n" " tas %1 \n"
"sne %0 \n" " sne %0 \n"
: "=d"(rv), "=m"(*lock) : "=d"(rv), "=m"(*lock)
: "1"(*lock) : "1"(*lock)
: "cc"); : "cc");
...@@ -241,17 +241,15 @@ tas(volatile slock_t *lock) ...@@ -241,17 +241,15 @@ tas(volatile slock_t *lock)
*/ */
#define TAS(lock) tas(lock) #define TAS(lock) tas(lock)
typedef unsigned char slock_t;
static __inline__ int static __inline__ int
tas(volatile slock_t *lock) tas(volatile slock_t *lock)
{ {
register _res; register _res;
__asm__ __volatile__( __asm__ __volatile__(
"movl $1, r0 \n" " movl $1, r0 \n"
"bbssi $0, (%1), 1f \n" " bbssi $0, (%1), 1f \n"
"clrl r0 \n" " clrl r0 \n"
"1: movl r0, %0 \n" "1: movl r0, %0 \n"
: "=r"(_res) : "=r"(_res)
: "r"(lock) : "r"(lock)
...@@ -271,8 +269,8 @@ tas(volatile slock_t *lock) ...@@ -271,8 +269,8 @@ tas(volatile slock_t *lock)
register _res; register _res;
__asm__ __volatile__( __asm__ __volatile__(
"sbitb 0, %0 \n" " sbitb 0, %0 \n"
"sfsd %1 \n" " sfsd %1 \n"
: "=m"(*lock), "=r"(_res)); : "=m"(*lock), "=r"(_res));
return (int) _res; return (int) _res;
} }
...@@ -329,7 +327,7 @@ tas(volatile slock_t *s_lock) ...@@ -329,7 +327,7 @@ tas(volatile slock_t *s_lock)
#define S_UNLOCK(lock) \ #define S_UNLOCK(lock) \
do \ do \
{\ {\
__asm__ __volatile__ ("mb"); \ __asm__ __volatile__ (" mb \n"); \
*(lock) = 0; \ *(lock) = 0; \
} while (0) } while (0)
...@@ -339,15 +337,15 @@ tas(volatile slock_t *lock) ...@@ -339,15 +337,15 @@ tas(volatile slock_t *lock)
register slock_t _res; register slock_t _res;
__asm__ __volatile__( __asm__ __volatile__(
"ldq $0, %0 \n" " ldq $0, %0 \n"
"bne $0, 2f \n" " bne $0, 2f \n"
"ldq_l %1, %0 \n" " ldq_l %1, %0 \n"
"bne %1, 2f \n" " bne %1, 2f \n"
"mov 1, $0 \n" " mov 1, $0 \n"
"stq_c $0, %0 \n" " stq_c $0, %0 \n"
"beq $0, 2f \n" " beq $0, 2f \n"
"mb \n" " mb \n"
"br 3f \n" " br 3f \n"
"2: mov 1, %1 \n" "2: mov 1, %1 \n"
"3: \n" "3: \n"
: "=m"(*lock), "=r"(_res) : "=m"(*lock), "=r"(_res)
......
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