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 Implement atomic64_add_return and atom...



details:   https://anonhg.NetBSD.org/src/rev/a9f0d5586a27
branches:  trunk
changeset: 835467:a9f0d5586a27
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 15:11:17 2018 +0000

description:
Implement atomic64_add_return and atomic64_inc_return.

diffstat:

 sys/external/bsd/drm2/include/linux/atomic.h |  22 +++++++++++++++++++++-
 sys/external/bsd/drm2/linux/linux_atomic64.c |  16 ++++++++++++++--
 2 files changed, 35 insertions(+), 3 deletions(-)

diffs (92 lines):

diff -r a7204746b495 -r a9f0d5586a27 sys/external/bsd/drm2/include/linux/atomic.h
--- a/sys/external/bsd/drm2/include/linux/atomic.h      Mon Aug 27 15:11:04 2018 +0000
+++ b/sys/external/bsd/drm2/include/linux/atomic.h      Mon Aug 27 15:11:17 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic.h,v 1.18 2018/08/27 15:11:04 riastradh Exp $    */
+/*     $NetBSD: atomic.h,v 1.19 2018/08/27 15:11:17 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -264,6 +264,18 @@
        atomic_add_64(&a->a_v, -d);
 }
 
+static inline int64_t
+atomic64_add_return(int64_t d, struct atomic64 *a)
+{
+       int64_t v;
+
+       smp_mb__before_atomic();
+       v = (int64_t)atomic_add_64_nv(&a->a_v, d);
+       smp_mb__after_atomic();
+
+       return v;
+}
+
 static inline uint64_t
 atomic64_xchg(struct atomic64 *a, uint64_t new)
 {
@@ -296,6 +308,7 @@
 #else  /* !defined(__HAVE_ATOMIC64_OPS) */
 
 #define        atomic64_add            linux_atomic64_add
+#define        atomic64_add_return     linux_atomic64_add_return
 #define        atomic64_cmpxchg        linux_atomic64_cmpxchg
 #define        atomic64_read           linux_atomic64_read
 #define        atomic64_set            linux_atomic64_set
@@ -306,11 +319,18 @@
 void           atomic64_set(struct atomic64 *, uint64_t);
 void           atomic64_add(int64_t, struct atomic64 *);
 void           atomic64_sub(int64_t, struct atomic64 *);
+int64_t                atomic64_add_return(int64_t, struct atomic64 *);
 uint64_t       atomic64_xchg(struct atomic64 *, uint64_t);
 uint64_t       atomic64_cmpxchg(struct atomic64 *, uint64_t, uint64_t);
 
 #endif
 
+static inline int64_t
+atomic64_inc_return(struct atomic64 *a)
+{
+       return atomic64_add_return(1, a);
+}
+
 struct atomic_long {
        volatile unsigned long  al_v;
 };
diff -r a7204746b495 -r a9f0d5586a27 sys/external/bsd/drm2/linux/linux_atomic64.c
--- a/sys/external/bsd/drm2/linux/linux_atomic64.c      Mon Aug 27 15:11:04 2018 +0000
+++ b/sys/external/bsd/drm2/linux/linux_atomic64.c      Mon Aug 27 15:11:17 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_atomic64.c,v 1.2 2018/08/27 15:10:53 riastradh Exp $     */
+/*     $NetBSD: linux_atomic64.c,v 1.3 2018/08/27 15:11:17 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_atomic64.c,v 1.2 2018/08/27 15:10:53 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_atomic64.c,v 1.3 2018/08/27 15:11:17 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bitops.h>
@@ -164,6 +164,18 @@
        atomic64_unlock(a);
 }
 
+int64_t
+atomic64_add_return(int64_t delta, struct atomic64 *a)
+{
+       int64_t v;
+
+       atomic64_lock(a);
+       v = (int64_t)(a->a_v += delta);
+       atomic64_unlock(a);
+
+       return v;
+}
+
 uint64_t
 atomic64_xchg(struct atomic64 *a, uint64_t new)
 {



Home | Main Index | Thread Index | Old Index