about summary refs log tree commit diff
path: root/src/rt/sync/spin_lock.cpp
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2010-09-08 19:13:49 -0700
committerGraydon Hoare <graydon@mozilla.com>2010-09-08 19:13:49 -0700
commit616b7afb724a32df41eebfaf95402d008c60b411 (patch)
tree03e13578e8b43b9001cef983d1117800a6f93e65 /src/rt/sync/spin_lock.cpp
parent13d6f874316c9f69ab3a29f120ce410da2290a64 (diff)
downloadrust-616b7afb724a32df41eebfaf95402d008c60b411.tar.gz
rust-616b7afb724a32df41eebfaf95402d008c60b411.zip
Tidy up the sync dir, remove dead or mis-designed code in favour of OS primitives, switch rust_kernel to use a lock/signal pair and wait rather than spin.
Diffstat (limited to 'src/rt/sync/spin_lock.cpp')
-rw-r--r--src/rt/sync/spin_lock.cpp48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/rt/sync/spin_lock.cpp b/src/rt/sync/spin_lock.cpp
deleted file mode 100644
index 4a113d1aef9..00000000000
--- a/src/rt/sync/spin_lock.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "../globals.h"
-#include "spin_lock.h"
-
-/*
- * Your average spin lock.
- */
-
-// #define TRACE
-
-spin_lock::spin_lock() {
-    unlock();
-}
-
-spin_lock::~spin_lock() {
-}
-
-static inline unsigned xchg32(void *ptr, unsigned x) {
-    __asm__ __volatile__("xchgl %0,%1"
-                :"=r" ((unsigned) x)
-                :"m" (*(volatile unsigned *)ptr), "0" (x)
-                :"memory");
-    return x;
-}
-
-void spin_lock::lock() {
-    while (true) {
-        if (!xchg32(&ticket, 1)) {
-            return;
-        }
-        while (ticket) {
-            pause();
-        }
-    }
-#ifdef TRACE
-    printf("  lock: %d", ticket);
-#endif
-}
-
-void spin_lock::unlock() {
-    ticket = 0;
-#ifdef TRACE
-    printf("unlock:");
-#endif
-}
-
-void spin_lock::pause() {
-    asm volatile("pause\n" : : : "memory");
-}