summaryrefslogtreecommitdiff
path: root/sys/arch/m68k/include/atomic.h
blob: 9a411d7d0b84b678558c4a8e41b0849b3a372730 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*	$OpenBSD: atomic.h,v 1.3 2007/03/21 05:28:20 miod Exp $	*/

/* Public Domain */

#ifndef __M68K_ATOMIC_H__
#define __M68K_ATOMIC_H__

#if defined(_KERNEL)

static __inline void
atomic_setbits_int(__volatile unsigned int *uip, unsigned int v)
{
	unsigned int witness, old, new;

	do {
		witness = old = *uip;
		new = old | v;
		__asm__ __volatile__ (
			"casl %0, %2, %1" : "+d"(old), "=m"(*uip) : "d"(new));
	} while (old != witness);
}

static __inline void
atomic_clearbits_int(__volatile unsigned int *uip, unsigned int v)
{
	unsigned int witness, old, new;

	do {
		witness = old = *uip;
		new = old & ~v;
		__asm__ __volatile__ (
			"casl %0, %2, %1" : "+d"(old), "=m"(*uip) : "d"(new));
	} while (old != witness);
}

#endif /* defined(_KERNEL) */
#endif /* __M68K_ATOMIC_H__ */