3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Nginx, Inc.
9 #define NGX_SMP_LOCK "lock;"
27 * The "r" is any register, %rax (%r0) - %r16.
28 * The "=a" and "a" are the %rax register.
29 * Although we can return result in any register, we use "a" because it is
30 * used in cmpxchgq anyway. The result is actually in %al but not in $rax,
31 * however as the code is inlined gcc can test %al as well as %rax.
33 * The "cc" means that flags were changed.
36 static ngx_inline ngx_atomic_uint_t
37 ngx_atomic_cmp_set(ngx_atomic_t
*lock
, ngx_atomic_uint_t old
,
38 ngx_atomic_uint_t set
)
48 : "=a" (res
) : "m" (*lock
), "a" (old
), "r" (set
) : "cc", "memory");
62 * The "+r" is any register, %rax (%r0) - %r16.
63 * The "cc" means that flags were changed.
66 static ngx_inline ngx_atomic_int_t
67 ngx_atomic_fetch_add(ngx_atomic_t
*value
, ngx_atomic_int_t add
)
74 : "+r" (add
) : "m" (*value
) : "cc", "memory");
80 #define ngx_memory_barrier() __asm__ volatile ("" ::: "memory")
82 #define ngx_cpu_pause() __asm__ ("pause")