Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Define apporpriate an value for SIMPLELOCK_LOCKED, ...



details:   https://anonhg.NetBSD.org/src/rev/af3bd8d13888
branches:  trunk
changeset: 474959:af3bd8d13888
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Jul 27 22:22:33 1999 +0000

description:
Define apporpriate an value for SIMPLELOCK_LOCKED, based on the
semantics of ldstub.

diffstat:

 sys/arch/sparc/include/lock.h   |  19 +++++++++++++------
 sys/arch/sparc64/include/lock.h |  19 +++++++++++++------
 2 files changed, 26 insertions(+), 12 deletions(-)

diffs (122 lines):

diff -r 1f99d132be37 -r af3bd8d13888 sys/arch/sparc/include/lock.h
--- a/sys/arch/sparc/include/lock.h     Tue Jul 27 21:50:37 1999 +0000
+++ b/sys/arch/sparc/include/lock.h     Tue Jul 27 22:22:33 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock.h,v 1.4 1999/07/27 21:45:41 thorpej Exp $ */
+/*     $NetBSD: lock.h,v 1.5 1999/07/27 22:22:33 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -47,6 +47,13 @@
 
 #include <sparc/sparc/asm.h>
 
+/*
+ * The value for SIMPLELOCK_LOCKED is what ldstub() naturally stores
+ * `lock_data' given its address (and the fact that SPARC is big-endian).
+ */
+#define        SIMPLELOCK_LOCKED       0xff000000
+#define        SIMPLELOCK_UNLOCKED     0
+
 static void    cpu_simple_lock_init __P((__volatile struct simplelock *));
 static void    cpu_simple_lock __P((__volatile struct simplelock *));
 static int     cpu_simple_lock_try __P((__volatile struct simplelock *));
@@ -57,7 +64,7 @@
        __volatile struct simplelock *alp;
 {
 
-       alp->lock_data = 0;
+       alp->lock_data = SIMPLELOCK_UNLOCKED;
 }
 
 static __inline__ void
@@ -72,8 +79,8 @@
         * becaused the cache-coherency logic does not have to
         * broadcast invalidates on the lock while we spin on it.
         */
-       while (ldstub(&alp->lock_data) != 0) {
-               while (alp->lock_data != 0)
+       while (ldstub(&alp->lock_data) != SIMPLELOCK_UNLOCKED) {
+               while (alp->lock_data != SIMPLELOCK_UNLOCKED)
                        /*void*/;
        }
 }
@@ -83,7 +90,7 @@
        __volatile struct simplelock *alp;
 {
 
-       return (ldstub(&alp->lock_data) == 0);
+       return (ldstub(&alp->lock_data) == SIMPLELOCK_UNLOCKED);
 }
 
 static __inline__ void
@@ -91,7 +98,7 @@
        __volatile struct simplelock *alp;
 {
 
-       alp->lock_data = 0;
+       alp->lock_data = SIMPLELOCK_UNLOCKED;
 }
 
 #endif /* _KERNEL */
diff -r 1f99d132be37 -r af3bd8d13888 sys/arch/sparc64/include/lock.h
--- a/sys/arch/sparc64/include/lock.h   Tue Jul 27 21:50:37 1999 +0000
+++ b/sys/arch/sparc64/include/lock.h   Tue Jul 27 22:22:33 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lock.h,v 1.2 1999/07/27 21:45:41 thorpej Exp $ */
+/*     $NetBSD: lock.h,v 1.3 1999/07/27 22:22:34 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -47,6 +47,13 @@
 
 #include <sparc64/sparc64/asm.h>
 
+/*
+ * The value for SIMPLELOCK_LOCKED is what ldstub() naturally stores
+ * `lock_data' given its address (and the fact that SPARC is big-endian).
+ */
+#define        SIMPLELOCK_LOCKED       0xff000000
+#define        SIMPLELOCK_UNLOCKED     0
+
 static void    cpu_simple_lock_init __P((__volatile struct simplelock *));
 static void    cpu_simple_lock __P((__volatile struct simplelock *));
 static int     cpu_simple_lock_try __P((__volatile struct simplelock *));
@@ -57,7 +64,7 @@
        __volatile struct simplelock *alp;
 {
 
-       alp->lock_data = 0;
+       alp->lock_data = SIMPLELOCK_UNLOCKED;
 }
 
 static __inline__ void
@@ -72,8 +79,8 @@
         * becaused the cache-coherency logic does not have to
         * broadcast invalidates on the lock while we spin on it.
         */
-       while (ldstub(&alp->lock_data) != 0) {
-               while (alp->lock_data != 0)
+       while (ldstub(&alp->lock_data) != SIMPLELOCK_UNLOCKED) {
+               while (alp->lock_data != SIMPLELOCK_UNLOCKED)
                        /*void*/;
        }
 }
@@ -83,7 +90,7 @@
        __volatile struct simplelock *alp;
 {
 
-       return (ldstub(&alp->lock_data) == 0);
+       return (ldstub(&alp->lock_data) == SIMPLELOCK_UNLOCKED);
 }
 
 static __inline__ void
@@ -91,7 +98,7 @@
        __volatile struct simplelock *alp;
 {
 
-       alp->lock_data = 0;
+       alp->lock_data = SIMPLELOCK_UNLOCKED;
 }
 
 #endif /* _KERNEL */



Home | Main Index | Thread Index | Old Index