1 /*-------------------------------------------------------------------------
2  *
3  * c.h
4  *	  Fundamental C definitions.  This is included by every .c file in
5  *	  PostgreSQL (via either postgres.h or postgres_fe.h, as appropriate).
6  *
7  *	  Note that the definitions here are not intended to be exposed to clients
8  *	  of the frontend interface libraries --- so we don't worry much about
9  *	  polluting the namespace with lots of stuff...
10  *
11  *
12  * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
13  * Portions Copyright (c) 1994, Regents of the University of California
14  *
15  * src/include/c.h
16  *
17  *-------------------------------------------------------------------------
18  */
19 /*
20  *----------------------------------------------------------------
21  *	 TABLE OF CONTENTS
22  *
23  *		When adding stuff to this file, please try to put stuff
24  *		into the relevant section, or add new sections as appropriate.
25  *
26  *	  section	description
27  *	  -------	------------------------------------------------
28  *		0)		pg_config.h and standard system headers
29  *		1)		compiler characteristics
30  *		2)		bool, true, false
31  *		3)		standard system types
32  *		4)		IsValid macros for system types
33  *		5)		offsetof, lengthof, alignment
34  *		6)		assertions
35  *		7)		widely useful macros
36  *		8)		random stuff
37  *		9)		system-specific hacks
38  *
39  * NOTE: since this file is included by both frontend and backend modules,
40  * it's usually wrong to put an "extern" declaration here, unless it's
41  * ifdef'd so that it's seen in only one case or the other.
42  * typedefs and macros are the kind of thing that might go here.
43  *
44  *----------------------------------------------------------------
45  */
46 #ifndef C_H
47 #define C_H
48 
49 #include "postgres_ext.h"
50 
51 /* Must undef pg_config_ext.h symbols before including pg_config.h */
52 #undef PG_INT64_TYPE
53 
54 #include "pg_config.h"
55 #include "pg_config_manual.h"	/* must be after pg_config.h */
56 #include "pg_config_os.h"		/* must be before any system header files */
57 
58 /* System header files that should be available everywhere in Postgres */
59 #include <stdio.h>
60 #include <stdlib.h>
61 #include <string.h>
62 #include <stddef.h>
63 #include <stdarg.h>
64 #ifdef HAVE_STRINGS_H
65 #include <strings.h>
66 #endif
67 #ifdef HAVE_STDINT_H
68 #include <stdint.h>
69 #endif
70 #include <sys/types.h>
71 #include <errno.h>
72 #if defined(WIN32) || defined(__CYGWIN__)
73 #include <fcntl.h>				/* ensure O_BINARY is available */
74 #endif
75 #include <locale.h>
76 #ifdef ENABLE_NLS
77 #include <libintl.h>
78 #endif
79 
80 
81 /* ----------------------------------------------------------------
82  *				Section 1: compiler characteristics
83  *
84  * type prefixes (const, signed, volatile, inline) are handled in pg_config.h.
85  * ----------------------------------------------------------------
86  */
87 
88 /*
89  * Disable "inline" if PG_FORCE_DISABLE_INLINE is defined.
90  * This is used to work around compiler bugs and might also be useful for
91  * investigatory purposes.
92  */
93 #ifdef PG_FORCE_DISABLE_INLINE
94 #undef inline
95 #define inline
96 #endif
97 
98 /*
99  * Attribute macros
100  *
101  * GCC: https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
102  * GCC: https://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html
103  * Sunpro: https://docs.oracle.com/cd/E18659_01/html/821-1384/gjzke.html
104  * XLC: http://www-01.ibm.com/support/knowledgecenter/SSGH2K_11.1.0/com.ibm.xlc111.aix.doc/language_ref/function_attributes.html
105  * XLC: http://www-01.ibm.com/support/knowledgecenter/SSGH2K_11.1.0/com.ibm.xlc111.aix.doc/language_ref/type_attrib.html
106  */
107 
108 /* only GCC supports the unused attribute */
109 #ifdef __GNUC__
110 #define pg_attribute_unused() __attribute__((unused))
111 #else
112 #define pg_attribute_unused()
113 #endif
114 
115 /*
116  * Place this macro before functions that should be allowed to make misaligned
117  * accesses.  Think twice before using it on non-x86-specific code!
118  * Testing can be done with "-fsanitize=alignment -fsanitize-trap=alignment"
119  * on clang, or "-fsanitize=alignment -fno-sanitize-recover=alignment" on gcc.
120  */
121 #if __clang_major__ >= 7 || __GNUC__ >= 8
122 #define pg_attribute_no_sanitize_alignment() __attribute__((no_sanitize("alignment")))
123 #else
124 #define pg_attribute_no_sanitize_alignment()
125 #endif
126 
127 /*
128  * Append PG_USED_FOR_ASSERTS_ONLY to definitions of variables that are only
129  * used in assert-enabled builds, to avoid compiler warnings about unused
130  * variables in assert-disabled builds.
131  */
132 #ifdef USE_ASSERT_CHECKING
133 #define PG_USED_FOR_ASSERTS_ONLY
134 #else
135 #define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused()
136 #endif
137 
138 /* GCC and XLC support format attributes */
139 #if defined(__GNUC__) || defined(__IBMC__)
140 #define pg_attribute_format_arg(a) __attribute__((format_arg(a)))
141 #define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))
142 #else
143 #define pg_attribute_format_arg(a)
144 #define pg_attribute_printf(f,a)
145 #endif
146 
147 /* GCC, Sunpro and XLC support aligned, packed and noreturn */
148 #if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
149 #define pg_attribute_aligned(a) __attribute__((aligned(a)))
150 #define pg_attribute_noreturn() __attribute__((noreturn))
151 #define pg_attribute_packed() __attribute__((packed))
152 #define HAVE_PG_ATTRIBUTE_NORETURN 1
153 #else
154 /*
155  * NB: aligned and packed are not given default definitions because they
156  * affect code functionality; they *must* be implemented by the compiler
157  * if they are to be used.
158  */
159 #define pg_attribute_noreturn()
160 #endif
161 
162 /*
163  * Use "pg_attribute_always_inline" in place of "inline" for functions that
164  * we wish to force inlining of, even when the compiler's heuristics would
165  * choose not to.  But, if possible, don't force inlining in unoptimized
166  * debug builds.
167  */
168 #if (defined(__GNUC__) && __GNUC__ > 3 && defined(__OPTIMIZE__)) || defined(__SUNPRO_C) || defined(__IBMC__)
169 /* GCC > 3, Sunpro and XLC support always_inline via __attribute__ */
170 #define pg_attribute_always_inline __attribute__((always_inline)) inline
171 #elif defined(_MSC_VER)
172 /* MSVC has a special keyword for this */
173 #define pg_attribute_always_inline __forceinline
174 #else
175 /* Otherwise, the best we can do is to say "inline" */
176 #define pg_attribute_always_inline inline
177 #endif
178 
179 /*
180  * Forcing a function not to be inlined can be useful if it's the slow path of
181  * a performance-critical function, or should be visible in profiles to allow
182  * for proper cost attribution.  Note that unlike the pg_attribute_XXX macros
183  * above, this should be placed before the function's return type and name.
184  */
185 /* GCC, Sunpro and XLC support noinline via __attribute__ */
186 #if (defined(__GNUC__) && __GNUC__ > 2) || defined(__SUNPRO_C) || defined(__IBMC__)
187 #define pg_noinline __attribute__((noinline))
188 /* msvc via declspec */
189 #elif defined(_MSC_VER)
190 #define pg_noinline __declspec(noinline)
191 #else
192 #define pg_noinline
193 #endif
194 
195 /*
196  * Mark a point as unreachable in a portable fashion.  This should preferably
197  * be something that the compiler understands, to aid code generation.
198  * In assert-enabled builds, we prefer abort() for debugging reasons.
199  */
200 #if defined(HAVE__BUILTIN_UNREACHABLE) && !defined(USE_ASSERT_CHECKING)
201 #define pg_unreachable() __builtin_unreachable()
202 #elif defined(_MSC_VER) && !defined(USE_ASSERT_CHECKING)
203 #define pg_unreachable() __assume(0)
204 #else
205 #define pg_unreachable() abort()
206 #endif
207 
208 /*
209  * Hints to the compiler about the likelihood of a branch. Both likely() and
210  * unlikely() return the boolean value of the contained expression.
211  *
212  * These should only be used sparingly, in very hot code paths. It's very easy
213  * to mis-estimate likelihoods.
214  */
215 #if __GNUC__ >= 3
216 #define likely(x)	__builtin_expect((x) != 0, 1)
217 #define unlikely(x) __builtin_expect((x) != 0, 0)
218 #else
219 #define likely(x)	((x) != 0)
220 #define unlikely(x) ((x) != 0)
221 #endif
222 
223 /*
224  * CppAsString
225  *		Convert the argument to a string, using the C preprocessor.
226  * CppAsString2
227  *		Convert the argument to a string, after one round of macro expansion.
228  * CppConcat
229  *		Concatenate two arguments together, using the C preprocessor.
230  *
231  * Note: There used to be support here for pre-ANSI C compilers that didn't
232  * support # and ##.  Nowadays, these macros are just for clarity and/or
233  * backward compatibility with existing PostgreSQL code.
234  */
235 #define CppAsString(identifier) #identifier
236 #define CppAsString2(x)			CppAsString(x)
237 #define CppConcat(x, y)			x##y
238 
239 /*
240  * dummyret is used to set return values in macros that use ?: to make
241  * assignments.  gcc wants these to be void, other compilers like char
242  */
243 #ifdef __GNUC__					/* GNU cc */
244 #define dummyret	void
245 #else
246 #define dummyret	char
247 #endif
248 
249 /* Which __func__ symbol do we have, if any? */
250 #ifdef HAVE_FUNCNAME__FUNC
251 #define PG_FUNCNAME_MACRO	__func__
252 #else
253 #ifdef HAVE_FUNCNAME__FUNCTION
254 #define PG_FUNCNAME_MACRO	__FUNCTION__
255 #else
256 #define PG_FUNCNAME_MACRO	NULL
257 #endif
258 #endif
259 
260 
261 /* ----------------------------------------------------------------
262  *				Section 2:	bool, true, false
263  * ----------------------------------------------------------------
264  */
265 
266 /*
267  * bool
268  *		Boolean value, either true or false.
269  *
270  * Use stdbool.h if available and its bool has size 1.  That's useful for
271  * better compiler and debugger output and for compatibility with third-party
272  * libraries.  But PostgreSQL currently cannot deal with bool of other sizes;
273  * there are static assertions around the code to prevent that.
274  *
275  * For C++ compilers, we assume the compiler has a compatible built-in
276  * definition of bool.
277  */
278 
279 #ifndef __cplusplus
280 
281 #if defined(HAVE_STDBOOL_H) && SIZEOF_BOOL == 1
282 #include <stdbool.h>
283 #define USE_STDBOOL 1
284 #else
285 
286 #ifndef bool
287 typedef char bool;
288 #endif
289 
290 #ifndef true
291 #define true	((bool) 1)
292 #endif
293 
294 #ifndef false
295 #define false	((bool) 0)
296 #endif
297 
298 #endif
299 #endif							/* not C++ */
300 
301 
302 /* ----------------------------------------------------------------
303  *				Section 3:	standard system types
304  * ----------------------------------------------------------------
305  */
306 
307 /*
308  * Pointer
309  *		Variable holding address of any memory resident object.
310  *
311  *		XXX Pointer arithmetic is done with this, so it can't be void *
312  *		under "true" ANSI compilers.
313  */
314 typedef char *Pointer;
315 
316 /*
317  * intN
318  *		Signed integer, EXACTLY N BITS IN SIZE,
319  *		used for numerical computations and the
320  *		frontend/backend protocol.
321  */
322 #ifndef HAVE_INT8
323 typedef signed char int8;		/* == 8 bits */
324 typedef signed short int16;		/* == 16 bits */
325 typedef signed int int32;		/* == 32 bits */
326 #endif							/* not HAVE_INT8 */
327 
328 /*
329  * uintN
330  *		Unsigned integer, EXACTLY N BITS IN SIZE,
331  *		used for numerical computations and the
332  *		frontend/backend protocol.
333  */
334 #ifndef HAVE_UINT8
335 typedef unsigned char uint8;	/* == 8 bits */
336 typedef unsigned short uint16;	/* == 16 bits */
337 typedef unsigned int uint32;	/* == 32 bits */
338 #endif							/* not HAVE_UINT8 */
339 
340 /*
341  * bitsN
342  *		Unit of bitwise operation, AT LEAST N BITS IN SIZE.
343  */
344 typedef uint8 bits8;			/* >= 8 bits */
345 typedef uint16 bits16;			/* >= 16 bits */
346 typedef uint32 bits32;			/* >= 32 bits */
347 
348 /*
349  * 64-bit integers
350  */
351 #ifdef HAVE_LONG_INT_64
352 /* Plain "long int" fits, use it */
353 
354 #ifndef HAVE_INT64
355 typedef long int int64;
356 #endif
357 #ifndef HAVE_UINT64
358 typedef unsigned long int uint64;
359 #endif
360 #define INT64CONST(x)  (x##L)
361 #define UINT64CONST(x) (x##UL)
362 #elif defined(HAVE_LONG_LONG_INT_64)
363 /* We have working support for "long long int", use that */
364 
365 #ifndef HAVE_INT64
366 typedef long long int int64;
367 #endif
368 #ifndef HAVE_UINT64
369 typedef unsigned long long int uint64;
370 #endif
371 #define INT64CONST(x)  (x##LL)
372 #define UINT64CONST(x) (x##ULL)
373 #else
374 /* neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 */
375 #error must have a working 64-bit integer datatype
376 #endif
377 
378 /* snprintf format strings to use for 64-bit integers */
379 #define INT64_FORMAT "%" INT64_MODIFIER "d"
380 #define UINT64_FORMAT "%" INT64_MODIFIER "u"
381 
382 /*
383  * 128-bit signed and unsigned integers
384  *		There currently is only limited support for such types.
385  *		E.g. 128bit literals and snprintf are not supported; but math is.
386  *		Also, because we exclude such types when choosing MAXIMUM_ALIGNOF,
387  *		it must be possible to coerce the compiler to allocate them on no
388  *		more than MAXALIGN boundaries.
389  */
390 #if defined(PG_INT128_TYPE)
391 #if defined(pg_attribute_aligned) || ALIGNOF_PG_INT128_TYPE <= MAXIMUM_ALIGNOF
392 #define HAVE_INT128 1
393 
394 typedef PG_INT128_TYPE int128
395 #if defined(pg_attribute_aligned)
396 pg_attribute_aligned(MAXIMUM_ALIGNOF)
397 #endif
398 ;
399 
400 typedef unsigned PG_INT128_TYPE uint128
401 #if defined(pg_attribute_aligned)
402 pg_attribute_aligned(MAXIMUM_ALIGNOF)
403 #endif
404 ;
405 
406 #endif
407 #endif
408 
409 /*
410  * stdint.h limits aren't guaranteed to be present and aren't guaranteed to
411  * have compatible types with our fixed width types. So just define our own.
412  */
413 #define PG_INT8_MIN		(-0x7F-1)
414 #define PG_INT8_MAX		(0x7F)
415 #define PG_UINT8_MAX	(0xFF)
416 #define PG_INT16_MIN	(-0x7FFF-1)
417 #define PG_INT16_MAX	(0x7FFF)
418 #define PG_UINT16_MAX	(0xFFFF)
419 #define PG_INT32_MIN	(-0x7FFFFFFF-1)
420 #define PG_INT32_MAX	(0x7FFFFFFF)
421 #define PG_UINT32_MAX	(0xFFFFFFFFU)
422 #define PG_INT64_MIN	(-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1)
423 #define PG_INT64_MAX	INT64CONST(0x7FFFFFFFFFFFFFFF)
424 #define PG_UINT64_MAX	UINT64CONST(0xFFFFFFFFFFFFFFFF)
425 
426 /* Max value of size_t might also be missing if we don't have stdint.h */
427 #ifndef SIZE_MAX
428 #if SIZEOF_SIZE_T == 8
429 #define SIZE_MAX PG_UINT64_MAX
430 #else
431 #define SIZE_MAX PG_UINT32_MAX
432 #endif
433 #endif
434 
435 /*
436  * We now always use int64 timestamps, but keep this symbol defined for the
437  * benefit of external code that might test it.
438  */
439 #define HAVE_INT64_TIMESTAMP
440 
441 /*
442  * Size
443  *		Size of any memory resident object, as returned by sizeof.
444  */
445 typedef size_t Size;
446 
447 /*
448  * Index
449  *		Index into any memory resident array.
450  *
451  * Note:
452  *		Indices are non negative.
453  */
454 typedef unsigned int Index;
455 
456 /*
457  * Offset
458  *		Offset into any memory resident array.
459  *
460  * Note:
461  *		This differs from an Index in that an Index is always
462  *		non negative, whereas Offset may be negative.
463  */
464 typedef signed int Offset;
465 
466 /*
467  * Common Postgres datatype names (as used in the catalogs)
468  */
469 typedef float float4;
470 typedef double float8;
471 
472 /*
473  * Oid, RegProcedure, TransactionId, SubTransactionId, MultiXactId,
474  * CommandId
475  */
476 
477 /* typedef Oid is in postgres_ext.h */
478 
479 /*
480  * regproc is the type name used in the include/catalog headers, but
481  * RegProcedure is the preferred name in C code.
482  */
483 typedef Oid regproc;
484 typedef regproc RegProcedure;
485 
486 typedef uint32 TransactionId;
487 
488 typedef uint32 LocalTransactionId;
489 
490 typedef uint32 SubTransactionId;
491 
492 #define InvalidSubTransactionId		((SubTransactionId) 0)
493 #define TopSubTransactionId			((SubTransactionId) 1)
494 
495 /* MultiXactId must be equivalent to TransactionId, to fit in t_xmax */
496 typedef TransactionId MultiXactId;
497 
498 typedef uint32 MultiXactOffset;
499 
500 typedef uint32 CommandId;
501 
502 #define FirstCommandId	((CommandId) 0)
503 #define InvalidCommandId	(~(CommandId)0)
504 
505 /*
506  * Array indexing support
507  */
508 #define MAXDIM 6
509 typedef struct
510 {
511 	int			indx[MAXDIM];
512 }			IntArray;
513 
514 /* ----------------
515  *		Variable-length datatypes all share the 'struct varlena' header.
516  *
517  * NOTE: for TOASTable types, this is an oversimplification, since the value
518  * may be compressed or moved out-of-line.  However datatype-specific routines
519  * are mostly content to deal with de-TOASTed values only, and of course
520  * client-side routines should never see a TOASTed value.  But even in a
521  * de-TOASTed value, beware of touching vl_len_ directly, as its
522  * representation is no longer convenient.  It's recommended that code always
523  * use macros VARDATA_ANY, VARSIZE_ANY, VARSIZE_ANY_EXHDR, VARDATA, VARSIZE,
524  * and SET_VARSIZE instead of relying on direct mentions of the struct fields.
525  * See postgres.h for details of the TOASTed form.
526  * ----------------
527  */
528 struct varlena
529 {
530 	char		vl_len_[4];		/* Do not touch this field directly! */
531 	char		vl_dat[FLEXIBLE_ARRAY_MEMBER];	/* Data content is here */
532 };
533 
534 #define VARHDRSZ		((int32) sizeof(int32))
535 
536 /*
537  * These widely-used datatypes are just a varlena header and the data bytes.
538  * There is no terminating null or anything like that --- the data length is
539  * always VARSIZE_ANY_EXHDR(ptr).
540  */
541 typedef struct varlena bytea;
542 typedef struct varlena text;
543 typedef struct varlena BpChar;	/* blank-padded char, ie SQL char(n) */
544 typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */
545 
546 /*
547  * Specialized array types.  These are physically laid out just the same
548  * as regular arrays (so that the regular array subscripting code works
549  * with them).  They exist as distinct types mostly for historical reasons:
550  * they have nonstandard I/O behavior which we don't want to change for fear
551  * of breaking applications that look at the system catalogs.  There is also
552  * an implementation issue for oidvector: it's part of the primary key for
553  * pg_proc, and we can't use the normal btree array support routines for that
554  * without circularity.
555  */
556 typedef struct
557 {
558 	int32		vl_len_;		/* these fields must match ArrayType! */
559 	int			ndim;			/* always 1 for int2vector */
560 	int32		dataoffset;		/* always 0 for int2vector */
561 	Oid			elemtype;
562 	int			dim1;
563 	int			lbound1;
564 	int16		values[FLEXIBLE_ARRAY_MEMBER];
565 } int2vector;
566 
567 typedef struct
568 {
569 	int32		vl_len_;		/* these fields must match ArrayType! */
570 	int			ndim;			/* always 1 for oidvector */
571 	int32		dataoffset;		/* always 0 for oidvector */
572 	Oid			elemtype;
573 	int			dim1;
574 	int			lbound1;
575 	Oid			values[FLEXIBLE_ARRAY_MEMBER];
576 } oidvector;
577 
578 /*
579  * Representation of a Name: effectively just a C string, but null-padded to
580  * exactly NAMEDATALEN bytes.  The use of a struct is historical.
581  */
582 typedef struct nameData
583 {
584 	char		data[NAMEDATALEN];
585 } NameData;
586 typedef NameData *Name;
587 
588 #define NameStr(name)	((name).data)
589 
590 
591 /* ----------------------------------------------------------------
592  *				Section 4:	IsValid macros for system types
593  * ----------------------------------------------------------------
594  */
595 /*
596  * BoolIsValid
597  *		True iff bool is valid.
598  */
599 #define BoolIsValid(boolean)	((boolean) == false || (boolean) == true)
600 
601 /*
602  * PointerIsValid
603  *		True iff pointer is valid.
604  */
605 #define PointerIsValid(pointer) ((const void*)(pointer) != NULL)
606 
607 /*
608  * PointerIsAligned
609  *		True iff pointer is properly aligned to point to the given type.
610  */
611 #define PointerIsAligned(pointer, type) \
612 		(((uintptr_t)(pointer) % (sizeof (type))) == 0)
613 
614 #define OffsetToPointer(base, offset) \
615 		((void *)((char *) base + offset))
616 
617 #define OidIsValid(objectId)  ((bool) ((objectId) != InvalidOid))
618 
619 #define RegProcedureIsValid(p)	OidIsValid(p)
620 
621 
622 /* ----------------------------------------------------------------
623  *				Section 5:	offsetof, lengthof, alignment
624  * ----------------------------------------------------------------
625  */
626 /*
627  * offsetof
628  *		Offset of a structure/union field within that structure/union.
629  *
630  *		XXX This is supposed to be part of stddef.h, but isn't on
631  *		some systems (like SunOS 4).
632  */
633 #ifndef offsetof
634 #define offsetof(type, field)	((long) &((type *)0)->field)
635 #endif							/* offsetof */
636 
637 /*
638  * lengthof
639  *		Number of elements in an array.
640  */
641 #define lengthof(array) (sizeof (array) / sizeof ((array)[0]))
642 
643 /* ----------------
644  * Alignment macros: align a length or address appropriately for a given type.
645  * The fooALIGN() macros round up to a multiple of the required alignment,
646  * while the fooALIGN_DOWN() macros round down.  The latter are more useful
647  * for problems like "how many X-sized structures will fit in a page?".
648  *
649  * NOTE: TYPEALIGN[_DOWN] will not work if ALIGNVAL is not a power of 2.
650  * That case seems extremely unlikely to be needed in practice, however.
651  *
652  * NOTE: MAXIMUM_ALIGNOF, and hence MAXALIGN(), intentionally exclude any
653  * larger-than-8-byte types the compiler might have.
654  * ----------------
655  */
656 
657 #define TYPEALIGN(ALIGNVAL,LEN)  \
658 	(((uintptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((uintptr_t) ((ALIGNVAL) - 1)))
659 
660 #define SHORTALIGN(LEN)			TYPEALIGN(ALIGNOF_SHORT, (LEN))
661 #define INTALIGN(LEN)			TYPEALIGN(ALIGNOF_INT, (LEN))
662 #define LONGALIGN(LEN)			TYPEALIGN(ALIGNOF_LONG, (LEN))
663 #define DOUBLEALIGN(LEN)		TYPEALIGN(ALIGNOF_DOUBLE, (LEN))
664 #define MAXALIGN(LEN)			TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))
665 /* MAXALIGN covers only built-in types, not buffers */
666 #define BUFFERALIGN(LEN)		TYPEALIGN(ALIGNOF_BUFFER, (LEN))
667 #define CACHELINEALIGN(LEN)		TYPEALIGN(PG_CACHE_LINE_SIZE, (LEN))
668 
669 #define TYPEALIGN_DOWN(ALIGNVAL,LEN)  \
670 	(((uintptr_t) (LEN)) & ~((uintptr_t) ((ALIGNVAL) - 1)))
671 
672 #define SHORTALIGN_DOWN(LEN)	TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN))
673 #define INTALIGN_DOWN(LEN)		TYPEALIGN_DOWN(ALIGNOF_INT, (LEN))
674 #define LONGALIGN_DOWN(LEN)		TYPEALIGN_DOWN(ALIGNOF_LONG, (LEN))
675 #define DOUBLEALIGN_DOWN(LEN)	TYPEALIGN_DOWN(ALIGNOF_DOUBLE, (LEN))
676 #define MAXALIGN_DOWN(LEN)		TYPEALIGN_DOWN(MAXIMUM_ALIGNOF, (LEN))
677 #define BUFFERALIGN_DOWN(LEN)	TYPEALIGN_DOWN(ALIGNOF_BUFFER, (LEN))
678 
679 /*
680  * The above macros will not work with types wider than uintptr_t, like with
681  * uint64 on 32-bit platforms.  That's not problem for the usual use where a
682  * pointer or a length is aligned, but for the odd case that you need to
683  * align something (potentially) wider, use TYPEALIGN64.
684  */
685 #define TYPEALIGN64(ALIGNVAL,LEN)  \
686 	(((uint64) (LEN) + ((ALIGNVAL) - 1)) & ~((uint64) ((ALIGNVAL) - 1)))
687 
688 /* we don't currently need wider versions of the other ALIGN macros */
689 #define MAXALIGN64(LEN)			TYPEALIGN64(MAXIMUM_ALIGNOF, (LEN))
690 
691 
692 /* ----------------------------------------------------------------
693  *				Section 6:	assertions
694  * ----------------------------------------------------------------
695  */
696 
697 /*
698  * USE_ASSERT_CHECKING, if defined, turns on all the assertions.
699  * - plai  9/5/90
700  *
701  * It should _NOT_ be defined in releases or in benchmark copies
702  */
703 
704 /*
705  * Assert() can be used in both frontend and backend code. In frontend code it
706  * just calls the standard assert, if it's available. If use of assertions is
707  * not configured, it does nothing.
708  */
709 #ifndef USE_ASSERT_CHECKING
710 
711 #define Assert(condition)	((void)true)
712 #define AssertMacro(condition)	((void)true)
713 #define AssertArg(condition)	((void)true)
714 #define AssertState(condition)	((void)true)
715 #define AssertPointerAlignment(ptr, bndr)	((void)true)
716 #define Trap(condition, errorType)	((void)true)
717 #define TrapMacro(condition, errorType) (true)
718 
719 #elif defined(FRONTEND)
720 
721 #include <assert.h>
722 #define Assert(p) assert(p)
723 #define AssertMacro(p)	((void) assert(p))
724 #define AssertArg(condition) assert(condition)
725 #define AssertState(condition) assert(condition)
726 #define AssertPointerAlignment(ptr, bndr)	((void)true)
727 
728 #else							/* USE_ASSERT_CHECKING && !FRONTEND */
729 
730 /*
731  * Trap
732  *		Generates an exception if the given condition is true.
733  */
734 #define Trap(condition, errorType) \
735 	do { \
736 		if (condition) \
737 			ExceptionalCondition(CppAsString(condition), (errorType), \
738 								 __FILE__, __LINE__); \
739 	} while (0)
740 
741 /*
742  *	TrapMacro is the same as Trap but it's intended for use in macros:
743  *
744  *		#define foo(x) (AssertMacro(x != 0), bar(x))
745  *
746  *	Isn't CPP fun?
747  */
748 #define TrapMacro(condition, errorType) \
749 	((bool) (! (condition) || \
750 			 (ExceptionalCondition(CppAsString(condition), (errorType), \
751 								   __FILE__, __LINE__), 0)))
752 
753 #define Assert(condition) \
754 		Trap(!(condition), "FailedAssertion")
755 
756 #define AssertMacro(condition) \
757 		((void) TrapMacro(!(condition), "FailedAssertion"))
758 
759 #define AssertArg(condition) \
760 		Trap(!(condition), "BadArgument")
761 
762 #define AssertState(condition) \
763 		Trap(!(condition), "BadState")
764 
765 /*
766  * Check that `ptr' is `bndr' aligned.
767  */
768 #define AssertPointerAlignment(ptr, bndr) \
769 	Trap(TYPEALIGN(bndr, (uintptr_t)(ptr)) != (uintptr_t)(ptr), \
770 		 "UnalignedPointer")
771 
772 #endif							/* USE_ASSERT_CHECKING && !FRONTEND */
773 
774 /*
775  * ExceptionalCondition is compiled into the backend whether or not
776  * USE_ASSERT_CHECKING is defined, so as to support use of extensions
777  * that are built with that #define with a backend that isn't.  Hence,
778  * we should declare it as long as !FRONTEND.
779  */
780 #ifndef FRONTEND
781 extern void ExceptionalCondition(const char *conditionName,
782 					 const char *errorType,
783 					 const char *fileName, int lineNumber) pg_attribute_noreturn();
784 #endif
785 
786 /*
787  * Macros to support compile-time assertion checks.
788  *
789  * If the "condition" (a compile-time-constant expression) evaluates to false,
790  * throw a compile error using the "errmessage" (a string literal).
791  *
792  * gcc 4.6 and up supports _Static_assert(), but there are bizarre syntactic
793  * placement restrictions.  These macros make it safe to use as a statement
794  * or in an expression, respectively.
795  *
796  * Otherwise we fall back on a kluge that assumes the compiler will complain
797  * about a negative width for a struct bit-field.  This will not include a
798  * helpful error message, but it beats not getting an error at all.
799  */
800 #ifndef __cplusplus
801 #ifdef HAVE__STATIC_ASSERT
802 #define StaticAssertStmt(condition, errmessage) \
803 	do { _Static_assert(condition, errmessage); } while(0)
804 #define StaticAssertExpr(condition, errmessage) \
805 	((void) ({ StaticAssertStmt(condition, errmessage); true; }))
806 #else							/* !HAVE__STATIC_ASSERT */
807 #define StaticAssertStmt(condition, errmessage) \
808 	((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; }))
809 #define StaticAssertExpr(condition, errmessage) \
810 	StaticAssertStmt(condition, errmessage)
811 #endif							/* HAVE__STATIC_ASSERT */
812 #else							/* C++ */
813 #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410
814 #define StaticAssertStmt(condition, errmessage) \
815 	static_assert(condition, errmessage)
816 #define StaticAssertExpr(condition, errmessage) \
817 	({ static_assert(condition, errmessage); })
818 #else
819 #define StaticAssertStmt(condition, errmessage) \
820 	do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0)
821 #define StaticAssertExpr(condition, errmessage) \
822 	((void) ({ StaticAssertStmt(condition, errmessage); }))
823 #endif
824 #endif							/* C++ */
825 
826 
827 /*
828  * Compile-time checks that a variable (or expression) has the specified type.
829  *
830  * AssertVariableIsOfType() can be used as a statement.
831  * AssertVariableIsOfTypeMacro() is intended for use in macros, eg
832  *		#define foo(x) (AssertVariableIsOfTypeMacro(x, int), bar(x))
833  *
834  * If we don't have __builtin_types_compatible_p, we can still assert that
835  * the types have the same size.  This is far from ideal (especially on 32-bit
836  * platforms) but it provides at least some coverage.
837  */
838 #ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P
839 #define AssertVariableIsOfType(varname, typename) \
840 	StaticAssertStmt(__builtin_types_compatible_p(__typeof__(varname), typename), \
841 	CppAsString(varname) " does not have type " CppAsString(typename))
842 #define AssertVariableIsOfTypeMacro(varname, typename) \
843 	(StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
844 	 CppAsString(varname) " does not have type " CppAsString(typename)))
845 #else							/* !HAVE__BUILTIN_TYPES_COMPATIBLE_P */
846 #define AssertVariableIsOfType(varname, typename) \
847 	StaticAssertStmt(sizeof(varname) == sizeof(typename), \
848 	CppAsString(varname) " does not have type " CppAsString(typename))
849 #define AssertVariableIsOfTypeMacro(varname, typename) \
850 	(StaticAssertExpr(sizeof(varname) == sizeof(typename), \
851 	 CppAsString(varname) " does not have type " CppAsString(typename)))
852 #endif							/* HAVE__BUILTIN_TYPES_COMPATIBLE_P */
853 
854 
855 /* ----------------------------------------------------------------
856  *				Section 7:	widely useful macros
857  * ----------------------------------------------------------------
858  */
859 /*
860  * Max
861  *		Return the maximum of two numbers.
862  */
863 #define Max(x, y)		((x) > (y) ? (x) : (y))
864 
865 /*
866  * Min
867  *		Return the minimum of two numbers.
868  */
869 #define Min(x, y)		((x) < (y) ? (x) : (y))
870 
871 /*
872  * Abs
873  *		Return the absolute value of the argument.
874  */
875 #define Abs(x)			((x) >= 0 ? (x) : -(x))
876 
877 /*
878  * StrNCpy
879  *	Like standard library function strncpy(), except that result string
880  *	is guaranteed to be null-terminated --- that is, at most N-1 bytes
881  *	of the source string will be kept.
882  *	Also, the macro returns no result (too hard to do that without
883  *	evaluating the arguments multiple times, which seems worse).
884  *
885  *	BTW: when you need to copy a non-null-terminated string (like a text
886  *	datum) and add a null, do not do it with StrNCpy(..., len+1).  That
887  *	might seem to work, but it fetches one byte more than there is in the
888  *	text object.  One fine day you'll have a SIGSEGV because there isn't
889  *	another byte before the end of memory.  Don't laugh, we've had real
890  *	live bug reports from real live users over exactly this mistake.
891  *	Do it honestly with "memcpy(dst,src,len); dst[len] = '\0';", instead.
892  */
893 #define StrNCpy(dst,src,len) \
894 	do \
895 	{ \
896 		char * _dst = (dst); \
897 		Size _len = (len); \
898 \
899 		if (_len > 0) \
900 		{ \
901 			strncpy(_dst, (src), _len); \
902 			_dst[_len-1] = '\0'; \
903 		} \
904 	} while (0)
905 
906 
907 /* Get a bit mask of the bits set in non-long aligned addresses */
908 #define LONG_ALIGN_MASK (sizeof(long) - 1)
909 
910 /*
911  * MemSet
912  *	Exactly the same as standard library function memset(), but considerably
913  *	faster for zeroing small word-aligned structures (such as parsetree nodes).
914  *	This has to be a macro because the main point is to avoid function-call
915  *	overhead.   However, we have also found that the loop is faster than
916  *	native libc memset() on some platforms, even those with assembler
917  *	memset() functions.  More research needs to be done, perhaps with
918  *	MEMSET_LOOP_LIMIT tests in configure.
919  */
920 #define MemSet(start, val, len) \
921 	do \
922 	{ \
923 		/* must be void* because we don't know if it is integer aligned yet */ \
924 		void   *_vstart = (void *) (start); \
925 		int		_val = (val); \
926 		Size	_len = (len); \
927 \
928 		if ((((uintptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \
929 			(_len & LONG_ALIGN_MASK) == 0 && \
930 			_val == 0 && \
931 			_len <= MEMSET_LOOP_LIMIT && \
932 			/* \
933 			 *	If MEMSET_LOOP_LIMIT == 0, optimizer should find \
934 			 *	the whole "if" false at compile time. \
935 			 */ \
936 			MEMSET_LOOP_LIMIT != 0) \
937 		{ \
938 			long *_start = (long *) _vstart; \
939 			long *_stop = (long *) ((char *) _start + _len); \
940 			while (_start < _stop) \
941 				*_start++ = 0; \
942 		} \
943 		else \
944 			memset(_vstart, _val, _len); \
945 	} while (0)
946 
947 /*
948  * MemSetAligned is the same as MemSet except it omits the test to see if
949  * "start" is word-aligned.  This is okay to use if the caller knows a-priori
950  * that the pointer is suitably aligned (typically, because he just got it
951  * from palloc(), which always delivers a max-aligned pointer).
952  */
953 #define MemSetAligned(start, val, len) \
954 	do \
955 	{ \
956 		long   *_start = (long *) (start); \
957 		int		_val = (val); \
958 		Size	_len = (len); \
959 \
960 		if ((_len & LONG_ALIGN_MASK) == 0 && \
961 			_val == 0 && \
962 			_len <= MEMSET_LOOP_LIMIT && \
963 			MEMSET_LOOP_LIMIT != 0) \
964 		{ \
965 			long *_stop = (long *) ((char *) _start + _len); \
966 			while (_start < _stop) \
967 				*_start++ = 0; \
968 		} \
969 		else \
970 			memset(_start, _val, _len); \
971 	} while (0)
972 
973 
974 /*
975  * MemSetTest/MemSetLoop are a variant version that allow all the tests in
976  * MemSet to be done at compile time in cases where "val" and "len" are
977  * constants *and* we know the "start" pointer must be word-aligned.
978  * If MemSetTest succeeds, then it is okay to use MemSetLoop, otherwise use
979  * MemSetAligned.  Beware of multiple evaluations of the arguments when using
980  * this approach.
981  */
982 #define MemSetTest(val, len) \
983 	( ((len) & LONG_ALIGN_MASK) == 0 && \
984 	(len) <= MEMSET_LOOP_LIMIT && \
985 	MEMSET_LOOP_LIMIT != 0 && \
986 	(val) == 0 )
987 
988 #define MemSetLoop(start, val, len) \
989 	do \
990 	{ \
991 		long * _start = (long *) (start); \
992 		long * _stop = (long *) ((char *) _start + (Size) (len)); \
993 	\
994 		while (_start < _stop) \
995 			*_start++ = 0; \
996 	} while (0)
997 
998 /*
999  * Macros for range-checking float values before converting to integer.
1000  * We must be careful here that the boundary values are expressed exactly
1001  * in the float domain.  PG_INTnn_MIN is an exact power of 2, so it will
1002  * be represented exactly; but PG_INTnn_MAX isn't, and might get rounded
1003  * off, so avoid using that.
1004  * The input must be rounded to an integer beforehand, typically with rint(),
1005  * else we might draw the wrong conclusion about close-to-the-limit values.
1006  * These macros will do the right thing for Inf, but not necessarily for NaN,
1007  * so check isnan(num) first if that's a possibility.
1008  */
1009 #define FLOAT4_FITS_IN_INT16(num) \
1010 	((num) >= (float4) PG_INT16_MIN && (num) < -((float4) PG_INT16_MIN))
1011 #define FLOAT4_FITS_IN_INT32(num) \
1012 	((num) >= (float4) PG_INT32_MIN && (num) < -((float4) PG_INT32_MIN))
1013 #define FLOAT4_FITS_IN_INT64(num) \
1014 	((num) >= (float4) PG_INT64_MIN && (num) < -((float4) PG_INT64_MIN))
1015 #define FLOAT8_FITS_IN_INT16(num) \
1016 	((num) >= (float8) PG_INT16_MIN && (num) < -((float8) PG_INT16_MIN))
1017 #define FLOAT8_FITS_IN_INT32(num) \
1018 	((num) >= (float8) PG_INT32_MIN && (num) < -((float8) PG_INT32_MIN))
1019 #define FLOAT8_FITS_IN_INT64(num) \
1020 	((num) >= (float8) PG_INT64_MIN && (num) < -((float8) PG_INT64_MIN))
1021 
1022 
1023 /* ----------------------------------------------------------------
1024  *				Section 8:	random stuff
1025  * ----------------------------------------------------------------
1026  */
1027 
1028 /*
1029  * Invert the sign of a qsort-style comparison result, ie, exchange negative
1030  * and positive integer values, being careful not to get the wrong answer
1031  * for INT_MIN.  The argument should be an integral variable.
1032  */
1033 #define INVERT_COMPARE_RESULT(var) \
1034 	((var) = ((var) < 0) ? 1 : -(var))
1035 
1036 /*
1037  * Use this, not "char buf[BLCKSZ]", to declare a field or local variable
1038  * holding a page buffer, if that page might be accessed as a page and not
1039  * just a string of bytes.  Otherwise the variable might be under-aligned,
1040  * causing problems on alignment-picky hardware.  (In some places, we use
1041  * this to declare buffers even though we only pass them to read() and
1042  * write(), because copying to/from aligned buffers is usually faster than
1043  * using unaligned buffers.)  We include both "double" and "int64" in the
1044  * union to ensure that the compiler knows the value must be MAXALIGN'ed
1045  * (cf. configure's computation of MAXIMUM_ALIGNOF).
1046  */
1047 typedef union PGAlignedBlock
1048 {
1049 	char		data[BLCKSZ];
1050 	double		force_align_d;
1051 	int64		force_align_i64;
1052 } PGAlignedBlock;
1053 
1054 /* Same, but for an XLOG_BLCKSZ-sized buffer */
1055 typedef union PGAlignedXLogBlock
1056 {
1057 	char		data[XLOG_BLCKSZ];
1058 	double		force_align_d;
1059 	int64		force_align_i64;
1060 } PGAlignedXLogBlock;
1061 
1062 /* msb for char */
1063 #define HIGHBIT					(0x80)
1064 #define IS_HIGHBIT_SET(ch)		((unsigned char)(ch) & HIGHBIT)
1065 
1066 /*
1067  * Support macros for escaping strings.  escape_backslash should be true
1068  * if generating a non-standard-conforming string.  Prefixing a string
1069  * with ESCAPE_STRING_SYNTAX guarantees it is non-standard-conforming.
1070  * Beware of multiple evaluation of the "ch" argument!
1071  */
1072 #define SQL_STR_DOUBLE(ch, escape_backslash)	\
1073 	((ch) == '\'' || ((ch) == '\\' && (escape_backslash)))
1074 
1075 #define ESCAPE_STRING_SYNTAX	'E'
1076 
1077 
1078 #define STATUS_OK				(0)
1079 #define STATUS_ERROR			(-1)
1080 #define STATUS_EOF				(-2)
1081 #define STATUS_FOUND			(1)
1082 #define STATUS_WAITING			(2)
1083 
1084 /*
1085  * gettext support
1086  */
1087 
1088 #ifndef ENABLE_NLS
1089 /* stuff we'd otherwise get from <libintl.h> */
1090 #define gettext(x) (x)
1091 #define dgettext(d,x) (x)
1092 #define ngettext(s,p,n) ((n) == 1 ? (s) : (p))
1093 #define dngettext(d,s,p,n) ((n) == 1 ? (s) : (p))
1094 #endif
1095 
1096 #define _(x) gettext(x)
1097 
1098 /*
1099  *	Use this to mark string constants as needing translation at some later
1100  *	time, rather than immediately.  This is useful for cases where you need
1101  *	access to the original string and translated string, and for cases where
1102  *	immediate translation is not possible, like when initializing global
1103  *	variables.
1104  *		http://www.gnu.org/software/autoconf/manual/gettext/Special-cases.html
1105  */
1106 #define gettext_noop(x) (x)
1107 
1108 /*
1109  * To better support parallel installations of major PostgreSQL
1110  * versions as well as parallel installations of major library soname
1111  * versions, we mangle the gettext domain name by appending those
1112  * version numbers.  The coding rule ought to be that wherever the
1113  * domain name is mentioned as a literal, it must be wrapped into
1114  * PG_TEXTDOMAIN().  The macros below do not work on non-literals; but
1115  * that is somewhat intentional because it avoids having to worry
1116  * about multiple states of premangling and postmangling as the values
1117  * are being passed around.
1118  *
1119  * Make sure this matches the installation rules in nls-global.mk.
1120  */
1121 #ifdef SO_MAJOR_VERSION
1122 #define PG_TEXTDOMAIN(domain) (domain CppAsString2(SO_MAJOR_VERSION) "-" PG_MAJORVERSION)
1123 #else
1124 #define PG_TEXTDOMAIN(domain) (domain "-" PG_MAJORVERSION)
1125 #endif
1126 
1127 
1128 /* ----------------------------------------------------------------
1129  *				Section 9: system-specific hacks
1130  *
1131  *		This should be limited to things that absolutely have to be
1132  *		included in every source file.  The port-specific header file
1133  *		is usually a better place for this sort of thing.
1134  * ----------------------------------------------------------------
1135  */
1136 
1137 /*
1138  *	NOTE:  this is also used for opening text files.
1139  *	WIN32 treats Control-Z as EOF in files opened in text mode.
1140  *	Therefore, we open files in binary mode on Win32 so we can read
1141  *	literal control-Z.  The other affect is that we see CRLF, but
1142  *	that is OK because we can already handle those cleanly.
1143  */
1144 #if defined(WIN32) || defined(__CYGWIN__)
1145 #define PG_BINARY	O_BINARY
1146 #define PG_BINARY_A "ab"
1147 #define PG_BINARY_R "rb"
1148 #define PG_BINARY_W "wb"
1149 #else
1150 #define PG_BINARY	0
1151 #define PG_BINARY_A "a"
1152 #define PG_BINARY_R "r"
1153 #define PG_BINARY_W "w"
1154 #endif
1155 
1156 /*
1157  * Provide prototypes for routines not present in a particular machine's
1158  * standard C library.
1159  */
1160 
1161 #if !HAVE_DECL_SNPRINTF
1162 extern int	snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3, 4);
1163 #endif
1164 
1165 #if !HAVE_DECL_VSNPRINTF
1166 extern int	vsnprintf(char *str, size_t count, const char *fmt, va_list args);
1167 #endif
1168 
1169 #if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
1170 extern int	fdatasync(int fildes);
1171 #endif
1172 
1173 #ifdef HAVE_LONG_LONG_INT
1174 /* Older platforms may provide strto[u]ll functionality under other names */
1175 #if !defined(HAVE_STRTOLL) && defined(HAVE___STRTOLL)
1176 #define strtoll __strtoll
1177 #define HAVE_STRTOLL 1
1178 #endif
1179 
1180 #if !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
1181 #define strtoll strtoq
1182 #define HAVE_STRTOLL 1
1183 #endif
1184 
1185 #if !defined(HAVE_STRTOULL) && defined(HAVE___STRTOULL)
1186 #define strtoull __strtoull
1187 #define HAVE_STRTOULL 1
1188 #endif
1189 
1190 #if !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
1191 #define strtoull strtouq
1192 #define HAVE_STRTOULL 1
1193 #endif
1194 
1195 #if defined(HAVE_STRTOLL) && !HAVE_DECL_STRTOLL
1196 extern long long strtoll(const char *str, char **endptr, int base);
1197 #endif
1198 
1199 #if defined(HAVE_STRTOULL) && !HAVE_DECL_STRTOULL
1200 extern unsigned long long strtoull(const char *str, char **endptr, int base);
1201 #endif
1202 #endif							/* HAVE_LONG_LONG_INT */
1203 
1204 #if !defined(HAVE_MEMMOVE) && !defined(memmove)
1205 #define memmove(d, s, c)		bcopy(s, d, c)
1206 #endif
1207 
1208 /* no special DLL markers on most ports */
1209 #ifndef PGDLLIMPORT
1210 #define PGDLLIMPORT
1211 #endif
1212 #ifndef PGDLLEXPORT
1213 #define PGDLLEXPORT
1214 #endif
1215 
1216 /*
1217  * The following is used as the arg list for signal handlers.  Any ports
1218  * that take something other than an int argument should override this in
1219  * their pg_config_os.h file.  Note that variable names are required
1220  * because it is used in both the prototypes as well as the definitions.
1221  * Note also the long name.  We expect that this won't collide with
1222  * other names causing compiler warnings.
1223  */
1224 
1225 #ifndef SIGNAL_ARGS
1226 #define SIGNAL_ARGS  int postgres_signal_arg
1227 #endif
1228 
1229 /*
1230  * When there is no sigsetjmp, its functionality is provided by plain
1231  * setjmp. Incidentally, nothing provides setjmp's functionality in
1232  * that case.  We now support the case only on Windows.
1233  */
1234 #ifdef WIN32
1235 #define sigjmp_buf jmp_buf
1236 #define sigsetjmp(x,y) setjmp(x)
1237 #define siglongjmp longjmp
1238 #endif
1239 
1240 /* EXEC_BACKEND defines */
1241 #ifdef EXEC_BACKEND
1242 #define NON_EXEC_STATIC
1243 #else
1244 #define NON_EXEC_STATIC static
1245 #endif
1246 
1247 /* /port compatibility functions */
1248 #include "port.h"
1249 
1250 #endif							/* C_H */
1251