PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
atomics.h File Reference
#include <limits.h>
#include "port/atomics/fallback.h"
#include "port/atomics/generic.h"
Include dependency graph for atomics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define INSIDE_ATOMICS_H
 
#define pg_compiler_barrier()   pg_compiler_barrier_impl()
 
#define pg_memory_barrier()   pg_memory_barrier_impl()
 
#define pg_read_barrier()   pg_read_barrier_impl()
 
#define pg_write_barrier()   pg_write_barrier_impl()
 
#define pg_spin_delay()   pg_spin_delay_impl()
 

Functions

static void pg_atomic_init_flag (volatile pg_atomic_flag *ptr)
 
static bool pg_atomic_test_set_flag (volatile pg_atomic_flag *ptr)
 
static bool pg_atomic_unlocked_test_flag (volatile pg_atomic_flag *ptr)
 
static void pg_atomic_clear_flag (volatile pg_atomic_flag *ptr)
 
static void pg_atomic_init_u32 (volatile pg_atomic_uint32 *ptr, uint32 val)
 
static uint32 pg_atomic_read_u32 (volatile pg_atomic_uint32 *ptr)
 
static void pg_atomic_write_u32 (volatile pg_atomic_uint32 *ptr, uint32 val)
 
static void pg_atomic_unlocked_write_u32 (volatile pg_atomic_uint32 *ptr, uint32 val)
 
static uint32 pg_atomic_exchange_u32 (volatile pg_atomic_uint32 *ptr, uint32 newval)
 
static bool pg_atomic_compare_exchange_u32 (volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
 
static uint32 pg_atomic_fetch_add_u32 (volatile pg_atomic_uint32 *ptr, int32 add_)
 
static uint32 pg_atomic_fetch_sub_u32 (volatile pg_atomic_uint32 *ptr, int32 sub_)
 
static uint32 pg_atomic_fetch_and_u32 (volatile pg_atomic_uint32 *ptr, uint32 and_)
 
static uint32 pg_atomic_fetch_or_u32 (volatile pg_atomic_uint32 *ptr, uint32 or_)
 
static uint32 pg_atomic_add_fetch_u32 (volatile pg_atomic_uint32 *ptr, int32 add_)
 
static uint32 pg_atomic_sub_fetch_u32 (volatile pg_atomic_uint32 *ptr, int32 sub_)
 

Macro Definition Documentation

#define INSIDE_ATOMICS_H

Definition at line 44 of file atomics.h.

#define pg_compiler_barrier ( )    pg_compiler_barrier_impl()

Definition at line 135 of file atomics.h.

#define pg_memory_barrier ( )    pg_memory_barrier_impl()
#define pg_read_barrier ( )    pg_read_barrier_impl()
#define pg_spin_delay ( )    pg_spin_delay_impl()

Definition at line 166 of file atomics.h.

Function Documentation

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

Definition at line 396 of file atomics.h.

References AssertPointerAlignment.

Referenced by test_atomic_uint32().

397 {
398  AssertPointerAlignment(ptr, 4);
399  return pg_atomic_add_fetch_u32_impl(ptr, add_);
400 }
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
static void pg_atomic_clear_flag ( volatile pg_atomic_flag ptr)
inlinestatic

Definition at line 217 of file atomics.h.

References AssertPointerAlignment, and pg_atomic_clear_flag_impl().

218 {
219  AssertPointerAlignment(ptr, sizeof(*ptr));
220 
222 }
void pg_atomic_clear_flag_impl(volatile pg_atomic_flag *ptr)
Definition: atomics.c:81
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
static bool pg_atomic_compare_exchange_u32 ( volatile pg_atomic_uint32 ptr,
uint32 expected,
uint32  newval 
)
inlinestatic

Definition at line 321 of file atomics.h.

References AssertPointerAlignment, and pg_atomic_compare_exchange_u32_impl().

Referenced by ClockSweepTick(), LWLockAttemptLock(), LWLockWakeup(), MarkBufferDirty(), PinBuffer(), ProcArrayGroupClearXid(), test_atomic_uint32(), and UnpinBuffer().

323 {
324  AssertPointerAlignment(ptr, 4);
325  AssertPointerAlignment(expected, 4);
326 
327  return pg_atomic_compare_exchange_u32_impl(ptr, expected, newval);
328 }
bool pg_atomic_compare_exchange_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 *expected, uint32 newval)
Definition: atomics.c:121
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
#define newval
static uint32 pg_atomic_exchange_u32 ( volatile pg_atomic_uint32 ptr,
uint32  newval 
)
inlinestatic

Definition at line 302 of file atomics.h.

References AssertPointerAlignment.

Referenced by StrategySyncStart(), and test_atomic_uint32().

303 {
304  AssertPointerAlignment(ptr, 4);
305 
306  return pg_atomic_exchange_u32_impl(ptr, newval);
307 }
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
#define newval
static uint32 pg_atomic_fetch_add_u32 ( volatile pg_atomic_uint32 ptr,
int32  add_ 
)
inlinestatic

Definition at line 338 of file atomics.h.

References AssertPointerAlignment, and pg_atomic_fetch_add_u32_impl().

Referenced by ClockSweepTick(), LWLockQueueSelf(), StrategyGetBuffer(), and test_atomic_uint32().

339 {
340  AssertPointerAlignment(ptr, 4);
341  return pg_atomic_fetch_add_u32_impl(ptr, add_);
342 }
uint32 pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_)
Definition: atomics.c:149
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
static uint32 pg_atomic_fetch_and_u32 ( volatile pg_atomic_uint32 ptr,
uint32  and_ 
)
inlinestatic

Definition at line 368 of file atomics.h.

References AssertPointerAlignment.

Referenced by LWLockDequeueSelf(), LWLockWaitListUnlock(), and test_atomic_uint32().

369 {
370  AssertPointerAlignment(ptr, 4);
371  return pg_atomic_fetch_and_u32_impl(ptr, and_);
372 }
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
static uint32 pg_atomic_fetch_or_u32 ( volatile pg_atomic_uint32 ptr,
uint32  or_ 
)
inlinestatic

Definition at line 382 of file atomics.h.

References AssertPointerAlignment.

Referenced by LockBufHdr(), LWLockAcquire(), LWLockDequeueSelf(), LWLockQueueSelf(), LWLockWaitForVar(), LWLockWaitListLock(), and test_atomic_uint32().

383 {
384  AssertPointerAlignment(ptr, 4);
385  return pg_atomic_fetch_or_u32_impl(ptr, or_);
386 }
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
static uint32 pg_atomic_fetch_sub_u32 ( volatile pg_atomic_uint32 ptr,
int32  sub_ 
)
inlinestatic

Definition at line 353 of file atomics.h.

References Assert, and AssertPointerAlignment.

Referenced by LWLockAcquire(), LWLockAcquireOrWait(), LWLockDequeueSelf(), LWLockWaitForVar(), and test_atomic_uint32().

354 {
355  AssertPointerAlignment(ptr, 4);
356  Assert(sub_ != INT_MIN);
357  return pg_atomic_fetch_sub_u32_impl(ptr, sub_);
358 }
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
#define Assert(condition)
Definition: c.h:671
static void pg_atomic_init_flag ( volatile pg_atomic_flag ptr)
inlinestatic

Definition at line 174 of file atomics.h.

References AssertPointerAlignment, and pg_atomic_init_flag_impl().

175 {
176  AssertPointerAlignment(ptr, sizeof(*ptr));
177 
179 }
void pg_atomic_init_flag_impl(volatile pg_atomic_flag *ptr)
Definition: atomics.c:56
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
static void pg_atomic_init_u32 ( volatile pg_atomic_uint32 ptr,
uint32  val 
)
inlinestatic

Definition at line 233 of file atomics.h.

References AssertPointerAlignment, and pg_atomic_init_u32_impl().

Referenced by InitBufferPool(), InitProcess(), InitProcGlobal(), LWLockInitialize(), StrategyInitialize(), and test_atomic_uint32().

234 {
235  AssertPointerAlignment(ptr, 4);
236 
238 }
void pg_atomic_init_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 val_)
Definition: atomics.c:90
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
long val
Definition: informix.c:689
static uint32 pg_atomic_sub_fetch_u32 ( volatile pg_atomic_uint32 ptr,
int32  sub_ 
)
inlinestatic

Definition at line 411 of file atomics.h.

References Assert, and AssertPointerAlignment.

Referenced by LWLockRelease(), and test_atomic_uint32().

412 {
413  AssertPointerAlignment(ptr, 4);
414  Assert(sub_ != INT_MIN);
415  return pg_atomic_sub_fetch_u32_impl(ptr, sub_);
416 }
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
#define Assert(condition)
Definition: c.h:671
static bool pg_atomic_test_set_flag ( volatile pg_atomic_flag ptr)
inlinestatic

Definition at line 189 of file atomics.h.

References AssertPointerAlignment, and pg_atomic_test_set_flag_impl().

190 {
191  AssertPointerAlignment(ptr, sizeof(*ptr));
192 
193  return pg_atomic_test_set_flag_impl(ptr);
194 }
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
bool pg_atomic_test_set_flag_impl(volatile pg_atomic_flag *ptr)
Definition: atomics.c:75
static bool pg_atomic_unlocked_test_flag ( volatile pg_atomic_flag ptr)
inlinestatic

Definition at line 204 of file atomics.h.

References AssertPointerAlignment, and pg_atomic_unlocked_test_flag_impl().

205 {
206  AssertPointerAlignment(ptr, sizeof(*ptr));
207 
209 }
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
static bool pg_atomic_unlocked_test_flag_impl(volatile pg_atomic_flag *ptr)
Definition: fallback.h:118
static void pg_atomic_unlocked_write_u32 ( volatile pg_atomic_uint32 ptr,
uint32  val 
)
inlinestatic

Definition at line 287 of file atomics.h.

References AssertPointerAlignment, and pg_atomic_unlocked_write_u32_impl().

Referenced by DropRelFileNodeAllLocalBuffers(), DropRelFileNodeLocalBuffers(), FlushRelationBuffers(), LocalBufferAlloc(), MarkLocalBufferDirty(), and ReadBuffer_common().

288 {
289  AssertPointerAlignment(ptr, 4);
290 
292 }
static void pg_atomic_unlocked_write_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition: generic.h:64
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
long val
Definition: informix.c:689
static void pg_atomic_write_u32 ( volatile pg_atomic_uint32 ptr,
uint32  val 
)
inlinestatic

Definition at line 268 of file atomics.h.

References AssertPointerAlignment, and pg_atomic_write_u32_impl().

Referenced by ProcArrayGroupClearXid(), and test_atomic_uint32().

269 {
270  AssertPointerAlignment(ptr, 4);
271 
273 }
void pg_atomic_write_u32_impl(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition: atomics.c:108
#define AssertPointerAlignment(ptr, bndr)
Definition: c.h:675
long val
Definition: informix.c:689