|
|
|
@ -7,7 +7,7 @@ |
|
|
|
* |
|
|
|
* |
|
|
|
* |
|
|
|
* |
|
|
|
* IDENTIFICATION |
|
|
|
* IDENTIFICATION |
|
|
|
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.19 1997/08/20 00:50:11 scrappy Exp $ |
|
|
|
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.20 1997/08/24 23:07:28 momjian Exp $ |
|
|
|
* |
|
|
|
* |
|
|
|
*------------------------------------------------------------------------- |
|
|
|
*------------------------------------------------------------------------- |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -44,12 +44,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
#if defined(HAS_TEST_AND_SET) |
|
|
|
#if defined(HAS_TEST_AND_SET) |
|
|
|
|
|
|
|
|
|
|
|
# if defined(__alpha__) && defined(linux) |
|
|
|
|
|
|
|
static long int tas(slock_t *lock); |
|
|
|
|
|
|
|
# else |
|
|
|
|
|
|
|
static int tas(slock_t *lock); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined (nextstep) |
|
|
|
#if defined (nextstep) |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* NEXTSTEP (mach) |
|
|
|
* NEXTSTEP (mach) |
|
|
|
@ -167,6 +161,8 @@ S_LOCK_FREE(slock_t *lock) |
|
|
|
defined(sparc_solaris) |
|
|
|
defined(sparc_solaris) |
|
|
|
/* for xxxxx_solaris, this is defined in port/.../tas.s */ |
|
|
|
/* for xxxxx_solaris, this is defined in port/.../tas.s */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int tas(slock_t *lock); |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -233,6 +229,8 @@ S_INIT_LOCK(slock_t *lock) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static slock_t clear_lock = { -1, -1, -1, -1 }; |
|
|
|
static slock_t clear_lock = { -1, -1, -1, -1 }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int tas(slock_t *lock); |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -268,6 +266,8 @@ S_LOCK_FREE(slock_t *lock) |
|
|
|
|
|
|
|
|
|
|
|
#if defined(sun3) |
|
|
|
#if defined(sun3) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int tas(slock_t *lock); |
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -320,6 +320,8 @@ tas_dummy() |
|
|
|
#define asm(x) __asm__(x) |
|
|
|
#define asm(x) __asm__(x) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int tas(slock_t *lock); |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
static int |
|
|
|
tas_dummy() |
|
|
|
tas_dummy() |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -383,19 +385,14 @@ S_INIT_LOCK(unsigned char *addr) |
|
|
|
|
|
|
|
|
|
|
|
#if defined(NEED_I386_TAS_ASM) |
|
|
|
#if defined(NEED_I386_TAS_ASM) |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
|
|
|
|
tas(slock_t *m) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
slock_t res; |
|
|
|
|
|
|
|
__asm__("xchgb %0,%1":"=q" (res),"=m" (*m):"0" (0x1)); |
|
|
|
|
|
|
|
return(res); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
{ |
|
|
|
{ |
|
|
|
while (tas(lock)) |
|
|
|
slock_t res; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
do{ |
|
|
|
|
|
|
|
__asm__("xchgb %0,%1":"=q" (res),"=m" (*lock):"0" (0x1)); |
|
|
|
|
|
|
|
}while(res != 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
@ -415,31 +412,26 @@ S_INIT_LOCK(slock_t *lock) |
|
|
|
|
|
|
|
|
|
|
|
#if defined(__alpha__) && defined(linux) |
|
|
|
#if defined(__alpha__) && defined(linux) |
|
|
|
|
|
|
|
|
|
|
|
static long int |
|
|
|
|
|
|
|
tas(slock_t *m) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
slock_t res; |
|
|
|
|
|
|
|
__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" (*m), "=r" (res) :: "0" ); |
|
|
|
|
|
|
|
return(res); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
{ |
|
|
|
{ |
|
|
|
while (tas(lock)) |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
@ -459,56 +451,16 @@ S_INIT_LOCK(slock_t *lock) |
|
|
|
|
|
|
|
|
|
|
|
#if defined(linux) && defined(sparc) |
|
|
|
#if defined(linux) && defined(sparc) |
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
|
|
|
tas(slock_t *m) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
slock_t res; |
|
|
|
|
|
|
|
__asm__("ldstub [%1], %0" |
|
|
|
|
|
|
|
: "=&r" (res) |
|
|
|
|
|
|
|
: "r" (m)); |
|
|
|
|
|
|
|
return (res != 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
{ |
|
|
|
{ |
|
|
|
while (tas(lock)) |
|
|
|
slock_t res; |
|
|
|
; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
S_UNLOCK(slock_t *lock) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
*lock = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
S_INIT_LOCK(slock_t *lock) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
S_UNLOCK(lock); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* defined(linux) && defined(sparc) */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(NEED_NS32K_TAS_ASM) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
|
|
|
|
tas(slock_t *m) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
slock_t res = 0; |
|
|
|
|
|
|
|
__asm__("movd 8(fp), r1"); |
|
|
|
|
|
|
|
__asm__("movqd 0, r0"); |
|
|
|
|
|
|
|
__asm__("sbitd r0, 0(r1)"); |
|
|
|
|
|
|
|
__asm__("sprb us, %0" : "=r" (res)); |
|
|
|
|
|
|
|
res = (res >> 5) & 1; |
|
|
|
|
|
|
|
return res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
do{ |
|
|
|
S_LOCK(slock_t *lock) |
|
|
|
__asm__("ldstub [%1], %0" |
|
|
|
{ |
|
|
|
: "=&r" (res) |
|
|
|
while (tas(lock)) |
|
|
|
: "r" (lock)); |
|
|
|
; |
|
|
|
}while(!res != 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
@ -523,7 +475,7 @@ S_INIT_LOCK(slock_t *lock) |
|
|
|
S_UNLOCK(lock); |
|
|
|
S_UNLOCK(lock); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif /* NEED_NS32K_TAS_ASM */ |
|
|
|
#endif /* defined(linux) && defined(sparc) */ |
|
|
|
|
|
|
|
|
|
|
|
#if defined(linux) && defined(PPC) |
|
|
|
#if defined(linux) && defined(PPC) |
|
|
|
|
|
|
|
|
|
|
|
|