| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifndef C_H |
| | #define C_H |
| |
|
| | #include "postgres_ext.h" |
| |
|
| | |
| | #undef PG_INT64_TYPE |
| |
|
| | #include "pg_config.h" |
| | #include "pg_config_manual.h" |
| | #include "pg_config_os.h" |
| |
|
| | |
| | #include <stdio.h> |
| | #include <stdlib.h> |
| | #include <string.h> |
| | #include <stddef.h> |
| | #include <stdarg.h> |
| | #ifdef HAVE_STRINGS_H |
| | #include <strings.h> |
| | #endif |
| | #include <stdint.h> |
| | #include <sys/types.h> |
| | #include <errno.h> |
| | #if defined(WIN32) || defined(__CYGWIN__) |
| | #include <fcntl.h> |
| | #endif |
| | #include <locale.h> |
| | #ifdef ENABLE_NLS |
| | #include <libintl.h> |
| | #endif |
| |
|
| | |
| | #ifdef HAVE_LIBZ |
| | #define ZLIB_CONST |
| | #endif |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | #ifdef PG_FORCE_DISABLE_INLINE |
| | #undef inline |
| | #define inline |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | #ifndef __has_attribute |
| | #define __has_attribute(attribute) 0 |
| | #endif |
| |
|
| | |
| | #ifdef __GNUC__ |
| | #define pg_attribute_unused() __attribute__((unused)) |
| | #else |
| | #define pg_attribute_unused() |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifdef __GNUC__ |
| | #define pg_nodiscard __attribute__((warn_unused_result)) |
| | #else |
| | #define pg_nodiscard |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | #if defined(__clang__) || __GNUC__ >= 8 |
| | #define pg_attribute_no_sanitize_address() __attribute__((no_sanitize("address"))) |
| | #elif __has_attribute(no_sanitize_address) |
| | |
| | #define pg_attribute_no_sanitize_address() __attribute__((no_sanitize_address)) |
| | #else |
| | #define pg_attribute_no_sanitize_address() |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | #if __clang_major__ >= 7 || __GNUC__ >= 8 |
| | #define pg_attribute_no_sanitize_alignment() __attribute__((no_sanitize("alignment"))) |
| | #else |
| | #define pg_attribute_no_sanitize_alignment() |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | #if __has_attribute (nonnull) |
| | #define pg_attribute_nonnull(...) __attribute__((nonnull(__VA_ARGS__))) |
| | #else |
| | #define pg_attribute_nonnull(...) |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | #ifdef USE_ASSERT_CHECKING |
| | #define PG_USED_FOR_ASSERTS_ONLY |
| | #else |
| | #define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused() |
| | #endif |
| |
|
| | |
| | #if defined(__GNUC__) |
| | #define pg_attribute_format_arg(a) __attribute__((format_arg(a))) |
| | #define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a))) |
| | #else |
| | #define pg_attribute_format_arg(a) |
| | #define pg_attribute_printf(f,a) |
| | #endif |
| |
|
| | |
| | #if defined(__GNUC__) || defined(__SUNPRO_C) |
| | #define pg_attribute_aligned(a) __attribute__((aligned(a))) |
| | #define pg_attribute_noreturn() __attribute__((noreturn)) |
| | #define pg_attribute_packed() __attribute__((packed)) |
| | #define HAVE_PG_ATTRIBUTE_NORETURN 1 |
| | #elif defined(_MSC_VER) |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #define pg_attribute_aligned(a) __declspec(align(a)) |
| | #define pg_attribute_noreturn() |
| | #else |
| | |
| | |
| | |
| | |
| | |
| | #define pg_attribute_noreturn() |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | #if (defined(__GNUC__) && __GNUC__ > 3 && defined(__OPTIMIZE__)) || defined(__SUNPRO_C) |
| | |
| | #define pg_attribute_always_inline __attribute__((always_inline)) inline |
| | #elif defined(_MSC_VER) |
| | |
| | #define pg_attribute_always_inline __forceinline |
| | #else |
| | |
| | #define pg_attribute_always_inline inline |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #if (defined(__GNUC__) && __GNUC__ > 2) || defined(__SUNPRO_C) |
| | #define pg_noinline __attribute__((noinline)) |
| | |
| | #elif defined(_MSC_VER) |
| | #define pg_noinline __declspec(noinline) |
| | #else |
| | #define pg_noinline |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #if defined(__MINGW64__) && __GNUC__ == 8 && __GNUC_MINOR__ == 1 |
| |
|
| | #define pg_attribute_cold |
| | #define pg_attribute_hot |
| |
|
| | #else |
| | |
| | |
| | |
| | |
| | #if __has_attribute (cold) |
| | #define pg_attribute_cold __attribute__((cold)) |
| | #else |
| | #define pg_attribute_cold |
| | #endif |
| |
|
| | #if __has_attribute (hot) |
| | #define pg_attribute_hot __attribute__((hot)) |
| | #else |
| | #define pg_attribute_hot |
| | #endif |
| |
|
| | #endif |
| | |
| | |
| | |
| | |
| | |
| | |
| | #if defined(HAVE__BUILTIN_UNREACHABLE) && !defined(USE_ASSERT_CHECKING) |
| | #define pg_unreachable() __builtin_unreachable() |
| | #elif defined(_MSC_VER) && !defined(USE_ASSERT_CHECKING) |
| | #define pg_unreachable() __assume(0) |
| | #else |
| | #define pg_unreachable() abort() |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #if __GNUC__ >= 3 |
| | #define likely(x) __builtin_expect((x) != 0, 1) |
| | #define unlikely(x) __builtin_expect((x) != 0, 0) |
| | #else |
| | #define likely(x) ((x) != 0) |
| | #define unlikely(x) ((x) != 0) |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #define CppAsString(identifier) #identifier |
| | #define CppAsString2(x) CppAsString(x) |
| | #define CppConcat(x, y) x##y |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifdef _MSC_VER |
| | #define EXPAND(args) args |
| | #define VA_ARGS_NARGS(...) \ |
| | VA_ARGS_NARGS_ EXPAND((__VA_ARGS__, \ |
| | 63,62,61,60, \ |
| | 59,58,57,56,55,54,53,52,51,50, \ |
| | 49,48,47,46,45,44,43,42,41,40, \ |
| | 39,38,37,36,35,34,33,32,31,30, \ |
| | 29,28,27,26,25,24,23,22,21,20, \ |
| | 19,18,17,16,15,14,13,12,11,10, \ |
| | 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) |
| | #else |
| |
|
| | #define VA_ARGS_NARGS(...) \ |
| | VA_ARGS_NARGS_(__VA_ARGS__, \ |
| | 63,62,61,60, \ |
| | 59,58,57,56,55,54,53,52,51,50, \ |
| | 49,48,47,46,45,44,43,42,41,40, \ |
| | 39,38,37,36,35,34,33,32,31,30, \ |
| | 29,28,27,26,25,24,23,22,21,20, \ |
| | 19,18,17,16,15,14,13,12,11,10, \ |
| | 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) |
| | #endif |
| |
|
| | #define VA_ARGS_NARGS_( \ |
| | _01,_02,_03,_04,_05,_06,_07,_08,_09,_10, \ |
| | _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \ |
| | _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \ |
| | _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \ |
| | _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \ |
| | _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \ |
| | _61,_62,_63, N, ...) \ |
| | (N) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | typedef void (*pg_funcptr_t) (void); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #define FLEXIBLE_ARRAY_MEMBER |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifdef __GNUC__ |
| | #define HAVE_PRAGMA_GCC_SYSTEM_HEADER 1 |
| | #endif |
| |
|
| |
|
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #ifndef __cplusplus |
| |
|
| | #ifdef PG_USE_STDBOOL |
| | #include <stdbool.h> |
| | #else |
| |
|
| | #ifndef bool |
| | typedef unsigned char bool; |
| | #endif |
| |
|
| | #ifndef true |
| | #define true ((bool) 1) |
| | #endif |
| |
|
| | #ifndef false |
| | #define false ((bool) 0) |
| | #endif |
| |
|
| | #endif |
| | #endif |
| |
|
| |
|
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef char *Pointer; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifndef HAVE_INT8 |
| | typedef signed char int8; |
| | typedef signed short int16; |
| | typedef signed int int32; |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifndef HAVE_UINT8 |
| | typedef unsigned char uint8; |
| | typedef unsigned short uint16; |
| | typedef unsigned int uint32; |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | typedef uint8 bits8; |
| | typedef uint16 bits16; |
| | typedef uint32 bits32; |
| |
|
| | |
| | |
| | |
| | #ifdef HAVE_LONG_INT_64 |
| | |
| |
|
| | #ifndef HAVE_INT64 |
| | typedef long int int64; |
| | #endif |
| | #ifndef HAVE_UINT64 |
| | typedef unsigned long int uint64; |
| | #endif |
| | #define INT64CONST(x) (x##L) |
| | #define UINT64CONST(x) (x##UL) |
| | #elif defined(HAVE_LONG_LONG_INT_64) |
| | |
| |
|
| | #ifndef HAVE_INT64 |
| | typedef long long int int64; |
| | #endif |
| | #ifndef HAVE_UINT64 |
| | typedef unsigned long long int uint64; |
| | #endif |
| | #define INT64CONST(x) (x##LL) |
| | #define UINT64CONST(x) (x##ULL) |
| | #else |
| | |
| | #error must have a working 64-bit integer datatype |
| | #endif |
| |
|
| | |
| | #define INT64_FORMAT "%" INT64_MODIFIER "d" |
| | #define UINT64_FORMAT "%" INT64_MODIFIER "u" |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #if defined(PG_INT128_TYPE) |
| | #if defined(pg_attribute_aligned) || ALIGNOF_PG_INT128_TYPE <= MAXIMUM_ALIGNOF |
| | #define HAVE_INT128 1 |
| |
|
| | typedef PG_INT128_TYPE int128 |
| | #if defined(pg_attribute_aligned) |
| | pg_attribute_aligned(MAXIMUM_ALIGNOF) |
| | #endif |
| | ; |
| |
|
| | typedef unsigned PG_INT128_TYPE uint128 |
| | #if defined(pg_attribute_aligned) |
| | pg_attribute_aligned(MAXIMUM_ALIGNOF) |
| | #endif |
| | ; |
| |
|
| | #endif |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | #define PG_INT8_MIN (-0x7F-1) |
| | #define PG_INT8_MAX (0x7F) |
| | #define PG_UINT8_MAX (0xFF) |
| | #define PG_INT16_MIN (-0x7FFF-1) |
| | #define PG_INT16_MAX (0x7FFF) |
| | #define PG_UINT16_MAX (0xFFFF) |
| | #define PG_INT32_MIN (-0x7FFFFFFF-1) |
| | #define PG_INT32_MAX (0x7FFFFFFF) |
| | #define PG_UINT32_MAX (0xFFFFFFFFU) |
| | #define PG_INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1) |
| | #define PG_INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF) |
| | #define PG_UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF) |
| |
|
| | |
| | |
| | |
| | |
| | #define HAVE_INT64_TIMESTAMP |
| |
|
| | |
| | |
| | |
| | |
| | typedef size_t Size; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef unsigned int Index; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef signed int Offset; |
| |
|
| | |
| | |
| | |
| | typedef float float4; |
| | typedef double float8; |
| |
|
| | #ifdef USE_FLOAT8_BYVAL |
| | #define FLOAT8PASSBYVAL true |
| | #else |
| | #define FLOAT8PASSBYVAL false |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| |
|
| | |
| |
|
| | |
| | |
| | |
| | |
| | typedef Oid regproc; |
| | typedef regproc RegProcedure; |
| |
|
| | typedef uint32 TransactionId; |
| |
|
| | typedef uint32 LocalTransactionId; |
| |
|
| | typedef uint32 SubTransactionId; |
| |
|
| | #define InvalidSubTransactionId ((SubTransactionId) 0) |
| | #define TopSubTransactionId ((SubTransactionId) 1) |
| |
|
| | |
| | typedef TransactionId MultiXactId; |
| |
|
| | typedef uint32 MultiXactOffset; |
| |
|
| | typedef uint32 CommandId; |
| |
|
| | #define FirstCommandId ((CommandId) 0) |
| | #define InvalidCommandId (~(CommandId)0) |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | struct varlena |
| | { |
| | char vl_len_[4]; |
| | char vl_dat[FLEXIBLE_ARRAY_MEMBER]; |
| | }; |
| |
|
| | #define VARHDRSZ ((int32) sizeof(int32)) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | typedef struct varlena bytea; |
| | typedef struct varlena text; |
| | typedef struct varlena BpChar; |
| | typedef struct varlena VarChar; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef struct |
| | { |
| | int32 vl_len_; |
| | int ndim; |
| | int32 dataoffset; |
| | Oid elemtype; |
| | int dim1; |
| | int lbound1; |
| | int16 values[FLEXIBLE_ARRAY_MEMBER]; |
| | } int2vector; |
| |
|
| | typedef struct |
| | { |
| | int32 vl_len_; |
| | int ndim; |
| | int32 dataoffset; |
| | Oid elemtype; |
| | int dim1; |
| | int lbound1; |
| | Oid values[FLEXIBLE_ARRAY_MEMBER]; |
| | } oidvector; |
| |
|
| | |
| | |
| | |
| | |
| | typedef struct nameData |
| | { |
| | char data[NAMEDATALEN]; |
| | } NameData; |
| | typedef NameData *Name; |
| |
|
| | #define NameStr(name) ((name).data) |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #define BoolIsValid(boolean) ((boolean) == false || (boolean) == true) |
| |
|
| | |
| | |
| | |
| | |
| | #define PointerIsValid(pointer) ((const void*)(pointer) != NULL) |
| |
|
| | |
| | |
| | |
| | |
| | #define PointerIsAligned(pointer, type) \ |
| | (((uintptr_t)(pointer) % (sizeof (type))) == 0) |
| |
|
| | #define OffsetToPointer(base, offset) \ |
| | ((void *)((char *) base + offset)) |
| |
|
| | #define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid)) |
| |
|
| | #define RegProcedureIsValid(p) OidIsValid(p) |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #define lengthof(array) (sizeof (array) / sizeof ((array)[0])) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #define TYPEALIGN(ALIGNVAL,LEN) \ |
| | (((uintptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((uintptr_t) ((ALIGNVAL) - 1))) |
| |
|
| | #define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN)) |
| | #define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN)) |
| | #define LONGALIGN(LEN) TYPEALIGN(ALIGNOF_LONG, (LEN)) |
| | #define DOUBLEALIGN(LEN) TYPEALIGN(ALIGNOF_DOUBLE, (LEN)) |
| | #define MAXALIGN(LEN) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN)) |
| | |
| | #define BUFFERALIGN(LEN) TYPEALIGN(ALIGNOF_BUFFER, (LEN)) |
| | #define CACHELINEALIGN(LEN) TYPEALIGN(PG_CACHE_LINE_SIZE, (LEN)) |
| |
|
| | #define TYPEALIGN_DOWN(ALIGNVAL,LEN) \ |
| | (((uintptr_t) (LEN)) & ~((uintptr_t) ((ALIGNVAL) - 1))) |
| |
|
| | #define SHORTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN)) |
| | #define INTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT, (LEN)) |
| | #define LONGALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_LONG, (LEN)) |
| | #define DOUBLEALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_DOUBLE, (LEN)) |
| | #define MAXALIGN_DOWN(LEN) TYPEALIGN_DOWN(MAXIMUM_ALIGNOF, (LEN)) |
| | #define BUFFERALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_BUFFER, (LEN)) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | #define TYPEALIGN64(ALIGNVAL,LEN) \ |
| | (((uint64) (LEN) + ((ALIGNVAL) - 1)) & ~((uint64) ((ALIGNVAL) - 1))) |
| |
|
| | |
| | #define MAXALIGN64(LEN) TYPEALIGN64(MAXIMUM_ALIGNOF, (LEN)) |
| |
|
| |
|
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | #ifndef USE_ASSERT_CHECKING |
| |
|
| | #define Assert(condition) ((void)true) |
| | #define AssertMacro(condition) ((void)true) |
| |
|
| | #elif defined(FRONTEND) |
| |
|
| | #include <assert.h> |
| | #define Assert(p) assert(p) |
| | #define AssertMacro(p) ((void) assert(p)) |
| |
|
| | #else |
| |
|
| | |
| | |
| | |
| | |
| | #define Assert(condition) \ |
| | do { \ |
| | if (!(condition)) \ |
| | ExceptionalCondition(#condition, __FILE__, __LINE__); \ |
| | } while (0) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | #define AssertMacro(condition) \ |
| | ((void) ((condition) || \ |
| | (ExceptionalCondition(#condition, __FILE__, __LINE__), 0))) |
| |
|
| | #endif |
| |
|
| | |
| | |
| | |
| | #define AssertPointerAlignment(ptr, bndr) \ |
| | Assert(TYPEALIGN(bndr, (uintptr_t)(ptr)) == (uintptr_t)(ptr)) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifndef FRONTEND |
| | extern void ExceptionalCondition(const char *conditionName, |
| | const char *fileName, int lineNumber) pg_attribute_noreturn(); |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifndef __cplusplus |
| | #ifdef HAVE__STATIC_ASSERT |
| | #define StaticAssertDecl(condition, errmessage) \ |
| | _Static_assert(condition, errmessage) |
| | #define StaticAssertStmt(condition, errmessage) \ |
| | do { _Static_assert(condition, errmessage); } while(0) |
| | #define StaticAssertExpr(condition, errmessage) \ |
| | ((void) ({ StaticAssertStmt(condition, errmessage); true; })) |
| | #else |
| | #define StaticAssertDecl(condition, errmessage) \ |
| | extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) |
| | #define StaticAssertStmt(condition, errmessage) \ |
| | ((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; })) |
| | #define StaticAssertExpr(condition, errmessage) \ |
| | StaticAssertStmt(condition, errmessage) |
| | #endif |
| | #else |
| | #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410 |
| | #define StaticAssertDecl(condition, errmessage) \ |
| | static_assert(condition, errmessage) |
| | #define StaticAssertStmt(condition, errmessage) \ |
| | static_assert(condition, errmessage) |
| | #define StaticAssertExpr(condition, errmessage) \ |
| | ({ static_assert(condition, errmessage); }) |
| | #else |
| | #define StaticAssertDecl(condition, errmessage) \ |
| | extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) |
| | #define StaticAssertStmt(condition, errmessage) \ |
| | do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0) |
| | #define StaticAssertExpr(condition, errmessage) \ |
| | ((void) ({ StaticAssertStmt(condition, errmessage); })) |
| | #endif |
| | #endif |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P |
| | #define AssertVariableIsOfType(varname, typename) \ |
| | StaticAssertStmt(__builtin_types_compatible_p(__typeof__(varname), typename), \ |
| | CppAsString(varname) " does not have type " CppAsString(typename)) |
| | #define AssertVariableIsOfTypeMacro(varname, typename) \ |
| | (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \ |
| | CppAsString(varname) " does not have type " CppAsString(typename))) |
| | #else |
| | #define AssertVariableIsOfType(varname, typename) \ |
| | StaticAssertStmt(sizeof(varname) == sizeof(typename), \ |
| | CppAsString(varname) " does not have type " CppAsString(typename)) |
| | #define AssertVariableIsOfTypeMacro(varname, typename) \ |
| | (StaticAssertExpr(sizeof(varname) == sizeof(typename), \ |
| | CppAsString(varname) " does not have type " CppAsString(typename))) |
| | #endif |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #define Max(x, y) ((x) > (y) ? (x) : (y)) |
| |
|
| | |
| | |
| | |
| | |
| | #define Min(x, y) ((x) < (y) ? (x) : (y)) |
| |
|
| |
|
| | |
| | #define LONG_ALIGN_MASK (sizeof(long) - 1) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #define MemSet(start, val, len) \ |
| | do \ |
| | { \ |
| | \ |
| | void *_vstart = (void *) (start); \ |
| | int _val = (val); \ |
| | Size _len = (len); \ |
| | \ |
| | if ((((uintptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \ |
| | (_len & LONG_ALIGN_MASK) == 0 && \ |
| | _val == 0 && \ |
| | _len <= MEMSET_LOOP_LIMIT && \ |
| | |
| | |
| | |
| | \ |
| | MEMSET_LOOP_LIMIT != 0) \ |
| | { \ |
| | long *_start = (long *) _vstart; \ |
| | long *_stop = (long *) ((char *) _start + _len); \ |
| | while (_start < _stop) \ |
| | *_start++ = 0; \ |
| | } \ |
| | else \ |
| | memset(_vstart, _val, _len); \ |
| | } while (0) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | #define MemSetAligned(start, val, len) \ |
| | do \ |
| | { \ |
| | long *_start = (long *) (start); \ |
| | int _val = (val); \ |
| | Size _len = (len); \ |
| | \ |
| | if ((_len & LONG_ALIGN_MASK) == 0 && \ |
| | _val == 0 && \ |
| | _len <= MEMSET_LOOP_LIMIT && \ |
| | MEMSET_LOOP_LIMIT != 0) \ |
| | { \ |
| | long *_stop = (long *) ((char *) _start + _len); \ |
| | while (_start < _stop) \ |
| | *_start++ = 0; \ |
| | } \ |
| | else \ |
| | memset(_start, _val, _len); \ |
| | } while (0) |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #define FLOAT4_FITS_IN_INT16(num) \ |
| | ((num) >= (float4) PG_INT16_MIN && (num) < -((float4) PG_INT16_MIN)) |
| | #define FLOAT4_FITS_IN_INT32(num) \ |
| | ((num) >= (float4) PG_INT32_MIN && (num) < -((float4) PG_INT32_MIN)) |
| | #define FLOAT4_FITS_IN_INT64(num) \ |
| | ((num) >= (float4) PG_INT64_MIN && (num) < -((float4) PG_INT64_MIN)) |
| | #define FLOAT8_FITS_IN_INT16(num) \ |
| | ((num) >= (float8) PG_INT16_MIN && (num) < -((float8) PG_INT16_MIN)) |
| | #define FLOAT8_FITS_IN_INT32(num) \ |
| | ((num) >= (float8) PG_INT32_MIN && (num) < -((float8) PG_INT32_MIN)) |
| | #define FLOAT8_FITS_IN_INT64(num) \ |
| | ((num) >= (float8) PG_INT64_MIN && (num) < -((float8) PG_INT64_MIN)) |
| |
|
| |
|
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | #define INVERT_COMPARE_RESULT(var) \ |
| | ((var) = ((var) < 0) ? 1 : -(var)) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef union PGAlignedBlock |
| | { |
| | char data[BLCKSZ]; |
| | double force_align_d; |
| | int64 force_align_i64; |
| | } PGAlignedBlock; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef union PGIOAlignedBlock |
| | { |
| | #ifdef pg_attribute_aligned |
| | pg_attribute_aligned(PG_IO_ALIGN_SIZE) |
| | #endif |
| | char data[BLCKSZ]; |
| | double force_align_d; |
| | int64 force_align_i64; |
| | } PGIOAlignedBlock; |
| |
|
| | |
| | typedef union PGAlignedXLogBlock |
| | { |
| | #ifdef pg_attribute_aligned |
| | pg_attribute_aligned(PG_IO_ALIGN_SIZE) |
| | #endif |
| | char data[XLOG_BLCKSZ]; |
| | double force_align_d; |
| | int64 force_align_i64; |
| | } PGAlignedXLogBlock; |
| |
|
| | |
| | #define HIGHBIT (0x80) |
| | #define IS_HIGHBIT_SET(ch) ((unsigned char)(ch) & HIGHBIT) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | #define SQL_STR_DOUBLE(ch, escape_backslash) \ |
| | ((ch) == '\'' || ((ch) == '\\' && (escape_backslash))) |
| |
|
| | #define ESCAPE_STRING_SYNTAX 'E' |
| |
|
| |
|
| | #define STATUS_OK (0) |
| | #define STATUS_ERROR (-1) |
| | #define STATUS_EOF (-2) |
| |
|
| | |
| | |
| | |
| |
|
| | #ifndef ENABLE_NLS |
| | |
| | #define gettext(x) (x) |
| | #define dgettext(d,x) (x) |
| | #define ngettext(s,p,n) ((n) == 1 ? (s) : (p)) |
| | #define dngettext(d,s,p,n) ((n) == 1 ? (s) : (p)) |
| | #endif |
| |
|
| | #define _(x) gettext(x) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #define gettext_noop(x) (x) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifdef SO_MAJOR_VERSION |
| | #define PG_TEXTDOMAIN(domain) (domain CppAsString2(SO_MAJOR_VERSION) "-" PG_MAJORVERSION) |
| | #else |
| | #define PG_TEXTDOMAIN(domain) (domain "-" PG_MAJORVERSION) |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #if defined(__cplusplus) |
| | #define unconstify(underlying_type, expr) const_cast<underlying_type>(expr) |
| | #define unvolatize(underlying_type, expr) const_cast<underlying_type>(expr) |
| | #elif defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P) |
| | #define unconstify(underlying_type, expr) \ |
| | (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), const underlying_type), \ |
| | "wrong cast"), \ |
| | (underlying_type) (expr)) |
| | #define unvolatize(underlying_type, expr) \ |
| | (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), volatile underlying_type), \ |
| | "wrong cast"), \ |
| | (underlying_type) (expr)) |
| | #else |
| | #define unconstify(underlying_type, expr) \ |
| | ((underlying_type) (expr)) |
| | #define unvolatize(underlying_type, expr) \ |
| | ((underlying_type) (expr)) |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #if defined(WIN32) || defined(__CYGWIN__) |
| | #define PG_BINARY O_BINARY |
| | #define PG_BINARY_A "ab" |
| | #define PG_BINARY_R "rb" |
| | #define PG_BINARY_W "wb" |
| | #else |
| | #define PG_BINARY 0 |
| | #define PG_BINARY_A "a" |
| | #define PG_BINARY_R "r" |
| | #define PG_BINARY_W "w" |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| |
|
| | #if !HAVE_DECL_FDATASYNC |
| | extern int fdatasync(int fildes); |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | #ifdef HAVE_LONG_INT_64 |
| | #define strtoi64(str, endptr, base) ((int64) strtol(str, endptr, base)) |
| | #define strtou64(str, endptr, base) ((uint64) strtoul(str, endptr, base)) |
| | #else |
| | #define strtoi64(str, endptr, base) ((int64) strtoll(str, endptr, base)) |
| | #define strtou64(str, endptr, base) ((uint64) strtoull(str, endptr, base)) |
| | #endif |
| |
|
| | |
| | |
| | |
| | #ifdef HAVE_LONG_INT_64 |
| | #define i64abs(i) labs(i) |
| | #else |
| | #define i64abs(i) llabs(i) |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | #ifndef PGDLLIMPORT |
| | #define PGDLLIMPORT |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifndef PGDLLEXPORT |
| | #ifdef HAVE_VISIBILITY_ATTRIBUTE |
| | #define PGDLLEXPORT __attribute__((visibility("default"))) |
| | #else |
| | #define PGDLLEXPORT |
| | #endif |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #ifndef SIGNAL_ARGS |
| | #define SIGNAL_ARGS int postgres_signal_arg |
| | #endif |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifdef WIN32 |
| | #ifdef __MINGW64__ |
| | typedef intptr_t sigjmp_buf[5]; |
| | #define sigsetjmp(x,y) __builtin_setjmp(x) |
| | #define siglongjmp __builtin_longjmp |
| | #else |
| | #define sigjmp_buf jmp_buf |
| | #define sigsetjmp(x,y) setjmp(x) |
| | #define siglongjmp longjmp |
| | #endif |
| | #endif |
| |
|
| | |
| | #include "port.h" |
| |
|
| | #endif |
| |
|