34 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
35 #if defined(__i386__) || defined(__i386)
36 #define pg_memory_barrier_impl() \
37 __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory", "cc")
38 #elif defined(__x86_64__)
39 #define pg_memory_barrier_impl() \
40 __asm__ __volatile__ ("lock; addl $0,0(%%rsp)" : : : "memory", "cc")
44 #define pg_read_barrier_impl() pg_compiler_barrier_impl()
45 #define pg_write_barrier_impl() pg_compiler_barrier_impl()
52 #if defined(HAVE_ATOMICS)
54 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
56 #define PG_HAVE_ATOMIC_FLAG_SUPPORT
62 #define PG_HAVE_ATOMIC_U32_SUPPORT
73 #define PG_HAVE_ATOMIC_U64_SUPPORT
77 volatile uint64
value;
85 #if !defined(PG_HAVE_SPIN_DELAY)
109 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
110 #define PG_HAVE_SPIN_DELAY
111 static __inline__
void
114 __asm__ __volatile__(
" rep; nop \n");
116 #elif defined(_MSC_VER) && defined(__x86_64__)
117 #define PG_HAVE_SPIN_DELAY
118 static __forceinline
void
123 #elif defined(_MSC_VER)
124 #define PG_HAVE_SPIN_DELAY
125 static __forceinline
void
135 #if defined(HAVE_ATOMICS)
137 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
139 #define PG_HAVE_ATOMIC_TEST_SET_FLAG
145 __asm__ __volatile__(
148 :
"+q"(_res),
"+m"(ptr->
value)
154 #define PG_HAVE_ATOMIC_CLEAR_FLAG
162 __asm__ __volatile__(
"" :::
"memory");
166 #define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32
177 __asm__ __volatile__(
181 :
"=a" (*expected),
"=m"(ptr->
value),
"=q" (ret)
187 #define PG_HAVE_ATOMIC_FETCH_ADD_U32
192 __asm__ __volatile__(
196 :
"0" (add_),
"m"(ptr->
value)
203 #define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64
206 uint64 *expected, uint64
newval)
214 __asm__ __volatile__(
218 :
"=a" (*expected),
"=m"(ptr->
value),
"=q" (ret)
224 #define PG_HAVE_ATOMIC_FETCH_ADD_U64
229 __asm__ __volatile__(
233 :
"0" (add_),
"m"(ptr->
value)
246 #if defined(__i568__) || defined(__i668__) || \
247 (defined(_M_IX86) && _M_IX86 >= 500) || \
248 defined(__x86_64__) || defined(__x86_64) || defined(_M_X64)
249 #define PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY
struct pg_atomic_uint32 pg_atomic_uint32
bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
void pg_atomic_clear_flag_impl(volatile pg_atomic_flag *ptr)
uint64 pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_)
uint32 pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_)
bool pg_atomic_test_set_flag_impl(volatile pg_atomic_flag *ptr)
bool pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 *expected, uint64 newval)
static void PGresult * res
struct pg_atomic_flag pg_atomic_flag
struct pg_atomic_uint64 pg_atomic_uint64
#define pg_spin_delay_impl()