OSDN Git Service

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