Deleted Added
full compact
drm_atomic.h (152909) drm_atomic.h (183573)
1/**
2 * \file drm_atomic.h
3 * Atomic operations used in the DRM which may or may not be provided by the OS.
4 *
5 * \author Eric Anholt <anholt@FreeBSD.org>
6 */
7
8/*-

--- 16 unchanged lines hidden (view full) ---

25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 * OTHER DEALINGS IN THE SOFTWARE.
30 */
31
32#include <sys/cdefs.h>
1/**
2 * \file drm_atomic.h
3 * Atomic operations used in the DRM which may or may not be provided by the OS.
4 *
5 * \author Eric Anholt <anholt@FreeBSD.org>
6 */
7
8/*-

--- 16 unchanged lines hidden (view full) ---

25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
27 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 * OTHER DEALINGS IN THE SOFTWARE.
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/dev/drm/drm_atomic.h 152909 2005-11-28 23:13:57Z anholt $");
33__FBSDID("$FreeBSD: head/sys/dev/drm/drm_atomic.h 183573 2008-10-03 16:59:11Z rnoland $");
34
35/* Many of these implementations are rather fake, but good enough. */
36
37typedef u_int32_t atomic_t;
38
34
35/* Many of these implementations are rather fake, but good enough. */
36
37typedef u_int32_t atomic_t;
38
39#ifdef __FreeBSD__
40#define atomic_set(p, v) (*(p) = (v))
41#define atomic_read(p) (*(p))
42#define atomic_inc(p) atomic_add_int(p, 1)
43#define atomic_dec(p) atomic_subtract_int(p, 1)
44#define atomic_add(n, p) atomic_add_int(p, n)
45#define atomic_sub(n, p) atomic_subtract_int(p, n)
39#define atomic_set(p, v) (*(p) = (v))
40#define atomic_read(p) (*(p))
41#define atomic_inc(p) atomic_add_int(p, 1)
42#define atomic_dec(p) atomic_subtract_int(p, 1)
43#define atomic_add(n, p) atomic_add_int(p, n)
44#define atomic_sub(n, p) atomic_subtract_int(p, n)
46#else /* __FreeBSD__ */
47/* FIXME */
48#define atomic_set(p, v) (*(p) = (v))
49#define atomic_read(p) (*(p))
50#define atomic_inc(p) (*(p) += 1)
51#define atomic_dec(p) (*(p) -= 1)
52#define atomic_add(n, p) (*(p) += (n))
53#define atomic_sub(n, p) (*(p) -= (n))
54/* FIXME */
55#define atomic_add_int(p, v) *(p) += v
56#define atomic_subtract_int(p, v) *(p) -= v
57#define atomic_set_int(p, bits) *(p) |= (bits)
58#define atomic_clear_int(p, bits) *(p) &= ~(bits)
59#endif /* !__FreeBSD__ */
60
45
61#if !defined(__FreeBSD_version) || (__FreeBSD_version < 500000)
62#if defined(__i386__)
63/* The extra atomic functions from 5.0 haven't been merged to 4.x */
64static __inline int
65atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
66{
67 int res = exp;
68
69 __asm __volatile (
70 " lock ; "
71 " cmpxchgl %1,%2 ; "
72 " setz %%al ; "
73 " movzbl %%al,%0 ; "
74 "1: "
75 "# atomic_cmpset_int"
76 : "+a" (res) /* 0 (result) */
77 : "r" (src), /* 1 */
78 "m" (*(dst)) /* 2 */
79 : "memory");
80
81 return (res);
82}
83#else /* __i386__ */
84static __inline int
85atomic_cmpset_int(__volatile__ int *dst, int old, int new)
86{
87 int s = splhigh();
88 if (*dst==old) {
89 *dst = new;
90 splx(s);
91 return 1;
92 }
93 splx(s);
94 return 0;
95}
96#endif /* !__i386__ */
97#endif /* !__FreeBSD_version || __FreeBSD_version < 500000 */
98
99static __inline atomic_t
100test_and_set_bit(int b, volatile void *p)
101{
102 int s = splhigh();
103 unsigned int m = 1<<b;
104 unsigned int r = *(volatile int *)p & m;
105 *(volatile int *)p |= m;
106 splx(s);

--- 38 unchanged lines hidden ---
46static __inline atomic_t
47test_and_set_bit(int b, volatile void *p)
48{
49 int s = splhigh();
50 unsigned int m = 1<<b;
51 unsigned int r = *(volatile int *)p & m;
52 *(volatile int *)p |= m;
53 splx(s);

--- 38 unchanged lines hidden ---