2 Copyright (c) 2003 Bernie Solomon <bernard@ugsolutions.com>
4 Permission is hereby granted, free of charge, to any person obtaining
5 a copy of this software and associated documentation files (the
6 "Software"), to deal in the Software without restriction, including
7 without limitation the rights to use, copy, modify, merge, publish,
8 distribute, sublicense, and/or sell copies of the Software, and to
9 permit persons to whom the Software is furnished to do so, subject to
10 the following conditions:
12 The above copyright notice and this permission notice shall be
13 included in all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Implementation of "atomic" operations for HPPA. Currently (Oct 9th 2003)
26 only implemented for 64 bit compiles. There is only one atomic
27 instruction LDCW which is used to implement spinlocks. There are
28 16 locks which are selected by taking 4 bits out of the address of
29 the relevant variable to try to avoid too much contention
33 #if SIZEOF_VOID_P != 8
34 #error "Currently only supports 64 bit pointers"
38 .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=0x2c,CODE_ONLY,SORT=24
40 .EXPORT InterlockedIncrement,ENTRY,PRIV_LEV=3,NO_RELOCATION,LONG_RETURN
42 .CALLINFO FRAME=0,ARGS_SAVED,ORDERING_AWARE
44 ADDIL L'locks-$global$,%r27,%r1
45 LDO R'locks-$global$(%r1),%r31
46 EXTRD,U %r26,60,4,%r28
47 DEPD,Z %r28,59,60,%r29
51 CMPB,<>,N %r0,%r29,gotlock$1
55 CMPB,=,N %r29,%r0,spin$1
69 .EXPORT InterlockedDecrement,ENTRY,PRIV_LEV=3,NO_RELOCATION,LONG_RETURN
71 .CALLINFO FRAME=0,ARGS_SAVED,ORDERING_AWARE
73 ADDIL L'locks-$global$,%r27,%r1
74 LDO R'locks-$global$(%r1),%r31
75 EXTRD,U %r26,60,4,%r28
76 DEPD,Z %r28,59,60,%r29
80 CMPB,<>,N %r0,%r29,gotlock$2
84 CMPB,=,N %r29,%r0,spin$2
98 .EXPORT InterlockedExchange,ENTRY,PRIV_LEV=3,NO_RELOCATION,LONG_RETURN
100 .CALLINFO FRAME=0,ARGS_SAVED,ORDERING_AWARE
102 ADDIL L'locks-$global$,%r27,%r1
103 LDO R'locks-$global$(%r1),%r31
104 EXTRD,U %r26,60,4,%r28
105 DEPD,Z %r28,59,60,%r29
109 CMPB,<>,N %r0,%r29,gotlock$3
113 CMPB,=,N %r29,%r0,spin$3
125 InterlockedExchangePointer
126 .EXPORT InterlockedExchangePointer,ENTRY,PRIV_LEV=3,NO_RELOCATION,LONG_RETURN
128 .CALLINFO FRAME=0,ARGS_SAVED,ORDERING_AWARE
130 ADDIL L'locks-$global$,%r27,%r1
131 LDO R'locks-$global$(%r1),%r31
132 EXTRD,U %r26,60,4,%r28
133 DEPD,Z %r28,59,60,%r29
137 CMPB,<>,N %r0,%r29,gotlock$4
141 CMPB,=,N %r29,%r0,spin$4
153 InterlockedCompareExchange
154 .EXPORT InterlockedCompareExchange,ENTRY,PRIV_LEV=3,NO_RELOCATION,LONG_RETURN
156 .CALLINFO FRAME=0,ARGS_SAVED,ORDERING_AWARE
158 ADDIL L'locks-$global$,%r27,%r1
159 LDO R'locks-$global$(%r1),%r31
160 EXTRD,U %r26,60,4,%r28
161 DEPD,Z %r28,59,60,%r29
165 CMPB,<>,N %r0,%r29,gotlock$5
169 CMPB,=,N %r29,%r0,spin$5
174 CMPB,<> %r28,%r24,noexchange$5
184 InterlockedCompareExchangePointer
185 .EXPORT InterlockedCompareExchangePointer,ENTRY,PRIV_LEV=3,NO_RELOCATION,LONG_RETURN
187 .CALLINFO FRAME=0,ARGS_SAVED,ORDERING_AWARE
189 ADDIL L'locks-$global$,%r27,%r1
190 LDO R'locks-$global$(%r1),%r31
191 EXTRD,U %r26,60,4,%r28
192 DEPD,Z %r28,59,60,%r29
196 CMPB,<>,N %r0,%r29,gotlock$6
200 CMPB,=,N %r29,%r0,spin$6
205 CMPB,*<> %r28,%r24,noexchange$6
216 .SPACE $PRIVATE$,SORT=16
217 .SUBSPA $SHORTDATA$,QUAD=1,ALIGN=8,ACCESS=0x1f,SORT=24
220 .STRING "\x00\x00\x00\x01"
222 .STRING "\x00\x00\x00\x01"
224 .STRING "\x00\x00\x00\x01"
226 .STRING "\x00\x00\x00\x01"
228 .STRING "\x00\x00\x00\x01"
230 .STRING "\x00\x00\x00\x01"
232 .STRING "\x00\x00\x00\x01"
234 .STRING "\x00\x00\x00\x01"
236 .STRING "\x00\x00\x00\x01"
238 .STRING "\x00\x00\x00\x01"
240 .STRING "\x00\x00\x00\x01"
242 .STRING "\x00\x00\x00\x01"
244 .STRING "\x00\x00\x00\x01"
246 .STRING "\x00\x00\x00\x01"
248 .STRING "\x00\x00\x00\x01"
250 .STRING "\x00\x00\x00\x01"
251 .IMPORT $global$,DATA