Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/include Implement __cpu_simple_{, un}lock{, try}...
details: https://anonhg.NetBSD.org/src/rev/a45a434507e7
branches: trunk
changeset: 485510:a45a434507e7
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sat Apr 29 19:39:51 2000 +0000
description:
Implement __cpu_simple_{,un}lock{,try}(), modeled after the Alpha
implementation.
diffstat:
sys/arch/i386/include/lock.h | 49 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 48 insertions(+), 1 deletions(-)
diffs (61 lines):
diff -r 2b7ccaec0375 -r a45a434507e7 sys/arch/i386/include/lock.h
--- a/sys/arch/i386/include/lock.h Sat Apr 29 17:42:46 2000 +0000
+++ b/sys/arch/i386/include/lock.h Sat Apr 29 19:39:51 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lock.h,v 1.2 2000/04/29 03:31:49 thorpej Exp $ */
+/* $NetBSD: lock.h,v 1.3 2000/04/29 19:39:51 thorpej Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -46,4 +46,51 @@
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0
+static __inline void __cpu_simple_lock_init __P((__volatile int *))
+ __attribute__((__unused__));
+static __inline void __cpu_simple_lock __P((__volatile int *))
+ __attribute__((__unused__));
+static __inline int __cpu_simple_lock_try __P((__volatile int *))
+ __attribute__((__unused__));
+static __inline void __cpu_simple_unlock __P((__volatile int *))
+ __attribute__((__unused__));
+
+static __inline void
+__cpu_simple_lock_init(__volatile int *alp)
+{
+
+ *alp = __SIMPLELOCK_UNLOCKED;
+}
+
+static __inline void
+__cpu_simple_lock(__volatile int *alp)
+{
+ int __val = __SIMPLELOCK_LOCKED;
+
+ do {
+ __asm __volatile("xchgl %0, %2"
+ : "=r" (__val)
+ : "0" (__val), "m" (*alp));
+ } while (__val != __SIMPLELOCK_UNLOCKED);
+}
+
+static __inline int
+__cpu_simple_lock_try(__volatile int *alp)
+{
+ int __val = __SIMPLELOCK_LOCKED;
+
+ __asm __volatile("xchgl %0, %2"
+ : "=r" (__val)
+ : "0" (__val), "m" (*alp));
+
+ return ((__val == __SIMPLELOCK_UNLOCKED) ? 1 : 0);
+}
+
+void
+__cpu_simple_unlock(__volatile int *alp)
+{
+
+ *alp = __SIMPLELOCK_UNLOCKED;
+}
+
#endif /* _I386_LOCK_H_ */
Home |
Main Index |
Thread Index |
Old Index