mirror of
https://github.com/postgres/postgres.git
synced 2025-08-06 18:42:54 +03:00
Postgres95 1.01 Distribution - Virgin Sources
This commit is contained in:
36
src/backend/port/hpux/tas.c.template
Normal file
36
src/backend/port/hpux/tas.c.template
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* To generate tas.s using this template:
|
||||
* 1. cc +O2 -S -c tas.c
|
||||
* 2. edit tas.s:
|
||||
* - replace the LDW with LDCWX
|
||||
* For details about the LDCWX instruction, see the "Precision
|
||||
* Architecture and Instruction Reference Manual" (09740-90014 of June
|
||||
* 1987), p. 5-38.
|
||||
*/
|
||||
|
||||
int
|
||||
tas(lock)
|
||||
int *lock; /* LDCWX is a word instruction */
|
||||
{
|
||||
/*
|
||||
* LDCWX requires that we align the "semaphore" to a 16-byte
|
||||
* boundary. The actual datum is a single word (4 bytes).
|
||||
*/
|
||||
lock = ((long) lock + 15) & ~15;
|
||||
|
||||
/*
|
||||
* The LDCWX instruction atomically clears the target word and
|
||||
* returns the previous value. Hence, if the instruction returns
|
||||
* 0, someone else has already acquired the lock before we tested
|
||||
* it (i.e., we have failed).
|
||||
*
|
||||
* Notice that this means that we actually clear the word to set
|
||||
* the lock and set the word to clear the lock. This is the
|
||||
* opposite behavior from the SPARC LDSTUB instruction. For some
|
||||
* reason everything that H-P does is rather baroque...
|
||||
*/
|
||||
if (*lock) { /* this generates the LDW */
|
||||
return(0); /* success */
|
||||
}
|
||||
return(1); /* failure */
|
||||
}
|
Reference in New Issue
Block a user