1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

New ASM format:

/*
 * Standard __asm__ format:
 *
 *  __asm__(
 *          "command;"
 *          "command;"
 *          "command;"
 *      :   "=r"(_res)          return value, in register
 *      :   "r"(lock)           argument, 'lock pointer', in register
 *      :   "r0");              inline code uses this register
 */
This commit is contained in:
Bruce Momjian
2001-01-19 02:58:59 +00:00
parent 27e618986b
commit d7810023c5

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.78 2001/01/18 23:40:26 momjian Exp $
* $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.79 2001/01/19 02:58:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -48,10 +48,8 @@
* unsigned spins = 0;
*
* while (TAS(lock))
* {
* S_LOCK_SLEEP(lock, spins++);
* }
* }
*
* where S_LOCK_SLEEP() checks for timeout and sleeps for a short
* interval. Callers that want to perform useful work while waiting
@ -101,6 +99,18 @@ extern void s_lock_sleep(unsigned spins, int microsec,
* All the gcc inlines
*/
/*
* Standard __asm__ format:
*
* __asm__(
* "command;"
* "command;"
* "command;"
* : "=r"(_res) return value, in register
* : "r"(lock) argument, 'lock pointer', in register
* : "r0"); inline code uses this register
*/
#if defined(__i386__)
#define TAS(lock) tas(lock)
@ -110,7 +120,11 @@ tas(volatile slock_t *lock)
{
register slock_t _res = 1;
__asm__("lock; xchgb %0,%1": "=q"(_res), "=m"(*lock):"0"(_res));
__asm__(
"lock;"
"xchgb %0,%1;"
: "=q"(_res), "=m"(*lock)
: "0"(_res));
return (int) _res;
}
@ -126,13 +140,14 @@ tas (volatile slock_t *lock)
long int ret;
__asm__ __volatile__(
"xchg4 %0=%1,%2"
"xchg4 %0=%1,%2;"
: "=r"(ret), "=m"(*lock)
: "r"(1), "1"(*lock)
: "memory");
return (int) ret;
}
#endif /* __ia64__ */
@ -144,7 +159,10 @@ tas(volatile slock_t *lock)
{
register slock_t _res = 1;
__asm__("swpb %0, %0, [%3]": "=r"(_res), "=m"(*lock):"0"(_res), "r" (lock));
__asm__(
"swpb %0, %0, [%3];"
: "=r"(_res), "=m"(*lock)
: "0"(_res), "r"(lock));
return (int) _res;
}
@ -161,17 +179,19 @@ tas(volatile slock_t *lock)
{
int _res;
__asm__ __volatile(" la 1,1\n"
" l 2,%2\n"
" slr 0,0\n"
" cs 0,1,0(2)\n"
" lr %1,0"
__asm__ __volatile(
"la 1,1;"
"l 2,%2;"
"slr 0,0;"
"cs 0,1,0(2);"
"lr %1,0;"
: "=m"(lock), "=d"(_res)
: "m"(lock)
: "0", "1", "2");
return (_res);
}
#endif /* __s390__ */
@ -183,8 +203,9 @@ tas(volatile slock_t *lock)
{
register slock_t _res = 1;
__asm__("ldstub [%2], %0" \
: "=r"(_res), "=m"(*lock) \
__asm__(
"ldstub [%2], %0;"
: "=r"(_res), "=m"(*lock)
: "r"(lock));
return (int) _res;
}
@ -201,10 +222,12 @@ tas(volatile slock_t *lock)
register int rv;
__asm__ __volatile__(
"tas %1; sne %0"
"tas %1;"
"sne %0;"
: "=d"(rv), "=m"(*lock)
: "1"(*lock)
: "cc");
return rv;
}
@ -225,13 +248,14 @@ tas(volatile slock_t *lock)
{
register _res;
__asm__(" movl $1, r0 \
bbssi $0, (%1), 1f \
clrl r0 \
1: movl r0, %0 "
: "=r"(_res) /* return value, in register */
: "r"(lock) /* argument, 'lock pointer', in register */
: "r0"); /* inline code uses this register */
__asm__(
"movl $1, r0;"
"bbssi $0, (%1), 1f;"
"clrl r0;"
"1: movl r0, %0;"
: "=r"(_res)
: "r"(lock)
: "r0");
return (int) _res;
}
@ -245,8 +269,10 @@ static __inline__ int
tas(volatile slock_t *lock)
{
register _res;
__asm__("sbitb 0, %0 \n\
sfsd %1"
__asm__(
"sbitb 0, %0;"
"sfsd %1;"
: "=m"(*lock), "=r"(_res));
return (int) _res;
}
@ -307,18 +333,21 @@ tas(volatile slock_t *lock)
{
register slock_t _res;
__asm__ volatile
(" ldq $0, %0 \n\
bne $0, 2f \n\
ldq_l %1, %0 \n\
bne %1, 2f \n\
mov 1, $0 \n\
stq_c $0, %0 \n\
beq $0, 2f \n\
mb \n\
br 3f \n\
2: mov 1, %1 \n\
3: \n" : "=m"(*lock), "=r"(_res) : : "0");
__asm__ volatile(
"ldq $0, %0;"
"bne $0, 2f;"
"ldq_l %1, %0;"
"bne %1, 2f;"
"mov 1, $0;"
"stq_c $0, %0;"
"beq $0, 2f;"
"mb;"
"br 3f;"
"2: mov 1, %1;"
"3:"
: "=m"(*lock), "=r"(_res)
:
: "0");
return (int) _res;
}