comparison src/core/ngx_atomic.h @ 297:ee394e997c77

nginx-0.0.3-2004-03-29-21:43:58 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 29 Mar 2004 17:43:58 +0000
parents 0ba4821f4460
children 4a3f18406832
comparison
equal deleted inserted replaced
296:bfe099e3f5b4 297:ee394e997c77
19 19
20 static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value) 20 static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value)
21 { 21 {
22 uint32_t old; 22 uint32_t old;
23 23
24 old = 1;
25
24 __asm__ volatile ( 26 __asm__ volatile (
25 27
26 " movl $1, %0; "
27 NGX_SMP_LOCK 28 NGX_SMP_LOCK
28 " xaddl %0, %1; " 29 " xaddl %0, %1; "
29 30
30 : "=a" (old) : "m" (*value)); 31 : "=q" (old) : "m" (*value));
31 32
32 return old; 33 return old;
33 } 34 }
34 35
35 36
36 static ngx_inline uint32_t ngx_atomic_dec(ngx_atomic_t *value) 37 static ngx_inline uint32_t ngx_atomic_dec(ngx_atomic_t *value)
37 { 38 {
38 uint32_t old; 39 uint32_t old;
39 40
41 old = (uint32_t) -1;
42
40 __asm__ volatile ( 43 __asm__ volatile (
41 44
42 " movl $-1, %0; "
43 NGX_SMP_LOCK 45 NGX_SMP_LOCK
44 " xaddl %0, %1; " 46 " xaddl %0, %1; "
45 47
46 : "=a" (old) : "m" (*value)); 48 : "=q" (old) : "m" (*value));
47 49
48 return old; 50 return old;
49 } 51 }
50 52
51 53
60 NGX_SMP_LOCK 62 NGX_SMP_LOCK
61 " cmpxchgl %3, %1; " 63 " cmpxchgl %3, %1; "
62 " setz %%al; " 64 " setz %%al; "
63 " movzbl %%al, %0; " 65 " movzbl %%al, %0; "
64 66
65 : "=a" (res) : "m" (*lock), "a" (old), "q" (set)); 67 : "+a" (res) : "m" (*lock), "a" (old), "q" (set));
66 68
67 return res; 69 return res;
68 } 70 }
69 71
70 #else 72 #else