Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd/drm2/include/linux atomic_fetch_xor



details:   https://anonhg.NetBSD.org/src/rev/a6fe649a94ac
branches:  trunk
changeset: 1028015:a6fe649a94ac
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 01:39:20 2021 +0000

description:
atomic_fetch_xor

diffstat:

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

diffs (32 lines):

diff -r c591a19d8985 -r a6fe649a94ac sys/external/bsd/drm2/include/linux/atomic.h
--- a/sys/external/bsd/drm2/include/linux/atomic.h      Sun Dec 19 01:39:12 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/atomic.h      Sun Dec 19 01:39:20 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic.h,v 1.24 2021/12/19 01:33:51 riastradh Exp $    */
+/*     $NetBSD: atomic.h,v 1.25 2021/12/19 01:39:20 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -169,6 +169,22 @@
        atomic_and_uint(&atomic->a_u.au_uint, ~value);
 }
 
+static inline int
+atomic_fetch_xor(int value, atomic_t *atomic)
+{
+       unsigned old, new;
+
+       smp_mb__before_atomic();
+       do {
+               old = atomic->a_u.au_uint;
+               __insn_barrier();
+               new = old ^ value;
+       } while (atomic_cas_uint(&atomic->a_u.au_uint, old, new) != old);
+       smp_mb__after_atomic();
+
+       return old;
+}
+
 static inline void
 atomic_set_mask(unsigned long mask, atomic_t *atomic)
 {



Home | Main Index | Thread Index | Old Index