From 6016148c6110e03d94cc73b7466e088202e23b21 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 7 Nov 1997 21:35:41 +0000 Subject: [PATCH] new alpha linux locking from Travis Melhiser --- src/include/storage/s_lock.h | 72 +++++++++++++------------------------------- 1 file changed, 21 insertions(+), 51 deletions(-) diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index 1722d33b93..5892e8a2c3 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.11 1997/10/30 05:24:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.12 1997/11/07 21:35:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,10 +24,6 @@ * ; * } * - * In addition to modifying this file you will need to modify - * the appropriate ...src/include/port/...h file to define - * HAS_TEST_AND_SET for the appropriate circumstances. - * * If this is not done, POSTGRES will default to using System V * semaphores (and take a large performance hit -- around 40% of * its time on a DS5000/240 is spent in semop(3)...). @@ -233,31 +229,6 @@ tas_dummy() #endif /* sun3 */ /* - * M68000 ports under NetBSD. - * - * This version should also work on a sun3, but I can't test it. - * Conversely the sun3 version should work under NetBSD/m68k, but - * it doesn't. - */ -#if defined(__NetBSD__) && defined(__m68k__) - -static void S_LOCK(char *lock) -{ - asm(" - movel a6@(8),a0 - LOOP: - tas a0@ - bmi LOOP - "); -} - -#define S_UNLOCK(lock) (*(lock) = 0) - -#define S_INIT_LOCK(lock) S_UNLOCK(lock) - -#endif /* M68000 && NetBSD */ - -/* * sparc machines */ @@ -342,29 +313,28 @@ tas_dummy() #if defined(__alpha__) && defined(linux) -#define S_LOCK(lock) do \ - { \ - slock_t _res; \ - do \ - { \ - __asm__(" ldq $0, %0 \n\ - bne $0, already_set \n\ - ldq_l $0, %0 \n\ - bne $0, already_set \n\ - or $31, 1, $0 \n\ - stq_c $0, %0 \n\ - beq $0, stqc_fail \n\ - success: bis $31, $31, %1 \n\ - mb \n\ - jmp $31, end \n\ - stqc_fail: or $31, 1, $0 \n\ - already_set: bis $0, $0, %1 \n\ - end: nop ": "=m"(*lock), "=r"(_res): :"0"); \ - } while (_res != 0); \ - } while (0) +#define S_LOCK(lock) do { \ + slock_t _res; \ + do { \ + __asm__(" ldq $0, %0 \n\ + bne $0, already_set%= \n\ + ldq_l $0, %0 \n\ + bne $0, already_set%= \n\ + or $31, 1, $0 \n\ + stq_c $0, %0 \n\ + beq $0, stqc_fail%= \n\ + success%=: \n\ + bis $31, $31, %1 \n\ + mb \n\ + jmp $31, end%= \n\ + stqc_fail%=: or $31, 1, $0 \n\ + already_set%=: bis $0, $0, %1 \n\ + end%=: nop ": "=m"(*lock), "=r"(_res): :"0"); \ + } while (_res != 0); \ + } while (0) -#define S_UNLOCK(lock) (__asm__("mb"), *(lock) = 0) +#define S_UNLOCK(lock) ({ __asm__("mb \n"); *(lock) = 0; }) #define S_INIT_LOCK(lock) S_UNLOCK(lock) -- 2.11.0