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
35 #if SIZEOF_VOID_P != 8
36 #error "__LP64__ state and SIZEOF_VOID_P don't match!!"
38 #define EXPORT_ARGS ,NO_RELOCATION,LONG_RETURN
39 #define CALLINFO_ARGS ,ARGS_SAVED,ORDERING_AWARE
40 #define RETURN bve,n (%rp)
44 #if SIZEOF_VOID_P != 4
45 #error "__LP64__ state and SIZEOF_VOID_P don't match!!"
49 #define RETURN bv,n (%rp)
55 .label InterlockedIncrement
56 .EXPORT InterlockedIncrement,ENTRY,PRIV_LEV=3 EXPORT_ARGS
58 .CALLINFO FRAME=0 CALLINFO_ARGS
62 LDPTR RT%locks(%r1),%r31
64 ADDIL L%locks-$global$,%dp
65 LDO R%locks-$global$(%r1),%r31
72 CMPB,<> %r0,%r29,gotlock$1
76 CMPB,= %r29,%r0,spin$1
89 .label InterlockedDecrement
90 .EXPORT InterlockedDecrement,ENTRY,PRIV_LEV=3 EXPORT_ARGS
92 .CALLINFO FRAME=0 CALLINFO_ARGS
96 LDPTR RT%locks(%r1),%r31
98 ADDIL L%locks-$global$,%dp
99 LDO R%locks-$global$(%r1),%r31
101 EXTRU %arg0,28,4,%r28
106 CMPB,<> %r0,%r29,gotlock$2
110 CMPB,= %r29,%r0,spin$2
123 .label InterlockedExchange
124 .EXPORT InterlockedExchange,ENTRY,PRIV_LEV=3 EXPORT_ARGS
126 .CALLINFO FRAME=0 CALLINFO_ARGS
130 LDPTR RT%locks(%r1),%r31
132 ADDIL L%locks-$global$,%dp
133 LDO R%locks-$global$(%r1),%r31
135 EXTRU %arg0,28,4,%r28
140 CMPB,<> %r0,%r29,gotlock$3
144 CMPB,= %r29,%r0,spin$3
156 .label InterlockedExchangePointer
157 .EXPORT InterlockedExchangePointer,ENTRY,PRIV_LEV=3 EXPORT_ARGS
159 .CALLINFO FRAME=0 CALLINFO_ARGS
163 LDPTR RT%locks(%r1),%r31
165 ADDIL L%locks-$global$,%dp
166 LDO R%locks-$global$(%r1),%r31
168 EXTRU %arg0,28,4,%r28
173 CMPB,<> %r0,%r29,gotlock$4
177 CMPB,= %r29,%r0,spin$4
189 .label InterlockedCompareExchange
190 .EXPORT InterlockedCompareExchange,ENTRY,PRIV_LEV=3 EXPORT_ARGS
192 .CALLINFO FRAME=0 CALLINFO_ARGS
196 LDPTR RT%locks(%r1),%r31
198 ADDIL L%locks-$global$,%dp
199 LDO R%locks-$global$(%r1),%r31
201 EXTRU %arg0,28,4,%r28
206 CMPB,<> %r0,%r29,gotlock$5
210 CMPB,= %r29,%r0,spin$5
215 sub,<> %ret0,%r24,%r0
216 STW %arg1,0(%arg0) /* not done if %ret0 <> %r24 */
223 .label InterlockedCompareExchangePointer
224 .EXPORT InterlockedCompareExchangePointer,ENTRY,PRIV_LEV=3 EXPORT_ARGS
226 .CALLINFO FRAME=0 CALLINFO_ARGS
230 LDPTR RT%locks(%r1),%r31
232 ADDIL L%locks-$global$,%dp
233 LDO R%locks-$global$(%r1),%r31
235 EXTRU %arg0,28,4,%r28
240 CMPB,<> %r0,%r29,gotlock$6
244 CMPB,= %r29,%r0,spin$6
249 sub,<> %ret0,%r24,%r0
261 .STRING "\x00\x00\x00\x01"
263 .STRING "\x00\x00\x00\x01"
265 .STRING "\x00\x00\x00\x01"
267 .STRING "\x00\x00\x00\x01"
269 .STRING "\x00\x00\x00\x01"
271 .STRING "\x00\x00\x00\x01"
273 .STRING "\x00\x00\x00\x01"
275 .STRING "\x00\x00\x00\x01"
277 .STRING "\x00\x00\x00\x01"
279 .STRING "\x00\x00\x00\x01"
281 .STRING "\x00\x00\x00\x01"
283 .STRING "\x00\x00\x00\x01"
285 .STRING "\x00\x00\x00\x01"
287 .STRING "\x00\x00\x00\x01"
289 .STRING "\x00\x00\x00\x01"
291 .STRING "\x00\x00\x00\x01"
292 .IMPORT $global$,DATA