xref: /openbsd/sys/arch/powerpc/include/atomic.h (revision cca36db2)
1 /*	$OpenBSD: atomic.h,v 1.4 2011/03/23 16:54:36 pirofti Exp $	*/
2 
3 /* Public Domain */
4 
5 #ifndef _POWERPC_ATOMIC_H_
6 #define _POWERPC_ATOMIC_H_
7 
8 #if defined(_KERNEL)
9 
10 static __inline void
11 atomic_setbits_int(__volatile unsigned int *uip, unsigned int v)
12 {
13 	unsigned int tmp;
14 
15 	__asm volatile (
16 	    "1:	lwarx	%0, 0, %2	\n"
17 	    "	or	%0, %1, %0	\n"
18 	    "	stwcx.	%0, 0, %2	\n"
19 	    "	bne-	1b		\n"
20 	    "	sync" : "=&r" (tmp) : "r" (v), "r" (uip) : "memory");
21 }
22 
23 static __inline void
24 atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v)
25 {
26 	unsigned int tmp;
27 
28 	__asm volatile (
29 	    "1:	lwarx	%0, 0, %2	\n"
30 	    "	andc	%0, %0, %1	\n"
31 	    "	stwcx.	%0, 0, %2	\n"
32 	    "	bne-	1b		\n"
33 	    "	sync" : "=&r" (tmp) : "r" (v), "r" (uip) : "memory");
34 }
35 
36 #endif /* defined(_KERNEL) */
37 #endif /* _POWERPC_ATOMIC_H_ */
38