Module Name:    src
Committed By:   riastradh
Date:           Sun Dec 19 01:39:20 UTC 2021

Modified Files:
        src/sys/external/bsd/drm2/include/linux: atomic.h

Log Message:
atomic_fetch_xor


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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.24 src/sys/external/bsd/drm2/include/linux/atomic.h:1.25
--- src/sys/external/bsd/drm2/include/linux/atomic.h:1.24	Sun Dec 19 01:33:51 2021
+++ src/sys/external/bsd/drm2/include/linux/atomic.h	Sun Dec 19 01:39:20 2021
@@ -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_andnot(int value, atomic_t *atomi
 	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)
 {

Reply via email to