aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_x86_mutex.h
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-04-28 15:06:39 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-04-28 15:06:39 +0000
commit1d8d9eee942ab1d2565048e00d1817147c49f48c (patch)
tree05b00d2609f9a7264f2356b559353b466d1be0d4 /src/os/unix/ngx_x86_mutex.h
parenta09f08dbab9f06b81c1224a32607b26292015c8b (diff)
downloadnginx-1d8d9eee942ab1d2565048e00d1817147c49f48c.tar.gz
nginx-1d8d9eee942ab1d2565048e00d1817147c49f48c.zip
nginx-0.0.1-2003-04-28-19:06:39 import
Diffstat (limited to 'src/os/unix/ngx_x86_mutex.h')
-rw-r--r--src/os/unix/ngx_x86_mutex.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/os/unix/ngx_x86_mutex.h b/src/os/unix/ngx_x86_mutex.h
new file mode 100644
index 000000000..a8ed2eee2
--- /dev/null
+++ b/src/os/unix/ngx_x86_mutex.h
@@ -0,0 +1,30 @@
+
+
+typedef struct {
+ int lock;
+} ngx_mutex_t;
+
+
+static inline int ngx_spin_lock(ngx_mutex_t *m, int count)
+{
+ int lock;
+
+ __asm__ __volatile("
+
+get_lock:
+ mov $1, %1
+ xchg %1, %2
+ cmp $0, %1
+ jne spin_lock
+
+spin_lock:
+ cmp $0, %3
+ je failed
+
+ dec %3
+ rep nop
+ cmp $0, %2
+ jne spin_lock
+
+ ": "=q" (lock), "m" (m->lock), "q" (count));
+}