PostgreSQL Source Code git master
Loading...
Searching...
No Matches
c.h File Reference
#include "pg_config.h"
#include "pg_config_manual.h"
#include "pg_config_os.h"
#include <assert.h>
#include <inttypes.h>
#include <stdalign.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdint.h>
#include <sys/types.h>
#include <errno.h>
#include <locale.h>
#include "postgres_ext.h"
#include <stdbool.h>
#include "port.h"
Include dependency graph for c.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  varlena
 
struct  int2vector
 
struct  oidvector
 
struct  nameData
 
struct  PGAlignedBlock
 
struct  PGIOAlignedBlock
 
struct  PGAlignedXLogBlock
 
struct  pg_signal_info
 

Macros

#define __has_attribute(attribute)   0
 
#define pg_attribute_unused()
 
#define pg_fallthrough
 
#define pg_nodiscard
 
#define pg_noreturn   _Noreturn
 
#define pg_attribute_no_sanitize_address()
 
#define pg_attribute_no_sanitize_alignment()
 
#define pg_attribute_nonnull(...)
 
#define pg_attribute_target(...)
 
#define PG_USED_FOR_ASSERTS_ONLY   pg_attribute_unused()
 
#define PG_PRINTF_ATTRIBUTE   PG_C_PRINTF_ATTRIBUTE
 
#define pg_attribute_format_arg(a)
 
#define pg_attribute_printf(f, a)
 
#define pg_attribute_always_inline   inline
 
#define pg_noinline
 
#define pg_attribute_cold
 
#define pg_attribute_hot
 
#define pg_unreachable()   abort()
 
#define pg_assume(expr)   ((void) 0)
 
#define likely(x)   ((x) != 0)
 
#define unlikely(x)   ((x) != 0)
 
#define CppAsString(identifier)   #identifier
 
#define CppAsString2(x)   CppAsString(x)
 
#define CppConcat(x, y)   x##y
 
#define VA_ARGS_NARGS(...)
 
#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)
 
#define FLEXIBLE_ARRAY_MEMBER   /* empty */
 
#define INT64CONST(x)   INT64_C(x)
 
#define UINT64CONST(x)   UINT64_C(x)
 
#define INT64_FORMAT   "%" PRId64
 
#define UINT64_FORMAT   "%" PRIu64
 
#define OID8_FORMAT   "%" PRIu64
 
#define PG_INT8_MIN   INT8_MIN
 
#define PG_INT8_MAX   INT8_MAX
 
#define PG_UINT8_MAX   UINT8_MAX
 
#define PG_INT16_MIN   INT16_MIN
 
#define PG_INT16_MAX   INT16_MAX
 
#define PG_UINT16_MAX   UINT16_MAX
 
#define PG_INT32_MIN   INT32_MIN
 
#define PG_INT32_MAX   INT32_MAX
 
#define PG_UINT32_MAX   UINT32_MAX
 
#define PG_INT64_MIN   INT64_MIN
 
#define PG_INT64_MAX   INT64_MAX
 
#define PG_UINT64_MAX   UINT64_MAX
 
#define HAVE_INT64_TIMESTAMP
 
#define FLOAT8PASSBYVAL   true
 
#define InvalidSubTransactionId   ((SubTransactionId) 0)
 
#define TopSubTransactionId   ((SubTransactionId) 1)
 
#define FirstCommandId   ((CommandId) 0)
 
#define InvalidCommandId   (~(CommandId)0)
 
#define InvalidOid8   ((Oid8) 0)
 
#define OID8_MAX   UINT64_MAX
 
#define VARHDRSZ   ((int32) sizeof(int32))
 
#define NameStr(name)   ((name).data)
 
#define BoolIsValid(boolean)   ((boolean) == false || (boolean) == true)
 
#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 Oid8IsValid(objectId)   ((bool) ((objectId) != InvalidOid8))
 
#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 INT64ALIGN(LEN)   TYPEALIGN(ALIGNOF_INT64_T, (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 INT64ALIGN_DOWN(LEN)   TYPEALIGN_DOWN(ALIGNOF_INT64_T, (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))
 
#define Assert(condition)   ((void)true)
 
#define AssertMacro(condition)   ((void)true)
 
#define AssertPointerAlignment(ptr, bndr)    Assert(TYPEALIGN(bndr, (uintptr_t)(ptr)) == (uintptr_t)(ptr))
 
#define StaticAssertDecl(condition, errmessage)    static_assert(condition, errmessage)
 
#define StaticAssertStmt(condition, errmessage)    do { static_assert(condition, errmessage); } while(0)
 
#define StaticAssertExpr(condition, errmessage)    ((void) sizeof(struct {static_assert(condition, errmessage); char a;}))
 
#define StaticAssertVariableIsOfType(varname, typename)
 
#define StaticAssertVariableIsOfTypeMacro(varname, typename)
 
#define Max(x, y)   ((x) > (y) ? (x) : (y))
 
#define Min(x, y)   ((x) < (y) ? (x) : (y))
 
#define SIZE_T_ALIGN_MASK   (sizeof(size_t) - 1)
 
#define MemSet(start, val, len)
 
#define MemSetAligned(start, val, len)
 
#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))
 
#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)
 
#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))
 
#define _(x)   gettext(x)
 
#define gettext_noop(x)   (x)
 
#define PG_TEXTDOMAIN(domain)   (domain "-" PG_MAJORVERSION)
 
#define unconstify(underlying_type, expr)
 
#define unvolatize(underlying_type, expr)
 
#define PG_BINARY   0
 
#define PG_BINARY_A   "a"
 
#define PG_BINARY_R   "r"
 
#define PG_BINARY_W   "w"
 
#define PGDLLIMPORT
 
#define PGDLLEXPORT
 
#define SIGNAL_ARGS   int postgres_signal_arg, const pg_signal_info *pg_siginfo
 

Typedefs

typedef void(* pg_funcptr_t) (void)
 
typedef voidPointer
 
typedef int8_t int8
 
typedef int16_t int16
 
typedef int32_t int32
 
typedef int64_t int64
 
typedef uint8_t uint8
 
typedef uint16_t uint16
 
typedef uint32_t uint32
 
typedef uint64_t uint64
 
typedef size_t Size
 
typedef unsigned int Index
 
typedef signed int Offset
 
typedef float float4
 
typedef double float8
 
typedef Oid regproc
 
typedef regproc RegProcedure
 
typedef uint32 TransactionId
 
typedef uint32 LocalTransactionId
 
typedef uint32 SubTransactionId
 
typedef TransactionId MultiXactId
 
typedef uint64 MultiXactOffset
 
typedef uint32 CommandId
 
typedef uint64 Oid8
 
typedef struct varlena varlena
 
typedef varlena bytea
 
typedef varlena text
 
typedef varlena BpChar
 
typedef varlena VarChar
 
typedef struct nameData NameData
 
typedef NameDataName
 
typedef struct PGAlignedBlock PGAlignedBlock
 
typedef struct PGIOAlignedBlock PGIOAlignedBlock
 
typedef struct PGAlignedXLogBlock PGAlignedXLogBlock
 
typedef struct pg_signal_info pg_signal_info
 
typedef uint16_t char16_t
 
typedef uint32_t char32_t
 

Functions

pg_noreturn void ExceptionalCondition (const char *conditionName, const char *fileName, int lineNumber)
 
int fdatasync (int fd)
 

Macro Definition Documentation

◆ _

#define _ (   x)    gettext(x)

Definition at line 1333 of file c.h.

◆ __has_attribute

#define __has_attribute (   attribute)    0

Definition at line 197 of file c.h.

◆ Assert

#define Assert (   condition)    ((void)true)

Definition at line 1002 of file c.h.

◆ AssertMacro

#define AssertMacro (   condition)    ((void)true)

Definition at line 1003 of file c.h.

◆ AssertPointerAlignment

#define AssertPointerAlignment (   ptr,
  bndr 
)     Assert(TYPEALIGN(bndr, (uintptr_t)(ptr)) == (uintptr_t)(ptr))

Definition at line 1037 of file c.h.

1074 { static_assert(condition, errmessage); } while(0)
1075
1076/*
1077 * StaticAssertExpr() is for use in an expression.
1078 *
1079 * See <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3715.pdf> for some
1080 * rationale for the precise behavior of this implementation. See
1081 * <https://stackoverflow.com/questions/31311748> about the C++
1082 * implementation.
1083 *
1084 * For compilers that don't support this, we fall back on a kluge that assumes
1085 * the compiler will complain about a negative width for a struct bit-field.
1086 * This will not include a helpful error message, but it beats not getting an
1087 * error at all.
1088 */
1089#ifndef __cplusplus
1090#if !defined(_MSC_VER) || _MSC_VER >= 1933
1091#define StaticAssertExpr(condition, errmessage) \
1092 ((void) sizeof(struct {static_assert(condition, errmessage); char a;}))
1093#else /* _MSC_VER < 1933 */
1094/*
1095 * This compiler is buggy and fails to compile the previous variant; use a
1096 * fallback implementation.
1097 */
1098#define StaticAssertExpr(condition, errmessage) \
1099 ((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; }))
1100#endif /* _MSC_VER < 1933 */
1101#else /* __cplusplus */
1102#define StaticAssertExpr(condition, errmessage) \
1103 ([]{static_assert(condition, errmessage);})
1104#endif
1105
1106
1107/*
1108 * Compile-time checks that a variable (or expression) has the specified type.
1109 *
1110 * StaticAssertVariableIsOfType() can be used as a declaration.
1111 * StaticAssertVariableIsOfTypeMacro() is intended for use in macros, eg
1112 * #define foo(x) (StaticAssertVariableIsOfTypeMacro(x, int), bar(x))
1113 *
1114 * If we don't have __builtin_types_compatible_p, we can still assert that
1115 * the types have the same size. This is far from ideal (especially on 32-bit
1116 * platforms) but it provides at least some coverage.
1117 */
1118#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P
1119#define StaticAssertVariableIsOfType(varname, typename) \
1120 StaticAssertDecl(__builtin_types_compatible_p(typeof(varname), typename), \
1121 CppAsString(varname) " does not have type " CppAsString(typename))
1122#define StaticAssertVariableIsOfTypeMacro(varname, typename) \
1123 (StaticAssertExpr(__builtin_types_compatible_p(typeof(varname), typename), \
1124 CppAsString(varname) " does not have type " CppAsString(typename)))
1125#else /* !HAVE__BUILTIN_TYPES_COMPATIBLE_P */
1126#define StaticAssertVariableIsOfType(varname, typename) \
1127 StaticAssertDecl(sizeof(varname) == sizeof(typename), \
1128 CppAsString(varname) " does not have type " CppAsString(typename))
1129#define StaticAssertVariableIsOfTypeMacro(varname, typename) \
1130 (StaticAssertExpr(sizeof(varname) == sizeof(typename), \
1131 CppAsString(varname) " does not have type " CppAsString(typename)))
1132#endif /* HAVE__BUILTIN_TYPES_COMPATIBLE_P */
1133
1134
1135/* ----------------------------------------------------------------
1136 * Section 7: widely useful macros
1137 * ----------------------------------------------------------------
1138 */
1139/*
1140 * Max
1141 * Return the maximum of two numbers.
1142 */
1143#define Max(x, y) ((x) > (y) ? (x) : (y))
1144
1145/*
1146 * Min
1147 * Return the minimum of two numbers.
1148 */
1149#define Min(x, y) ((x) < (y) ? (x) : (y))
1150
1151
1152/* Get a bit mask of the bits set in non-size_t aligned addresses */
1153#define SIZE_T_ALIGN_MASK (sizeof(size_t) - 1)
1154
1155/*
1156 * MemSet
1157 * Exactly the same as standard library function memset(), but considerably
1158 * faster for zeroing small size_t-aligned structures (such as parsetree
1159 * nodes). This has to be a macro because the main point is to avoid
1160 * function-call overhead. However, we have also found that the loop is
1161 * faster than native libc memset() on some platforms, even those with
1162 * assembler memset() functions. More research needs to be done, perhaps
1163 * with MEMSET_LOOP_LIMIT tests in configure.
1164 */
1165#define MemSet(start, val, len) \
1166 do \
1167 { \
1168 /* must be void* because we don't know if it is size_t aligned yet */ \
1169 void *_vstart = (void *) (start); \
1170 int _val = (val); \
1171 Size _len = (len); \
1172\
1173 if ((((uintptr_t) _vstart) & SIZE_T_ALIGN_MASK) == 0 && \
1174 (_len & SIZE_T_ALIGN_MASK) == 0 && \
1175 _val == 0 && \
1176 _len <= MEMSET_LOOP_LIMIT && \
1177 /* \
1178 * If MEMSET_LOOP_LIMIT == 0, optimizer should find \
1179 * the whole "if" false at compile time. \
1180 */ \
1181 MEMSET_LOOP_LIMIT != 0) \
1182 { \
1183 size_t *_start = (size_t *) _vstart; \
1184 size_t *_stop = (size_t *) ((char *) _start + _len); \
1185 while (_start < _stop) \
1186 *_start++ = 0; \
1187 } \
1188 else \
1189 memset(_vstart, _val, _len); \
1190 } while (0)
1191
1192/*
1193 * MemSetAligned is the same as MemSet except it omits the test to see if
1194 * "start" is size_t-aligned. This is okay to use if the caller knows
1195 * a-priori that the pointer is suitably aligned (typically, because he just
1196 * got it from palloc(), which always delivers a max-aligned pointer).
1197 */
1198#define MemSetAligned(start, val, len) \
1199 do \
1200 { \
1201 size_t *_start = (size_t *) (start); \
1202 int _val = (val); \
1203 Size _len = (len); \
1204\
1205 if ((_len & SIZE_T_ALIGN_MASK) == 0 && \
1206 _val == 0 && \
1207 _len <= MEMSET_LOOP_LIMIT && \
1208 MEMSET_LOOP_LIMIT != 0) \
1209 { \
1210 size_t *_stop = (size_t *) ((char *) _start + _len); \
1211 while (_start < _stop) \
1212 *_start++ = 0; \
1213 } \
1214 else \
1215 memset(_start, _val, _len); \
1216 } while (0)
1217
1218
1219/*
1220 * Macros for range-checking float values before converting to integer.
1221 * We must be careful here that the boundary values are expressed exactly
1222 * in the float domain. PG_INTnn_MIN is an exact power of 2, so it will
1223 * be represented exactly; but PG_INTnn_MAX isn't, and might get rounded
1224 * off, so avoid using that.
1225 * The input must be rounded to an integer beforehand, typically with rint(),
1226 * else we might draw the wrong conclusion about close-to-the-limit values.
1227 * These macros will do the right thing for Inf, but not necessarily for NaN,
1228 * so check isnan(num) first if that's a possibility.
1229 */
1230#define FLOAT4_FITS_IN_INT16(num) \
1231 ((num) >= (float4) PG_INT16_MIN && (num) < -((float4) PG_INT16_MIN))
1232#define FLOAT4_FITS_IN_INT32(num) \
1233 ((num) >= (float4) PG_INT32_MIN && (num) < -((float4) PG_INT32_MIN))
1234#define FLOAT4_FITS_IN_INT64(num) \
1235 ((num) >= (float4) PG_INT64_MIN && (num) < -((float4) PG_INT64_MIN))
1236#define FLOAT8_FITS_IN_INT16(num) \
1237 ((num) >= (float8) PG_INT16_MIN && (num) < -((float8) PG_INT16_MIN))
1238#define FLOAT8_FITS_IN_INT32(num) \
1239 ((num) >= (float8) PG_INT32_MIN && (num) < -((float8) PG_INT32_MIN))
1240#define FLOAT8_FITS_IN_INT64(num) \
1241 ((num) >= (float8) PG_INT64_MIN && (num) < -((float8) PG_INT64_MIN))
1242
1243
1244/* ----------------------------------------------------------------
1245 * Section 8: random stuff
1246 * ----------------------------------------------------------------
1247 */
1248
1249/*
1250 * Invert the sign of a qsort-style comparison result, ie, exchange negative
1251 * and positive integer values, being careful not to get the wrong answer
1252 * for INT_MIN. The argument should be an integral variable.
1253 */
1254#define INVERT_COMPARE_RESULT(var) \
1255 ((var) = ((var) < 0) ? 1 : -(var))
1256
1257/*
1258 * Use this, not "char buf[BLCKSZ]", to declare a field or local variable
1259 * holding a page buffer, if that page might be accessed as a page. Otherwise
1260 * the variable might be under-aligned, causing problems on alignment-picky
1261 * hardware.
1262 */
1263typedef struct PGAlignedBlock
1264{
1265 alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ];
1267
1268/*
1269 * alignas with extended alignments is buggy in g++ < 9. As a simple
1270 * workaround, we disable these definitions in that case.
1271 *
1272 * <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89357>
1273 */
1274#if !(defined(__cplusplus) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 9)
1275
1276/*
1277 * Use this to declare a field or local variable holding a page buffer, if that
1278 * page might be accessed as a page or passed to an SMgr I/O function. If
1279 * allocating using the MemoryContext API, the aligned allocation functions
1280 * should be used with PG_IO_ALIGN_SIZE. This alignment may be more efficient
1281 * for I/O in general, but may be strictly required on some platforms when
1282 * using direct I/O.
1283 */
1284typedef struct PGIOAlignedBlock
1285{
1286 alignas(PG_IO_ALIGN_SIZE) char data[BLCKSZ];
1288
1289/* Same, but for an XLOG_BLCKSZ-sized buffer */
1290typedef struct PGAlignedXLogBlock
1291{
1292 alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ];
1294
1295#else /* (g++ < 9) */
1296
1297/* Allow these types to be used as abstract types when using old g++ */
1298typedef struct PGIOAlignedBlock PGIOAlignedBlock;
1300
1301#endif /* !(g++ < 9) */
1302
1303/* msb for char */
1304#define HIGHBIT (0x80)
1305#define IS_HIGHBIT_SET(ch) ((unsigned char)(ch) & HIGHBIT)
1306
1307/*
1308 * Support macros for escaping strings. escape_backslash should be true
1309 * if generating a non-standard-conforming string. Prefixing a string
1310 * with ESCAPE_STRING_SYNTAX guarantees it is non-standard-conforming.
1311 * Beware of multiple evaluation of the "ch" argument!
1312 */
1313#define SQL_STR_DOUBLE(ch, escape_backslash) \
1314 ((ch) == '\'' || ((ch) == '\\' && (escape_backslash)))
1315
1316#define ESCAPE_STRING_SYNTAX 'E'
1317
1318
1319#define STATUS_OK (0)
1320#define STATUS_ERROR (-1)
1321#define STATUS_EOF (-2)
1322
1323/*
1324 * gettext support
1325 */
1326
1327#ifndef ENABLE_NLS
1328/* stuff we'd otherwise get from <libintl.h> */
1329#define gettext(x) (x)
1330#define dgettext(d,x) (x)
1331#define ngettext(s,p,n) ((n) == 1 ? (s) : (p))
1332#define dngettext(d,s,p,n) ((n) == 1 ? (s) : (p))
1333#endif
1334
1335#define _(x) gettext(x)
1336
1337/*
1338 * Use this to mark string constants as needing translation at some later
1339 * time, rather than immediately. This is useful for cases where you need
1340 * access to the original string and translated string, and for cases where
1341 * immediate translation is not possible, like when initializing global
1342 * variables.
1343 *
1344 * https://www.gnu.org/software/gettext/manual/html_node/Special-cases.html
1345 */
1346#define gettext_noop(x) (x)
1347
1348/*
1349 * To better support parallel installations of major PostgreSQL
1350 * versions as well as parallel installations of major library soname
1351 * versions, we mangle the gettext domain name by appending those
1352 * version numbers. The coding rule ought to be that wherever the
1353 * domain name is mentioned as a literal, it must be wrapped into
1354 * PG_TEXTDOMAIN(). The macros below do not work on non-literals; but
1355 * that is somewhat intentional because it avoids having to worry
1356 * about multiple states of premangling and postmangling as the values
1357 * are being passed around.
1358 *
1359 * Make sure this matches the installation rules in nls-global.mk.
1360 */
1361#ifdef SO_MAJOR_VERSION
1362#define PG_TEXTDOMAIN(domain) (domain CppAsString2(SO_MAJOR_VERSION) "-" PG_MAJORVERSION)
1363#else
1364#define PG_TEXTDOMAIN(domain) (domain "-" PG_MAJORVERSION)
1365#endif
1366
1367/*
1368 * Macro that allows to cast constness and volatile away from an expression, but doesn't
1369 * allow changing the underlying type. Enforcement of the latter
1370 * currently only works for gcc like compilers.
1371 *
1372 * Please note IT IS NOT SAFE to cast constness away if the result will ever
1373 * be modified (it would be undefined behaviour). Doing so anyway can cause
1374 * compiler misoptimizations or runtime crashes (modifying readonly memory).
1375 * It is only safe to use when the result will not be modified, but API
1376 * design or language restrictions prevent you from declaring that
1377 * (e.g. because a function returns both const and non-const variables).
1378 *
1379 * Note that this only works in function scope, not for global variables (it'd
1380 * be nice, but not trivial, to improve that).
1381 */
1382#if defined(__cplusplus)
1383#define unconstify(underlying_type, expr) const_cast<underlying_type>(expr)
1384#define unvolatize(underlying_type, expr) const_cast<underlying_type>(expr)
1385#else
1386#define unconstify(underlying_type, expr) \
1387 (StaticAssertVariableIsOfTypeMacro(expr, const underlying_type), \
1388 (underlying_type) (expr))
1389#define unvolatize(underlying_type, expr) \
1390 (StaticAssertVariableIsOfTypeMacro(expr, volatile underlying_type), \
1391 (underlying_type) (expr))
1392#endif
1393
1394/*
1395 * SSE2 instructions are part of the spec for the 64-bit x86 ISA. We assume
1396 * that compilers targeting this architecture understand SSE2 intrinsics.
1397 */
1398#if defined(__x86_64__)
1399#define USE_SSE2
1400
1401#else /* ! x86_64 */
1402
1403/*
1404 * In "universal" macOS builds, it's possible for AVX-related symbols to
1405 * get defined if the build host is x86_64, but we mustn't try to build
1406 * that code when cross-compiling to aarch64.
1407 */
1408#undef USE_AVX2_WITH_RUNTIME_CHECK
1409#undef USE_AVX512_CRC32C_WITH_RUNTIME_CHECK
1410#undef USE_AVX512_POPCNT_WITH_RUNTIME_CHECK
1411
1412/*
1413 * We use the Neon instructions if the compiler provides access to them (as
1414 * indicated by __ARM_NEON) and we are on aarch64. While Neon support is
1415 * technically optional for aarch64, it appears that all available 64-bit
1416 * hardware does have it. Neon exists in some 32-bit hardware too, but we
1417 * could not realistically use it there without a run-time check, which seems
1418 * not worth the trouble for now.
1419 */
1420#if defined(__aarch64__) && defined(__ARM_NEON)
1421#define USE_NEON
1422#endif
1423#endif /* x86_64 */
1424
1425/* ----------------------------------------------------------------
1426 * Section 9: system-specific hacks
1427 *
1428 * This should be limited to things that absolutely have to be
1429 * included in every source file. The port-specific header file
1430 * is usually a better place for this sort of thing.
1431 * ----------------------------------------------------------------
1432 */
1433
1434/*
1435 * NOTE: this is also used for opening text files.
1436 * WIN32 treats Control-Z as EOF in files opened in text mode.
1437 * Therefore, we open files in binary mode on Win32 so we can read
1438 * literal control-Z. The other affect is that we see CRLF, but
1439 * that is OK because we can already handle those cleanly.
1440 */
1441#if defined(WIN32) || defined(__CYGWIN__)
1442#define PG_BINARY O_BINARY
1443#define PG_BINARY_A "ab"
1444#define PG_BINARY_R "rb"
1445#define PG_BINARY_W "wb"
1446#else
1447#define PG_BINARY 0
1448#define PG_BINARY_A "a"
1449#define PG_BINARY_R "r"
1450#define PG_BINARY_W "w"
1451#endif
1452
1453/*
1454 * Provide prototypes for routines not present in a particular machine's
1455 * standard C library.
1456 */
1457
1458#if !HAVE_DECL_FDATASYNC
1459extern int fdatasync(int fd);
1460#endif
1461
1462/*
1463 * Thin wrappers that convert strings to exactly 64-bit integers, matching our
1464 * definition of int64. (For the naming, compare that POSIX has
1465 * strtoimax()/strtoumax() which return intmax_t/uintmax_t.)
1466 */
1467#if SIZEOF_LONG == 8
1468#define strtoi64(str, endptr, base) ((int64) strtol(str, endptr, base))
1469#define strtou64(str, endptr, base) ((uint64) strtoul(str, endptr, base))
1470#elif SIZEOF_LONG_LONG == 8
1471#define strtoi64(str, endptr, base) ((int64) strtoll(str, endptr, base))
1472#define strtou64(str, endptr, base) ((uint64) strtoull(str, endptr, base))
1473#else
1474#error "cannot find integer type of the same size as int64_t"
1475#endif
1476
1477/*
1478 * Similarly, wrappers around labs()/llabs() matching our int64.
1479 */
1480#if SIZEOF_LONG == 8
1481#define i64abs(i) ((int64) labs(i))
1482#elif SIZEOF_LONG_LONG == 8
1483#define i64abs(i) ((int64) llabs(i))
1484#else
1485#error "cannot find integer type of the same size as int64_t"
1486#endif
1487
1488/*
1489 * Use "extern PGDLLIMPORT ..." to declare variables that are defined
1490 * in the core backend and need to be accessible by loadable modules.
1491 * No special marking is required on most ports.
1492 */
1493#ifndef PGDLLIMPORT
1494#define PGDLLIMPORT
1495#endif
1496
1497/*
1498 * Use "extern PGDLLEXPORT ..." to declare functions that are defined in
1499 * loadable modules and need to be callable by the core backend or other
1500 * loadable modules.
1501 * If the compiler knows __attribute__((visibility("*"))), we use that,
1502 * unless we already have a platform-specific definition. Otherwise,
1503 * no special marking is required.
1504 */
1505#ifndef PGDLLEXPORT
1506#ifdef HAVE_VISIBILITY_ATTRIBUTE
1507#define PGDLLEXPORT __attribute__((visibility("default")))
1508#else
1509#define PGDLLEXPORT
1510#endif
1511#endif
1512
1513/*
1514 * Platform independent struct representing additional information about the
1515 * received signal. If the system does not support the extended information,
1516 * or a field does not apply to the signal, the value is instead reset to the
1517 * documented default value.
1518 */
1519
1520typedef struct pg_signal_info
1521{
1522 uint32_t pid; /* pid of sending process or 0 if unknown */
1523 uint32_t uid; /* uid of sending process; only meaningful
1524 * when pid is not 0 */
1526
1527/*
1528 * The following is used as the arg list for signal handlers. These days we
1529 * use the same argument to all signal handlers and hide the difference
1530 * between platforms in wrapper functions.
1531 *
1532 * SIGNAL_ARGS just exists separately from the pqsignal() definition for
1533 * historical reasons.
1534 */
1535#define SIGNAL_ARGS int postgres_signal_arg, const pg_signal_info *pg_siginfo
1536
1537/*
1538 * When there is no sigsetjmp, its functionality is provided by plain
1539 * setjmp. We now support the case only on Windows. However, it seems
1540 * that MinGW-64 has some longstanding issues in its setjmp support,
1541 * so on that toolchain we cheat and use gcc's builtins.
1542 */
1543#ifdef WIN32
1544#ifdef __MINGW64__
1545typedef intptr_t sigjmp_buf[5];
1546#define sigsetjmp(x,y) __builtin_setjmp(x)
1547#define siglongjmp __builtin_longjmp
1548#else /* !__MINGW64__ */
1549#define sigjmp_buf jmp_buf
1550#define sigsetjmp(x,y) setjmp(x)
1551#define siglongjmp longjmp
1552#endif /* __MINGW64__ */
1553#endif /* WIN32 */
1554
1555/* /port compatibility functions */
1556#include "port.h"
1557
1558/*
1559 * char16_t and char32_t
1560 * Unicode code points.
1561 *
1562 * uchar.h should always be available in C11, but it's not available on
1563 * Mac. However, these types are keywords in C++11, so when using C++, we
1564 * can't redefine the types.
1565 *
1566 * XXX: when uchar.h is available everywhere, we can remove this check and
1567 * just include uchar.h unconditionally.
1568 *
1569 * XXX: this section is out of place because uchar.h needs to be included
1570 * after port.h, due to an interaction with win32_port.h in some cases.
1571 */
1572#ifdef HAVE_UCHAR_H
1573#include <uchar.h>
1574#else
1575#ifndef __cplusplus
1576typedef uint16_t char16_t;
1577typedef uint32_t char32_t;
1578#endif
1579#endif
1580
1581/* IWYU pragma: end_exports */
1582
1583#endif /* C_H */
int fdatasync(int fd)
uint16_t char16_t
Definition c.h:1574
uint32_t char32_t
Definition c.h:1575
#define PG_IO_ALIGN_SIZE
static int fd(const char *x, int i)
static int fb(int x)
char data[BLCKSZ]
Definition c.h:1263
char data[XLOG_BLCKSZ]
Definition c.h:1290
char data[BLCKSZ]
Definition c.h:1284
uint32_t pid
Definition c.h:1520
uint32_t uid
Definition c.h:1521

◆ BoolIsValid

#define BoolIsValid (   boolean)    ((boolean) == false || (boolean) == true)

Definition at line 905 of file c.h.

◆ BUFFERALIGN

#define BUFFERALIGN (   LEN)    TYPEALIGN(ALIGNOF_BUFFER, (LEN))

Definition at line 957 of file c.h.

◆ BUFFERALIGN_DOWN

#define BUFFERALIGN_DOWN (   LEN)    TYPEALIGN_DOWN(ALIGNOF_BUFFER, (LEN))

Definition at line 968 of file c.h.

◆ CACHELINEALIGN

#define CACHELINEALIGN (   LEN)    TYPEALIGN(PG_CACHE_LINE_SIZE, (LEN))

Definition at line 958 of file c.h.

◆ CppAsString

#define CppAsString (   identifier)    #identifier

Definition at line 564 of file c.h.

◆ CppAsString2

#define CppAsString2 (   x)    CppAsString(x)

Definition at line 565 of file c.h.

◆ CppConcat

#define CppConcat (   x,
  y 
)    x##y

Definition at line 566 of file c.h.

◆ dgettext

#define dgettext (   d,
  x 
)    (x)

Definition at line 1328 of file c.h.

◆ dngettext

#define dngettext (   d,
  s,
  p,
 
)    ((n) == 1 ? (s) : (p))

Definition at line 1330 of file c.h.

◆ DOUBLEALIGN

#define DOUBLEALIGN (   LEN)    TYPEALIGN(ALIGNOF_DOUBLE, (LEN))

Definition at line 954 of file c.h.

◆ DOUBLEALIGN_DOWN

#define DOUBLEALIGN_DOWN (   LEN)    TYPEALIGN_DOWN(ALIGNOF_DOUBLE, (LEN))

Definition at line 966 of file c.h.

◆ ESCAPE_STRING_SYNTAX

#define ESCAPE_STRING_SYNTAX   'E'

Definition at line 1314 of file c.h.

◆ FirstCommandId

#define FirstCommandId   ((CommandId) 0)

Definition at line 811 of file c.h.

◆ FLEXIBLE_ARRAY_MEMBER

#define FLEXIBLE_ARRAY_MEMBER   /* empty */

Definition at line 617 of file c.h.

◆ FLOAT4_FITS_IN_INT16

#define FLOAT4_FITS_IN_INT16 (   num)     ((num) >= (float4) PG_INT16_MIN && (num) < -((float4) PG_INT16_MIN))

Definition at line 1228 of file c.h.

◆ FLOAT4_FITS_IN_INT32

#define FLOAT4_FITS_IN_INT32 (   num)     ((num) >= (float4) PG_INT32_MIN && (num) < -((float4) PG_INT32_MIN))

Definition at line 1230 of file c.h.

◆ FLOAT4_FITS_IN_INT64

#define FLOAT4_FITS_IN_INT64 (   num)     ((num) >= (float4) PG_INT64_MIN && (num) < -((float4) PG_INT64_MIN))

Definition at line 1232 of file c.h.

◆ FLOAT8_FITS_IN_INT16

#define FLOAT8_FITS_IN_INT16 (   num)     ((num) >= (float8) PG_INT16_MIN && (num) < -((float8) PG_INT16_MIN))

Definition at line 1234 of file c.h.

◆ FLOAT8_FITS_IN_INT32

#define FLOAT8_FITS_IN_INT32 (   num)     ((num) >= (float8) PG_INT32_MIN && (num) < -((float8) PG_INT32_MIN))

Definition at line 1236 of file c.h.

◆ FLOAT8_FITS_IN_INT64

#define FLOAT8_FITS_IN_INT64 (   num)     ((num) >= (float8) PG_INT64_MIN && (num) < -((float8) PG_INT64_MIN))

Definition at line 1238 of file c.h.

◆ FLOAT8PASSBYVAL

#define FLOAT8PASSBYVAL   true

Definition at line 779 of file c.h.

◆ gettext

#define gettext (   x)    (x)

Definition at line 1327 of file c.h.

◆ gettext_noop

#define gettext_noop (   x)    (x)

Definition at line 1344 of file c.h.

◆ HAVE_INT64_TIMESTAMP

#define HAVE_INT64_TIMESTAMP

Definition at line 742 of file c.h.

◆ HIGHBIT

#define HIGHBIT   (0x80)

Definition at line 1302 of file c.h.

◆ INT64_FORMAT

#define INT64_FORMAT   "%" PRId64

Definition at line 693 of file c.h.

◆ INT64ALIGN

#define INT64ALIGN (   LEN)    TYPEALIGN(ALIGNOF_INT64_T, (LEN))

Definition at line 953 of file c.h.

◆ INT64ALIGN_DOWN

#define INT64ALIGN_DOWN (   LEN)    TYPEALIGN_DOWN(ALIGNOF_INT64_T, (LEN))

Definition at line 965 of file c.h.

◆ INT64CONST

#define INT64CONST (   x)    INT64_C(x)

Definition at line 689 of file c.h.

◆ INTALIGN

#define INTALIGN (   LEN)    TYPEALIGN(ALIGNOF_INT, (LEN))

Definition at line 952 of file c.h.

◆ INTALIGN_DOWN

#define INTALIGN_DOWN (   LEN)    TYPEALIGN_DOWN(ALIGNOF_INT, (LEN))

Definition at line 964 of file c.h.

◆ InvalidCommandId

#define InvalidCommandId   (~(CommandId)0)

Definition at line 812 of file c.h.

◆ InvalidOid8

#define InvalidOid8   ((Oid8) 0)

Definition at line 817 of file c.h.

◆ InvalidSubTransactionId

#define InvalidSubTransactionId   ((SubTransactionId) 0)

Definition at line 801 of file c.h.

◆ INVERT_COMPARE_RESULT

#define INVERT_COMPARE_RESULT (   var)     ((var) = ((var) < 0) ? 1 : -(var))

Definition at line 1252 of file c.h.

◆ IS_HIGHBIT_SET

#define IS_HIGHBIT_SET (   ch)    ((unsigned char)(ch) & HIGHBIT)

Definition at line 1303 of file c.h.

◆ lengthof

#define lengthof (   array)    (sizeof (array) / sizeof ((array)[0]))

Definition at line 932 of file c.h.

◆ likely

#define likely (   x)    ((x) != 0)

Definition at line 496 of file c.h.

◆ Max

#define Max (   x,
  y 
)    ((x) > (y) ? (x) : (y))

Definition at line 1144 of file c.h.

◆ MAXALIGN

#define MAXALIGN (   LEN)    TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))

Definition at line 955 of file c.h.

◆ MAXALIGN64

#define MAXALIGN64 (   LEN)    TYPEALIGN64(MAXIMUM_ALIGNOF, (LEN))

Definition at line 980 of file c.h.

◆ MAXALIGN_DOWN

#define MAXALIGN_DOWN (   LEN)    TYPEALIGN_DOWN(MAXIMUM_ALIGNOF, (LEN))

Definition at line 967 of file c.h.

◆ MemSet

#define MemSet (   start,
  val,
  len 
)
Value:
do \
{ \
/* must be void* because we don't know if it is size_t aligned yet */ \
void *_vstart = (void *) (start); \
int _val = (val); \
Size _len = (len); \
(_len & SIZE_T_ALIGN_MASK) == 0 && \
_val == 0 && \
/* \
* If MEMSET_LOOP_LIMIT == 0, optimizer should find \
* the whole "if" false at compile time. \
*/ \
{ \
size_t *_start = (size_t *) _vstart; \
size_t *_stop = (size_t *) ((char *) _start + _len); \
*_start++ = 0; \
} \
} while (0)
#define SIZE_T_ALIGN_MASK
Definition c.h:1154
size_t Size
Definition c.h:748
return str start
long val
Definition informix.c:689
const void size_t len

Definition at line 1166 of file c.h.

1168 { \
1169 /* must be void* because we don't know if it is size_t aligned yet */ \
1170 void *_vstart = (void *) (start); \
1171 int _val = (val); \
1172 Size _len = (len); \
1173\
1174 if ((((uintptr_t) _vstart) & SIZE_T_ALIGN_MASK) == 0 && \
1175 (_len & SIZE_T_ALIGN_MASK) == 0 && \
1176 _val == 0 && \
1177 _len <= MEMSET_LOOP_LIMIT && \
1178 /* \
1179 * If MEMSET_LOOP_LIMIT == 0, optimizer should find \
1180 * the whole "if" false at compile time. \
1181 */ \
1182 MEMSET_LOOP_LIMIT != 0) \
1183 { \
1184 size_t *_start = (size_t *) _vstart; \
1185 size_t *_stop = (size_t *) ((char *) _start + _len); \
1186 while (_start < _stop) \
1187 *_start++ = 0; \
1188 } \

◆ MemSetAligned

#define MemSetAligned (   start,
  val,
  len 
)
Value:
do \
{ \
size_t *_start = (size_t *) (start); \
int _val = (val); \
Size _len = (len); \
if ((_len & SIZE_T_ALIGN_MASK) == 0 && \
_val == 0 && \
{ \
size_t *_stop = (size_t *) ((char *) _start + _len); \
*_start++ = 0; \
} \
} while (0)

Definition at line 1196 of file c.h.

1201 { \
1202 size_t *_start = (size_t *) (start); \
1203 int _val = (val); \
1204 Size _len = (len); \
1205\
1206 if ((_len & SIZE_T_ALIGN_MASK) == 0 && \
1207 _val == 0 && \
1208 _len <= MEMSET_LOOP_LIMIT && \
1209 MEMSET_LOOP_LIMIT != 0) \
1210 { \
1211 size_t *_stop = (size_t *) ((char *) _start + _len); \
1212 while (_start < _stop) \
1213 *_start++ = 0; \
1214 } \

◆ Min

#define Min (   x,
  y 
)    ((x) < (y) ? (x) : (y))

Definition at line 1150 of file c.h.

◆ NameStr

#define NameStr (   name)    ((name).data)

Definition at line 894 of file c.h.

◆ ngettext

#define ngettext (   s,
  p,
 
)    ((n) == 1 ? (s) : (p))

Definition at line 1329 of file c.h.

◆ OffsetToPointer

#define OffsetToPointer (   base,
  offset 
)     ((void *)((char *) base + offset))

Definition at line 914 of file c.h.

◆ OID8_FORMAT

#define OID8_FORMAT   "%" PRIu64

Definition at line 695 of file c.h.

◆ OID8_MAX

#define OID8_MAX   UINT64_MAX

Definition at line 818 of file c.h.

◆ Oid8IsValid

#define Oid8IsValid (   objectId)    ((bool) ((objectId) != InvalidOid8))

Definition at line 919 of file c.h.

◆ OidIsValid

#define OidIsValid (   objectId)    ((bool) ((objectId) != InvalidOid))

Definition at line 917 of file c.h.

◆ pg_assume

#define pg_assume (   expr)    ((void) 0)

Definition at line 482 of file c.h.

◆ pg_attribute_always_inline

#define pg_attribute_always_inline   inline

Definition at line 364 of file c.h.

◆ pg_attribute_cold

#define pg_attribute_cold

Definition at line 405 of file c.h.

◆ pg_attribute_format_arg

#define pg_attribute_format_arg (   a)

Definition at line 326 of file c.h.

◆ pg_attribute_hot

#define pg_attribute_hot

Definition at line 411 of file c.h.

◆ pg_attribute_no_sanitize_address

#define pg_attribute_no_sanitize_address ( )

Definition at line 262 of file c.h.

◆ pg_attribute_no_sanitize_alignment

#define pg_attribute_no_sanitize_alignment ( )

Definition at line 274 of file c.h.

◆ pg_attribute_nonnull

#define pg_attribute_nonnull (   ...)

Definition at line 285 of file c.h.

◆ pg_attribute_printf

#define pg_attribute_printf (   f,
  a 
)

Definition at line 327 of file c.h.

◆ pg_attribute_target

#define pg_attribute_target (   ...)

Definition at line 297 of file c.h.

◆ pg_attribute_unused

#define pg_attribute_unused ( )

Definition at line 208 of file c.h.

◆ PG_BINARY

#define PG_BINARY   0

Definition at line 1445 of file c.h.

◆ PG_BINARY_A

#define PG_BINARY_A   "a"

Definition at line 1446 of file c.h.

◆ PG_BINARY_R

#define PG_BINARY_R   "r"

Definition at line 1447 of file c.h.

◆ PG_BINARY_W

#define PG_BINARY_W   "w"

Definition at line 1448 of file c.h.

◆ pg_fallthrough

#define pg_fallthrough

Definition at line 220 of file c.h.

◆ PG_INT16_MAX

#define PG_INT16_MAX   INT16_MAX

Definition at line 729 of file c.h.

◆ PG_INT16_MIN

#define PG_INT16_MIN   INT16_MIN

Definition at line 728 of file c.h.

◆ PG_INT32_MAX

#define PG_INT32_MAX   INT32_MAX

Definition at line 732 of file c.h.

◆ PG_INT32_MIN

#define PG_INT32_MIN   INT32_MIN

Definition at line 731 of file c.h.

◆ PG_INT64_MAX

#define PG_INT64_MAX   INT64_MAX

Definition at line 735 of file c.h.

◆ PG_INT64_MIN

#define PG_INT64_MIN   INT64_MIN

Definition at line 734 of file c.h.

◆ PG_INT8_MAX

#define PG_INT8_MAX   INT8_MAX

Definition at line 726 of file c.h.

◆ PG_INT8_MIN

#define PG_INT8_MIN   INT8_MIN

Definition at line 725 of file c.h.

◆ pg_nodiscard

#define pg_nodiscard

Definition at line 232 of file c.h.

◆ pg_noinline

#define pg_noinline

Definition at line 380 of file c.h.

◆ pg_noreturn

#define pg_noreturn   _Noreturn

Definition at line 249 of file c.h.

◆ PG_PRINTF_ATTRIBUTE

#define PG_PRINTF_ATTRIBUTE   PG_C_PRINTF_ATTRIBUTE

Definition at line 316 of file c.h.

◆ PG_TEXTDOMAIN

#define PG_TEXTDOMAIN (   domain)    (domain "-" PG_MAJORVERSION)

Definition at line 1362 of file c.h.

◆ PG_UINT16_MAX

#define PG_UINT16_MAX   UINT16_MAX

Definition at line 730 of file c.h.

◆ PG_UINT32_MAX

#define PG_UINT32_MAX   UINT32_MAX

Definition at line 733 of file c.h.

◆ PG_UINT64_MAX

#define PG_UINT64_MAX   UINT64_MAX

Definition at line 736 of file c.h.

◆ PG_UINT8_MAX

#define PG_UINT8_MAX   UINT8_MAX

Definition at line 727 of file c.h.

◆ pg_unreachable

#define pg_unreachable ( )    abort()

Definition at line 426 of file c.h.

◆ PG_USED_FOR_ASSERTS_ONLY

#define PG_USED_FOR_ASSERTS_ONLY   pg_attribute_unused()

Definition at line 308 of file c.h.

◆ PGDLLEXPORT

#define PGDLLEXPORT

Definition at line 1507 of file c.h.

◆ PGDLLIMPORT

#define PGDLLIMPORT

Definition at line 1492 of file c.h.

◆ PointerIsAligned

#define PointerIsAligned (   pointer,
  type 
)     (((uintptr_t)(pointer) % (sizeof (type))) == 0)

Definition at line 911 of file c.h.

◆ RegProcedureIsValid

#define RegProcedureIsValid (   p)    OidIsValid(p)

Definition at line 921 of file c.h.

◆ SHORTALIGN

#define SHORTALIGN (   LEN)    TYPEALIGN(ALIGNOF_SHORT, (LEN))

Definition at line 951 of file c.h.

◆ SHORTALIGN_DOWN

#define SHORTALIGN_DOWN (   LEN)    TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN))

Definition at line 963 of file c.h.

◆ SIGNAL_ARGS

Definition at line 1533 of file c.h.

◆ SIZE_T_ALIGN_MASK

#define SIZE_T_ALIGN_MASK   (sizeof(size_t) - 1)

Definition at line 1154 of file c.h.

◆ SQL_STR_DOUBLE

#define SQL_STR_DOUBLE (   ch,
  escape_backslash 
)     ((ch) == '\'' || ((ch) == '\\' && (escape_backslash)))

Definition at line 1311 of file c.h.

◆ StaticAssertDecl

#define StaticAssertDecl (   condition,
  errmessage 
)     static_assert(condition, errmessage)

Definition at line 1067 of file c.h.

◆ StaticAssertExpr

#define StaticAssertExpr (   condition,
  errmessage 
)     ((void) sizeof(struct {static_assert(condition, errmessage); char a;}))

Definition at line 1092 of file c.h.

1093 {static_assert(condition, errmessage); char a;}))
int a
Definition isn.c:73

◆ StaticAssertStmt

#define StaticAssertStmt (   condition,
  errmessage 
)     do { static_assert(condition, errmessage); } while(0)

Definition at line 1074 of file c.h.

1075 { static_assert(condition, errmessage); } while(0)

◆ StaticAssertVariableIsOfType

#define StaticAssertVariableIsOfType (   varname,
  typename 
)
Value:
StaticAssertDecl(sizeof(varname) == sizeof(typename), \
CppAsString(varname) " does not have type " CppAsString(typename))
#define CppAsString(identifier)
Definition c.h:564
#define StaticAssertDecl(condition, errmessage)
Definition c.h:1067

Definition at line 1127 of file c.h.

◆ StaticAssertVariableIsOfTypeMacro

#define StaticAssertVariableIsOfTypeMacro (   varname,
  typename 
)
Value:
(StaticAssertExpr(sizeof(varname) == sizeof(typename), \
CppAsString(varname) " does not have type " CppAsString(typename)))
#define StaticAssertExpr(condition, errmessage)
Definition c.h:1092

Definition at line 1130 of file c.h.

◆ STATUS_EOF

#define STATUS_EOF   (-2)

Definition at line 1319 of file c.h.

◆ STATUS_ERROR

#define STATUS_ERROR   (-1)

Definition at line 1318 of file c.h.

◆ STATUS_OK

#define STATUS_OK   (0)

Definition at line 1317 of file c.h.

◆ TopSubTransactionId

#define TopSubTransactionId   ((SubTransactionId) 1)

Definition at line 802 of file c.h.

◆ TYPEALIGN

#define TYPEALIGN (   ALIGNVAL,
  LEN 
)     (((uintptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((uintptr_t) ((ALIGNVAL) - 1)))

Definition at line 948 of file c.h.

◆ TYPEALIGN64

#define TYPEALIGN64 (   ALIGNVAL,
  LEN 
)     (((uint64) (LEN) + ((ALIGNVAL) - 1)) & ~((uint64) ((ALIGNVAL) - 1)))

Definition at line 976 of file c.h.

◆ TYPEALIGN_DOWN

#define TYPEALIGN_DOWN (   ALIGNVAL,
  LEN 
)     (((uintptr_t) (LEN)) & ~((uintptr_t) ((ALIGNVAL) - 1)))

Definition at line 960 of file c.h.

◆ UINT64_FORMAT

#define UINT64_FORMAT   "%" PRIu64

Definition at line 694 of file c.h.

◆ UINT64CONST

#define UINT64CONST (   x)    UINT64_C(x)

Definition at line 690 of file c.h.

◆ unconstify

#define unconstify (   underlying_type,
  expr 
)
Value:
(underlying_type) (expr))
#define StaticAssertVariableIsOfTypeMacro(varname, typename)
Definition c.h:1130

Definition at line 1384 of file c.h.

◆ unlikely

#define unlikely (   x)    ((x) != 0)

Definition at line 497 of file c.h.

◆ unvolatize

#define unvolatize (   underlying_type,
  expr 
)
Value:

Definition at line 1387 of file c.h.

◆ VA_ARGS_NARGS

#define VA_ARGS_NARGS (   ...)
Value:
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)
#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,...)
Definition c.h:592

Definition at line 582 of file c.h.

◆ VA_ARGS_NARGS_

#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)

Definition at line 592 of file c.h.

◆ VARHDRSZ

#define VARHDRSZ   ((int32) sizeof(int32))

Definition at line 840 of file c.h.

Typedef Documentation

◆ BpChar

Definition at line 849 of file c.h.

◆ bytea

Definition at line 847 of file c.h.

◆ char16_t

Definition at line 1574 of file c.h.

◆ char32_t

Definition at line 1575 of file c.h.

◆ CommandId

Definition at line 809 of file c.h.

◆ float4

Definition at line 772 of file c.h.

◆ float8

Definition at line 773 of file c.h.

◆ Index

Definition at line 757 of file c.h.

◆ int16

Definition at line 678 of file c.h.

◆ int32

Definition at line 679 of file c.h.

◆ int64

Definition at line 680 of file c.h.

◆ int8

Definition at line 677 of file c.h.

◆ LocalTransactionId

Definition at line 797 of file c.h.

◆ MultiXactId

Definition at line 805 of file c.h.

◆ MultiXactOffset

Definition at line 807 of file c.h.

◆ Name

Definition at line 892 of file c.h.

◆ NameData

◆ Offset

Definition at line 767 of file c.h.

◆ Oid8

Definition at line 815 of file c.h.

◆ pg_funcptr_t

typedef void(* pg_funcptr_t) (void)

Definition at line 607 of file c.h.

◆ pg_signal_info

◆ PGAlignedBlock

◆ PGAlignedXLogBlock

◆ PGIOAlignedBlock

◆ Pointer

Definition at line 674 of file c.h.

◆ regproc

Definition at line 792 of file c.h.

◆ RegProcedure

Definition at line 793 of file c.h.

◆ Size

Definition at line 748 of file c.h.

◆ SubTransactionId

Definition at line 799 of file c.h.

◆ text

Definition at line 848 of file c.h.

◆ TransactionId

Definition at line 795 of file c.h.

◆ uint16

Definition at line 682 of file c.h.

◆ uint32

Definition at line 683 of file c.h.

◆ uint64

Definition at line 684 of file c.h.

◆ uint8

Definition at line 681 of file c.h.

◆ VarChar

Definition at line 850 of file c.h.

◆ varlena

Function Documentation

◆ ExceptionalCondition()

pg_noreturn void ExceptionalCondition ( const char conditionName,
const char fileName,
int  lineNumber 
)
extern

Definition at line 30 of file assert.c.

33{
34 /* Report the failure on stderr (or local equivalent) */
35 if (!conditionName || !fileName)
36 write_stderr("TRAP: ExceptionalCondition: bad arguments in PID %d\n",
37 (int) getpid());
38 else
39 write_stderr("TRAP: failed Assert(\"%s\"), File: \"%s\", Line: %d, PID: %d\n",
40 conditionName, fileName, lineNumber, (int) getpid());
41
42 /* Usually this shouldn't be needed, but make sure the msg went out */
44
45 /* If we have support for it, dump a simple backtrace */
46#ifdef HAVE_BACKTRACE_SYMBOLS
47 {
48 void *buf[100];
49 int nframes;
50
51 nframes = backtrace(buf, lengthof(buf));
53 }
54#endif
55
56 /*
57 * If configured to do so, sleep indefinitely to allow user to attach a
58 * debugger. It would be nice to use pg_usleep() here, but that can sleep
59 * at most 2G usec or ~33 minutes, which seems too short.
60 */
61#ifdef SLEEP_ON_ASSERT
62 sleep(1000000);
63#endif
64
65 abort();
66}
#define write_stderr(str)
Definition parallel.c:186
#define lengthof(array)
Definition c.h:932
static char buf[DEFAULT_XLOG_SEG_SIZE]

References buf, fb(), lengthof, and write_stderr.

Referenced by pg_re_throw().

◆ fdatasync()

int fdatasync ( int  fd)
extern

Definition at line 23 of file win32fdatasync.c.

24{
26 NTSTATUS status;
27 HANDLE handle;
28
29 handle = (HANDLE) _get_osfhandle(fd);
30 if (handle == INVALID_HANDLE_VALUE)
31 {
32 errno = EBADF;
33 return -1;
34 }
35
36 if (initialize_ntdll() < 0)
37 return -1;
38
39 memset(&iosb, 0, sizeof(iosb));
40 status = pg_NtFlushBuffersFileEx(handle,
42 NULL,
43 0,
44 &iosb);
45
46 if (NT_SUCCESS(status))
47 return 0;
48
50 return -1;
51}
void _dosmaperr(unsigned long)
Definition win32error.c:177
PGDLLIMPORT NtFlushBuffersFileEx_t pg_NtFlushBuffersFileEx
Definition win32ntdll.c:22
int initialize_ntdll(void)
Definition win32ntdll.c:39
#define FLUSH_FLAGS_FILE_DATA_SYNC_ONLY
Definition win32ntdll.h:21
PGDLLIMPORT RtlNtStatusToDosError_t pg_RtlNtStatusToDosError
Definition win32ntdll.c:21

References _dosmaperr(), fb(), fd(), FLUSH_FLAGS_FILE_DATA_SYNC_ONLY, initialize_ntdll(), pg_NtFlushBuffersFileEx, and pg_RtlNtStatusToDosError.

Referenced by pg_fdatasync(), and test_sync().