Debian Codegraph @

src/include/port/atomics/fallback.h

raw
1 /*-------------------------------------------------------------------------
2 *
3 * fallback.h
4 * Fallback for platforms without 64 bit atomics support. Slower
5 * than native atomics support, but not unusably slow.
6 *
7 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/port/atomics/fallback.h
11 *
12 *-------------------------------------------------------------------------
13 */
14
15 /* intentionally no include guards, should only be included by atomics.h */
16 #ifndef INSIDE_ATOMICS_H
17 # error "should be included via atomics.h"
18 #endif
19
20
21 #if !defined(PG_HAVE_ATOMIC_U64_SUPPORT)
22
23 #define PG_HAVE_ATOMIC_U64_SIMULATION
24
25 #define PG_HAVE_ATOMIC_U64_SUPPORT
26 typedef struct pg_atomic_uint64
27 {
28 int sema;
29 volatile uint64 value;
30 } pg_atomic_uint64;
31
32 #define PG_HAVE_ATOMIC_INIT_U64
33 extern void pg_atomic_init_u64_impl(volatile pg_atomic_uint64 *ptr, uint64 val_);
34
35 #define PG_HAVE_ATOMIC_COMPARE_EXCHANGE_U64
36 extern bool pg_atomic_compare_exchange_u64_impl(volatile pg_atomic_uint64 *ptr,
37 uint64 *expected, uint64 newval);
38
39 #define PG_HAVE_ATOMIC_FETCH_ADD_U64
40 extern uint64 pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_);
41
42 #endif /* PG_HAVE_ATOMIC_U64_SUPPORT */