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 several ope...
details: https://anonhg.NetBSD.org/src/rev/32567a1e6af3
branches: riastradh-drm2
changeset: 788394:32567a1e6af3
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jul 24 03:35:50 2013 +0000
description:
Add several operations to <linux/atomic.h>.
atomic_add_unless
atomic_clear_mask
atomic_inc_not_zero
atomic_set_mask
atomic_sub
diffstat:
sys/external/bsd/drm2/include/linux/atomic.h | 41 +++++++++++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletions(-)
diffs (62 lines):
diff -r 53e697022ec0 -r 32567a1e6af3 sys/external/bsd/drm2/include/linux/atomic.h
--- a/sys/external/bsd/drm2/include/linux/atomic.h Wed Jul 24 03:35:34 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/atomic.h Wed Jul 24 03:35:50 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic.h,v 1.1.2.8 2013/07/24 02:28:36 riastradh Exp $ */
+/* $NetBSD: atomic.h,v 1.1.2.9 2013/07/24 03:35:50 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -61,6 +61,12 @@
atomic_add_int(&atomic->a_u.au_uint, addend);
}
+static inline void
+atomic_sub(int subtrahend, atomic_t *atomic)
+{
+ atomic_add_int(&atomic->a_u.au_uint, -subtrahend);
+}
+
static inline int
atomic_add_return(int addend, atomic_t *atomic)
{
@@ -86,6 +92,39 @@
}
static inline void
+atomic_set_mask(unsigned long mask, atomic_t *atomic)
+{
+ atomic_or_uint(&atomic->a_u.au_uint, mask);
+}
+
+static inline void
+atomic_clear_mask(unsigned long mask, atomic_t *atomic)
+{
+ atomic_and_uint(&atomic->a_u.au_uint, ~mask);
+}
+
+static inline int
+atomic_add_unless(atomic_t *atomic, int addend, int zero)
+{
+ int value;
+
+ do {
+ value = atomic->a_u.au_int;
+ if (value == zero)
+ return 0;
+ } while (atomic_cas_uint(&atomic->a_u.au_uint, value, (value + addend))
+ != value);
+
+ return 1;
+}
+
+static inline int
+atomic_inc_not_zero(atomic_t *atomic)
+{
+ return atomic_add_unless(atomic, 1, 0);
+}
+
+static inline void
set_bit(unsigned long bit, volatile unsigned long *ptr)
{
atomic_or_ulong(ptr, (1 << bit));
Home |
Main Index |
Thread Index |
Old Index