]> granicus.if.org Git - postgresql/blob - src/include/c.h
29657169f94beb04c30e4582c5d5cc3a4c6ce550
[postgresql] / src / include / c.h
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-2004, PostgreSQL Global Development Group
13  * Portions Copyright (c) 1994, Regents of the University of California
14  *
15  * $PostgreSQL: pgsql/src/include/c.h,v 1.174 2004/09/26 15:13:42 tgl Exp $
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)              hacks to cope with non-ANSI C compilers
30  *              2)              bool, true, false, TRUE, FALSE, NULL
31  *              3)              standard system types
32  *              4)              IsValid macros for system types
33  *              5)              offsetof, lengthof, endof, alignment
34  *              6)              widely useful macros
35  *              7)              random stuff
36  *              8)              system-specific hacks
37  *
38  * NOTE: since this file is included by both frontend and backend modules, it's
39  * almost certainly wrong to put an "extern" declaration here.  typedefs and
40  * macros are the kind of thing that might go here.
41  *
42  *----------------------------------------------------------------
43  */
44 #ifndef C_H
45 #define C_H
46
47 /*
48  * We have to include stdlib.h here because it defines many of these macros
49  * on some platforms, and we only want our definitions used if stdlib.h doesn't
50  * have its own.  The same goes for stddef and stdarg if present.
51  */
52
53 #include "pg_config.h"
54 #include "pg_config_manual.h"   /* must be after pg_config.h */
55 #if !defined(WIN32) && !defined(__CYGWIN__)
56 #include "pg_config_os.h"               /* must be before any system header files */
57 #endif
58 #include "postgres_ext.h"
59
60 #include <stdio.h>
61 #include <stdlib.h>
62 #include <string.h>
63 #include <stddef.h>
64 #include <stdarg.h>
65 #ifdef HAVE_STRINGS_H
66 #include <strings.h>
67 #endif
68 #include <sys/types.h>
69
70 #include <errno.h>
71 #if defined(WIN32) || defined(__CYGWIN__)
72 #include <fcntl.h>                              /* ensure O_BINARY is available */
73 #endif
74 #ifdef HAVE_SUPPORTDEFS_H
75 #include <SupportDefs.h>
76 #endif
77
78 #if defined(WIN32) || defined(__CYGWIN__)
79 #if     !defined(_MSC_VER) && !defined(__BORLANDC__)
80 /* We have to redefine some system functions after they are included above */
81 #include "pg_config_os.h"
82 #else
83 #include <windows.h>    /* We don't have a port file for MSC/BCC */
84 #endif
85 #endif
86
87 /* Must be before gettext() games below */
88 #include <locale.h>
89
90 #ifdef ENABLE_NLS
91 #include <libintl.h>
92 #else
93 #define gettext(x) (x)
94 #endif
95 #define gettext_noop(x) (x)
96
97
98 /* ----------------------------------------------------------------
99  *                              Section 1: hacks to cope with non-ANSI C compilers
100  *
101  * type prefixes (const, signed, volatile, inline) are handled in pg_config.h.
102  * ----------------------------------------------------------------
103  */
104
105 /*
106  * CppAsString
107  *              Convert the argument to a string, using the C preprocessor.
108  * CppConcat
109  *              Concatenate two arguments together, using the C preprocessor.
110  *
111  * Note: the standard Autoconf macro AC_C_STRINGIZE actually only checks
112  * whether #identifier works, but if we have that we likely have ## too.
113  */
114 #if defined(HAVE_STRINGIZE)
115
116 #define CppAsString(identifier) #identifier
117 #define CppConcat(x, y)                 x##y
118
119 #else                                                   /* !HAVE_STRINGIZE */
120
121 #define CppAsString(identifier) "identifier"
122
123 /*
124  * CppIdentity -- On Reiser based cpp's this is used to concatenate
125  *              two tokens.  That is
126  *                              CppIdentity(A)B ==> AB
127  *              We renamed it to _private_CppIdentity because it should not
128  *              be referenced outside this file.  On other cpp's it
129  *              produces  A  B.
130  */
131 #define _priv_CppIdentity(x)x
132 #define CppConcat(x, y)                 _priv_CppIdentity(x)y
133 #endif   /* !HAVE_STRINGIZE */
134
135 /*
136  * dummyret is used to set return values in macros that use ?: to make
137  * assignments.  gcc wants these to be void, other compilers like char
138  */
139 #ifdef __GNUC__                                 /* GNU cc */
140 #define dummyret        void
141 #else
142 #define dummyret        char
143 #endif
144
145 #ifndef __GNUC__
146 #define __attribute__(_arg_)
147 #endif
148
149 /* ----------------------------------------------------------------
150  *                              Section 2:      bool, true, false, TRUE, FALSE, NULL
151  * ----------------------------------------------------------------
152  */
153
154 /*
155  * bool
156  *              Boolean value, either true or false.
157  *
158  * XXX for C++ compilers, we assume the compiler has a compatible
159  * built-in definition of bool.
160  */
161
162 /* BeOS defines bool already, but the compiler chokes on the
163  * #ifndef unless we wrap it in this check.
164  */
165 #ifndef __BEOS__
166
167 #ifndef __cplusplus
168
169 #ifndef bool
170 typedef char bool;
171 #endif
172
173 #ifndef true
174 #define true    ((bool) 1)
175 #endif
176
177 #ifndef false
178 #define false   ((bool) 0)
179 #endif
180 #endif   /* not C++ */
181 #endif   /* __BEOS__ */
182
183 typedef bool *BoolPtr;
184
185 #ifndef TRUE
186 #define TRUE    1
187 #endif
188
189 #ifndef FALSE
190 #define FALSE   0
191 #endif
192
193 /*
194  * NULL
195  *              Null pointer.
196  */
197 #ifndef NULL
198 #define NULL    ((void *) 0)
199 #endif
200
201
202 /* ----------------------------------------------------------------
203  *                              Section 3:      standard system types
204  * ----------------------------------------------------------------
205  */
206
207 /*
208  * Pointer
209  *              Variable holding address of any memory resident object.
210  *
211  *              XXX Pointer arithmetic is done with this, so it can't be void *
212  *              under "true" ANSI compilers.
213  */
214 typedef char *Pointer;
215
216 /*
217  * intN
218  *              Signed integer, EXACTLY N BITS IN SIZE,
219  *              used for numerical computations and the
220  *              frontend/backend protocol.
221  */
222 #ifndef HAVE_INT8
223 typedef signed char int8;               /* == 8 bits */
224 typedef signed short int16;             /* == 16 bits */
225 typedef signed int int32;               /* == 32 bits */
226 #endif   /* not HAVE_INT8 */
227
228 /*
229  * uintN
230  *              Unsigned integer, EXACTLY N BITS IN SIZE,
231  *              used for numerical computations and the
232  *              frontend/backend protocol.
233  */
234 /* Also defined in interfaces/odbc/md5.h */
235 #ifndef HAVE_UINT8
236 typedef unsigned char uint8;    /* == 8 bits */
237 typedef unsigned short uint16;  /* == 16 bits */
238 typedef unsigned int uint32;    /* == 32 bits */
239 #endif   /* not HAVE_UINT8 */
240
241 /*
242  * bitsN
243  *              Unit of bitwise operation, AT LEAST N BITS IN SIZE.
244  */
245 typedef uint8 bits8;                    /* >= 8 bits */
246 typedef uint16 bits16;                  /* >= 16 bits */
247 typedef uint32 bits32;                  /* >= 32 bits */
248
249 /*
250  * floatN
251  *              Floating point number, AT LEAST N BITS IN SIZE,
252  *              used for numerical computations.
253  *
254  *              Since sizeof(floatN) may be > sizeof(char *), always pass
255  *              floatN by reference.
256  *
257  * XXX: these typedefs are now deprecated in favor of float4 and float8.
258  * They will eventually go away.
259  */
260 typedef float float32data;
261 typedef double float64data;
262 typedef float *float32;
263 typedef double *float64;
264
265 /*
266  * 64-bit integers
267  */
268 #ifdef HAVE_LONG_INT_64
269 /* Plain "long int" fits, use it */
270
271 #ifndef HAVE_INT64
272 typedef long int int64;
273 #endif
274 #ifndef HAVE_UINT64
275 typedef unsigned long int uint64;
276 #endif
277
278 #elif defined(HAVE_LONG_LONG_INT_64)
279 /* We have working support for "long long int", use that */
280
281 #ifndef HAVE_INT64
282 typedef long long int int64;
283 #endif
284 #ifndef HAVE_UINT64
285 typedef unsigned long long int uint64;
286 #endif
287
288 #else                                                   /* not HAVE_LONG_INT_64 and not
289                                                                  * HAVE_LONG_LONG_INT_64 */
290
291 /* Won't actually work, but fall back to long int so that code compiles */
292 #ifndef HAVE_INT64
293 typedef long int int64;
294 #endif
295 #ifndef HAVE_UINT64
296 typedef unsigned long int uint64;
297 #endif
298
299 #define INT64_IS_BUSTED
300 #endif   /* not HAVE_LONG_INT_64 and not
301                                                                  * HAVE_LONG_LONG_INT_64 */
302
303 /* Decide if we need to decorate 64-bit constants */
304 #ifdef HAVE_LL_CONSTANTS
305 #define INT64CONST(x)  ((int64) x##LL)
306 #define UINT64CONST(x) ((uint64) x##ULL)
307 #else
308 #define INT64CONST(x)  ((int64) x)
309 #define UINT64CONST(x) ((uint64) x)
310 #endif
311
312
313 /* Select timestamp representation (float8 or int64) */
314 #if defined(USE_INTEGER_DATETIMES) && !defined(INT64_IS_BUSTED)
315 #define HAVE_INT64_TIMESTAMP
316 #endif
317
318 /* sig_atomic_t is required by ANSI C, but may be missing on old platforms */
319 #ifndef HAVE_SIG_ATOMIC_T
320 typedef int sig_atomic_t;
321 #endif
322
323 /*
324  * Size
325  *              Size of any memory resident object, as returned by sizeof.
326  */
327 typedef size_t Size;
328
329 /*
330  * Index
331  *              Index into any memory resident array.
332  *
333  * Note:
334  *              Indices are non negative.
335  */
336 typedef unsigned int Index;
337
338 /*
339  * Offset
340  *              Offset into any memory resident array.
341  *
342  * Note:
343  *              This differs from an Index in that an Index is always
344  *              non negative, whereas Offset may be negative.
345  */
346 typedef signed int Offset;
347
348 /*
349  * Common Postgres datatype names (as used in the catalogs)
350  */
351 typedef int16 int2;
352 typedef int32 int4;
353 typedef float float4;
354 typedef double float8;
355
356 /*
357  * Oid, RegProcedure, TransactionId, SubTransactionId, CommandId, AclId
358  */
359
360 /* typedef Oid is in postgres_ext.h */
361
362 /*
363  * regproc is the type name used in the include/catalog headers, but
364  * RegProcedure is the preferred name in C code.
365  */
366 typedef Oid regproc;
367 typedef regproc RegProcedure;
368
369 typedef uint32 TransactionId;
370
371 typedef uint32 SubTransactionId;
372
373 #define InvalidSubTransactionId         ((SubTransactionId) 0)
374 #define TopSubTransactionId                     ((SubTransactionId) 1)
375
376 typedef uint32 CommandId;
377
378 #define FirstCommandId  ((CommandId) 0)
379
380 typedef int32 AclId;                    /* user and group identifiers */
381
382 /*
383  * Array indexing support
384  */
385 #define MAXDIM 6
386 typedef struct
387 {
388         int                     indx[MAXDIM];
389 } IntArray;
390
391 /* ----------------
392  *              Variable-length datatypes all share the 'struct varlena' header.
393  *
394  * NOTE: for TOASTable types, this is an oversimplification, since the value
395  * may be compressed or moved out-of-line.      However datatype-specific routines
396  * are mostly content to deal with de-TOASTed values only, and of course
397  * client-side routines should never see a TOASTed value.  See postgres.h for
398  * details of the TOASTed form.
399  * ----------------
400  */
401 struct varlena
402 {
403         int32           vl_len;
404         char            vl_dat[1];
405 };
406
407 #define VARHDRSZ                ((int32) sizeof(int32))
408
409 /*
410  * These widely-used datatypes are just a varlena header and the data bytes.
411  * There is no terminating null or anything like that --- the data length is
412  * always VARSIZE(ptr) - VARHDRSZ.
413  */
414 typedef struct varlena bytea;
415 typedef struct varlena text;
416 typedef struct varlena BpChar;  /* blank-padded char, ie SQL char(n) */
417 typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */
418
419 /*
420  * Fixed-length array types (these are not varlena's!)
421  */
422
423 typedef int2 int2vector[INDEX_MAX_KEYS];
424 typedef Oid oidvector[INDEX_MAX_KEYS];
425
426 /*
427  * We want NameData to have length NAMEDATALEN and int alignment,
428  * because that's how the data type 'name' is defined in pg_type.
429  * Use a union to make sure the compiler agrees.  Note that NAMEDATALEN
430  * must be a multiple of sizeof(int), else sizeof(NameData) will probably
431  * not come out equal to NAMEDATALEN.
432  */
433 typedef union nameData
434 {
435         char            data[NAMEDATALEN];
436         int                     alignmentDummy;
437 } NameData;
438 typedef NameData *Name;
439
440 #define NameStr(name)   ((name).data)
441
442
443 /* ----------------------------------------------------------------
444  *                              Section 4:      IsValid macros for system types
445  * ----------------------------------------------------------------
446  */
447 /*
448  * BoolIsValid
449  *              True iff bool is valid.
450  */
451 #define BoolIsValid(boolean)    ((boolean) == false || (boolean) == true)
452
453 /*
454  * PointerIsValid
455  *              True iff pointer is valid.
456  */
457 #define PointerIsValid(pointer) ((void*)(pointer) != NULL)
458
459 /*
460  * PointerIsAligned
461  *              True iff pointer is properly aligned to point to the given type.
462  */
463 #define PointerIsAligned(pointer, type) \
464                 (((long)(pointer) % (sizeof (type))) == 0)
465
466 #define OidIsValid(objectId)  ((bool) ((objectId) != InvalidOid))
467
468 #define AclIdIsValid(aclId)  ((bool) ((aclId) != 0))
469
470 #define RegProcedureIsValid(p)  OidIsValid(p)
471
472
473 /* ----------------------------------------------------------------
474  *                              Section 5:      offsetof, lengthof, endof, alignment
475  * ----------------------------------------------------------------
476  */
477 /*
478  * offsetof
479  *              Offset of a structure/union field within that structure/union.
480  *
481  *              XXX This is supposed to be part of stddef.h, but isn't on
482  *              some systems (like SunOS 4).
483  */
484 #ifndef offsetof
485 #define offsetof(type, field)   ((long) &((type *)0)->field)
486 #endif   /* offsetof */
487
488 /*
489  * lengthof
490  *              Number of elements in an array.
491  */
492 #define lengthof(array) (sizeof (array) / sizeof ((array)[0]))
493
494 /*
495  * endof
496  *              Address of the element one past the last in an array.
497  */
498 #define endof(array)    (&array[lengthof(array)])
499
500 /* ----------------
501  * Alignment macros: align a length or address appropriately for a given type.
502  *
503  * There used to be some incredibly crufty platform-dependent hackery here,
504  * but now we rely on the configure script to get the info for us. Much nicer.
505  *
506  * NOTE: TYPEALIGN will not work if ALIGNVAL is not a power of 2.
507  * That case seems extremely unlikely to occur in practice, however.
508  * ----------------
509  */
510
511 #define TYPEALIGN(ALIGNVAL,LEN)  \
512         (((long) (LEN) + (ALIGNVAL-1)) & ~((long) (ALIGNVAL-1)))
513
514 #define SHORTALIGN(LEN)                 TYPEALIGN(ALIGNOF_SHORT, (LEN))
515 #define INTALIGN(LEN)                   TYPEALIGN(ALIGNOF_INT, (LEN))
516 #define LONGALIGN(LEN)                  TYPEALIGN(ALIGNOF_LONG, (LEN))
517 #define DOUBLEALIGN(LEN)                TYPEALIGN(ALIGNOF_DOUBLE, (LEN))
518 #define MAXALIGN(LEN)                   TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))
519 /* MAXALIGN covers only built-in types, not buffers */
520 #define BUFFERALIGN(LEN)                TYPEALIGN(ALIGNOF_BUFFER, (LEN))
521
522
523 /* ----------------------------------------------------------------
524  *                              Section 6:      widely useful macros
525  * ----------------------------------------------------------------
526  */
527 /*
528  * Max
529  *              Return the maximum of two numbers.
530  */
531 #define Max(x, y)               ((x) > (y) ? (x) : (y))
532
533 /*
534  * Min
535  *              Return the minimum of two numbers.
536  */
537 #define Min(x, y)               ((x) < (y) ? (x) : (y))
538
539 /*
540  * Abs
541  *              Return the absolute value of the argument.
542  */
543 #define Abs(x)                  ((x) >= 0 ? (x) : -(x))
544
545 /*
546  * StrNCpy
547  *      Like standard library function strncpy(), except that result string
548  *      is guaranteed to be null-terminated --- that is, at most N-1 bytes
549  *      of the source string will be kept.
550  *      Also, the macro returns no result (too hard to do that without
551  *      evaluating the arguments multiple times, which seems worse).
552  *
553  *      BTW: when you need to copy a non-null-terminated string (like a text
554  *      datum) and add a null, do not do it with StrNCpy(..., len+1).  That
555  *      might seem to work, but it fetches one byte more than there is in the
556  *      text object.  One fine day you'll have a SIGSEGV because there isn't
557  *      another byte before the end of memory.  Don't laugh, we've had real
558  *      live bug reports from real live users over exactly this mistake.
559  *      Do it honestly with "memcpy(dst,src,len); dst[len] = '\0';", instead.
560  */
561 #define StrNCpy(dst,src,len) \
562         do \
563         { \
564                 char * _dst = (dst); \
565                 Size _len = (len); \
566 \
567                 if (_len > 0) \
568                 { \
569                         strncpy(_dst, (src), _len); \
570                         _dst[_len-1] = '\0'; \
571                 } \
572         } while (0)
573
574
575 /* Get a bit mask of the bits set in non-int32 aligned addresses */
576 #define INT_ALIGN_MASK (sizeof(int32) - 1)
577
578 /*
579  * MemSet
580  *      Exactly the same as standard library function memset(), but considerably
581  *      faster for zeroing small word-aligned structures (such as parsetree nodes).
582  *      This has to be a macro because the main point is to avoid function-call
583  *      overhead.       However, we have also found that the loop is faster than
584  *      native libc memset() on some platforms, even those with assembler
585  *      memset() functions.  More research needs to be done, perhaps with
586  *      platform-specific MEMSET_LOOP_LIMIT values or tests in configure.
587  *
588  *      bjm 2002-10-08
589  */
590 #define MemSet(start, val, len) \
591         do \
592         { \
593                 int32 * _start = (int32 *) (start); \
594                 int             _val = (val); \
595                 Size    _len = (len); \
596 \
597                 if ((((long) _start) & INT_ALIGN_MASK) == 0 && \
598                         (_len & INT_ALIGN_MASK) == 0 && \
599                         _val == 0 && \
600                         _len <= MEMSET_LOOP_LIMIT) \
601                 { \
602                         int32 * _stop = (int32 *) ((char *) _start + _len); \
603                         while (_start < _stop) \
604                                 *_start++ = 0; \
605                 } \
606                 else \
607                         memset((char *) _start, _val, _len); \
608         } while (0)
609
610 #define MEMSET_LOOP_LIMIT  1024
611
612 /*
613  * MemSetAligned is the same as MemSet except it omits the test to see if
614  * "start" is word-aligned.  This is okay to use if the caller knows a-priori
615  * that the pointer is suitably aligned (typically, because he just got it
616  * from palloc(), which always delivers a max-aligned pointer).
617  */
618 #define MemSetAligned(start, val, len) \
619         do \
620         { \
621                 int32 * _start = (int32 *) (start); \
622                 int             _val = (val); \
623                 Size    _len = (len); \
624 \
625                 if ((_len & INT_ALIGN_MASK) == 0 && \
626                         _val == 0 && \
627                         _len <= MEMSET_LOOP_LIMIT) \
628                 { \
629                         int32 * _stop = (int32 *) ((char *) _start + _len); \
630                         while (_start < _stop) \
631                                 *_start++ = 0; \
632                 } \
633                 else \
634                         memset((char *) _start, _val, _len); \
635         } while (0)
636
637
638 /*
639  * MemSetTest/MemSetLoop are a variant version that allow all the tests in
640  * MemSet to be done at compile time in cases where "val" and "len" are
641  * constants *and* we know the "start" pointer must be word-aligned.
642  * If MemSetTest succeeds, then it is okay to use MemSetLoop, otherwise use
643  * MemSetAligned.  Beware of multiple evaluations of the arguments when using
644  * this approach.
645  */
646 #define MemSetTest(val, len) \
647         ( ((len) & INT_ALIGN_MASK) == 0 && \
648         (len) <= MEMSET_LOOP_LIMIT && \
649         (val) == 0 )
650
651 #define MemSetLoop(start, val, len) \
652         do \
653         { \
654                 int32 * _start = (int32 *) (start); \
655                 int32 * _stop = (int32 *) ((char *) _start + (Size) (len)); \
656         \
657                 while (_start < _stop) \
658                         *_start++ = 0; \
659         } while (0)
660
661
662 /* ----------------------------------------------------------------
663  *                              Section 7:      random stuff
664  * ----------------------------------------------------------------
665  */
666
667 /* msb for char */
668 #define CSIGNBIT (0x80)
669
670 #define STATUS_OK                               (0)
671 #define STATUS_ERROR                    (-1)
672 #define STATUS_EOF                              (-2)
673 #define STATUS_FOUND                    (1)
674
675
676 /* ----------------------------------------------------------------
677  *                              Section 8: system-specific hacks
678  *
679  *              This should be limited to things that absolutely have to be
680  *              included in every source file.  The port-specific header file
681  *              is usually a better place for this sort of thing.
682  * ----------------------------------------------------------------
683  */
684
685 /*
686  *      NOTE:  this is also used for opening text files.
687  *      WIN32 treats Control-Z as EOF in files opened in text mode.
688  *      Therefore, we open files in binary mode on Win32 so we can read
689  *      literal control-Z.      The other affect is that we see CRLF, but
690  *      that is OK because we can already handle those cleanly.
691  */
692 #if defined(WIN32) || defined(__CYGWIN__)
693 #define PG_BINARY       O_BINARY
694 #define PG_BINARY_R "rb"
695 #define PG_BINARY_W "wb"
696 #else
697 #define PG_BINARY       0
698 #define PG_BINARY_R "r"
699 #define PG_BINARY_W "w"
700 #endif
701
702 #if defined(sun) && defined(__sparc__) && !defined(__SVR4)
703 #include <unistd.h>
704 #endif
705
706 /* These are for things that are one way on Unix and another on NT */
707 #define NULL_DEV                "/dev/null"
708
709 /*
710  * Provide prototypes for routines not present in a particular machine's
711  * standard C library.
712  */
713
714 #if !HAVE_DECL_SNPRINTF
715 extern int
716 snprintf(char *str, size_t count, const char *fmt,...)
717 /* This extension allows gcc to check the format string */
718 __attribute__((format(printf, 3, 4)));
719 #endif
720
721 #if !HAVE_DECL_VSNPRINTF
722 extern int      vsnprintf(char *str, size_t count, const char *fmt, va_list args);
723 #endif
724
725 #if !defined(HAVE_MEMMOVE) && !defined(memmove)
726 #define memmove(d, s, c)                bcopy(s, d, c)
727 #endif
728
729 #ifndef DLLIMPORT
730 #define DLLIMPORT                               /* no special DLL markers on most ports */
731 #endif
732
733 /*
734  * The following is used as the arg list for signal handlers.  Any ports
735  * that take something other than an int argument should override this in
736  * their pg_config_os.h file.  Note that variable names are required
737  * because it is used in both the prototypes as well as the definitions.
738  * Note also the long name.  We expect that this won't collide with
739  * other names causing compiler warnings.
740  */
741
742 #ifndef SIGNAL_ARGS
743 #define SIGNAL_ARGS  int postgres_signal_arg
744 #endif
745
746 /*
747  * When there is no sigsetjmp, its functionality is provided by plain
748  * setjmp. Incidentally, nothing provides setjmp's functionality in
749  * that case.
750  */
751 #ifndef HAVE_SIGSETJMP
752 #define sigjmp_buf jmp_buf
753 #define sigsetjmp(x,y) setjmp(x)
754 #define siglongjmp longjmp
755 #endif
756
757 #if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
758 extern int      fdatasync(int fildes);
759 #endif
760
761 /* If strtoq() exists, rename it to the more standard strtoll() */
762 #if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
763 #define strtoll strtoq
764 #define HAVE_STRTOLL 1
765 #endif
766
767 /* If strtouq() exists, rename it to the more standard strtoull() */
768 #if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
769 #define strtoull strtouq
770 #define HAVE_STRTOULL 1
771 #endif
772
773 /* EXEC_BACKEND defines */
774 #ifdef EXEC_BACKEND
775 #define NON_EXEC_STATIC
776 #else
777 #define NON_EXEC_STATIC static
778 #endif
779
780 /* /port compatibility functions */
781 #include "port.h"
782
783 #endif   /* C_H */