PostgreSQL Source Code  git master
arch-ppc.h File Reference

Go to the source code of this file.

Data Structures

struct  pg_atomic_uint32
 

Macros

#define PG_HAVE_ATOMIC_U32_SUPPORT
 
#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32
 
#define PG_HAVE_ATOMIC_FETCH_ADD_U32
 
#define PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY
 

Typedefs

typedef struct pg_atomic_uint32 pg_atomic_uint32
 

Functions

static bool pg_atomic_compare_exchange_u32_impl (volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
 
static uint32 pg_atomic_fetch_add_u32_impl (volatile pg_atomic_uint32 *ptr, int32 add_)
 

Macro Definition Documentation

◆ PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY

#define PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY

Definition at line 254 of file arch-ppc.h.

◆ PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32

#define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U32

Definition at line 78 of file arch-ppc.h.

◆ PG_HAVE_ATOMIC_FETCH_ADD_U32

#define PG_HAVE_ATOMIC_FETCH_ADD_U32

Definition at line 129 of file arch-ppc.h.

◆ PG_HAVE_ATOMIC_U32_SUPPORT

#define PG_HAVE_ATOMIC_U32_SUPPORT

Definition at line 28 of file arch-ppc.h.

Typedef Documentation

◆ pg_atomic_uint32

Function Documentation

◆ pg_atomic_compare_exchange_u32_impl()

static bool pg_atomic_compare_exchange_u32_impl ( volatile pg_atomic_uint32 ptr,
uint32 expected,
uint32  newval 
)
inlinestatic

Definition at line 80 of file arch-ppc.h.

82 {
83  uint32 found;
84  uint32 condition_register;
85  bool ret;
86 
87 #ifdef HAVE_I_CONSTRAINT__BUILTIN_CONSTANT_P
88  if (__builtin_constant_p(*expected) &&
89  (int32) *expected <= PG_INT16_MAX &&
90  (int32) *expected >= PG_INT16_MIN)
91  __asm__ __volatile__(
92  " sync \n"
93  " lwarx %0,0,%5,1 \n"
94  " cmpwi %0,%3 \n"
95  " bne $+12 \n" /* branch to lwsync */
96  " stwcx. %4,0,%5 \n"
97  " bne $-16 \n" /* branch to lwarx */
98  " lwsync \n"
99  " mfcr %1 \n"
100 : "=&r"(found), "=r"(condition_register), "+m"(ptr->value)
101 : "i"(*expected), "r"(newval), "r"(&ptr->value)
102 : "memory", "cc");
103  else
104 #endif
105  __asm__ __volatile__(
106  " sync \n"
107  " lwarx %0,0,%5,1 \n"
108  " cmpw %0,%3 \n"
109  " bne $+12 \n" /* branch to lwsync */
110  " stwcx. %4,0,%5 \n"
111  " bne $-16 \n" /* branch to lwarx */
112  " lwsync \n"
113  " mfcr %1 \n"
114 : "=&r"(found), "=r"(condition_register), "+m"(ptr->value)
115 : "r"(*expected), "r"(newval), "r"(&ptr->value)
116 : "memory", "cc");
117 
118  ret = (condition_register >> 29) & 1; /* test eq bit of cr0 */
119  if (!ret)
120  *expected = found;
121  return ret;
122 }
unsigned int uint32
Definition: c.h:495
signed int int32
Definition: c.h:483
#define PG_INT16_MIN
Definition: c.h:574
#define PG_INT16_MAX
Definition: c.h:575
#define newval

References newval, PG_INT16_MAX, PG_INT16_MIN, and pg_atomic_uint32::value.

◆ pg_atomic_fetch_add_u32_impl()

static uint32 pg_atomic_fetch_add_u32_impl ( volatile pg_atomic_uint32 ptr,
int32  add_ 
)
inlinestatic

Definition at line 131 of file arch-ppc.h.

132 {
133  uint32 _t;
134  uint32 res;
135 
136 #ifdef HAVE_I_CONSTRAINT__BUILTIN_CONSTANT_P
137  if (__builtin_constant_p(add_) &&
138  add_ <= PG_INT16_MAX && add_ >= PG_INT16_MIN)
139  __asm__ __volatile__(
140  " sync \n"
141  " lwarx %1,0,%4,1 \n"
142  " addi %0,%1,%3 \n"
143  " stwcx. %0,0,%4 \n"
144  " bne $-12 \n" /* branch to lwarx */
145  " lwsync \n"
146 : "=&r"(_t), "=&b"(res), "+m"(ptr->value)
147 : "i"(add_), "r"(&ptr->value)
148 : "memory", "cc");
149  else
150 #endif
151  __asm__ __volatile__(
152  " sync \n"
153  " lwarx %1,0,%4,1 \n"
154  " add %0,%1,%3 \n"
155  " stwcx. %0,0,%4 \n"
156  " bne $-12 \n" /* branch to lwarx */
157  " lwsync \n"
158 : "=&r"(_t), "=&r"(res), "+m"(ptr->value)
159 : "r"(add_), "r"(&ptr->value)
160 : "memory", "cc");
161 
162  return res;
163 }

References PG_INT16_MIN, res, and pg_atomic_uint32::value.