diff src/core/ngx_atomic.h @ 267:83205e0b5522

nginx-0.0.2-2004-02-24-20:31:46 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 24 Feb 2004 17:31:46 +0000
parents 5238e93961a1
children d4e65d74db9f
line wrap: on
line diff
--- a/src/core/ngx_atomic.h
+++ b/src/core/ngx_atomic.h
@@ -6,9 +6,9 @@
 #include <ngx_core.h>
 
 
-#ifdef __i386__
+#if ( __i386__ || __amd64__ )
 
-typedef uint32_t  ngx_atomic_t;
+typedef volatile uint32_t  ngx_atomic_t;
 
 #if (NGX_SMP)
 #define NGX_SMP_LOCK  "lock"
@@ -21,13 +21,13 @@ static ngx_inline uint32_t ngx_atomic_in
 {
     uint32_t  old;
 
-    __asm__ __volatile ("
+    __asm__ volatile (
 
-        movl   $1, %0
-    "   NGX_SMP_LOCK
-    "   xaddl  %0, %1
+    "   movl   $1, %0;   "
+        NGX_SMP_LOCK
+    "   xaddl  %0, %1;   "
 
-    ": "=a" (old) : "m" (*value));
+    : "=a" (old) : "m" (*value));
 
     return old;
 }
@@ -37,13 +37,13 @@ static ngx_inline uint32_t ngx_atomic_de
 {
     uint32_t  old;
 
-    __asm__ __volatile ("
+    __asm__ volatile (
 
-        movl   $-1, %0
-    "   NGX_SMP_LOCK
-    "   xaddl  %0, %1
+    "   movl   $-1, %0;  "
+        NGX_SMP_LOCK
+    "   xaddl  %0, %1;   "
 
-    ": "=a" (old) : "m" (*value));
+    : "=a" (old) : "m" (*value));
 
     return old;
 }
@@ -55,21 +55,21 @@ static ngx_inline uint32_t ngx_atomic_cm
 {
     uint32_t  res;
 
-    __asm__ __volatile ("
+    __asm__ volatile (
 
-    "   NGX_SMP_LOCK
-    "   cmpxchgl  %3, %1
-        setzb     %%al
-        movzbl    %%al, %0
+        NGX_SMP_LOCK
+    "   cmpxchgl  %3, %1;   "
+    "   setzb     %%al;     "
+    "   movzbl    %%al, %0; "
 
-    ": "=a" (res) : "m" (*lock), "a" (old), "q" (set));
+    : "=a" (res) : "m" (*lock), "a" (old), "q" (set));
 
     return res;
 }
 
 #else
 
-typedef uint32_t  ngx_atomic_t;
+typedef volatile uint32_t  ngx_atomic_t;
 
 /* STUB */
 #define ngx_atomic_inc(x)   x++;