Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/riastradh-drm2]: src/sys/external/bsd/drm2/include/linux Add some bit-to...



details:   https://anonhg.NetBSD.org/src/rev/02a63a228bf4
branches:  riastradh-drm2
changeset: 788079:02a63a228bf4
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 24 02:08:01 2013 +0000

description:
Add some bit-toggling atomics to <linux/atomic.h>.

diffstat:

 sys/external/bsd/drm2/include/linux/atomic.h |  52 +++++++++++++++++++++++++++-
 1 files changed, 51 insertions(+), 1 deletions(-)

diffs (64 lines):

diff -r 53f2f8891f0c -r 02a63a228bf4 sys/external/bsd/drm2/include/linux/atomic.h
--- a/sys/external/bsd/drm2/include/linux/atomic.h      Wed Jul 24 02:07:46 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/atomic.h      Wed Jul 24 02:08:01 2013 +0000
@@ -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 @@
        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_ */



Home | Main Index | Thread Index | Old Index