71#if defined(WIN32) || defined(__CYGWIN__)
92#ifdef PG_FORCE_DISABLE_INLINE
113#ifndef __has_attribute
114#define __has_attribute(attribute) 0
119#define pg_attribute_unused() __attribute__((unused))
121#define pg_attribute_unused()
131#define pg_nodiscard __attribute__((warn_unused_result))
142#if __clang_major__ >= 7 || __GNUC__ >= 8
143#define pg_attribute_no_sanitize_alignment() __attribute__((no_sanitize("alignment")))
145#define pg_attribute_no_sanitize_alignment()
153#ifdef USE_ASSERT_CHECKING
154#define PG_USED_FOR_ASSERTS_ONLY
156#define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused()
160#if defined(__GNUC__) || defined(__IBMC__)
161#define pg_attribute_format_arg(a) __attribute__((format_arg(a)))
162#define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))
164#define pg_attribute_format_arg(a)
165#define pg_attribute_printf(f,a)
169#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
170#define pg_attribute_aligned(a) __attribute__((aligned(a)))
171#define pg_attribute_noreturn() __attribute__((noreturn))
172#define pg_attribute_packed() __attribute__((packed))
173#define HAVE_PG_ATTRIBUTE_NORETURN 1
180#define pg_attribute_noreturn()
189#if (defined(__GNUC__) && __GNUC__ > 3 && defined(__OPTIMIZE__)) || defined(__SUNPRO_C) || defined(__IBMC__)
191#define pg_attribute_always_inline __attribute__((always_inline)) inline
192#elif defined(_MSC_VER)
194#define pg_attribute_always_inline __forceinline
197#define pg_attribute_always_inline inline
207#if (defined(__GNUC__) && __GNUC__ > 2) || defined(__SUNPRO_C) || defined(__IBMC__)
208#define pg_noinline __attribute__((noinline))
210#elif defined(_MSC_VER)
211#define pg_noinline __declspec(noinline)
225#if defined(__MINGW64__) && __GNUC__ == 8 && __GNUC_MINOR__ == 1
227#define pg_attribute_cold
228#define pg_attribute_hot
235#if __has_attribute (cold)
236#define pg_attribute_cold __attribute__((cold))
238#define pg_attribute_cold
241#if __has_attribute (hot)
242#define pg_attribute_hot __attribute__((hot))
244#define pg_attribute_hot
254#if defined(HAVE__BUILTIN_UNREACHABLE) && !defined(USE_ASSERT_CHECKING)
255#define pg_unreachable() __builtin_unreachable()
256#elif defined(_MSC_VER) && !defined(USE_ASSERT_CHECKING)
257#define pg_unreachable() __assume(0)
259#define pg_unreachable() abort()
270#define likely(x) __builtin_expect((x) != 0, 1)
271#define unlikely(x) __builtin_expect((x) != 0, 0)
273#define likely(x) ((x) != 0)
274#define unlikely(x) ((x) != 0)
289#define CppAsString(identifier) #identifier
290#define CppAsString2(x) CppAsString(x)
291#define CppConcat(x, y) x##y
307#define VA_ARGS_NARGS(...) \
308 VA_ARGS_NARGS_(__VA_ARGS__, \
310 59,58,57,56,55,54,53,52,51,50, \
311 49,48,47,46,45,44,43,42,41,40, \
312 39,38,37,36,35,34,33,32,31,30, \
313 29,28,27,26,25,24,23,22,21,20, \
314 19,18,17,16,15,14,13,12,11,10, \
315 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
316#define VA_ARGS_NARGS_( \
317 _01,_02,_03,_04,_05,_06,_07,_08,_09,_10, \
318 _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
319 _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
320 _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
321 _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
322 _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
323 _61,_62,_63, N, ...) \
351#define FLEXIBLE_ARRAY_MEMBER
354#ifdef HAVE_FUNCNAME__FUNC
355#define PG_FUNCNAME_MACRO __func__
357#ifdef HAVE_FUNCNAME__FUNCTION
358#define PG_FUNCNAME_MACRO __FUNCTION__
360#define PG_FUNCNAME_MACRO NULL
394typedef unsigned char bool;
398#define true ((bool) 1)
402#define false ((bool) 0)
460#ifdef HAVE_LONG_INT_64
469#define INT64CONST(x) (x##L)
470#define UINT64CONST(x) (x##UL)
471#elif defined(HAVE_LONG_LONG_INT_64)
475typedef long long int int64;
478typedef unsigned long long int uint64;
480#define INT64CONST(x) (x##LL)
481#define UINT64CONST(x) (x##ULL)
484#error must have a working 64-bit integer datatype
488#define INT64_FORMAT "%" INT64_MODIFIER "d"
489#define UINT64_FORMAT "%" INT64_MODIFIER "u"
499#if defined(PG_INT128_TYPE)
500#if defined(pg_attribute_aligned) || ALIGNOF_PG_INT128_TYPE <= MAXIMUM_ALIGNOF
504#if defined(pg_attribute_aligned)
510#if defined(pg_attribute_aligned)
522#define PG_INT8_MIN (-0x7F-1)
523#define PG_INT8_MAX (0x7F)
524#define PG_UINT8_MAX (0xFF)
525#define PG_INT16_MIN (-0x7FFF-1)
526#define PG_INT16_MAX (0x7FFF)
527#define PG_UINT16_MAX (0xFFFF)
528#define PG_INT32_MIN (-0x7FFFFFFF-1)
529#define PG_INT32_MAX (0x7FFFFFFF)
530#define PG_UINT32_MAX (0xFFFFFFFFU)
531#define PG_INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1)
532#define PG_INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF)
533#define PG_UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF)
539#define HAVE_INT64_TIMESTAMP
572#ifdef USE_FLOAT8_BYVAL
573#define FLOAT8PASSBYVAL true
575#define FLOAT8PASSBYVAL false
598#define InvalidSubTransactionId ((SubTransactionId) 0)
599#define TopSubTransactionId ((SubTransactionId) 1)
608#define FirstCommandId ((CommandId) 0)
609#define InvalidCommandId (~(CommandId)0)
632#define VARHDRSZ ((int32) sizeof(int32))
699#define BoolIsValid(boolean) ((boolean) == false || (boolean) == true)
705#define PointerIsValid(pointer) ((const void*)(pointer) != NULL)
711#define PointerIsAligned(pointer, type) \
712 (((uintptr_t)(pointer) % (sizeof (type))) == 0)
714#define OffsetToPointer(base, offset) \
715 ((void *)((char *) base + offset))
717#define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))
719#define RegProcedureIsValid(p) OidIsValid(p)
734#define offsetof(type, field) ((long) &((type *)0)->field)
741#define lengthof(array) (sizeof (array) / sizeof ((array)[0]))
757#define TYPEALIGN(ALIGNVAL,LEN) \
758 (((uintptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((uintptr_t) ((ALIGNVAL) - 1)))
760#define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN))
761#define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN))
762#define LONGALIGN(LEN) TYPEALIGN(ALIGNOF_LONG, (LEN))
763#define DOUBLEALIGN(LEN) TYPEALIGN(ALIGNOF_DOUBLE, (LEN))
764#define MAXALIGN(LEN) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))
766#define BUFFERALIGN(LEN) TYPEALIGN(ALIGNOF_BUFFER, (LEN))
767#define CACHELINEALIGN(LEN) TYPEALIGN(PG_CACHE_LINE_SIZE, (LEN))
769#define TYPEALIGN_DOWN(ALIGNVAL,LEN) \
770 (((uintptr_t) (LEN)) & ~((uintptr_t) ((ALIGNVAL) - 1)))
772#define SHORTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN))
773#define INTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT, (LEN))
774#define LONGALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_LONG, (LEN))
775#define DOUBLEALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_DOUBLE, (LEN))
776#define MAXALIGN_DOWN(LEN) TYPEALIGN_DOWN(MAXIMUM_ALIGNOF, (LEN))
777#define BUFFERALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_BUFFER, (LEN))
785#define TYPEALIGN64(ALIGNVAL,LEN) \
786 (((uint64) (LEN) + ((ALIGNVAL) - 1)) & ~((uint64) ((ALIGNVAL) - 1)))
789#define MAXALIGN64(LEN) TYPEALIGN64(MAXIMUM_ALIGNOF, (LEN))
809#ifndef USE_ASSERT_CHECKING
811#define Assert(condition) ((void)true)
812#define AssertMacro(condition) ((void)true)
813#define AssertArg(condition) ((void)true)
814#define AssertState(condition) ((void)true)
815#define AssertPointerAlignment(ptr, bndr) ((void)true)
816#define Trap(condition, errorType) ((void)true)
817#define TrapMacro(condition, errorType) (true)
819#elif defined(FRONTEND)
822#define Assert(p) assert(p)
823#define AssertMacro(p) ((void) assert(p))
824#define AssertArg(condition) assert(condition)
825#define AssertState(condition) assert(condition)
826#define AssertPointerAlignment(ptr, bndr) ((void)true)
834#define Trap(condition, errorType) \
837 ExceptionalCondition(#condition, (errorType), \
838 __FILE__, __LINE__); \
848#define TrapMacro(condition, errorType) \
849 ((bool) (! (condition) || \
850 (ExceptionalCondition(#condition, (errorType), \
851 __FILE__, __LINE__), 0)))
853#define Assert(condition) \
856 ExceptionalCondition(#condition, "FailedAssertion", \
857 __FILE__, __LINE__); \
860#define AssertMacro(condition) \
861 ((void) ((condition) || \
862 (ExceptionalCondition(#condition, "FailedAssertion", \
863 __FILE__, __LINE__), 0)))
865#define AssertArg(condition) \
868 ExceptionalCondition(#condition, "BadArgument", \
869 __FILE__, __LINE__); \
872#define AssertState(condition) \
875 ExceptionalCondition(#condition, "BadState", \
876 __FILE__, __LINE__); \
882#define AssertPointerAlignment(ptr, bndr) \
883 Trap(TYPEALIGN(bndr, (uintptr_t)(ptr)) != (uintptr_t)(ptr), \
896 const char *errorType,
917#ifdef HAVE__STATIC_ASSERT
918#define StaticAssertStmt(condition, errmessage) \
919 do { _Static_assert(condition, errmessage); } while(0)
920#define StaticAssertExpr(condition, errmessage) \
921 ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
922#define StaticAssertDecl(condition, errmessage) \
923 _Static_assert(condition, errmessage)
925#define StaticAssertStmt(condition, errmessage) \
926 ((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; }))
927#define StaticAssertExpr(condition, errmessage) \
928 StaticAssertStmt(condition, errmessage)
929#define StaticAssertDecl(condition, errmessage) \
930 extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1])
933#if defined(__cpp_static_assert) && __cpp_static_assert >= 200410
934#define StaticAssertStmt(condition, errmessage) \
935 static_assert(condition, errmessage)
936#define StaticAssertExpr(condition, errmessage) \
937 ({ static_assert(condition, errmessage); })
938#define StaticAssertDecl(condition, errmessage) \
939 static_assert(condition, errmessage)
941#define StaticAssertStmt(condition, errmessage) \
942 do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0)
943#define StaticAssertExpr(condition, errmessage) \
944 ((void) ({ StaticAssertStmt(condition, errmessage); }))
945#define StaticAssertDecl(condition, errmessage) \
946 extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1])
962#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P
963#define AssertVariableIsOfType(varname, typename) \
964 StaticAssertStmt(__builtin_types_compatible_p(__typeof__(varname), typename), \
965 CppAsString(varname) " does not have type " CppAsString(typename))
966#define AssertVariableIsOfTypeMacro(varname, typename) \
967 (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
968 CppAsString(varname) " does not have type " CppAsString(typename)))
970#define AssertVariableIsOfType(varname, typename) \
971 StaticAssertStmt(sizeof(varname) == sizeof(typename), \
972 CppAsString(varname) " does not have type " CppAsString(typename))
973#define AssertVariableIsOfTypeMacro(varname, typename) \
974 (StaticAssertExpr(sizeof(varname) == sizeof(typename), \
975 CppAsString(varname) " does not have type " CppAsString(typename)))
987#define Max(x, y) ((x) > (y) ? (x) : (y))
993#define Min(x, y) ((x) < (y) ? (x) : (y))
999#define Abs(x) ((x) >= 0 ? (x) : -(x))
1003#define LONG_ALIGN_MASK (sizeof(long) - 1)
1015#define MemSet(start, val, len) \
1019 void *_vstart = (void *) (start); \
1021 Size _len = (len); \
1023 if ((((uintptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \
1024 (_len & LONG_ALIGN_MASK) == 0 && \
1026 _len <= MEMSET_LOOP_LIMIT && \
1031 MEMSET_LOOP_LIMIT != 0) \
1033 long *_start = (long *) _vstart; \
1034 long *_stop = (long *) ((char *) _start + _len); \
1035 while (_start < _stop) \
1039 memset(_vstart, _val, _len); \
1048#define MemSetAligned(start, val, len) \
1051 long *_start = (long *) (start); \
1053 Size _len = (len); \
1055 if ((_len & LONG_ALIGN_MASK) == 0 && \
1057 _len <= MEMSET_LOOP_LIMIT && \
1058 MEMSET_LOOP_LIMIT != 0) \
1060 long *_stop = (long *) ((char *) _start + _len); \
1061 while (_start < _stop) \
1065 memset(_start, _val, _len); \
1077#define MemSetTest(val, len) \
1078 ( ((len) & LONG_ALIGN_MASK) == 0 && \
1079 (len) <= MEMSET_LOOP_LIMIT && \
1080 MEMSET_LOOP_LIMIT != 0 && \
1083#define MemSetLoop(start, val, len) \
1086 long * _start = (long *) (start); \
1087 long * _stop = (long *) ((char *) _start + (Size) (len)); \
1089 while (_start < _stop) \
1104#define FLOAT4_FITS_IN_INT16(num) \
1105 ((num) >= (float4) PG_INT16_MIN && (num) < -((float4) PG_INT16_MIN))
1106#define FLOAT4_FITS_IN_INT32(num) \
1107 ((num) >= (float4) PG_INT32_MIN && (num) < -((float4) PG_INT32_MIN))
1108#define FLOAT4_FITS_IN_INT64(num) \
1109 ((num) >= (float4) PG_INT64_MIN && (num) < -((float4) PG_INT64_MIN))
1110#define FLOAT8_FITS_IN_INT16(num) \
1111 ((num) >= (float8) PG_INT16_MIN && (num) < -((float8) PG_INT16_MIN))
1112#define FLOAT8_FITS_IN_INT32(num) \
1113 ((num) >= (float8) PG_INT32_MIN && (num) < -((float8) PG_INT32_MIN))
1114#define FLOAT8_FITS_IN_INT64(num) \
1115 ((num) >= (float8) PG_INT64_MIN && (num) < -((float8) PG_INT64_MIN))
1123#ifdef HAVE_STRUCT_SOCKADDR_UN
1124#define HAVE_UNIX_SOCKETS 1
1132#define INVERT_COMPARE_RESULT(var) \
1133 ((var) = ((var) < 0) ? 1 : -(var))
1162#define HIGHBIT (0x80)
1163#define IS_HIGHBIT_SET(ch) ((unsigned char)(ch) & HIGHBIT)
1171#define SQL_STR_DOUBLE(ch, escape_backslash) \
1172 ((ch) == '\'' || ((ch) == '\\' && (escape_backslash)))
1174#define ESCAPE_STRING_SYNTAX 'E'
1177#define STATUS_OK (0)
1178#define STATUS_ERROR (-1)
1179#define STATUS_EOF (-2)
1187#define gettext(x) (x)
1188#define dgettext(d,x) (x)
1189#define ngettext(s,p,n) ((n) == 1 ? (s) : (p))
1190#define dngettext(d,s,p,n) ((n) == 1 ? (s) : (p))
1193#define _(x) gettext(x)
1204#define gettext_noop(x) (x)
1219#ifdef SO_MAJOR_VERSION
1220#define PG_TEXTDOMAIN(domain) (domain CppAsString2(SO_MAJOR_VERSION) "-" PG_MAJORVERSION)
1222#define PG_TEXTDOMAIN(domain) (domain "-" PG_MAJORVERSION)
1240#if defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P)
1241#define unconstify(underlying_type, expr) \
1242 (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), const underlying_type), \
1244 (underlying_type) (expr))
1245#define unvolatize(underlying_type, expr) \
1246 (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), volatile underlying_type), \
1248 (underlying_type) (expr))
1250#define unconstify(underlying_type, expr) \
1251 ((underlying_type) (expr))
1252#define unvolatize(underlying_type, expr) \
1253 ((underlying_type) (expr))
1272#if defined(WIN32) || defined(__CYGWIN__)
1273#define PG_BINARY O_BINARY
1274#define PG_BINARY_A "ab"
1275#define PG_BINARY_R "rb"
1276#define PG_BINARY_W "wb"
1279#define PG_BINARY_A "a"
1280#define PG_BINARY_R "r"
1281#define PG_BINARY_W "w"
1289#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
1290extern int fdatasync(
int fildes);
1294#if !defined(HAVE_STRTOLL) && defined(HAVE___STRTOLL)
1295#define strtoll __strtoll
1296#define HAVE_STRTOLL 1
1299#if !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
1300#define strtoll strtoq
1301#define HAVE_STRTOLL 1
1304#if !defined(HAVE_STRTOULL) && defined(HAVE___STRTOULL)
1305#define strtoull __strtoull
1306#define HAVE_STRTOULL 1
1309#if !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
1310#define strtoull strtouq
1311#define HAVE_STRTOULL 1
1314#if defined(HAVE_STRTOLL) && !HAVE_DECL_STRTOLL
1315extern long long strtoll(
const char *str,
char **endptr,
int base);
1318#if defined(HAVE_STRTOULL) && !HAVE_DECL_STRTOULL
1319extern unsigned long long strtoull(
const char *str,
char **endptr,
int base);
1340#define SIGNAL_ARGS int postgres_signal_arg
1351typedef intptr_t sigjmp_buf[5];
1352#define sigsetjmp(x,y) __builtin_setjmp(x)
1353#define siglongjmp __builtin_longjmp
1355#define sigjmp_buf jmp_buf
1356#define sigsetjmp(x,y) setjmp(x)
1357#define siglongjmp longjmp
1363#define NON_EXEC_STATIC
1365#define NON_EXEC_STATIC static
unsigned short uint16
Definition: c.h:445
#define pg_attribute_noreturn()
Definition: c.h:180
unsigned int uint32
Definition: c.h:446
uint16 bits16
Definition: c.h:454
signed char int8
Definition: c.h:432
union PGAlignedBlock PGAlignedBlock
signed short int16
Definition: c.h:433
union PGAlignedXLogBlock PGAlignedXLogBlock
void ExceptionalCondition(const char *conditionName, const char *errorType, const char *fileName, int lineNumber) pg_attribute_noreturn()
uint32 SubTransactionId
Definition: c.h:596
signed int int32
Definition: c.h:434
char * Pointer
Definition: c.h:423
Oid regproc
Definition: c.h:589
uint32 MultiXactOffset
Definition: c.h:604
double float8
Definition: c.h:570
TransactionId MultiXactId
Definition: c.h:602
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:351
regproc RegProcedure
Definition: c.h:590
uint8 bits8
Definition: c.h:453
uint32 bits32
Definition: c.h:455
unsigned int Index
Definition: c.h:554
float float4
Definition: c.h:569
uint32 LocalTransactionId
Definition: c.h:594
unsigned char uint8
Definition: c.h:444
uint32 CommandId
Definition: c.h:606
uint32 TransactionId
Definition: c.h:592
signed int Offset
Definition: c.h:564
unsigned long int uint64
Definition: c.h:467
void(* pg_funcptr_t)(void)
Definition: c.h:341
size_t Size
Definition: c.h:545
long int int64
Definition: c.h:464
#define BLCKSZ
Definition: pg_config.h:44
#define XLOG_BLCKSZ
Definition: pg_config.h:976
#define MAXIMUM_ALIGNOF
Definition: pg_config.h:783
#define PG_INT128_TYPE
Definition: pg_config.h:811
unsigned short uint16
Definition: pg_ext_defs.in.h:12
unsigned int uint32
Definition: pg_ext_defs.in.h:13
unsigned char uint8
Definition: pg_ext_defs.in.h:11
long int int64
Definition: pg_ext_defs.in.h:9
unsigned int Oid
Definition: postgres_ext.h:31
char vl_len_[4]
Definition: pg_ext_defs.in.h:32
char vl_dat[]
Definition: pg_ext_defs.in.h:33
Definition: pg_ext_defs.in.h:31
double force_align_d
Definition: c.h:1146
int64 force_align_i64
Definition: c.h:1147
char data[BLCKSZ]
Definition: c.h:1145
char data[XLOG_BLCKSZ]
Definition: c.h:1153
double force_align_d
Definition: c.h:1154
int64 force_align_i64
Definition: c.h:1155