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 drm/linux: atomic_fetch_...



details:   https://anonhg.NetBSD.org/src/rev/aec667a87a08
branches:  trunk
changeset: 1028533:aec667a87a08
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:16:00 2021 +0000

description:
drm/linux: atomic_fetch_add/inc

diffstat:

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

diffs (37 lines):

diff -r 52726fce17a2 -r aec667a87a08 sys/external/bsd/drm2/include/linux/atomic.h
--- a/sys/external/bsd/drm2/include/linux/atomic.h      Sun Dec 19 11:15:49 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/atomic.h      Sun Dec 19 11:16:00 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic.h,v 1.36 2021/12/19 11:14:56 riastradh Exp $    */
+/*     $NetBSD: atomic.h,v 1.37 2021/12/19 11:16:00 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -201,6 +201,27 @@
 }
 
 static inline int
+atomic_fetch_add(int value, atomic_t *atomic)
+{
+       unsigned old, new;
+
+       smp_mb__before_atomic();
+       do {
+               old = atomic->a_u.au_uint;
+               new = old + value;
+       } while (atomic_cas_uint(&atomic->a_u.au_uint, old, new) != old);
+       smp_mb__after_atomic();
+
+       return old;
+}
+
+static inline int
+atomic_fetch_inc(atomic_t *atomic)
+{
+       return atomic_fetch_add(1, atomic);
+}
+
+static inline int
 atomic_fetch_xor(int value, atomic_t *atomic)
 {
        unsigned old, new;



Home | Main Index | Thread Index | Old Index