Module Name: src
Committed By: riastradh
Date: Wed Jul 24 02:08:01 UTC 2013
Modified Files:
src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: atomic.h
Log Message:
Add some bit-toggling atomics to <linux/atomic.h>.
To generate a diff of this commit:
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 \
src/sys/external/bsd/drm2/include/linux/atomic.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/include/linux/atomic.h
diff -u src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.4 src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.5
--- src/sys/external/bsd/drm2/include/linux/atomic.h:1.1.2.4 Wed Jul 24 02:02:17 2013
+++ src/sys/external/bsd/drm2/include/linux/atomic.h Wed Jul 24 02:08:01 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic.h,v 1.1.2.4 2013/07/24 02:02:17 riastradh Exp $ */
+/* $NetBSD: atomic.h,v 1.1.2.5 2013/07/24 02:08:01 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -71,4 +71,54 @@ atomic_dec_and_test(atomic_t *atomic)
return (-1 == (int)atomic_dec_uint_nv(&atomic->a_u.au_uint));
}
+static inline void
+set_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+ atomic_or_ulong(ptr, (1 << bit));
+}
+
+static inline void
+clear_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+ atomic_and_ulong(ptr, ~(1 << bit));
+}
+
+static inline void
+change_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+ unsigned long v;
+
+ do v = *ptr; while (atomic_cas_ulong(ptr, v, v ^ (1 << bit)) != v);
+}
+
+static inline unsigned long
+test_and_set_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+ unsigned long v;
+
+ do v = *ptr; while (atomic_cas_ulong(ptr, v, v | (1 << bit)) != v);
+
+ return (v & (1 << bit));
+}
+
+static inline unsigned long
+test_and_clear_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+ unsigned long v;
+
+ do v = *ptr; while (atomic_cas_ulong(ptr, v, v &~ (1 << bit)) != v);
+
+ return (v & (1 << bit));
+}
+
+static inline unsigned long
+test_and_change_bit(unsigned long bit, volatile unsigned long *ptr)
+{
+ unsigned long v;
+
+ do v = *ptr; while (atomic_cas_ulong(ptr, v, v ^ (1 << bit)) != v);
+
+ return (v & (1 << bit));
+}
+
#endif /* _LINUX_ATOMIC_H_ */