diff --git a/src/include/postgres.h b/src/include/postgres.h index ff2c5c0..387d9f4 100644 --- a/src/include/postgres.h +++ b/src/include/postgres.h @@ -790,6 +790,35 @@ extern Datum Float8GetDatum(float8 X); #define Float4GetDatumFast(X) PointerGetDatum(&(X)) #endif +typedef struct dsa_area dsa_area; + +/* + * If this system only uses a 32-bit value for Size, then use the 32-bit + * implementation of DSA. This limits the amount of DSA that can be created + * to something significantly less than the entire 4GB address space because + * the DSA pointer must encode both a segment identifier and an offset, but + * that shouldn't be a significant limitation in practice. + * + * If this system doesn't support atomic operations on 64-bit values, then + * we fall back to 32-bit dsa_pointer for lack of other options. + * + * For testing purposes, USE_SMALL_DSA_POINTER can be defined to force the use + * of 32-bit dsa_pointer even on systems capable of supporting a 64-bit + * dsa_pointer. + */ +#if SIZEOF_SIZE_T == 4 || !defined(PG_HAVE_ATOMIC_U64_SUPPORT) || \ + defined(USE_SMALL_DSA_POINTER) +#define SIZEOF_DSA_POINTER 4 +#else +#define SIZEOF_DSA_POINTER 8 +#endif + +#if SIZEOF_DSA_POINTER == 4 +typedef uint32 dsa_pointer; +#else +typedef uint64 dsa_pointer; +#endif + /* ---------------------------------------------------------------- * Section 3: exception handling backend support diff --git a/src/include/utils/dsa.h b/src/include/utils/dsa.h index bb634e7..d9b4366 100644 --- a/src/include/utils/dsa.h +++ b/src/include/utils/dsa.h @@ -21,28 +21,7 @@ /* The opaque type used for an area. */ struct dsa_area; -typedef struct dsa_area dsa_area; -/* - * If this system only uses a 32-bit value for Size, then use the 32-bit - * implementation of DSA. This limits the amount of DSA that can be created - * to something significantly less than the entire 4GB address space because - * the DSA pointer must encode both a segment identifier and an offset, but - * that shouldn't be a significant limitation in practice. - * - * If this system doesn't support atomic operations on 64-bit values, then - * we fall back to 32-bit dsa_pointer for lack of other options. - * - * For testing purposes, USE_SMALL_DSA_POINTER can be defined to force the use - * of 32-bit dsa_pointer even on systems capable of supporting a 64-bit - * dsa_pointer. - */ -#if SIZEOF_SIZE_T == 4 || !defined(PG_HAVE_ATOMIC_U64_SUPPORT) || \ - defined(USE_SMALL_DSA_POINTER) -#define SIZEOF_DSA_POINTER 4 -#else -#define SIZEOF_DSA_POINTER 8 -#endif /* * The type of 'relative pointers' to memory allocated by a dynamic shared @@ -52,7 +31,6 @@ typedef struct dsa_area dsa_area; * operations. */ #if SIZEOF_DSA_POINTER == 4 -typedef uint32 dsa_pointer; typedef pg_atomic_uint32 dsa_pointer_atomic; #define dsa_pointer_atomic_init pg_atomic_init_u32 #define dsa_pointer_atomic_read pg_atomic_read_u32 @@ -61,7 +39,6 @@ typedef pg_atomic_uint32 dsa_pointer_atomic; #define dsa_pointer_atomic_compare_exchange pg_atomic_compare_exchange_u32 #define DSA_POINTER_FORMAT "%08x" #else -typedef uint64 dsa_pointer; typedef pg_atomic_uint64 dsa_pointer_atomic; #define dsa_pointer_atomic_init pg_atomic_init_u64 #define dsa_pointer_atomic_read pg_atomic_read_u64