OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [sync/] [atomic/] [atomic.c] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
/* atomic.c -- implement atomic routines for Go.
2
 
3
   Copyright 2011 The Go Authors. All rights reserved.
4
   Use of this source code is governed by a BSD-style
5
   license that can be found in the LICENSE file.  */
6
 
7
#include <stdint.h>
8
 
9
_Bool CompareAndSwapInt32 (int32_t *, int32_t, int32_t)
10
  asm ("libgo_sync.atomic.CompareAndSwapInt32");
11
 
12
_Bool
13
CompareAndSwapInt32 (int32_t *val, int32_t old, int32_t new)
14
{
15
  return __sync_bool_compare_and_swap (val, old, new);
16
}
17
 
18
_Bool CompareAndSwapInt64 (int64_t *, int64_t, int64_t)
19
  asm ("libgo_sync.atomic.CompareAndSwapInt64");
20
 
21
_Bool
22
CompareAndSwapInt64 (int64_t *val, int64_t old, int64_t new)
23
{
24
  return __sync_bool_compare_and_swap (val, old, new);
25
}
26
 
27
_Bool CompareAndSwapUint32 (uint32_t *, uint32_t, uint32_t)
28
  asm ("libgo_sync.atomic.CompareAndSwapUint32");
29
 
30
_Bool
31
CompareAndSwapUint32 (uint32_t *val, uint32_t old, uint32_t new)
32
{
33
  return __sync_bool_compare_and_swap (val, old, new);
34
}
35
 
36
_Bool CompareAndSwapUint64 (uint64_t *, uint64_t, uint64_t)
37
  asm ("libgo_sync.atomic.CompareAndSwapUint64");
38
 
39
_Bool
40
CompareAndSwapUint64 (uint64_t *val, uint64_t old, uint64_t new)
41
{
42
  return __sync_bool_compare_and_swap (val, old, new);
43
}
44
 
45
_Bool CompareAndSwapUintptr (uintptr_t *, uintptr_t, uintptr_t)
46
  asm ("libgo_sync.atomic.CompareAndSwapUintptr");
47
 
48
_Bool
49
CompareAndSwapUintptr (uintptr_t *val, uintptr_t old, uintptr_t new)
50
{
51
  return __sync_bool_compare_and_swap (val, old, new);
52
}
53
 
54
_Bool CompareAndSwapPointer (void **, void *, void *)
55
  asm ("libgo_sync.atomic.CompareAndSwapPointer");
56
 
57
_Bool
58
CompareAndSwapPointer (void **val, void *old, void *new)
59
{
60
  return __sync_bool_compare_and_swap (val, old, new);
61
}
62
 
63
int32_t AddInt32 (int32_t *, int32_t)
64
  asm ("libgo_sync.atomic.AddInt32");
65
 
66
int32_t
67
AddInt32 (int32_t *val, int32_t delta)
68
{
69
  return __sync_add_and_fetch (val, delta);
70
}
71
 
72
uint32_t AddUint32 (uint32_t *, uint32_t)
73
  asm ("libgo_sync.atomic.AddUint32");
74
 
75
uint32_t
76
AddUint32 (uint32_t *val, uint32_t delta)
77
{
78
  return __sync_add_and_fetch (val, delta);
79
}
80
 
81
int64_t AddInt64 (int64_t *, int64_t)
82
  asm ("libgo_sync.atomic.AddInt64");
83
 
84
int64_t
85
AddInt64 (int64_t *val, int64_t delta)
86
{
87
  return __sync_add_and_fetch (val, delta);
88
}
89
 
90
uint64_t AddUint64 (uint64_t *, uint64_t)
91
  asm ("libgo_sync.atomic.AddUint64");
92
 
93
uint64_t
94
AddUint64 (uint64_t *val, uint64_t delta)
95
{
96
  return __sync_add_and_fetch (val, delta);
97
}
98
 
99
uintptr_t AddUintptr (uintptr_t *, uintptr_t)
100
  asm ("libgo_sync.atomic.AddUintptr");
101
 
102
uintptr_t
103
AddUintptr (uintptr_t *val, uintptr_t delta)
104
{
105
  return __sync_add_and_fetch (val, delta);
106
}
107
 
108
int32_t LoadInt32 (int32_t *addr)
109
  asm ("libgo_sync.atomic.LoadInt32");
110
 
111
int32_t
112
LoadInt32 (int32_t *addr)
113
{
114
  int32_t v;
115
 
116
  v = *addr;
117
  while (! __sync_bool_compare_and_swap (addr, v, v))
118
    v = *addr;
119
  return v;
120
}
121
 
122
int64_t LoadInt64 (int64_t *addr)
123
  asm ("libgo_sync.atomic.LoadInt64");
124
 
125
int64_t
126
LoadInt64 (int64_t *addr)
127
{
128
  int64_t v;
129
 
130
  v = *addr;
131
  while (! __sync_bool_compare_and_swap (addr, v, v))
132
    v = *addr;
133
  return v;
134
}
135
 
136
uint32_t LoadUint32 (uint32_t *addr)
137
  asm ("libgo_sync.atomic.LoadUint32");
138
 
139
uint32_t
140
LoadUint32 (uint32_t *addr)
141
{
142
  uint32_t v;
143
 
144
  v = *addr;
145
  while (! __sync_bool_compare_and_swap (addr, v, v))
146
    v = *addr;
147
  return v;
148
}
149
 
150
uint64_t LoadUint64 (uint64_t *addr)
151
  asm ("libgo_sync.atomic.LoadUint64");
152
 
153
uint64_t
154
LoadUint64 (uint64_t *addr)
155
{
156
  uint64_t v;
157
 
158
  v = *addr;
159
  while (! __sync_bool_compare_and_swap (addr, v, v))
160
    v = *addr;
161
  return v;
162
}
163
 
164
uintptr_t LoadUintptr (uintptr_t *addr)
165
  asm ("libgo_sync.atomic.LoadUintptr");
166
 
167
uintptr_t
168
LoadUintptr (uintptr_t *addr)
169
{
170
  uintptr_t v;
171
 
172
  v = *addr;
173
  while (! __sync_bool_compare_and_swap (addr, v, v))
174
    v = *addr;
175
  return v;
176
}
177
 
178
void *LoadPointer (void **addr)
179
  asm ("libgo_sync.atomic.LoadPointer");
180
 
181
void *
182
LoadPointer (void **addr)
183
{
184
  void *v;
185
 
186
  v = *addr;
187
  while (! __sync_bool_compare_and_swap (addr, v, v))
188
    v = *addr;
189
  return v;
190
}
191
 
192
void StoreInt32 (int32_t *addr, int32_t val)
193
  asm ("libgo_sync.atomic.StoreInt32");
194
 
195
void
196
StoreInt32 (int32_t *addr, int32_t val)
197
{
198
  int32_t v;
199
 
200
  v = *addr;
201
  while (! __sync_bool_compare_and_swap (addr, v, val))
202
    v = *addr;
203
}
204
 
205
void StoreInt64 (int64_t *addr, int64_t val)
206
  asm ("libgo_sync.atomic.StoreInt64");
207
 
208
void
209
StoreInt64 (int64_t *addr, int64_t val)
210
{
211
  int64_t v;
212
 
213
  v = *addr;
214
  while (! __sync_bool_compare_and_swap (addr, v, val))
215
    v = *addr;
216
}
217
 
218
void StoreUint32 (uint32_t *addr, uint32_t val)
219
  asm ("libgo_sync.atomic.StoreUint32");
220
 
221
void
222
StoreUint32 (uint32_t *addr, uint32_t val)
223
{
224
  uint32_t v;
225
 
226
  v = *addr;
227
  while (! __sync_bool_compare_and_swap (addr, v, val))
228
    v = *addr;
229
}
230
 
231
void StoreUint64 (uint64_t *addr, uint64_t val)
232
  asm ("libgo_sync.atomic.StoreUint64");
233
 
234
void
235
StoreUint64 (uint64_t *addr, uint64_t val)
236
{
237
  uint64_t v;
238
 
239
  v = *addr;
240
  while (! __sync_bool_compare_and_swap (addr, v, val))
241
    v = *addr;
242
}
243
 
244
void StoreUintptr (uintptr_t *addr, uintptr_t val)
245
  asm ("libgo_sync.atomic.StoreUintptr");
246
 
247
void
248
StoreUintptr (uintptr_t *addr, uintptr_t val)
249
{
250
  uintptr_t v;
251
 
252
  v = *addr;
253
  while (! __sync_bool_compare_and_swap (addr, v, val))
254
    v = *addr;
255
}
256
 
257
void StorePointer (void **addr, void *val)
258
  asm ("libgo_sync.atomic.StorePointer");
259
 
260
void
261
StorePointer (void **addr, void *val)
262
{
263
  void *v;
264
 
265
  v = *addr;
266
  while (! __sync_bool_compare_and_swap (addr, v, val))
267
    v = *addr;
268
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.