|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* |
|
7 * Atomically add a new element to the top of the stack |
|
8 * |
|
9 * usage : PR_StackPush(listp, elementp); |
|
10 * ----------------------- |
|
11 */ |
|
12 |
|
13 #include "md/_irix.h" |
|
14 #ifdef _PR_HAVE_ATOMIC_CAS |
|
15 |
|
16 #include <sys/asm.h> |
|
17 #include <sys/regdef.h> |
|
18 |
|
19 LEAF(PR_StackPush) |
|
20 |
|
21 retry_push: |
|
22 .set noreorder |
|
23 lw v0,0(a0) |
|
24 li t1,1 |
|
25 beq v0,t1,retry_push |
|
26 move t0,a1 |
|
27 |
|
28 ll v0,0(a0) |
|
29 beq v0,t1,retry_push |
|
30 nop |
|
31 sc t1,0(a0) |
|
32 beq t1,0,retry_push |
|
33 nop |
|
34 sw v0,0(a1) |
|
35 sync |
|
36 sw t0,0(a0) |
|
37 nop |
|
38 nop |
|
39 nop |
|
40 nop |
|
41 nop |
|
42 nop |
|
43 nop |
|
44 nop |
|
45 nop |
|
46 nop |
|
47 nop |
|
48 nop |
|
49 nop |
|
50 nop |
|
51 nop |
|
52 nop |
|
53 nop |
|
54 nop |
|
55 nop |
|
56 nop |
|
57 nop |
|
58 nop |
|
59 nop |
|
60 nop |
|
61 nop |
|
62 nop |
|
63 nop |
|
64 nop |
|
65 jr ra |
|
66 nop |
|
67 |
|
68 END(PR_StackPush) |
|
69 |
|
70 /* |
|
71 * |
|
72 * Atomically remove the element at the top of the stack |
|
73 * |
|
74 * usage : elemep = PR_StackPop(listp); |
|
75 * |
|
76 */ |
|
77 |
|
78 LEAF(PR_StackPop) |
|
79 retry_pop: |
|
80 .set noreorder |
|
81 |
|
82 |
|
83 lw v0,0(a0) |
|
84 li t1,1 |
|
85 beq v0,0,done |
|
86 nop |
|
87 beq v0,t1,retry_pop |
|
88 nop |
|
89 |
|
90 ll v0,0(a0) |
|
91 beq v0,0,done |
|
92 nop |
|
93 beq v0,t1,retry_pop |
|
94 nop |
|
95 sc t1,0(a0) |
|
96 beq t1,0,retry_pop |
|
97 nop |
|
98 lw t0,0(v0) |
|
99 sw t0,0(a0) |
|
100 done: |
|
101 nop |
|
102 nop |
|
103 nop |
|
104 nop |
|
105 nop |
|
106 nop |
|
107 nop |
|
108 nop |
|
109 nop |
|
110 nop |
|
111 nop |
|
112 nop |
|
113 nop |
|
114 nop |
|
115 nop |
|
116 nop |
|
117 nop |
|
118 nop |
|
119 nop |
|
120 nop |
|
121 nop |
|
122 nop |
|
123 nop |
|
124 nop |
|
125 nop |
|
126 nop |
|
127 nop |
|
128 nop |
|
129 jr ra |
|
130 nop |
|
131 |
|
132 END(PR_StackPop) |
|
133 |
|
134 #endif /* _PR_HAVE_ATOMIC_CAS */ |