blob: c327848d8edacac1bcbb4b81b5c81b302010ff7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
!!
!! $PostgreSQL: pgsql/src/backend/port/tas/solaris_sparc.s,v 1.2 2003/11/29 19:51:54 pgsql Exp $
!!
!! this would be a piece of inlined assembler but it appears
!! to be easier to just write the assembler than to try to
!! figure out how to make sure that in/out registers are kept
!! straight in the asm's.
!!
.file "tas.c"
.section ".text"
.align 4
.global tas
.type tas,#function
.proc 04
tas:
!!
!! this is a leaf procedure - no need to save windows and
!! diddle the CWP.
!!
!#PROLOGUE# 0
!#PROLOGUE# 1
!!
!! write 0xFF into the lock address, saving the old value in %o0.
!! this is an atomic action, even on multiprocessors.
!!
ldstub [%o0],%o0
!!
!! if it was already set when we set it, somebody else already
!! owned the lock -- return 1.
!!
cmp %o0,0
bne .LL2
mov 1,%o0
!!
!! otherwise, it was clear and we now own the lock -- return 0.
!!
mov 0,%o0
.LL2:
!!
!! this is a leaf procedure - no need to restore windows and
!! diddle the CWP.
!!
retl
nop
.LLfe1:
.size tas,.LLfe1-tas
.ident "GCC: (GNU) 2.5.8"
|