Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/cddl/osnet/dev/dtrace Use native atomic function in...
details: https://anonhg.NetBSD.org/src/rev/158780efd73d
branches: trunk
changeset: 327342:158780efd73d
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Mar 05 06:06:42 2014 +0000
description:
Use native atomic function instead of DTrace's own one
So we don't need to implement it for each architecture.
This change is from FreeBSD (not as-is though).
diffstat:
external/cddl/osnet/dev/dtrace/dtrace_debug.c | 61 +-------------------------
1 files changed, 3 insertions(+), 58 deletions(-)
diffs (82 lines):
diff -r a21483578d57 -r 158780efd73d external/cddl/osnet/dev/dtrace/dtrace_debug.c
--- a/external/cddl/osnet/dev/dtrace/dtrace_debug.c Wed Mar 05 05:56:04 2014 +0000
+++ b/external/cddl/osnet/dev/dtrace/dtrace_debug.c Wed Mar 05 06:06:42 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dtrace_debug.c,v 1.7 2014/03/04 03:20:49 ozaki-r Exp $ */
+/* $NetBSD: dtrace_debug.c,v 1.8 2014/03/05 06:06:42 ozaki-r Exp $ */
/*-
* Copyright (C) 2008 John Birrell <jb%freebsd.org@localhost>.
@@ -36,62 +36,6 @@
#ifdef DEBUG
-#if defined(__amd64__)
-static __inline int
-dtrace_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
-{
- u_char res;
-
- __asm __volatile(
- " lock ; "
- " cmpxchgq %2,%1 ; "
- " sete %0 ; "
- "1: "
- "# dtrace_cmpset_long"
- : "=a" (res), /* 0 */
- "=m" (*dst) /* 1 */
- : "r" (src), /* 2 */
- "a" (exp), /* 3 */
- "m" (*dst) /* 4 */
- : "memory");
-
- return (res);
-}
-#elif defined(__i386__)
-static __inline int
-dtrace_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
-{
- u_char res;
-
- __asm __volatile(
- " lock ; "
- " cmpxchgl %2,%1 ; "
- " sete %0 ; "
- "1: "
- "# dtrace_cmpset_long"
- : "=a" (res), /* 0 */
- "=m" (*dst) /* 1 */
- : "r" (src), /* 2 */
- "a" (exp), /* 3 */
- "m" (*dst) /* 4 */
- : "memory");
-
- return (res);
-}
-#elif defined(__arm__)
-static __inline int
-dtrace_cmpset_long(volatile u_long *dst, u_long exp, u_long src)
-{
- u_char res;
- if (*dst == src) {
- res = *dst;
- *dst = src;
- return res;
- }
- return exp;
-}
-#endif
-
#define DTRACE_DEBUG_BUFR_SIZE (32 * 1024)
struct dtrace_debug_data {
@@ -108,7 +52,8 @@
static void
dtrace_debug_lock(int cpu)
{
- while (dtrace_cmpset_long(&dtrace_debug_flag[cpu], 0, 1) == 0)
+ /* FIXME: use atomic_cmpset_ulong once we have it */
+ while (atomic_cas_ulong(&dtrace_debug_flag[cpu], 0, 1) == 0)
/* Loop until the lock is obtained. */
;
}
Home |
Main Index |
Thread Index |
Old Index