Annotation of sys/arch/sparc64/include/atomic.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: atomic.h,v 1.3 2007/03/13 08:34:03 art Exp $ */
2: /*
3: * Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
4: *
5: * Permission to use, copy, modify, and distribute this software for any
6: * purpose with or without fee is hereby granted, provided that the above
7: * copyright notice and this permission notice appear in all copies.
8: *
9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16: */
17:
18: #ifndef _SPARC64_ATOMIC_H_
19: #define _SPARC64_ATOMIC_H_
20:
21: #if defined(_KERNEL)
22:
23: static __inline unsigned int
24: sparc64_casa(volatile unsigned int *uip, unsigned int expect, unsigned int new)
25: {
26: __asm __volatile("casa [%2] %3, %4, %0"
27: : "+r" (new), "=m" (*uip)
28: : "r" (uip), "n" (ASI_N), "r" (expect), "m" (*uip));
29:
30: return (new);
31: }
32:
33: static __inline void
34: atomic_setbits_int(volatile unsigned int *uip, unsigned int v)
35: {
36: volatile unsigned int e, r;
37:
38: r = *uip;
39: do {
40: e = r;
41: r = sparc64_casa(uip, e, e | v);
42: } while (r != e);
43: }
44:
45: static __inline void
46: atomic_clearbits_int(volatile unsigned int *uip, unsigned int v)
47: {
48: volatile unsigned int e, r;
49:
50: r = *uip;
51: do {
52: e = r;
53: r = sparc64_casa(uip, e, e & ~v);
54: } while (r != e);
55: }
56:
57: #endif /* defined(_KERNEL) */
58: #endif /* _SPARC64_ATOMIC_H_ */
CVSweb