xccmem.h
Go to the documentation of this file.
1 /* GCC macros for XC-cube primitives for XC-cube shared memory model.
2  version 0.10
3  Copyright (C) 2001 Masahiro Yasugi.
4 
5  Supported platform:
6  __i386__
7  __alpha__
8  __sparc_v9__
9  _POWER _ARCH_PPC
10  __mips__
11 
12  GCC compilation options:
13  for UltraSparc: -mcpu=ultrasparc
14  for PowerPC: -mcpu=powerpc
15  */
16 
17 #ifndef XCCMEM_H
18 #define XCCMEM_H
19 
20 /*
21  * assertion
22  */
23 
24 #define XCC_ASSERT(cond,msg) ({char msg[(cond)?1:(-1)]; 0;})
25 
26 /*
27  * Tools for instructions
28  */
29 
30 typedef int xcc_DItype __attribute__ ((mode (DI)));
31 typedef int xcc_SItype __attribute__ ((mode (SI)));
32 typedef int xcc_HItype __attribute__ ((mode (HI)));
33 typedef int xcc_QItype __attribute__ ((mode (QI)));
34 
35 typedef float xcc_SFtype __attribute__ ((mode (SF)));
36 typedef float xcc_DFtype __attribute__ ((mode (DF)));
37 
38 #define FORCE_TYPE(TP,x) \
39 ({ union { TP x1; typeof(x) x2; } _u ; _u.x2 = (x); _u.x1; })
40 
41 /*
42  * Instructions
43  */
44 
45 #ifdef __i386__
46 
47 /* lock add $0,(%esp) とどっちが速い? */
48 #define xcc_slbar_VOID() do{\
49  xcc_SItype _tmp1, _tmp2;\
50  __asm__("xchgl %1,%0": "=m"(_tmp1), "=r"(_tmp2) :: "memory");\
51 }while(0)
52 
53 
54 #define xcc_rawcas_DI(loc,ov,nv) __xcc_rawcas_DI((loc),(ov),(nv))
55 extern __inline__ int
56 __xcc_rawcas_DI(xcc_DItype *loc, xcc_DItype ov, xcc_DItype nv){
57  int s = 0;
58  union { xcc_DItype v; xcc_SItype w2[2]; } u;
59  u.v = nv;
60  __asm__ __volatile__("lock; cmpxchg8b %0\n"
61  " jz 1f\n"
62  " inc %1\n"
63  "1:"
64  : "=m"(*loc), "=r"(s), "=A"(ov)
65  : "m" (*loc), "1"(s), "2"(ov),
66  "b"(u.w2[0]), "c"(u.w2[1]) : "cc");
67  return s;
68 }
69 
70 #define xcc_rawcas_SI(loc,ov,nv) __xcc_rawcas_SI((loc),(ov),(nv))
71 extern __inline__ int
72 __xcc_rawcas_SI(xcc_SItype *loc, xcc_SItype ov, xcc_SItype nv){
73  int s = 0;
74  __asm__ __volatile__("lock; cmpxchgl %6,%0\n"
75  " jz 1f\n"
76  " inc %1\n"
77  "1:"
78  : "=m"(*loc), "=r"(s), "=a"(ov)
79  : "m"(*loc), "1"(s), "2"(ov), "q"(nv) : "cc");
80  return s;
81 }
82 
83 #define xcc_rawcas_HI(loc,ov,nv) __xcc_rawcas_HI((loc),(ov),(nv))
84 extern __inline__ int
85 __xcc_rawcas_HI(xcc_HItype *loc, xcc_HItype ov, xcc_HItype nv){
86  int s = 0;
87  __asm__ __volatile__("lock; cmpxchgw %6,%0\n"
88  " jz 1f\n"
89  " inc %1\n"
90  "1:"
91  : "=m"(*loc), "=r"(s), "=a"(ov)
92  : "m"(*loc), "1"(s), "2"(ov), "q"(nv) : "cc");
93  return s;
94 }
95 
96 #define xcc_cas_HI(loc,ov,nv) __xcc_cas_HI((loc),(ov),(nv))
97 extern __inline__ int
98 __xcc_cas_HI(xcc_HItype *loc, xcc_HItype ov, xcc_HItype nv){
99  return (*loc != ov) || xcc_rawcas_HI(loc,ov,nv);
100 }
101 
102 
103 #define xcc_rawcas_QI(loc,ov,nv) __xcc_rawcas_QI((loc),(ov),(nv))
104 extern __inline__ int
105 __xcc_rawcas_QI(xcc_QItype *loc, xcc_QItype ov, xcc_QItype nv){
106  int s = 0;
107  __asm__ __volatile__("lock; cmpxchgb %6,%0\n"
108  " jz 1f\n"
109  " inc %1\n"
110  "1:"
111  : "=m"(*loc), "=r"(s), "=a"(ov)
112  : "m"(*loc), "1"(s), "2"(ov), "q"(nv) : "cc");
113  return s;
114 }
115 
116 #define xcc_cas_QI(loc,ov,nv) __xcc_cas_QI((loc),(ov),(nv))
117 extern __inline__ int
118 __xcc_cas_QI(xcc_QItype *loc, xcc_QItype ov, xcc_QItype nv){
119  return (*loc != ov) || xcc_rawcas_QI(loc,ov,nv);
120 }
121 
122 #define xcc_atomic_swap_DI(loc,v) __xcc_atomic_swap_DI((loc),(v))
123 extern __inline__ xcc_DItype
124 __xcc_atomic_swap_DI(xcc_DItype *loc, xcc_DItype val){
125  __asm__ __volatile__("movl %%eax,%%ebx\n"
126  " movl %%edx,%%ecx\n"
127  " lock\n"
128  " cmpxchg8b %0\n"
129  "1: lock\n"
130  " cmpxchg8b %0\n"
131  " jnz 1b"
132  : "=m"(*loc), "=A"(val) : "m"(*loc), "1"(val)
133  : "ecx", "ebx", "cc");
134  return val;
135 }
136 
137 /* lock 必要?? */
138 #define xcc_atomic_swap_SI(loc,v) __xcc_atomic_swap_SI((loc),(v))
139 extern __inline__ xcc_SItype
140 __xcc_atomic_swap_SI(xcc_SItype *loc, xcc_SItype val){
141  __asm__ __volatile__("xchgl %1,%0"
142  : "=m"(*loc), "=r"(val) : "m"(*loc), "1"(val));
143  return val;
144 }
145 
146 
147 #define xcc_atomic_swap_HI(loc,v) __xcc_atomic_swap_HI((loc),(v))
148 extern __inline__ xcc_HItype
149 __xcc_atomic_swap_HI(xcc_HItype *loc, xcc_HItype val){
150  __asm__ __volatile__("xchgw %1,%0"
151  : "=m"(*loc), "=r"(val) : "m"(*loc), "1"(val));
152  return val;
153 }
154 
155 #define xcc_atomic_swap_QI(loc,v) __xcc_atomic_swap_QI((loc),(v))
156 extern __inline__ xcc_QItype
157 __xcc_atomic_swap_QI(xcc_QItype *loc, xcc_QItype val){
158  __asm__ __volatile__("xchgb %1,%0"
159  : "=m"(*loc), "=r"(val) : "m"(*loc), "1"(val));
160  return val;
161 }
162 
163 #define xcc_atomic_write_DI(loc,v) __xcc_atomic_write_DI((loc),(v))
164 extern __inline__ void
165 __xcc_atomic_write_DI(xcc_DItype *loc, xcc_DItype val){
166  xcc_DItype tmp;
167  __asm__ __volatile__("movl %%eax,%%ebx\n"
168  " movl %%edx,%%ecx\n"
169  " lock\n"
170  " cmpxchg8b %0\n"
171  "1: lock\n"
172  " cmpxchg8b %0\n"
173  " jnz 1b"
174  : "=m"(*loc), "=A"(tmp) : "A"(val)
175  : "ecx", "ebx", "cc");
176 }
177 
178 #define xcc_atomic_read_DI(loc) __xcc_atomic_read_DI(loc)
179 extern __inline__ xcc_DItype
180 __xcc_atomic_read_DI(xcc_DItype *loc){
181  xcc_DItype val;
182  __asm__ __volatile__("movl %%eax,%%ebx\n"
183  " movl %%edx,%%ecx\n"
184  " lock\n"
185  " cmpxchg8b %1"
186  : "=A"(val) : "m"(*loc)
187  : "ecx", "ebx", "cc", "memory");
188  return val;
189 }
190 
191 #endif /* __i386__ */
192 
193 #ifdef __alpha__
194 /* __alpha_ev4__ __alpha_ev5__ __alpha_ev6__ */
195 
196 #define xcc_aabar_VOID() __asm__ __volatile__("mb":::"memory")
197 
198 #define xcc_rawcas_DI(loc,ov,nv) xcc_cas_DI((loc),(ov),(nv))
199 #define xcc_cas_DI(loc,ov,nv) __xcc_cas_DI((loc),(ov),(nv))
200 extern __inline__ int
201 __xcc_cas_DI(xcc_DItype *loc, xcc_DItype ov, xcc_DItype nv){
202  int cmp;
203  xcc_DItype tmp;
204  __asm__ __volatile__("ldq_l %0,%5\n"
205  " cmpeq %0,%3,%1\n"
206  " beq %1,1f\n"
207  " mov %4,%1\n"
208  " stq_c %1,%2\n"
209  "1:"
210  : "=&r"(tmp),"=&r"(cmp),"=m"(*loc)
211  : "r"(ov),"r"(nv),"m"(*loc));
212  return !cmp;
213 }
214 
215 #define xcc_rawcas_SI(loc,ov,nv) xcc_cas_SI((loc),(ov),(nv))
216 #define xcc_cas_SI(loc,ov,nv) __xcc_cas_SI((loc),(ov),(nv))
217 extern __inline__ int
218 __xcc_cas_SI(xcc_SItype *loc, xcc_SItype ov, xcc_SItype nv){
219  int cmp;
220  xcc_SItype tmp;
221  __asm__ __volatile__("ldl_l %0,%5\n"
222  " cmpeq %0,%3,%1\n"
223  " beq %1,1f\n"
224  " mov %4,%1\n"
225  " stl_c %1,%2\n"
226  "1:"
227  : "=&r"(tmp),"=&r"(cmp),"=m"(*loc)
228  : "rI"(ov),"rI"(nv),"m"(*loc));
229  return !cmp;
230 }
231 
232 #define xcc_atomic_write_HI(loc,v) __xcc_atomic_write_HI((loc),(v))
233 extern __inline__ void
234 __xcc_atomic_write_HI(xcc_HItype *loc, xcc_HItype val){
235  xcc_DItype _tmp1, _tmp2, *_tmpa, *_tmpb;
236  __asm__ __volatile__("lda %3,%0\n"
237  " bic %3,7,%4\n"
238  " inswl %6,%3,%2\n"
239  "1: ldq_l %1,0(%4)\n"
240  " mskwl %1,%3,%1\n"
241  " bis %1,%2,%1\n"
242  " stq_c %1,0(%4)\n"
243  " bne %1,1b"
244  : "=m"(*loc),"=r"(_tmp1),"=r"(_tmp2),
245  "=&r"(_tmpa),"=&r"(_tmpb)
246  : "m"(*loc), "r"(val));
247 }
248 
249 
250 #define xcc_atomic_write_QI(loc,v) __xcc_atomic_write_QI((loc),(v))
251 extern __inline__ void
252 __xcc_atomic_write_QI(xcc_QItype *loc, xcc_QItype val){
253  xcc_DItype _tmp1, _tmp2, *_tmpa, *_tmpb;
254  __asm__ __volatile__("lda %3,%0\n"
255  " bic %3,7,%4\n"
256  " insbl %6,%3,%2\n"
257  "1: ldq_l %1,0(%4)\n"
258  " mskbl %1,%3,%1\n"
259  " bis %1,%2,%1\n"
260  " stq_c %1,0(%4)\n"
261  " bne %1,1b"
262  : "=m"(*loc),"=r"(_tmp1),"=r"(_tmp2),
263  "=&r"(_tmpa),"=&r"(_tmpb)
264  : "m"(*loc), "r"(val));
265 }
266 
267 #endif /* __alpha__ */
268 
269 #ifdef __sparc_v9__
270 #ifndef __arch64__
271 
272 #define xcc_slbar_VOID() __asm__("membar #StoreLoad"::: "memory")
273 
274 #define xcc_rawcas_DI(loc,ov,nv) __xcc_rawcas_DI((loc),(ov),(nv))
275 extern __inline__ int
276 __xcc_rawcas_DI(xcc_DItype *loc, xcc_DItype ov, xcc_DItype nv){
277  xcc_DItype tmpa, tmpb, ovm=ov, nvm=nv;
278  __asm__ __volatile__("ldx %6,%2\n"
279  " ldx %7,%3\n"
280  " casx [%5],%3,%2\n"
281  " stx %2,%1"
282  : "=m"(*loc),"=m"(nvm),"=&r"(tmpa),"=&r"(tmpb)
283  : "m"(*loc),"r"(loc),"m"(nvm),"m"(ovm) : "cc");
284  nv = nvm;
285  return (nv != ov);
286 }
287 
288 #define xcc_rawcas_SI(loc,ov,nv) __xcc_rawcas_SI((loc),(ov),(nv))
289 extern __inline__ int
290 __xcc_rawcas_SI(xcc_SItype *loc, xcc_SItype ov, xcc_SItype nv){
291  __asm__ __volatile__("cas [%3],%5,%1"
292  : "=m"(*loc),"=&r"(nv)
293  : "m"(*loc),"r"(loc),"1"(nv),"r"(ov) : "cc");
294  return (nv != ov);
295 }
296 
297 #endif /* not __arch64__ */
298 #endif /* __sparc_v9__ */
299 
300 #ifdef _POWER
301 #ifdef _ARCH_PPC
302 
303 #define xcc_aabar_VOID() __asm__ __volatile__("sync":::"memory")
304 #define xcc_isync_VOID() __asm__ __volatile__("isync":::"memory")
305 #define xcc_ssbar_VOID() __asm__ __volatile__("eieio":::"memory")
306 
307 #define xcc_rawcas_DI(loc,ov,nv) xcc_cas_SI((loc),(ov),(nv))
308 #define xcc_cas_DI(loc,ov,nv) XCC_ASSERT(0,_64bit_cas_not_support)
309 #define xcc_atomic_swap_DI(loc,v) XCC_ASSERT(0,_64bit_cas_not_support)
310 #define xcc_cas_DF(loc,ov,nv) XCC_ASSERT(0,_64bit_cas_not_support)
311 #define xcc_atomic_swap_DF(loc,v) XCC_ASSERT(0,_64bit_cas_not_support)
312 
313 #define xcc_rawcas_SI(loc,ov,nv) xcc_cas_SI((loc),(ov),(nv))
314 #define xcc_cas_SI(loc,ov,nv) __xcc_cas_SI((loc),(ov),(nv))
315 extern __inline__ int
316 __xcc_cas_SI(xcc_SItype *loc, xcc_SItype ov, xcc_SItype nv){
317  int cmp = 1;
318  xcc_SItype tmp;
319  __asm__ __volatile__("lwarx %2,0,%4\n"
320  " cmpw %6,%2\n"
321  " bne- 1f\n"
322  " stwcx. %5,0,%4\n"
323  " bne- 1f\n"
324  " li %1,0\n"
325  "1:"
326  : "=m"(*loc),"=r"(cmp),"=&r"(tmp)
327  : "m"(*loc),"r"(loc),"r"(nv),"r"(ov),"1"(cmp) : "cc");
328  return cmp;
329 }
330 
331 #endif /* _ARCH_PPC */
332 #endif /* _POWER */
333 
334 #ifdef __mips__
335 
336 #define xcc_rawcas_DI(loc,ov,nv) xcc_cas_DI((loc),(ov),(nv))
337 #define xcc_cas_DI(loc,ov,nv) __xcc_cas_DI((loc),(ov),(nv))
338 extern __inline__ int
339 __xcc_cas_DI(xcc_DItype *loc, xcc_DItype ov, xcc_DItype nv){
340  int cmp;
341  xcc_DItype tmp;
342  __asm__ __volatile__(".set noreorder\n"
343  " lld %0,%5\n"
344  " bne %0,%3,1f\n"
345  " or %1,$0,$0\n"
346  " or %1,%4,$0\n"
347  " scd %1,%2\n"
348  "1:\n"
349  " .set reorder"
350  : "=&r"(tmp),"=&r"(cmp),"=m"(*loc)
351  : "r"(ov),"r"(nv),"m"(*loc));
352  return !cmp;
353 }
354 
355 #define xcc_rawcas_SI(loc,ov,nv) xcc_cas_SI((loc),(ov),(nv))
356 #define xcc_cas_SI(loc,ov,nv) __xcc_cas_SI((loc),(ov),(nv))
357 extern __inline__ int
358 __xcc_cas_SI(xcc_SItype *loc, xcc_SItype ov, xcc_SItype nv){
359  int cmp;
360  xcc_SItype tmp;
361  __asm__ __volatile__(".set noreorder\n"
362  " ll %0,%5\n"
363  " bne %0,%3,1f\n"
364  " or %1,$0,$0\n"
365  " or %1,%4,$0\n"
366  " sc %1,%2\n"
367  "1:\n"
368  " .set reorder"
369  : "=&r"(tmp),"=&r"(cmp),"=m"(*loc)
370  : "r"(ov),"r"(nv),"m"(*loc));
371  return !cmp;
372 }
373 
374 #endif /* __mips__ */
375 
376 /*
377  * Common inst. and common emulations
378  */
379 
380 #ifndef xcc_nnbar_VOID
381 #define xcc_nnbar_VOID() __asm__ __volatile__("":::"memory")
382 #endif
383 
384 #ifndef xcc_cas_DI
385 #define xcc_cas_DI(loc,ov,nv) __xcc_cas_DI((loc),(ov),(nv))
386 extern __inline__ int
387 __xcc_cas_DI(xcc_DItype *loc, xcc_DItype ov, xcc_DItype nv){
388  return (*loc != ov) || xcc_rawcas_DI(loc,ov,nv);
389 }
390 #endif
391 
392 #ifndef xcc_cas_SI
393 #define xcc_cas_SI(loc,ov,nv) __xcc_cas_SI((loc),(ov),(nv))
394 extern __inline__ int
395 __xcc_cas_SI(xcc_SItype *loc, xcc_SItype ov, xcc_SItype nv){
396  return (*loc != ov) || xcc_rawcas_SI(loc,ov,nv);
397 }
398 #endif
399 
400 #ifndef xcc_cas_HI
401 #define xcc_cas_HI(loc,ov,nv) __xcc_cas_HI((loc),(ov),(nv))
402 extern __inline__ int
403 __xcc_cas_HI(xcc_HItype *loc, xcc_HItype ov, xcc_HItype nv){
404  int ofs = (loc - (xcc_HItype *)(xcc_SItype *)0) & 1;
405  xcc_SItype *p = (xcc_SItype *)(loc - ofs), uov = *p;
406  union { xcc_SItype v; xcc_HItype s[2]; } unv;
407  unv.v = uov;
408  if(unv.s[ofs] != ov) return 1;
409  unv.s[ofs] = nv;
410  return xcc_rawcas_SI(p,uov,unv.v);
411 }
412 #endif
413 
414 #ifndef xcc_cas_QI
415 #define xcc_cas_QI(loc,ov,nv) __xcc_cas_QI((loc),(ov),(nv))
416 extern __inline__ int
417 __xcc_cas_QI(xcc_QItype *loc, xcc_QItype ov, xcc_QItype nv){
418  int ofs = (loc - (xcc_QItype *)(xcc_SItype *)0) & 3;
419  xcc_SItype *p = (xcc_SItype *)(loc - ofs), uov = *p;
420  union { xcc_SItype v; xcc_QItype c[4]; } unv;
421  unv.v = uov;
422  if(unv.c[ofs] != ov) return 1;
423  unv.c[ofs] = nv;
424  return xcc_rawcas_SI(p,uov,unv.v);
425 }
426 #endif
427 
428 #ifndef xcc_cas_DF
429 #define xcc_cas_DF(loc,ov,nv) __xcc_cas_DF((loc),(ov),(nv))
430 extern __inline__ int
431 __xcc_cas_DF(xcc_DFtype *loc, xcc_DFtype ov, xcc_DFtype nv){
432  return xcc_cas_DI((xcc_DItype *)loc,
433  FORCE_TYPE(xcc_DItype,ov),
434  FORCE_TYPE(xcc_DItype,nv));
435 }
436 #endif
437 
438 #ifndef xcc_cas_SF
439 #define xcc_cas_SF(loc,ov,nv) __xcc_cas_SF((loc),(ov),(nv))
440 extern __inline__ int
441 __xcc_cas_SF(xcc_SFtype *loc, xcc_SFtype ov, xcc_SFtype nv){
442  return xcc_cas_SI((xcc_SItype *)loc,
443  FORCE_TYPE(xcc_SItype,ov),
444  FORCE_TYPE(xcc_SItype,nv));
445 }
446 #endif
447 
448 #ifndef xcc_atomic_swap_DI
449 #define xcc_atomic_swap_DI(loc,v) __xcc_atomic_swap_DI((loc),(v))
450 extern __inline__ xcc_DItype
451 __xcc_atomic_swap_DI(xcc_DItype *loc, xcc_DItype val){
452  xcc_DItype ov;
453  do{ ov = *loc; }while(xcc_rawcas_DI(loc,ov,val));
454  return ov;
455 }
456 #endif
457 
458 #ifndef xcc_atomic_swap_SI
459 #define xcc_atomic_swap_SI(loc,v) __xcc_atomic_swap_SI((loc),(v))
460 extern __inline__ xcc_SItype
461 __xcc_atomic_swap_SI(xcc_SItype *loc, xcc_SItype val){
462  xcc_SItype ov;
463  do{ ov = *loc; }while(xcc_rawcas_SI(loc,ov,val));
464  return ov;
465 }
466 #endif
467 
468 #ifndef xcc_atomic_swap_HI
469 #define xcc_atomic_swap_HI(loc,v) __xcc_atomic_swap_HI((loc),(v))
470 extern __inline__ xcc_HItype
471 __xcc_atomic_swap_HI(xcc_HItype *loc, xcc_HItype val){
472  int ofs = (loc- (xcc_HItype *)(xcc_SItype *)0) & 1;
473  xcc_SItype *p = (xcc_SItype *)(loc - ofs), uov;
474  union { xcc_SItype v; xcc_HItype s[2]; } unv;
475  do{ unv.v = uov = *p; unv.s[ofs] = val;
476  }while(xcc_rawcas_SI(p,uov,unv.v));
477  unv.v = uov; return unv.s[ofs];
478 }
479 #endif
480 
481 #ifndef xcc_atomic_swap_QI
482 #define xcc_atomic_swap_QI(loc,v) __xcc_atomic_swap_QI((loc),(v))
483 extern __inline__ xcc_QItype
484 __xcc_atomic_swap_QI(xcc_QItype *loc, xcc_QItype val){
485  int ofs = (loc- (xcc_QItype *)(xcc_SItype *)0) & 3;
486  xcc_SItype *p = (xcc_SItype *)(loc - ofs), uov;
487  union { xcc_SItype v; xcc_QItype c[4]; } unv;
488  do{ unv.v = uov = *p ; unv.c[ofs] = val;
489  }while(xcc_rawcas_SI(p,uov,unv.v));
490  unv.v = uov; return unv.c[ofs];
491 }
492 #endif
493 
494 #ifndef xcc_atomic_swap_DF
495 #define xcc_atomic_swap_DF(loc,v) __xcc_atomic_swap_DF((loc),(v))
496 extern __inline__ xcc_DFtype
497 __xcc_atomic_swap_DF(xcc_DFtype *loc, xcc_DFtype val){
498  return FORCE_TYPE(xcc_DFtype,
499  xcc_atomic_swap_DI((xcc_DItype *)(loc),
500  FORCE_TYPE(xcc_DItype,val)));
501 }
502 #endif
503 
504 #ifndef xcc_atomic_swap_SF
505 #define xcc_atomic_swap_SF(loc,v) __xcc_atomic_swap_SF((loc),(v))
506 extern __inline__ xcc_SFtype
507 __xcc_atomic_swap_SF(xcc_SFtype *loc, xcc_SFtype val){
508  return FORCE_TYPE(xcc_SFtype,
509  xcc_atomic_swap_SI((xcc_SItype *)(loc),
510  FORCE_TYPE(xcc_SItype,val)));
511 }
512 #endif
513 
514 /* end of Instructions */
515 
516 /* *//* *//* *//* *//* */
517 
518 /*
519  * data mapping
520  */
521 
522 #ifdef __i386__
523 
524 #define xcc_atomic_read_long_long(loc)\
525 (sizeof(*(loc))==8 ? xcc_atomic_read_DI((xcc_DItype *)(loc)) :\
526  XCC_ASSERT((sizeof(*(loc))==8), atomic_read_long_long))
527 
528 #define xcc_atomic_write_long_long(loc,v)\
529 do{ if(sizeof(*(loc))==8) xcc_atomic_write_DI((xcc_DItype *)(loc),(v)); \
530 else XCC_ASSERT((sizeof(*(loc))==8), atomic_write_long_long); }while(0)
531 
532 #define xcc_slbar() xcc_slbar_VOID()
533 #define xcc_sabar() xcc_slbar_VOID()
534 #define xcc_albar() xcc_slbar_VOID()
535 #define xcc_aabar() xcc_slbar_VOID()
536 
537 #define xcc_start_access_after_lock() xcc_nnbar_VOID()
538 #define xcc_start_read_after_lock() xcc_nnbar_VOID()
539 #define xcc_start_write_after_lock() xcc_nnbar_VOID()
540 
541 #endif /* __i386__ */
542 
543 #ifdef __alpha__
544 /* __alpha_ev4__ __alpha_ev5__ __alpha_ev6__ */
545 
546 #define xcc_atomic_write_char(loc,v)\
547 do{ if(sizeof(*(loc))==1) xcc_atomic_write_QI((xcc_QItype *)(loc),(v)); \
548 else XCC_ASSERT((sizeof(*(loc))==1), atomic_write_char); }while(0)
549 
550 #define xcc_atomic_write_short(loc,v)\
551 do{ if(sizeof(*(loc))==2) xcc_atomic_write_HI((xcc_HItype *)(loc),(v)); \
552 else XCC_ASSERT((sizeof(*(loc))==2), atomic_write_short); }while(0)
553 
554 #define xcc_defaultbar_VOID() xcc_aabar_VOID()
555 
556 #define XCC_LONG_TYPE_SIZE 8
557 #define XCC_PTR_TYPE_SIZE 8
558 
559 #endif /* __alpha__ */
560 
561 #ifdef __sparc_v9__
562 #ifndef __arch64__
563 /* -mcpu=ultrasparc */
564 
565 /* assuming TSO */
566 #define xcc_slbar() xcc_slbar_VOID()
567 #define xcc_sabar() xcc_slbar_VOID()
568 #define xcc_albar() xcc_slbar_VOID()
569 #define xcc_aabar() xcc_slbar_VOID()
570 
571 #define xcc_start_access_after_lock() xcc_nnbar_VOID()
572 #define xcc_start_read_after_lock() xcc_nnbar_VOID()
573 #define xcc_start_write_after_lock() xcc_nnbar_VOID()
574 
575 #endif /* ! __arch64__ */
576 #endif /* __sparc_v9__ */
577 
578 #ifdef _POWER
579 #ifdef _ARCH_PPC
580 /* -mcpu=powerpc */
581 
582 #define xcc_atomic_read_long_long(loc) XCC_ASSERT(0, atomic_read_long_long)
583 #define xcc_atomic_write_long_long(loc,v)\
584 do{ XCC_ASSERT((sizeof(*(loc))==8), atomic_write_long_long); }while(0)
585 #define xcc_atomic_swap_long_long(loc,v) XCC_ASSERT(0, atomic_swap_long_long)
586 #define xcc_cas_long_long(loc,ov,nv) XCC_ASSERT(0, cas_long_long)
587 #define xcc_atomic_swap_double(loc,v) XCC_ASSERT(0, atomic_swap_double)
588 #define xcc_cas_double(loc,ov,nv) XCC_ASSERT(0, cas_double)
589 
590 #define xcc_defaultbar_VOID() xcc_aabar_VOID()
591 #define xcc_ssbar() xcc_ssbar_VOID()
592 #define xcc_start_access_after_lock() xcc_isync_VOID()
593 #define xcc_start_read_after_lock() xcc_isync_VOID()
594 #define xcc_start_write_after_lock() xcc_isync_VOID()
595 
596 #endif /* _ARCH_PPC */
597 #endif /* _POWER */
598 
599 #ifdef __mips__
600 
601 #define XCC_INT_TYPE_SIZE (_MIPS_SZINT/8)
602 #define XCC_LONG_TYPE_SIZE (_MIPS_SZLONG/8)
603 #define XCC_PTR_TYPE_SIZE (_MIPS_SZPTR/8)
604 
605 #endif /* __mips__ */
606 
607 /*
608  * Common data mapping and/or common (usual) GNUC case
609  */
610 
611 #ifndef XCC_CHAR_TYPE_SIZE
612 #define XCC_CHAR_TYPE_SIZE 1
613 #endif
614 #ifndef XCC_SHORT_TYPE_SIZE
615 #define XCC_SHORT_TYPE_SIZE 2
616 #endif
617 #ifndef XCC_INT_TYPE_SIZE
618 #define XCC_INT_TYPE_SIZE 4
619 #endif
620 #ifndef XCC_LONG_TYPE_SIZE
621 #define XCC_LONG_TYPE_SIZE 4
622 #endif
623 #ifndef XCC_LONG_LONG_TYPE_SIZE
624 #define XCC_LONG_LONG_TYPE_SIZE 8
625 #endif
626 #ifndef XCC_FLOAT_TYPE_SIZE
627 #define XCC_FLOAT_TYPE_SIZE 4
628 #endif
629 #ifndef XCC_DOUBLE_TYPE_SIZE
630 #define XCC_DOUBLE_TYPE_SIZE 8
631 #endif
632 #ifndef XCC_PTR_TYPE_SIZE
633 #define XCC_PTR_TYPE_SIZE 4
634 #endif
635 
636 #ifndef xcc_atomic_read_char
637 #define xcc_atomic_read_char(loc) (*(volatile char *)(loc))
638 #endif
639 #ifndef xcc_atomic_read_short
640 #define xcc_atomic_read_short(loc) (*(volatile short *)(loc))
641 #endif
642 #ifndef xcc_atomic_read_int
643 #define xcc_atomic_read_int(loc) (*(volatile int *)(loc))
644 #endif
645 #ifndef xcc_atomic_read_long
646 #define xcc_atomic_read_long(loc) (*(volatile long *)(loc))
647 #endif
648 /* long long: except for i386, PPC32, MIPS1/2 */
649 #ifndef xcc_atomic_read_long_long
650 #define xcc_atomic_read_long_long(loc) (*(volatile long long *)(loc))
651 #endif
652 #ifndef xcc_atomic_read_float
653 #define xcc_atomic_read_float(loc) (*(volatile float *)(loc))
654 #endif
655 #ifndef xcc_atomic_read_double
656 #define xcc_atomic_read_double(loc) (*(volatile double *)(loc))
657 #endif
658 #ifndef xcc_atomic_read_ptr
659 #define xcc_atomic_read_ptr(loc) (*(void * volatile *)(loc))
660 #endif
661 
662 /* char: except for Alhpa */
663 #ifndef xcc_atomic_write_char
664 #define xcc_atomic_write_char(loc,v) do{*(volatile char *)(loc)=(v);}while(0)
665 #endif
666 #ifndef xcc_atomic_write_short
667 #define xcc_atomic_write_short(loc,v) do{*(volatile short *)(loc)=(v);}while(0)
668 #endif
669 #ifndef xcc_atomic_write_int
670 #define xcc_atomic_write_int(loc,v) do{*(volatile int *)(loc)=(v);}while(0)
671 #endif
672 #ifndef xcc_atomic_write_long
673 #define xcc_atomic_write_long(loc,v) do{*(volatile long *)(loc)=(v);}while(0)
674 #endif
675 /* long long: except for i386, PPC32, MIPS1/2 */
676 #ifndef xcc_atomic_write_long_long
677 #define xcc_atomic_write_long_long(loc,v)\
678 do{*(volatile long long *)(loc)=(v);}while(0)
679 #endif
680 #ifndef xcc_atomic_write_float
681 #define xcc_atomic_write_float(loc,v)\
682 do{*(volatile float *)(loc)=(v);}while(0)
683 #endif
684 #ifndef xcc_atomic_write_double
685 #define xcc_atomic_write_double(loc,v)\
686 do{*(volatile double *)(loc)=(v);}while(0)
687 #endif
688 #ifndef xcc_atomic_write_ptr
689 #define xcc_atomic_write_ptr(loc,v) do{*(void * volatile *)(loc)=(v);}while(0)
690 #endif
691 
692 #ifndef xcc_atomic_swap_char
693 #define xcc_atomic_swap_char(loc,v)\
694 (sizeof(*(loc))==1 ? xcc_atomic_swap_QI((xcc_QItype *)(loc),(v)) :\
695  XCC_ASSERT((sizeof(*(loc))==1), atomic_swap_char))
696 #endif
697 
698 #ifndef xcc_atomic_swap_short
699 #define xcc_atomic_swap_short(loc,v)\
700 (sizeof(*(loc))==2 ? xcc_atomic_swap_HI((xcc_HItype *)(loc),(v)) :\
701  XCC_ASSERT((sizeof(*(loc))==2), atomic_swap_short))
702 #endif
703 
704 #if XCC_INT_TYPE_SIZE == 4
705 #ifndef xcc_atomic_swap_int
706 #define xcc_atomic_swap_int(loc,v)\
707 (sizeof(*(loc))==4 ? xcc_atomic_swap_SI((xcc_SItype *)(loc),(v)) :\
708  XCC_ASSERT((sizeof(*(loc))==4), atomic_swap_int))
709 #endif
710 #elif XCC_INT_TYPE_SIZE == 8
711 #ifndef xcc_atomic_swap_int
712 #define xcc_atomic_swap_int(loc,v)\
713 (sizeof(*(loc))==8 ? xcc_atomic_swap_DI((xcc_DItype *)(loc),(v)) :\
714  XCC_ASSERT((sizeof(*(loc))==8), atomic_swap_int))
715 #endif
716 #endif /* XCC_INT_TYPE_SIZE == 8 */
717 
718 #if XCC_LONG_TYPE_SIZE == 4
719 #ifndef xcc_atomic_swap_long
720 #define xcc_atomic_swap_long(loc,v)\
721 (sizeof(*(loc))==4 ? xcc_atomic_swap_SI((xcc_SItype *)(loc),(v)) :\
722  XCC_ASSERT((sizeof(*(loc))==4), atomic_swap_long))
723 #endif
724 #elif XCC_LONG_TYPE_SIZE == 8
725 #ifndef xcc_atomic_swap_long
726 #define xcc_atomic_swap_long(loc,v)\
727 (sizeof(*(loc))==8 ? xcc_atomic_swap_DI((xcc_DItype *)(loc),(v)) :\
728  XCC_ASSERT((sizeof(*(loc))==8), atomic_swap_long))
729 #endif
730 #endif /* XCC_LONG_TYPE_SIZE == 8 */
731 
732 #ifndef xcc_atomic_swap_long_long
733 #define xcc_atomic_swap_long_long(loc,v)\
734 (sizeof(*(loc))==8 ? xcc_atomic_swap_DI((xcc_DItype *)(loc),(v)) :\
735  XCC_ASSERT((sizeof(*(loc))==8), atomic_swap_long_long))
736 #endif
737 
738 #ifndef xcc_atomic_swap
739 #define xcc_atomic_swap(loc,v)\
740 (sizeof(*(loc))==1 ? xcc_atomic_swap_QI((xcc_QItype *)(loc),(v)) :\
741  sizeof(*(loc))==2 ? xcc_atomic_swap_HI((xcc_HItype *)(loc),(v)) :\
742  sizeof(*(loc))==4 ? xcc_atomic_swap_SI((xcc_SItype *)(loc),(v)) :\
743  sizeof(*(loc))==8 ? xcc_atomic_swap_DI((xcc_DItype *)(loc),(v)) :\
744  XCC_ASSERT(((sizeof(*(loc))==1) && (__alignof__(*(loc))==1) ||\
745  (sizeof(*(loc))==2) && (__alignof__(*(loc))==2) ||\
746  (sizeof(*(loc))==4) && (__alignof__(*(loc))==4) ||\
747  (sizeof(*(loc))==8) && (__alignof__(*(loc))==8)),\
748  atomic_swap))
749 #endif
750 
751 #ifndef xcc_atomic_swap_float
752 #define xcc_atomic_swap_float(loc,v)\
753 (sizeof(*(loc))==4 ? xcc_atomic_swap_SF((xcc_SFtype *)(loc),(v)) :\
754  XCC_ASSERT((sizeof(*(loc))==4), atomic_swap_float))
755 #endif
756 
757 #ifndef xcc_atomic_swap_double
758 #define xcc_atomic_swap_double(loc,v)\
759 (sizeof(*(loc))==8 ? xcc_atomic_swap_DF((xcc_DFtype *)(loc),(v)) :\
760  XCC_ASSERT((sizeof(*(loc))==8), atomic_swap_double))
761 #endif
762 
763 #if XCC_PTR_TYPE_SIZE == 4
764 #ifndef xcc_atomic_swap_ptr
765 #define xcc_atomic_swap_ptr(loc,v)\
766 (sizeof(*(loc))==4 ? \
767  xcc_atomic_swap_SI((xcc_SItype *)(loc),(xcc_SItype)(v)) :\
768  XCC_ASSERT((sizeof(*(loc))==4), atomic_swap_ptr))
769 #endif
770 #elif XCC_PTR_TYPE_SIZE == 8
771 #ifndef xcc_atomic_swap_ptr
772 #define xcc_atomic_swap_ptr(loc,v)\
773 (sizeof(*(loc))==8 ? \
774  xcc_atomic_swap_DI((xcc_DItype *)(loc),(xcc_DItype)(v)) :\
775  XCC_ASSERT((sizeof(*(loc))==8), atomic_swap_ptr))
776 #endif
777 #endif /* XCC_PTR_TYPE_SIZE == 8 */
778 
779 #ifndef xcc_cas_char
780 #define xcc_cas_char(loc,ov,nv)\
781 (sizeof(*(loc))==1 ? xcc_cas_QI((xcc_QItype *)(loc),(ov),(nv)) :\
782  XCC_ASSERT((sizeof(*(loc))==1), cas_char))
783 #endif
784 
785 #ifndef xcc_cas_short
786 #define xcc_cas_short(loc,ov,nv)\
787 (sizeof(*(loc))==2 ? xcc_cas_HI((xcc_HItype *)(loc),(ov),(nv)) :\
788  XCC_ASSERT((sizeof(*(loc))==2), cas_short))
789 #endif
790 
791 #if XCC_INT_TYPE_SIZE == 4
792 #ifndef xcc_cas_int
793 #define xcc_cas_int(loc,ov,nv)\
794 (sizeof(*(loc))==4 ? xcc_cas_SI((xcc_SItype *)(loc),(ov),(nv)) :\
795  XCC_ASSERT((sizeof(*(loc))==4), cas_int))
796 #endif
797 #elif XCC_INT_TYPE_SIZE == 8
798 #ifndef xcc_cas_int
799 #define xcc_cas_int(loc,ov,nv)\
800 (sizeof(*(loc))==8 ? xcc_cas_DI((xcc_DItype *)(loc),(ov),(nv)) :\
801  XCC_ASSERT((sizeof(*(loc))==8), cas_int))
802 #endif
803 #endif /* XCC_INT_TYPE_SIZE == 8 */
804 
805 /* raw cas */
806 #if XCC_INT_TYPE_SIZE == 4
807 #ifndef xcc_rawcas_int
808 #define xcc_rawcas_int(loc,ov,nv)\
809 (sizeof(*(loc))==4 ? xcc_rawcas_SI((xcc_SItype *)(loc),(ov),(nv)) :\
810  XCC_ASSERT((sizeof(*(loc))==4), rawcas_int))
811 #endif
812 #elif XCC_INT_TYPE_SIZE == 8
813 #ifndef xcc_rawcas_int
814 #define xcc_rawcas_int(loc,ov,nv)\
815 (sizeof(*(loc))==8 ? xcc_rawcas_DI((xcc_DItype *)(loc),(ov),(nv)) :\
816  XCC_ASSERT((sizeof(*(loc))==8), rawcas_int))
817 #endif
818 #endif /* XCC_INT_TYPE_SIZE == 8 */
819 
820 #if XCC_LONG_TYPE_SIZE == 4
821 #ifndef xcc_cas_long
822 #define xcc_cas_long(loc,ov,nv)\
823 (sizeof(*(loc))==4 ? xcc_cas_SI((xcc_SItype *)(loc),(ov),(nv)) :\
824  XCC_ASSERT((sizeof(*(loc))==4), cas_long))
825 #endif
826 #elif XCC_LONG_TYPE_SIZE == 8
827 #ifndef xcc_cas_long
828 #define xcc_cas_long(loc,ov,nv)\
829 (sizeof(*(loc))==8 ? xcc_cas_DI((xcc_DItype *)(loc),(ov),(nv)) :\
830  XCC_ASSERT((sizeof(*(loc))==8), cas_long))
831 #endif
832 #endif /* XCC_LONG_TYPE_SIZE == 8 */
833 
834 #ifndef xcc_cas_long_long
835 #define xcc_cas_long_long(loc,ov,nv)\
836 (sizeof(*(loc))==8 ? xcc_cas_DI((xcc_DItype *)(loc),(ov),(nv)) :\
837  XCC_ASSERT((sizeof(*(loc))==8), cas_long_long))
838 #endif
839 
840 #ifndef xcc_cas_float
841 #define xcc_cas_float(loc,ov,nv)\
842 (sizeof(*(loc))==4 ? xcc_cas_SF((xcc_SFtype *)(loc),(ov),(nv)) :\
843  XCC_ASSERT((sizeof(*(loc))==4), cas_float))
844 #endif
845 
846 #ifndef xcc_cas_double
847 #define xcc_cas_double(loc,ov,nv)\
848 (sizeof(*(loc))==8 ? xcc_cas_DF((xcc_DFtype *)(loc),(ov),(nv)) :\
849  XCC_ASSERT((sizeof(*(loc))==8), cas_double))
850 #endif
851 
852 #if XCC_PTR_TYPE_SIZE == 4
853 #ifndef xcc_cas_ptr
854 #define xcc_cas_ptr(loc,ov,nv)\
855 (sizeof(*(loc))==4 ? \
856  xcc_cas_SI((xcc_SItype *)(loc),(xcc_SItype)(ov),(xcc_SItype)(nv)) :\
857  XCC_ASSERT((sizeof(*(loc))==4), cas_ptr))
858 #endif
859 #elif XCC_PTR_TYPE_SIZE == 8
860 #ifndef xcc_cas_ptr
861 #define xcc_cas_ptr(loc,ov,nv)\
862 (sizeof(*(loc))==8 ? \
863  xcc_cas_DI((xcc_DItype *)(loc),(xcc_DItype)(ov),(xcc_DItype)(nv)) :\
864  XCC_ASSERT((sizeof(*(loc))==8), cas_ptr))
865 #endif
866 #endif /* XCC_PTR_TYPE_SIZE == 8 */
867 
868 #ifndef xcc_defaultbar_VOID
869 #define xcc_defaultbar_VOID() xcc_nnbar_VOID()
870 #endif
871 
872 #ifndef xcc_ssbar
873 #define xcc_ssbar() xcc_defaultbar_VOID()
874 #endif
875 #ifndef xcc_slbar
876 #define xcc_slbar() xcc_defaultbar_VOID()
877 #endif
878 #ifndef xcc_sabar
879 #define xcc_sabar() xcc_defaultbar_VOID()
880 #endif
881 #ifndef xcc_lsbar
882 #define xcc_lsbar() xcc_defaultbar_VOID()
883 #endif
884 #ifndef xcc_llbar
885 #define xcc_llbar() xcc_defaultbar_VOID()
886 #endif
887 #ifndef xcc_labar
888 #define xcc_labar() xcc_defaultbar_VOID()
889 #endif
890 #ifndef xcc_asbar
891 #define xcc_asbar() xcc_defaultbar_VOID()
892 #endif
893 #ifndef xcc_albar
894 #define xcc_albar() xcc_defaultbar_VOID()
895 #endif
896 #ifndef xcc_aabar
897 #define xcc_aabar() xcc_defaultbar_VOID()
898 #endif
899 
900 /* Pentium's spinlock means aabar() Alpha's spinlock does not */
901 #ifndef xcc_start_access_after_lock
902 #define xcc_start_access_after_lock() xcc_aabar()
903 #endif
904 #ifndef xcc_start_access_after_read
905 #define xcc_start_access_after_read() xcc_labar()
906 #endif
907 #ifndef xcc_start_access_after_write
908 #define xcc_start_access_after_write() xcc_sabar()
909 #endif
910 #ifndef xcc_start_read_after_lock
911 #define xcc_start_read_after_lock() xcc_albar()
912 #endif
913 #ifndef xcc_start_read_after_read
914 #define xcc_start_read_after_read() xcc_llbar()
915 #endif
916 #ifndef xcc_start_read_after_write
917 #define xcc_start_read_after_write() xcc_slbar()
918 #endif
919 #ifndef xcc_start_write_after_lock
920 #define xcc_start_write_after_lock() xcc_asbar()
921 #endif
922 #ifndef xcc_start_write_after_read
923 #define xcc_start_write_after_read() xcc_lsbar()
924 #endif
925 #ifndef xcc_start_write_after_write
926 #define xcc_start_write_after_write() xcc_ssbar()
927 #endif
928 
929 #ifndef xcc_finish_access_before_unlock
930 #define xcc_finish_access_before_unlock() xcc_asbar()
931 #endif
932 #ifndef xcc_finish_access_before_read
933 #define xcc_finish_access_before_read() xcc_albar()
934 #endif
935 #ifndef xcc_finish_access_before_write
936 #define xcc_finish_access_before_write() xcc_asbar()
937 #endif
938 #ifndef xcc_finish_read_before_unlock
939 #define xcc_finish_read_before_unlock() xcc_lsbar()
940 #endif
941 #ifndef xcc_finish_read_before_read
942 #define xcc_finish_read_before_read() xcc_llbar()
943 #endif
944 #ifndef xcc_finish_read_before_write
945 #define xcc_finish_read_before_write() xcc_lsbar()
946 #endif
947 #ifndef xcc_finish_write_before_unlock
948 #define xcc_finish_write_before_unlock() xcc_ssbar()
949 #endif
950 #ifndef xcc_finish_write_before_read
951 #define xcc_finish_write_before_read() xcc_slbar()
952 #endif
953 #ifndef xcc_finish_write_before_write
954 #define xcc_finish_write_before_write() xcc_ssbar()
955 #endif
956 
957 #ifndef xcc_LOCK_INITIALIZER
958 #define xcc_LOCK_INITIALIZER 0
959 #endif
960 #ifndef xcc_lock_t
961 #define xcc_lock_t int
962 #endif
963 #ifndef xcc_try_lock
964 #define xcc_try_lock(loc) xcc_cas_int((loc),0,1)
965 #endif
966 #ifndef xcc_spin_lock
967 #define xcc_spin_lock(loc) __xcc_spin_lock(loc)
968 extern __inline__ void
969 __xcc_spin_lock(int *loc){ while(xcc_try_lock(loc)) xcc_llbar(); }
970 #endif
971 #ifndef xcc_release_lock
972 #define xcc_release_lock(loc) xcc_atomic_write_int((loc),0)
973 #endif
974 
975 #ifndef xcc_RWLOCK_INITIALIZER
976 #define xcc_RWLOCK_INITIALIZER 0
977 #endif
978 #ifndef xcc_rwlock_t
979 #define xcc_rwlock_t int
980 #endif
981 #ifndef xcc_try_rlock
982 #define xcc_try_rlock(loc) __xcc_try_rlock(loc)
983 extern __inline__ int
984 __xcc_try_rlock(int *loc){
985  int c=xcc_atomic_read_int(loc);
986  return ((c<0) || xcc_rawcas_int(loc,c,c+1));
987 }
988 #endif
989 #ifndef xcc_spin_rlock
990 #define xcc_spin_rlock(loc) __xcc_spin_rlock(loc)
991 extern __inline__ void
992 __xcc_spin_rlock(int *loc){ while(xcc_try_rlock(loc)) xcc_llbar(); }
993 #endif
994 #ifndef xcc_release_rlock
995 #define xcc_release_rlock(loc) __xcc_release_rlock(loc)
996 extern __inline__ void
998  int c; do{c = *loc;}while(xcc_rawcas_int(loc,c,c-1));
999 }
1000 #endif
1001 #ifndef xcc_try_wlock
1002 #define xcc_try_wlock(loc) xcc_cas_int((loc),0,-1)
1003 #endif
1004 #ifndef xcc_spin_wlock
1005 #define xcc_spin_wlock(loc) __xcc_spin_wlock(loc)
1006 extern __inline__ void
1007 __xcc_spin_wlock(int *loc){ while(xcc_try_wlock(loc)) xcc_llbar(); }
1008 #endif
1009 #ifndef xcc_release_wlock
1010 #define xcc_release_wlock(loc) xcc_atomic_write_int((loc),0)
1011 #endif
1012 
1013 /* *//* *//* *//* *//* */
1014 
1015 /*
1016  * xccmem API primitives
1017  */
1018 
1019 #define atomic_read_char(loc) xcc_atomic_read_char(&(loc))
1020 #define atomic_read_short(loc) xcc_atomic_read_short(&(loc))
1021 #define atomic_read_int(loc) xcc_atomic_read_int(&(loc))
1022 #define atomic_read_long(loc) xcc_atomic_read_long(&(loc))
1023 #define atomic_read_long_long(loc) xcc_atomic_read_long_long(&(loc))
1024 #define atomic_read_float(loc) xcc_atomic_read_float(&(loc))
1025 #define atomic_read_double(loc) xcc_atomic_read_double(&(loc))
1026 #define atomic_read_ptr(loc) xcc_atomic_read_ptr(&(loc))
1027 
1028 #define atomic_read_volatile_char(loc) atomic_read_char(loc)
1029 #define atomic_read_volatile_short(loc) atomic_read_short(loc)
1030 #define atomic_read_volatile_int(loc) atomic_read_int(loc)
1031 #define atomic_read_volatile_long(loc) atomic_read_long(loc)
1032 #define atomic_read_volatile_long_long(loc) atomic_read_long_long(loc)
1033 #define atomic_read_volatile_float(loc) atomic_read_float(loc)
1034 #define atomic_read_volatile_double(loc) atomic_read_double(loc)
1035 #define atomic_read_volatile_ptr(loc) atomic_read_ptr(loc)
1036 
1037 #define read_volatile_char(loc) atomic_read_char(loc)
1038 #define read_volatile_short(loc) atomic_read_short(loc)
1039 #define read_volatile_int(loc) atomic_read_int(loc)
1040 #define read_volatile_long(loc) atomic_read_long(loc)
1041 #define read_volatile_long_long(loc) atomic_read_long_long(loc)
1042 #define read_volatile_float(loc) atomic_read_float(loc)
1043 #define read_volatile_double(loc) atomic_read_double(loc)
1044 #define read_volatile_ptr(loc) atomic_read_ptr(loc)
1045 
1046 #define atomic_write_char(loc,v) xcc_atomic_write_char(&(loc),(v))
1047 #define atomic_write_short(loc,v) xcc_atomic_write_short(&(loc),(v))
1048 #define atomic_write_int(loc,v) xcc_atomic_write_int(&(loc),(v))
1049 #define atomic_write_long(loc,v) xcc_atomic_write_long(&(loc),(v))
1050 #define atomic_write_long_long(loc,v) xcc_atomic_write_long_long(&(loc),(v))
1051 #define atomic_write_float(loc,v) xcc_atomic_write_float(&(loc),(v))
1052 #define atomic_write_double(loc,v) xcc_atomic_write_double(&(loc),(v))
1053 #define atomic_write_ptr(loc,v) xcc_atomic_write_ptr(&(loc),(v))
1054 
1055 #define atomic_write_volatile_char(loc, v) atomic_write_char((loc), (v))
1056 #define atomic_write_volatile_short(loc, v) atomic_write_short((loc), (v))
1057 #define atomic_write_volatile_int(loc, v) atomic_write_int((loc), (v))
1058 #define atomic_write_volatile_long(loc, v) atomic_write_long((loc), (v))
1059 #define atomic_write_volatile_long_long(loc, v) \
1060 atomic_write_long_long((loc), (v))
1061 #define atomic_write_volatile_float(loc, v) atomic_write_float((loc), (v))
1062 #define atomic_write_volatile_double(loc, v) atomic_write_double((loc), (v))
1063 #define atomic_write_volatile_ptr(loc, v) atomic_write_ptr((loc), (v))
1064 
1065 #define write_volatile_char(loc, v) atomic_write_char((loc), (v))
1066 #define write_volatile_short(loc, v) atomic_write_short((loc), (v))
1067 #define write_volatile_int(loc, v) atomic_write_int((loc), (v))
1068 #define write_volatile_long(loc, v) atomic_write_long((loc), (v))
1069 #define write_volatile_long_long(loc, v) atomic_write_long_long((loc), (v))
1070 #define write_volatile_float(loc, v) atomic_write_float((loc), (v))
1071 #define write_volatile_double(loc, v) atomic_write_double((loc), (v))
1072 #define write_volatile_ptr(loc, v) atomic_write_ptr((loc), (v))
1073 
1074 #define atomic_swap_char(loc,v) xcc_atomic_swap_char(&(loc),(v))
1075 #define atomic_swap_short(loc,v) xcc_atomic_swap_short(&(loc),(v))
1076 #define atomic_swap_int(loc,v) xcc_atomic_swap_int(&(loc),(v))
1077 #define atomic_swap_long(loc,v) xcc_atomic_swap_long(&(loc),(v))
1078 #define atomic_swap_long_long(loc,v) xcc_atomic_swap_long_long(&(loc),(v))
1079 #define atomic_swap_float(loc,v) xcc_atomic_swap_float(&(loc),(v))
1080 #define atomic_swap_double(loc,v) xcc_atomic_swap_double(&(loc),(v))
1081 #define atomic_swap_ptr(loc,v) xcc_atomic_swap_ptr(&(loc),(v))
1082 
1083 #define atomic_swap(loc,v) xcc_atomic_swap(&(loc),(v))
1084 
1085 #define cas_char(loc,ov,nv) xcc_cas_char(&(loc),(ov),(nv))
1086 #define cas_short(loc,ov,nv) xcc_cas_short(&(loc),(ov),(nv))
1087 #define cas_int(loc,ov,nv) xcc_cas_int(&(loc),(ov),(nv))
1088 #define cas_long(loc,ov,nv) xcc_cas_long(&(loc),(ov),(nv))
1089 #define cas_long_long(loc,ov,nv) xcc_cas_long_long(&(loc),(ov),(nv))
1090 #define cas_float(loc,ov,nv) xcc_cas_float(&(loc),(ov),(nv))
1091 #define cas_double(loc,ov,nv) xcc_cas_double(&(loc),(ov),(nv))
1092 #define cas_ptr(loc,ov,nv) xcc_cas_ptr(&(loc),(ov),(nv))
1093 
1094 #define ssbar() xcc_ssbar()
1095 #define slbar() xcc_slbar()
1096 #define sabar() xcc_sabar()
1097 #define lsbar() xcc_lsbar()
1098 #define llbar() xcc_llbar()
1099 #define labar() xcc_labar()
1100 #define asbar() xcc_asbar()
1101 #define albar() xcc_albar()
1102 #define aabar() xcc_aabar()
1103 
1104 #define start_access_after_lock() xcc_start_access_after_lock()
1105 #define start_access_after_read() xcc_start_access_after_read()
1106 #define start_access_after_write() xcc_start_access_after_write()
1107 #define start_read_after_lock() xcc_start_read_after_lock()
1108 #define start_read_after_read() xcc_start_read_after_read()
1109 #define start_read_after_write() xcc_start_read_after_write()
1110 #define start_write_after_lock() xcc_start_write_after_lock()
1111 #define start_write_after_read() xcc_start_write_after_read()
1112 #define start_write_after_write() xcc_start_write_after_write()
1113 
1114 #define finish_access_before_unlock() xcc_finish_access_before_unlock()
1115 #define finish_access_before_read() xcc_finish_access_before_read()
1116 #define finish_access_before_write() xcc_finish_access_before_write()
1117 #define finish_read_before_unlock() xcc_finish_read_before_unlock()
1118 #define finish_read_before_read() xcc_finish_read_before_read()
1119 #define finish_read_before_write() xcc_finish_read_before_write()
1120 #define finish_write_before_unlock() xcc_finish_write_before_unlock()
1121 #define finish_write_before_read() xcc_finish_write_before_read()
1122 #define finish_write_before_write() xcc_finish_write_before_write()
1123 
1124 #define LOCK_INITIALIZER xcc_LOCK_INITIALIZER
1125 #define lock_t xcc_lock_t
1126 #define try_lock(loc) xcc_try_lock(&(loc))
1127 #define spin_lock(loc) xcc_spin_lock(&(loc))
1128 #define release_lock(loc) xcc_release_lock(&(loc))
1129 
1130 #define RWLOCK_INITIALIZER xcc_RWLOCK_INITIALIZER
1131 // #define rwlock_t xcc_rwlock_t /* R.Hanai */
1132 #define try_rlock(loc) xcc_try_rlock(&(loc))
1133 #define spin_rlock(loc) xcc_spin_rlock(&(loc))
1134 #define release_rlock(loc) xcc_release_rlock(&(loc))
1135 #define try_wlock(loc) xcc_try_wlock(&(loc))
1136 #define spin_wlock(loc) xcc_spin_wlock(&(loc))
1137 #define release_wlock(loc) xcc_release_wlock(&(loc))
1138 
1139 /* end of xccmem API primitives */
1140 
1141 /* *//* *//* *//* *//* */
1142 
1143 #endif /* not XCCMEM_H */
#define xcc_rawcas_int(loc, ov, nv)
Definition: xccmem.h:808
__inline__ xcc_QItype __xcc_atomic_swap_QI(xcc_QItype *loc, xcc_QItype val)
Definition: xccmem.h:484
__inline__ void __xcc_spin_lock(int *loc)
Definition: xccmem.h:969
__inline__ int __xcc_cas_DI(xcc_DItype *loc, xcc_DItype ov, xcc_DItype nv)
Definition: xccmem.h:387
__inline__ int __xcc_cas_DF(xcc_DFtype *loc, xcc_DFtype ov, xcc_DFtype nv)
Definition: xccmem.h:431
#define xcc_cas_SI(loc, ov, nv)
Definition: xccmem.h:393
__inline__ int __xcc_cas_QI(xcc_QItype *loc, xcc_QItype ov, xcc_QItype nv)
Definition: xccmem.h:417
#define xcc_atomic_read_int(loc)
Definition: xccmem.h:643
#define xcc_try_rlock(loc)
Definition: xccmem.h:982
__inline__ xcc_SFtype __xcc_atomic_swap_SF(xcc_SFtype *loc, xcc_SFtype val)
Definition: xccmem.h:507
__inline__ void __xcc_release_rlock(int *loc)
Definition: xccmem.h:997
#define xcc_llbar()
Definition: xccmem.h:885
#define xcc_try_lock(loc)
Definition: xccmem.h:964
__inline__ int __xcc_try_rlock(int *loc)
Definition: xccmem.h:984
#define xcc_atomic_swap_DI(loc, v)
Definition: xccmem.h:449
__inline__ xcc_DFtype __xcc_atomic_swap_DF(xcc_DFtype *loc, xcc_DFtype val)
Definition: xccmem.h:497
__inline__ int __xcc_cas_HI(xcc_HItype *loc, xcc_HItype ov, xcc_HItype nv)
Definition: xccmem.h:403
short s
Definition: structsize.c:2
#define xcc_cas_DI(loc, ov, nv)
Definition: xccmem.h:385
#define xcc_atomic_swap_SI(loc, v)
Definition: xccmem.h:459
__inline__ int __xcc_cas_SF(xcc_SFtype *loc, xcc_SFtype ov, xcc_SFtype nv)
Definition: xccmem.h:441
__inline__ void __xcc_spin_rlock(int *loc)
Definition: xccmem.h:992
__inline__ xcc_DItype __xcc_atomic_swap_DI(xcc_DItype *loc, xcc_DItype val)
Definition: xccmem.h:451
__inline__ int __xcc_cas_SI(xcc_SItype *loc, xcc_SItype ov, xcc_SItype nv)
Definition: xccmem.h:395
__inline__ xcc_SItype __xcc_atomic_swap_SI(xcc_SItype *loc, xcc_SItype val)
Definition: xccmem.h:461
__inline__ xcc_HItype __xcc_atomic_swap_HI(xcc_HItype *loc, xcc_HItype val)
Definition: xccmem.h:471
GLfloat v[8][3]
Definition: cube.c:21
#define xcc_try_wlock(loc)
Definition: xccmem.h:1002
int xcc_DItype __attribute__((mode(DI)))
Definition: xccmem.h:30
#define FORCE_TYPE(TP, x)
Definition: xccmem.h:38
__inline__ void __xcc_spin_wlock(int *loc)
Definition: xccmem.h:1007


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Jun 6 2019 20:00:44