提交 aaf1e428cfc4c8fba369eaeeeb83a87f35f9e389

作者 WZP 万忠平
1 个父辈 3e2eb693

wzp

要显示太多修改。

为保证性能只显示 12 of 869 个文件。

1   -{
2   - "files.associations": {
3   - "*.ipp": "cpp",
4   - "any": "cpp",
5   - "array": "cpp",
6   - "atomic": "cpp",
7   - "strstream": "cpp",
8   - "bit": "cpp",
9   - "*.tcc": "cpp",
10   - "bitset": "cpp",
11   - "cctype": "cpp",
12   - "chrono": "cpp",
13   - "clocale": "cpp",
14   - "cmath": "cpp",
15   - "codecvt": "cpp",
16   - "complex": "cpp",
17   - "condition_variable": "cpp",
18   - "csignal": "cpp",
19   - "cstdarg": "cpp",
20   - "cstddef": "cpp",
21   - "cstdint": "cpp",
22   - "cstdio": "cpp",
23   - "cstdlib": "cpp",
24   - "cstring": "cpp",
25   - "ctime": "cpp",
26   - "cwchar": "cpp",
27   - "cwctype": "cpp",
28   - "deque": "cpp",
29   - "list": "cpp",
30   - "map": "cpp",
31   - "set": "cpp",
32   - "unordered_map": "cpp",
33   - "vector": "cpp",
34   - "exception": "cpp",
35   - "algorithm": "cpp",
36   - "functional": "cpp",
37   - "iterator": "cpp",
38   - "memory": "cpp",
39   - "memory_resource": "cpp",
40   - "numeric": "cpp",
41   - "optional": "cpp",
42   - "random": "cpp",
43   - "ratio": "cpp",
44   - "regex": "cpp",
45   - "source_location": "cpp",
46   - "string": "cpp",
47   - "string_view": "cpp",
48   - "system_error": "cpp",
49   - "tuple": "cpp",
50   - "type_traits": "cpp",
51   - "utility": "cpp",
52   - "slist": "cpp",
53   - "fstream": "cpp",
54   - "future": "cpp",
55   - "initializer_list": "cpp",
56   - "iomanip": "cpp",
57   - "iosfwd": "cpp",
58   - "iostream": "cpp",
59   - "istream": "cpp",
60   - "limits": "cpp",
61   - "mutex": "cpp",
62   - "new": "cpp",
63   - "ostream": "cpp",
64   - "shared_mutex": "cpp",
65   - "sstream": "cpp",
66   - "stdexcept": "cpp",
67   - "streambuf": "cpp",
68   - "thread": "cpp",
69   - "cinttypes": "cpp",
70   - "typeindex": "cpp",
71   - "typeinfo": "cpp",
72   - "variant": "cpp",
73   - "cfenv": "cpp"
74   - }
  1 +{
  2 + "files.associations": {
  3 + "*.ipp": "cpp",
  4 + "any": "cpp",
  5 + "array": "cpp",
  6 + "atomic": "cpp",
  7 + "strstream": "cpp",
  8 + "bit": "cpp",
  9 + "*.tcc": "cpp",
  10 + "bitset": "cpp",
  11 + "cctype": "cpp",
  12 + "chrono": "cpp",
  13 + "clocale": "cpp",
  14 + "cmath": "cpp",
  15 + "codecvt": "cpp",
  16 + "complex": "cpp",
  17 + "condition_variable": "cpp",
  18 + "csignal": "cpp",
  19 + "cstdarg": "cpp",
  20 + "cstddef": "cpp",
  21 + "cstdint": "cpp",
  22 + "cstdio": "cpp",
  23 + "cstdlib": "cpp",
  24 + "cstring": "cpp",
  25 + "ctime": "cpp",
  26 + "cwchar": "cpp",
  27 + "cwctype": "cpp",
  28 + "deque": "cpp",
  29 + "list": "cpp",
  30 + "map": "cpp",
  31 + "set": "cpp",
  32 + "unordered_map": "cpp",
  33 + "vector": "cpp",
  34 + "exception": "cpp",
  35 + "algorithm": "cpp",
  36 + "functional": "cpp",
  37 + "iterator": "cpp",
  38 + "memory": "cpp",
  39 + "memory_resource": "cpp",
  40 + "numeric": "cpp",
  41 + "optional": "cpp",
  42 + "random": "cpp",
  43 + "ratio": "cpp",
  44 + "regex": "cpp",
  45 + "source_location": "cpp",
  46 + "string": "cpp",
  47 + "string_view": "cpp",
  48 + "system_error": "cpp",
  49 + "tuple": "cpp",
  50 + "type_traits": "cpp",
  51 + "utility": "cpp",
  52 + "slist": "cpp",
  53 + "fstream": "cpp",
  54 + "future": "cpp",
  55 + "initializer_list": "cpp",
  56 + "iomanip": "cpp",
  57 + "iosfwd": "cpp",
  58 + "iostream": "cpp",
  59 + "istream": "cpp",
  60 + "limits": "cpp",
  61 + "mutex": "cpp",
  62 + "new": "cpp",
  63 + "ostream": "cpp",
  64 + "shared_mutex": "cpp",
  65 + "sstream": "cpp",
  66 + "stdexcept": "cpp",
  67 + "streambuf": "cpp",
  68 + "thread": "cpp",
  69 + "cinttypes": "cpp",
  70 + "typeindex": "cpp",
  71 + "typeinfo": "cpp",
  72 + "variant": "cpp",
  73 + "cfenv": "cpp"
  74 + }
75 75 }
\ No newline at end of file
... ...
1   -{
2   - "tasks": [
3   - {
4   - "type": "cppbuild",
5   - "label": "C/C++: g++ build active file",
6   - "command": "/usr/bin/g++",
7   - "args": [
8   - "-fdiagnostics-color=always",
9   - "-g",
10   - "${file}",
11   - "-o",
12   - "${fileDirname}/${fileBasenameNoExtension}"
13   - ],
14   - "options": {
15   - "cwd": "${fileDirname}"
16   - },
17   - "problemMatcher": [
18   - "$gcc"
19   - ],
20   - "group": {
21   - "kind": "build",
22   - "isDefault": true
23   - },
24   - "detail": "Task generated by Debugger."
25   - }
26   - ],
27   - "version": "2.0.0"
  1 +{
  2 + "tasks": [
  3 + {
  4 + "type": "cppbuild",
  5 + "label": "C/C++: g++ build active file",
  6 + "command": "/usr/bin/g++",
  7 + "args": [
  8 + "-fdiagnostics-color=always",
  9 + "-g",
  10 + "${file}",
  11 + "-o",
  12 + "${fileDirname}/${fileBasenameNoExtension}"
  13 + ],
  14 + "options": {
  15 + "cwd": "${fileDirname}"
  16 + },
  17 + "problemMatcher": [
  18 + "$gcc"
  19 + ],
  20 + "group": {
  21 + "kind": "build",
  22 + "isDefault": true
  23 + },
  24 + "detail": "Task generated by Debugger."
  25 + }
  26 + ],
  27 + "version": "2.0.0"
28 28 }
\ No newline at end of file
... ...
1   -# CMake module to search for FastCGI headers
2   -#
3   -# If it's found it sets FCGI_FOUND to TRUE
4   -# and following variables are set:
5   -# FCGI_INCLUDE_DIR
6   -# FCGI_LIBRARY
7   -FIND_PATH(FCGI_INCLUDE_DIR
8   - fcgio.h
9   - PATHS
10   - /usr/include
11   - /usr/local/include
12   - /usr/include/fastcgi
13   - "$ENV{LIB_DIR}/include"
14   - $ENV{INCLUDE}
15   - )
16   -FIND_LIBRARY(FCGI_LIBRARY NAMES fcgi libfcgi PATHS
17   - /usr/local/lib
18   - /usr/lib
19   - "$ENV{LIB_DIR}/lib"
20   - "$ENV{LIB}"
21   - )
22   -
23   -IF (FCGI_INCLUDE_DIR AND FCGI_LIBRARY)
24   - SET(FCGI_FOUND TRUE)
25   -ENDIF (FCGI_INCLUDE_DIR AND FCGI_LIBRARY)
26   -
27   -IF (FCGI_FOUND)
28   - IF (NOT FCGI_FIND_QUIETLY)
29   - MESSAGE(STATUS "Found FCGI: ${FCGI_LIBRARY}")
30   - ENDIF (NOT FCGI_FIND_QUIETLY)
31   -ELSE (FCGI_FOUND)
32   - IF (FCGI_FIND_REQUIRED)
33   - MESSAGE(FATAL_ERROR "Could not find FCGI")
34   - ENDIF (FCGI_FIND_REQUIRED)
35   -ENDIF (FCGI_FOUND)
  1 +# CMake module to search for FastCGI headers
  2 +#
  3 +# If it's found it sets FCGI_FOUND to TRUE
  4 +# and following variables are set:
  5 +# FCGI_INCLUDE_DIR
  6 +# FCGI_LIBRARY
  7 +FIND_PATH(FCGI_INCLUDE_DIR
  8 + fcgio.h
  9 + PATHS
  10 + /usr/include
  11 + /usr/local/include
  12 + /usr/include/fastcgi
  13 + "$ENV{LIB_DIR}/include"
  14 + $ENV{INCLUDE}
  15 + )
  16 +FIND_LIBRARY(FCGI_LIBRARY NAMES fcgi libfcgi PATHS
  17 + /usr/local/lib
  18 + /usr/lib
  19 + "$ENV{LIB_DIR}/lib"
  20 + "$ENV{LIB}"
  21 + )
  22 +
  23 +IF (FCGI_INCLUDE_DIR AND FCGI_LIBRARY)
  24 + SET(FCGI_FOUND TRUE)
  25 +ENDIF (FCGI_INCLUDE_DIR AND FCGI_LIBRARY)
  26 +
  27 +IF (FCGI_FOUND)
  28 + IF (NOT FCGI_FIND_QUIETLY)
  29 + MESSAGE(STATUS "Found FCGI: ${FCGI_LIBRARY}")
  30 + ENDIF (NOT FCGI_FIND_QUIETLY)
  31 +ELSE (FCGI_FOUND)
  32 + IF (FCGI_FIND_REQUIRED)
  33 + MESSAGE(FATAL_ERROR "Could not find FCGI")
  34 + ENDIF (FCGI_FIND_REQUIRED)
  35 +ENDIF (FCGI_FOUND)
... ...
1   -/* src/interfaces/ecpg/include/ecpg_config.h. Generated from ecpg_config.h.in by configure. */
2   -/* Define to 1 if the system has the type `int64'. */
3   -/* #undef HAVE_INT64 */
4   -
5   -/* Define to 1 if `long int' works and is 64 bits. */
6   -#define HAVE_LONG_INT_64 1
7   -
8   -/* Define to 1 if the system has the type `long long int'. */
9   -#define HAVE_LONG_LONG_INT 1
10   -
11   -/* Define to 1 if `long long int' works and is 64 bits. */
12   -/* #undef HAVE_LONG_LONG_INT_64 */
13   -
14   -/* Define to 1 to build client libraries as thread-safe code.
15   - * (--enable-thread-safety) */
16   -#define ENABLE_THREAD_SAFETY 1
  1 +/* src/interfaces/ecpg/include/ecpg_config.h. Generated from ecpg_config.h.in by configure. */
  2 +/* Define to 1 if the system has the type `int64'. */
  3 +/* #undef HAVE_INT64 */
  4 +
  5 +/* Define to 1 if `long int' works and is 64 bits. */
  6 +#define HAVE_LONG_INT_64 1
  7 +
  8 +/* Define to 1 if the system has the type `long long int'. */
  9 +#define HAVE_LONG_LONG_INT 1
  10 +
  11 +/* Define to 1 if `long long int' works and is 64 bits. */
  12 +/* #undef HAVE_LONG_LONG_INT_64 */
  13 +
  14 +/* Define to 1 to build client libraries as thread-safe code.
  15 + * (--enable-thread-safety) */
  16 +#define ENABLE_THREAD_SAFETY 1
... ...
1   -/*
2   - * This file contains stuff needed to be as compatible to Informix as possible.
3   - * src/interfaces/ecpg/include/ecpg_informix.h
4   - */
5   -#ifndef _ECPG_INFORMIX_H
6   -#define _ECPG_INFORMIX_H
7   -
8   -#include <ecpglib.h>
9   -#include <pgtypes_date.h>
10   -#include <pgtypes_interval.h>
11   -#include <pgtypes_numeric.h>
12   -#include <pgtypes_timestamp.h>
13   -
14   -#define SQLNOTFOUND 100
15   -
16   -#define ECPG_INFORMIX_NUM_OVERFLOW -1200
17   -#define ECPG_INFORMIX_NUM_UNDERFLOW -1201
18   -#define ECPG_INFORMIX_DIVIDE_ZERO -1202
19   -#define ECPG_INFORMIX_BAD_YEAR -1204
20   -#define ECPG_INFORMIX_BAD_MONTH -1205
21   -#define ECPG_INFORMIX_BAD_DAY -1206
22   -#define ECPG_INFORMIX_ENOSHORTDATE -1209
23   -#define ECPG_INFORMIX_DATE_CONVERT -1210
24   -#define ECPG_INFORMIX_OUT_OF_MEMORY -1211
25   -#define ECPG_INFORMIX_ENOTDMY -1212
26   -#define ECPG_INFORMIX_BAD_NUMERIC -1213
27   -#define ECPG_INFORMIX_BAD_EXPONENT -1216
28   -#define ECPG_INFORMIX_BAD_DATE -1218
29   -#define ECPG_INFORMIX_EXTRA_CHARS -1264
30   -
31   -#ifdef __cplusplus
32   -extern "C"
33   -{
34   -#endif
35   -
36   -extern int rdatestr(date, char *);
37   -extern void rtoday(date *);
38   -extern int rjulmdy(date, short *);
39   -extern int rdefmtdate(date *, const char *, const char *);
40   -extern int rfmtdate(date, const char *, char *);
41   -extern int rmdyjul(short *, date *);
42   -extern int rstrdate(const char *, date *);
43   -extern int rdayofweek(date);
44   -
45   -extern int rfmtlong(long, const char *, char *);
46   -extern int rgetmsg(int, char *, int);
47   -extern int risnull(int, const char *);
48   -extern int rsetnull(int, char *);
49   -extern int rtypalign(int, int);
50   -extern int rtypmsize(int, int);
51   -extern int rtypwidth(int, int);
52   -extern void rupshift(char *);
53   -
54   -extern int byleng(char *, int);
55   -extern void ldchar(char *, int, char *);
56   -
57   -extern void ECPG_informix_set_var(int, void *, int);
58   -extern void *ECPG_informix_get_var(int);
59   -extern void ECPG_informix_reset_sqlca(void);
60   -
61   -/* Informix defines these in decimal.h */
62   -int decadd(decimal *, decimal *, decimal *);
63   -int deccmp(decimal *, decimal *);
64   -void deccopy(decimal *, decimal *);
65   -int deccvasc(const char *, int, decimal *);
66   -int deccvdbl(double, decimal *);
67   -int deccvint(int, decimal *);
68   -int deccvlong(long, decimal *);
69   -int decdiv(decimal *, decimal *, decimal *);
70   -int decmul(decimal *, decimal *, decimal *);
71   -int decsub(decimal *, decimal *, decimal *);
72   -int dectoasc(decimal *, char *, int, int);
73   -int dectodbl(decimal *, double *);
74   -int dectoint(decimal *, int *);
75   -int dectolong(decimal *, long *);
76   -
77   -/* Informix defines these in datetime.h */
78   -extern void dtcurrent(timestamp *);
79   -extern int dtcvasc(char *, timestamp *);
80   -extern int dtsub(timestamp *, timestamp *, interval *);
81   -extern int dttoasc(timestamp *, char *);
82   -extern int dttofmtasc(timestamp *, char *, int, char *);
83   -extern int intoasc(interval *, char *);
84   -extern int dtcvfmtasc(char *, char *, timestamp *);
85   -
86   -#ifdef __cplusplus
87   -}
88   -#endif
89   -
90   -#endif /* ndef _ECPG_INFORMIX_H */
  1 +/*
  2 + * This file contains stuff needed to be as compatible to Informix as possible.
  3 + * src/interfaces/ecpg/include/ecpg_informix.h
  4 + */
  5 +#ifndef _ECPG_INFORMIX_H
  6 +#define _ECPG_INFORMIX_H
  7 +
  8 +#include <ecpglib.h>
  9 +#include <pgtypes_date.h>
  10 +#include <pgtypes_interval.h>
  11 +#include <pgtypes_numeric.h>
  12 +#include <pgtypes_timestamp.h>
  13 +
  14 +#define SQLNOTFOUND 100
  15 +
  16 +#define ECPG_INFORMIX_NUM_OVERFLOW -1200
  17 +#define ECPG_INFORMIX_NUM_UNDERFLOW -1201
  18 +#define ECPG_INFORMIX_DIVIDE_ZERO -1202
  19 +#define ECPG_INFORMIX_BAD_YEAR -1204
  20 +#define ECPG_INFORMIX_BAD_MONTH -1205
  21 +#define ECPG_INFORMIX_BAD_DAY -1206
  22 +#define ECPG_INFORMIX_ENOSHORTDATE -1209
  23 +#define ECPG_INFORMIX_DATE_CONVERT -1210
  24 +#define ECPG_INFORMIX_OUT_OF_MEMORY -1211
  25 +#define ECPG_INFORMIX_ENOTDMY -1212
  26 +#define ECPG_INFORMIX_BAD_NUMERIC -1213
  27 +#define ECPG_INFORMIX_BAD_EXPONENT -1216
  28 +#define ECPG_INFORMIX_BAD_DATE -1218
  29 +#define ECPG_INFORMIX_EXTRA_CHARS -1264
  30 +
  31 +#ifdef __cplusplus
  32 +extern "C"
  33 +{
  34 +#endif
  35 +
  36 +extern int rdatestr(date, char *);
  37 +extern void rtoday(date *);
  38 +extern int rjulmdy(date, short *);
  39 +extern int rdefmtdate(date *, const char *, const char *);
  40 +extern int rfmtdate(date, const char *, char *);
  41 +extern int rmdyjul(short *, date *);
  42 +extern int rstrdate(const char *, date *);
  43 +extern int rdayofweek(date);
  44 +
  45 +extern int rfmtlong(long, const char *, char *);
  46 +extern int rgetmsg(int, char *, int);
  47 +extern int risnull(int, const char *);
  48 +extern int rsetnull(int, char *);
  49 +extern int rtypalign(int, int);
  50 +extern int rtypmsize(int, int);
  51 +extern int rtypwidth(int, int);
  52 +extern void rupshift(char *);
  53 +
  54 +extern int byleng(char *, int);
  55 +extern void ldchar(char *, int, char *);
  56 +
  57 +extern void ECPG_informix_set_var(int, void *, int);
  58 +extern void *ECPG_informix_get_var(int);
  59 +extern void ECPG_informix_reset_sqlca(void);
  60 +
  61 +/* Informix defines these in decimal.h */
  62 +int decadd(decimal *, decimal *, decimal *);
  63 +int deccmp(decimal *, decimal *);
  64 +void deccopy(decimal *, decimal *);
  65 +int deccvasc(const char *, int, decimal *);
  66 +int deccvdbl(double, decimal *);
  67 +int deccvint(int, decimal *);
  68 +int deccvlong(long, decimal *);
  69 +int decdiv(decimal *, decimal *, decimal *);
  70 +int decmul(decimal *, decimal *, decimal *);
  71 +int decsub(decimal *, decimal *, decimal *);
  72 +int dectoasc(decimal *, char *, int, int);
  73 +int dectodbl(decimal *, double *);
  74 +int dectoint(decimal *, int *);
  75 +int dectolong(decimal *, long *);
  76 +
  77 +/* Informix defines these in datetime.h */
  78 +extern void dtcurrent(timestamp *);
  79 +extern int dtcvasc(char *, timestamp *);
  80 +extern int dtsub(timestamp *, timestamp *, interval *);
  81 +extern int dttoasc(timestamp *, char *);
  82 +extern int dttofmtasc(timestamp *, char *, int, char *);
  83 +extern int intoasc(interval *, char *);
  84 +extern int dtcvfmtasc(char *, char *, timestamp *);
  85 +
  86 +#ifdef __cplusplus
  87 +}
  88 +#endif
  89 +
  90 +#endif /* ndef _ECPG_INFORMIX_H */
... ...
1   -/* src/interfaces/ecpg/include/ecpgerrno.h */
2   -
3   -#ifndef _ECPG_ERRNO_H
4   -#define _ECPG_ERRNO_H
5   -
6   -#include <errno.h>
7   -
8   -/* This is a list of all error codes the embedded SQL program can return */
9   -#define ECPG_NO_ERROR 0
10   -#define ECPG_NOT_FOUND 100
11   -
12   -/* system error codes returned by ecpglib get the correct number,
13   - * but are made negative
14   - */
15   -#define ECPG_OUT_OF_MEMORY -ENOMEM
16   -
17   -/* first we have a set of ecpg messages, they start at 200 */
18   -#define ECPG_UNSUPPORTED -200
19   -#define ECPG_TOO_MANY_ARGUMENTS -201
20   -#define ECPG_TOO_FEW_ARGUMENTS -202
21   -#define ECPG_TOO_MANY_MATCHES -203
22   -#define ECPG_INT_FORMAT -204
23   -#define ECPG_UINT_FORMAT -205
24   -#define ECPG_FLOAT_FORMAT -206
25   -#define ECPG_NUMERIC_FORMAT -207
26   -#define ECPG_INTERVAL_FORMAT -208
27   -#define ECPG_DATE_FORMAT -209
28   -#define ECPG_TIMESTAMP_FORMAT -210
29   -#define ECPG_CONVERT_BOOL -211
30   -#define ECPG_EMPTY -212
31   -#define ECPG_MISSING_INDICATOR -213
32   -#define ECPG_NO_ARRAY -214
33   -#define ECPG_DATA_NOT_ARRAY -215
34   -#define ECPG_ARRAY_INSERT -216
35   -
36   -#define ECPG_NO_CONN -220
37   -#define ECPG_NOT_CONN -221
38   -
39   -#define ECPG_INVALID_STMT -230
40   -
41   -/* dynamic SQL related */
42   -#define ECPG_UNKNOWN_DESCRIPTOR -240
43   -#define ECPG_INVALID_DESCRIPTOR_INDEX -241
44   -#define ECPG_UNKNOWN_DESCRIPTOR_ITEM -242
45   -#define ECPG_VAR_NOT_NUMERIC -243
46   -#define ECPG_VAR_NOT_CHAR -244
47   -
48   -/* finally the backend error messages, they start at 400 */
49   -#define ECPG_PGSQL -400
50   -#define ECPG_TRANS -401
51   -#define ECPG_CONNECT -402
52   -#define ECPG_DUPLICATE_KEY -403
53   -#define ECPG_SUBSELECT_NOT_ONE -404
54   -
55   -/* for compatibility we define some different error codes for the same error
56   - * if adding a new one make sure to not double define it */
57   -#define ECPG_INFORMIX_DUPLICATE_KEY -239
58   -#define ECPG_INFORMIX_SUBSELECT_NOT_ONE -284
59   -
60   -/* backend WARNINGs, starting at 600 */
61   -#define ECPG_WARNING_UNRECOGNIZED -600
62   - /* WARNING: (transaction aborted): queries ignored until END */
63   -
64   - /*
65   - * WARNING: current transaction is aborted, queries ignored until end of
66   - * transaction block
67   - */
68   -#define ECPG_WARNING_QUERY_IGNORED -601
69   - /* WARNING: PerformPortalClose: portal "*" not found */
70   -#define ECPG_WARNING_UNKNOWN_PORTAL -602
71   - /* WARNING: BEGIN: already a transaction in progress */
72   -#define ECPG_WARNING_IN_TRANSACTION -603
73   - /* WARNING: AbortTransaction and not in in-progress state */
74   - /* WARNING: COMMIT: no transaction in progress */
75   -#define ECPG_WARNING_NO_TRANSACTION -604
76   - /* WARNING: BlankPortalAssignName: portal * already exists */
77   -#define ECPG_WARNING_PORTAL_EXISTS -605
78   -
79   -#endif /* !_ECPG_ERRNO_H */
  1 +/* src/interfaces/ecpg/include/ecpgerrno.h */
  2 +
  3 +#ifndef _ECPG_ERRNO_H
  4 +#define _ECPG_ERRNO_H
  5 +
  6 +#include <errno.h>
  7 +
  8 +/* This is a list of all error codes the embedded SQL program can return */
  9 +#define ECPG_NO_ERROR 0
  10 +#define ECPG_NOT_FOUND 100
  11 +
  12 +/* system error codes returned by ecpglib get the correct number,
  13 + * but are made negative
  14 + */
  15 +#define ECPG_OUT_OF_MEMORY -ENOMEM
  16 +
  17 +/* first we have a set of ecpg messages, they start at 200 */
  18 +#define ECPG_UNSUPPORTED -200
  19 +#define ECPG_TOO_MANY_ARGUMENTS -201
  20 +#define ECPG_TOO_FEW_ARGUMENTS -202
  21 +#define ECPG_TOO_MANY_MATCHES -203
  22 +#define ECPG_INT_FORMAT -204
  23 +#define ECPG_UINT_FORMAT -205
  24 +#define ECPG_FLOAT_FORMAT -206
  25 +#define ECPG_NUMERIC_FORMAT -207
  26 +#define ECPG_INTERVAL_FORMAT -208
  27 +#define ECPG_DATE_FORMAT -209
  28 +#define ECPG_TIMESTAMP_FORMAT -210
  29 +#define ECPG_CONVERT_BOOL -211
  30 +#define ECPG_EMPTY -212
  31 +#define ECPG_MISSING_INDICATOR -213
  32 +#define ECPG_NO_ARRAY -214
  33 +#define ECPG_DATA_NOT_ARRAY -215
  34 +#define ECPG_ARRAY_INSERT -216
  35 +
  36 +#define ECPG_NO_CONN -220
  37 +#define ECPG_NOT_CONN -221
  38 +
  39 +#define ECPG_INVALID_STMT -230
  40 +
  41 +/* dynamic SQL related */
  42 +#define ECPG_UNKNOWN_DESCRIPTOR -240
  43 +#define ECPG_INVALID_DESCRIPTOR_INDEX -241
  44 +#define ECPG_UNKNOWN_DESCRIPTOR_ITEM -242
  45 +#define ECPG_VAR_NOT_NUMERIC -243
  46 +#define ECPG_VAR_NOT_CHAR -244
  47 +
  48 +/* finally the backend error messages, they start at 400 */
  49 +#define ECPG_PGSQL -400
  50 +#define ECPG_TRANS -401
  51 +#define ECPG_CONNECT -402
  52 +#define ECPG_DUPLICATE_KEY -403
  53 +#define ECPG_SUBSELECT_NOT_ONE -404
  54 +
  55 +/* for compatibility we define some different error codes for the same error
  56 + * if adding a new one make sure to not double define it */
  57 +#define ECPG_INFORMIX_DUPLICATE_KEY -239
  58 +#define ECPG_INFORMIX_SUBSELECT_NOT_ONE -284
  59 +
  60 +/* backend WARNINGs, starting at 600 */
  61 +#define ECPG_WARNING_UNRECOGNIZED -600
  62 + /* WARNING: (transaction aborted): queries ignored until END */
  63 +
  64 + /*
  65 + * WARNING: current transaction is aborted, queries ignored until end of
  66 + * transaction block
  67 + */
  68 +#define ECPG_WARNING_QUERY_IGNORED -601
  69 + /* WARNING: PerformPortalClose: portal "*" not found */
  70 +#define ECPG_WARNING_UNKNOWN_PORTAL -602
  71 + /* WARNING: BEGIN: already a transaction in progress */
  72 +#define ECPG_WARNING_IN_TRANSACTION -603
  73 + /* WARNING: AbortTransaction and not in in-progress state */
  74 + /* WARNING: COMMIT: no transaction in progress */
  75 +#define ECPG_WARNING_NO_TRANSACTION -604
  76 + /* WARNING: BlankPortalAssignName: portal * already exists */
  77 +#define ECPG_WARNING_PORTAL_EXISTS -605
  78 +
  79 +#endif /* !_ECPG_ERRNO_H */
... ...
1   -/*
2   - * this is a small part of c.h since we don't want to leak all postgres
3   - * definitions into ecpg programs
4   - * src/interfaces/ecpg/include/ecpglib.h
5   - */
6   -
7   -#ifndef _ECPGLIB_H
8   -#define _ECPGLIB_H
9   -
10   -#include "libpq-fe.h"
11   -#include "ecpgtype.h"
12   -#include "sqlca.h"
13   -#include <string.h>
14   -
15   -#ifdef ENABLE_NLS
16   -extern char *ecpg_gettext(const char *msgid) pg_attribute_format_arg(1);
17   -#else
18   -#define ecpg_gettext(x) (x)
19   -#endif
20   -
21   -#ifndef __cplusplus
22   -#ifndef bool
23   -#define bool char
24   -#endif /* ndef bool */
25   -
26   -#ifndef true
27   -#define true ((bool) 1)
28   -#endif /* ndef true */
29   -#ifndef false
30   -#define false ((bool) 0)
31   -#endif /* ndef false */
32   -#endif /* not C++ */
33   -
34   -#ifndef TRUE
35   -#define TRUE 1
36   -#endif /* TRUE */
37   -
38   -#ifndef FALSE
39   -#define FALSE 0
40   -#endif /* FALSE */
41   -
42   -#ifdef __cplusplus
43   -extern "C"
44   -{
45   -#endif
46   -
47   -void ECPGdebug(int, FILE *);
48   -bool ECPGstatus(int, const char *);
49   -bool ECPGsetcommit(int, const char *, const char *);
50   -bool ECPGsetconn(int, const char *);
51   -bool ECPGconnect(int, int, const char *, const char *, const char *, const char *, int);
52   -bool ECPGdo(const int, const int, const int, const char *, const bool, const int, const char *,...);
53   -bool ECPGtrans(int, const char *, const char *);
54   -bool ECPGdisconnect(int, const char *);
55   -bool ECPGprepare(int, const char *, const bool, const char *, const char *);
56   -bool ECPGdeallocate(int, int, const char *, const char *);
57   -bool ECPGdeallocate_all(int, int, const char *);
58   -char *ECPGprepared_statement(const char *, const char *, int);
59   -PGconn *ECPGget_PGconn(const char *);
60   -PGTransactionStatusType ECPGtransactionStatus(const char *);
61   -
62   -char *ECPGerrmsg(void);
63   -
64   - /* print an error message */
65   -void sqlprint(void);
66   -
67   -/* define this for simplicity as well as compatibility */
68   -
69   -#define SQLCODE sqlca.sqlcode
70   -#define SQLSTATE sqlca.sqlstate
71   -
72   -/* dynamic SQL */
73   -
74   -bool ECPGdo_descriptor(int, const char *, const char *, const char *);
75   -bool ECPGdeallocate_desc(int, const char *);
76   -bool ECPGallocate_desc(int, const char *);
77   -bool ECPGget_desc_header(int, const char *, int *);
78   -bool ECPGget_desc(int, const char *, int,...);
79   -bool ECPGset_desc_header(int, const char *, int);
80   -bool ECPGset_desc(int, const char *, int,...);
81   -
82   -void ECPGset_noind_null(enum ECPGttype, void *);
83   -bool ECPGis_noind_null(enum ECPGttype, const void *);
84   -bool ECPGdescribe(int, int, bool, const char *, const char *,...);
85   -
86   -void ECPGset_var(int, void *, int);
87   -void *ECPGget_var(int number);
88   -
89   -/* dynamic result allocation */
90   -void ECPGfree_auto_mem(void);
91   -
92   -#ifdef ENABLE_THREAD_SAFETY
93   -void ecpg_pthreads_init(void);
94   -#endif
95   -
96   -#ifdef __cplusplus
97   -}
98   -#endif
99   -
100   -#endif /* _ECPGLIB_H */
  1 +/*
  2 + * this is a small part of c.h since we don't want to leak all postgres
  3 + * definitions into ecpg programs
  4 + * src/interfaces/ecpg/include/ecpglib.h
  5 + */
  6 +
  7 +#ifndef _ECPGLIB_H
  8 +#define _ECPGLIB_H
  9 +
  10 +#include "libpq-fe.h"
  11 +#include "ecpgtype.h"
  12 +#include "sqlca.h"
  13 +#include <string.h>
  14 +
  15 +#ifdef ENABLE_NLS
  16 +extern char *ecpg_gettext(const char *msgid) pg_attribute_format_arg(1);
  17 +#else
  18 +#define ecpg_gettext(x) (x)
  19 +#endif
  20 +
  21 +#ifndef __cplusplus
  22 +#ifndef bool
  23 +#define bool char
  24 +#endif /* ndef bool */
  25 +
  26 +#ifndef true
  27 +#define true ((bool) 1)
  28 +#endif /* ndef true */
  29 +#ifndef false
  30 +#define false ((bool) 0)
  31 +#endif /* ndef false */
  32 +#endif /* not C++ */
  33 +
  34 +#ifndef TRUE
  35 +#define TRUE 1
  36 +#endif /* TRUE */
  37 +
  38 +#ifndef FALSE
  39 +#define FALSE 0
  40 +#endif /* FALSE */
  41 +
  42 +#ifdef __cplusplus
  43 +extern "C"
  44 +{
  45 +#endif
  46 +
  47 +void ECPGdebug(int, FILE *);
  48 +bool ECPGstatus(int, const char *);
  49 +bool ECPGsetcommit(int, const char *, const char *);
  50 +bool ECPGsetconn(int, const char *);
  51 +bool ECPGconnect(int, int, const char *, const char *, const char *, const char *, int);
  52 +bool ECPGdo(const int, const int, const int, const char *, const bool, const int, const char *,...);
  53 +bool ECPGtrans(int, const char *, const char *);
  54 +bool ECPGdisconnect(int, const char *);
  55 +bool ECPGprepare(int, const char *, const bool, const char *, const char *);
  56 +bool ECPGdeallocate(int, int, const char *, const char *);
  57 +bool ECPGdeallocate_all(int, int, const char *);
  58 +char *ECPGprepared_statement(const char *, const char *, int);
  59 +PGconn *ECPGget_PGconn(const char *);
  60 +PGTransactionStatusType ECPGtransactionStatus(const char *);
  61 +
  62 +char *ECPGerrmsg(void);
  63 +
  64 + /* print an error message */
  65 +void sqlprint(void);
  66 +
  67 +/* define this for simplicity as well as compatibility */
  68 +
  69 +#define SQLCODE sqlca.sqlcode
  70 +#define SQLSTATE sqlca.sqlstate
  71 +
  72 +/* dynamic SQL */
  73 +
  74 +bool ECPGdo_descriptor(int, const char *, const char *, const char *);
  75 +bool ECPGdeallocate_desc(int, const char *);
  76 +bool ECPGallocate_desc(int, const char *);
  77 +bool ECPGget_desc_header(int, const char *, int *);
  78 +bool ECPGget_desc(int, const char *, int,...);
  79 +bool ECPGset_desc_header(int, const char *, int);
  80 +bool ECPGset_desc(int, const char *, int,...);
  81 +
  82 +void ECPGset_noind_null(enum ECPGttype, void *);
  83 +bool ECPGis_noind_null(enum ECPGttype, const void *);
  84 +bool ECPGdescribe(int, int, bool, const char *, const char *,...);
  85 +
  86 +void ECPGset_var(int, void *, int);
  87 +void *ECPGget_var(int number);
  88 +
  89 +/* dynamic result allocation */
  90 +void ECPGfree_auto_mem(void);
  91 +
  92 +#ifdef ENABLE_THREAD_SAFETY
  93 +void ecpg_pthreads_init(void);
  94 +#endif
  95 +
  96 +#ifdef __cplusplus
  97 +}
  98 +#endif
  99 +
  100 +#endif /* _ECPGLIB_H */
... ...
1   -/*
2   - * This file implements a data structure that is built and maintained by the
3   - * preprocessor.
4   - *
5   - * All types that can be handled for host variable declarations has to
6   - * be handled eventually.
7   - *
8   - * src/interfaces/ecpg/include/ecpgtype.h
9   - */
10   -
11   -/*
12   - * Here are all the types that we are to handle. Note that it is the type
13   - * that is registered and that has nothing whatsoever to do with the storage
14   - * class.
15   - *
16   - * Simple types
17   - * integers: char, short, int, long (signed and unsigned)
18   - * floats: float, double
19   - *
20   - * Complex types:
21   - * VARCHAR, VARCHAR2 - Strings with length (maxlen is given in the declaration)
22   - * Arrays of simple types and of VARCHAR, VARCHAR2 (size given in declaration)
23   - * Records build of simple types, arrays and other structs.
24   - *
25   - * Complicating things:
26   - * typedefs and struct names!
27   - *
28   - * Conclusion:
29   - * This is a typically recursive definition. A structure of typed list elements
30   - * would probably work fine:
31   - */
32   -
33   -#ifndef _ECPGTYPE_H
34   -#define _ECPGTYPE_H
35   -
36   -#ifdef __cplusplus
37   -extern "C"
38   -{
39   -#endif
40   -
41   -enum ECPGttype
42   -{
43   - ECPGt_char = 1, ECPGt_unsigned_char, ECPGt_short, ECPGt_unsigned_short,
44   - ECPGt_int, ECPGt_unsigned_int, ECPGt_long, ECPGt_unsigned_long,
45   - ECPGt_long_long, ECPGt_unsigned_long_long,
46   - ECPGt_bool,
47   - ECPGt_float, ECPGt_double,
48   - ECPGt_varchar, ECPGt_varchar2,
49   - ECPGt_numeric, /* this is a decimal that stores its digits in
50   - * a malloced array */
51   - ECPGt_decimal, /* this is a decimal that stores its digits in
52   - * a fixed array */
53   - ECPGt_date,
54   - ECPGt_timestamp,
55   - ECPGt_interval,
56   - ECPGt_array,
57   - ECPGt_struct,
58   - ECPGt_union,
59   - ECPGt_descriptor, /* sql descriptor, no C variable */
60   - ECPGt_char_variable,
61   - ECPGt_const, /* a constant is needed sometimes */
62   - ECPGt_EOIT, /* End of insert types. */
63   - ECPGt_EORT, /* End of result types. */
64   - ECPGt_NO_INDICATOR, /* no indicator */
65   - ECPGt_string, /* trimmed (char *) type */
66   - ECPGt_sqlda /* C struct descriptor */
67   -};
68   -
69   - /* descriptor items */
70   -enum ECPGdtype
71   -{
72   - ECPGd_count = 1,
73   - ECPGd_data,
74   - ECPGd_di_code,
75   - ECPGd_di_precision,
76   - ECPGd_indicator,
77   - ECPGd_key_member,
78   - ECPGd_length,
79   - ECPGd_name,
80   - ECPGd_nullable,
81   - ECPGd_octet,
82   - ECPGd_precision,
83   - ECPGd_ret_length,
84   - ECPGd_ret_octet,
85   - ECPGd_scale,
86   - ECPGd_type,
87   - ECPGd_EODT, /* End of descriptor types. */
88   - ECPGd_cardinality
89   -};
90   -
91   -#define IS_SIMPLE_TYPE(type) (((type) >= ECPGt_char && (type) <= ECPGt_interval) || ((type) == ECPGt_string))
92   -
93   -/* we also have to handle different statement types */
94   -enum ECPG_statement_type
95   -{
96   - ECPGst_normal,
97   - ECPGst_execute,
98   - ECPGst_exec_immediate,
99   - ECPGst_prepnormal
100   -};
101   -
102   -#ifdef __cplusplus
103   -}
104   -#endif
105   -
106   -#endif /* _ECPGTYPE_H */
  1 +/*
  2 + * This file implements a data structure that is built and maintained by the
  3 + * preprocessor.
  4 + *
  5 + * All types that can be handled for host variable declarations has to
  6 + * be handled eventually.
  7 + *
  8 + * src/interfaces/ecpg/include/ecpgtype.h
  9 + */
  10 +
  11 +/*
  12 + * Here are all the types that we are to handle. Note that it is the type
  13 + * that is registered and that has nothing whatsoever to do with the storage
  14 + * class.
  15 + *
  16 + * Simple types
  17 + * integers: char, short, int, long (signed and unsigned)
  18 + * floats: float, double
  19 + *
  20 + * Complex types:
  21 + * VARCHAR, VARCHAR2 - Strings with length (maxlen is given in the declaration)
  22 + * Arrays of simple types and of VARCHAR, VARCHAR2 (size given in declaration)
  23 + * Records build of simple types, arrays and other structs.
  24 + *
  25 + * Complicating things:
  26 + * typedefs and struct names!
  27 + *
  28 + * Conclusion:
  29 + * This is a typically recursive definition. A structure of typed list elements
  30 + * would probably work fine:
  31 + */
  32 +
  33 +#ifndef _ECPGTYPE_H
  34 +#define _ECPGTYPE_H
  35 +
  36 +#ifdef __cplusplus
  37 +extern "C"
  38 +{
  39 +#endif
  40 +
  41 +enum ECPGttype
  42 +{
  43 + ECPGt_char = 1, ECPGt_unsigned_char, ECPGt_short, ECPGt_unsigned_short,
  44 + ECPGt_int, ECPGt_unsigned_int, ECPGt_long, ECPGt_unsigned_long,
  45 + ECPGt_long_long, ECPGt_unsigned_long_long,
  46 + ECPGt_bool,
  47 + ECPGt_float, ECPGt_double,
  48 + ECPGt_varchar, ECPGt_varchar2,
  49 + ECPGt_numeric, /* this is a decimal that stores its digits in
  50 + * a malloced array */
  51 + ECPGt_decimal, /* this is a decimal that stores its digits in
  52 + * a fixed array */
  53 + ECPGt_date,
  54 + ECPGt_timestamp,
  55 + ECPGt_interval,
  56 + ECPGt_array,
  57 + ECPGt_struct,
  58 + ECPGt_union,
  59 + ECPGt_descriptor, /* sql descriptor, no C variable */
  60 + ECPGt_char_variable,
  61 + ECPGt_const, /* a constant is needed sometimes */
  62 + ECPGt_EOIT, /* End of insert types. */
  63 + ECPGt_EORT, /* End of result types. */
  64 + ECPGt_NO_INDICATOR, /* no indicator */
  65 + ECPGt_string, /* trimmed (char *) type */
  66 + ECPGt_sqlda /* C struct descriptor */
  67 +};
  68 +
  69 + /* descriptor items */
  70 +enum ECPGdtype
  71 +{
  72 + ECPGd_count = 1,
  73 + ECPGd_data,
  74 + ECPGd_di_code,
  75 + ECPGd_di_precision,
  76 + ECPGd_indicator,
  77 + ECPGd_key_member,
  78 + ECPGd_length,
  79 + ECPGd_name,
  80 + ECPGd_nullable,
  81 + ECPGd_octet,
  82 + ECPGd_precision,
  83 + ECPGd_ret_length,
  84 + ECPGd_ret_octet,
  85 + ECPGd_scale,
  86 + ECPGd_type,
  87 + ECPGd_EODT, /* End of descriptor types. */
  88 + ECPGd_cardinality
  89 +};
  90 +
  91 +#define IS_SIMPLE_TYPE(type) (((type) >= ECPGt_char && (type) <= ECPGt_interval) || ((type) == ECPGt_string))
  92 +
  93 +/* we also have to handle different statement types */
  94 +enum ECPG_statement_type
  95 +{
  96 + ECPGst_normal,
  97 + ECPGst_execute,
  98 + ECPGst_exec_immediate,
  99 + ECPGst_prepnormal
  100 +};
  101 +
  102 +#ifdef __cplusplus
  103 +}
  104 +#endif
  105 +
  106 +#endif /* _ECPGTYPE_H */
... ...
1   -/* src/interfaces/ecpg/include/datetime.h */
2   -
3   -#ifndef _ECPG_DATETIME_H
4   -#define _ECPG_DATETIME_H
5   -
6   -#include <ecpg_informix.h>
7   -
8   -/* source created by ecpg which defines these symbols */
9   -#ifndef _ECPGLIB_H
10   -typedef timestamp dtime_t;
11   -typedef interval intrvl_t;
12   -#endif /* ndef _ECPGLIB_H */
13   -
14   -#endif /* ndef _ECPG_DATETIME_H */
  1 +/* src/interfaces/ecpg/include/datetime.h */
  2 +
  3 +#ifndef _ECPG_DATETIME_H
  4 +#define _ECPG_DATETIME_H
  5 +
  6 +#include <ecpg_informix.h>
  7 +
  8 +/* source created by ecpg which defines these symbols */
  9 +#ifndef _ECPGLIB_H
  10 +typedef timestamp dtime_t;
  11 +typedef interval intrvl_t;
  12 +#endif /* ndef _ECPGLIB_H */
  13 +
  14 +#endif /* ndef _ECPG_DATETIME_H */
... ...
1   -/* src/interfaces/ecpg/include/decimal.h */
2   -
3   -#ifndef _ECPG_DECIMAL_H
4   -#define _ECPG_DECIMAL_H
5   -
6   -#include <ecpg_informix.h>
7   -
8   -/* source created by ecpg which defines this */
9   -#ifndef _ECPGLIB_H
10   -typedef decimal dec_t;
11   -#endif /* ndef _ECPGLIB_H */
12   -
13   -#endif /* ndef _ECPG_DECIMAL_H */
  1 +/* src/interfaces/ecpg/include/decimal.h */
  2 +
  3 +#ifndef _ECPG_DECIMAL_H
  4 +#define _ECPG_DECIMAL_H
  5 +
  6 +#include <ecpg_informix.h>
  7 +
  8 +/* source created by ecpg which defines this */
  9 +#ifndef _ECPGLIB_H
  10 +typedef decimal dec_t;
  11 +#endif /* ndef _ECPGLIB_H */
  12 +
  13 +#endif /* ndef _ECPG_DECIMAL_H */
... ...
1   -#ifndef ECPG_SQLTYPES_H
2   -#define ECPG_SQLTYPES_H
3   -
4   -#include <limits.h>
5   -
6   -#define CCHARTYPE ECPGt_char
7   -#define CSHORTTYPE ECPGt_short
8   -#define CINTTYPE ECPGt_int
9   -#define CLONGTYPE ECPGt_long
10   -#define CFLOATTYPE ECPGt_float
11   -#define CDOUBLETYPE ECPGt_double
12   -#define CDECIMALTYPE ECPGt_decimal
13   -#define CFIXCHARTYPE 108
14   -#define CSTRINGTYPE ECPGt_char
15   -#define CDATETYPE ECPGt_date
16   -#define CMONEYTYPE 111
17   -#define CDTIMETYPE ECPGt_timestamp
18   -#define CLOCATORTYPE 113
19   -#define CVCHARTYPE ECPGt_varchar
20   -#define CINVTYPE 115
21   -#define CFILETYPE 116
22   -#define CINT8TYPE ECPGt_long_long
23   -#define CCOLLTYPE 118
24   -#define CLVCHARTYPE 119
25   -#define CFIXBINTYPE 120
26   -#define CVARBINTYPE 121
27   -#define CBOOLTYPE ECPGt_bool
28   -#define CROWTYPE 123
29   -#define CLVCHARPTRTYPE 124
30   -#define CTYPEMAX 25
31   -
32   -/*
33   - * Values used in sqlda->sqlvar[i]->sqltype
34   - */
35   -#define SQLCHAR ECPGt_char
36   -#define SQLSMINT ECPGt_short
37   -#define SQLINT ECPGt_int
38   -#define SQLFLOAT ECPGt_double
39   -#define SQLSMFLOAT ECPGt_float
40   -#define SQLDECIMAL ECPGt_decimal
41   -#define SQLSERIAL ECPGt_int
42   -#define SQLDATE ECPGt_date
43   -#define SQLDTIME ECPGt_timestamp
44   -#define SQLTEXT ECPGt_char
45   -#define SQLVCHAR ECPGt_char
46   -#define SQLINTERVAL ECPGt_interval
47   -#define SQLNCHAR ECPGt_char
48   -#define SQLNVCHAR ECPGt_char
49   -#ifdef HAVE_LONG_LONG_INT_64
50   -#define SQLINT8 ECPGt_long_long
51   -#define SQLSERIAL8 ECPGt_long_long
52   -#else
53   -#define SQLINT8 ECPGt_long
54   -#define SQLSERIAL8 ECPGt_long
55   -#endif
56   -
57   -#endif /* ndef ECPG_SQLTYPES_H */
  1 +#ifndef ECPG_SQLTYPES_H
  2 +#define ECPG_SQLTYPES_H
  3 +
  4 +#include <limits.h>
  5 +
  6 +#define CCHARTYPE ECPGt_char
  7 +#define CSHORTTYPE ECPGt_short
  8 +#define CINTTYPE ECPGt_int
  9 +#define CLONGTYPE ECPGt_long
  10 +#define CFLOATTYPE ECPGt_float
  11 +#define CDOUBLETYPE ECPGt_double
  12 +#define CDECIMALTYPE ECPGt_decimal
  13 +#define CFIXCHARTYPE 108
  14 +#define CSTRINGTYPE ECPGt_char
  15 +#define CDATETYPE ECPGt_date
  16 +#define CMONEYTYPE 111
  17 +#define CDTIMETYPE ECPGt_timestamp
  18 +#define CLOCATORTYPE 113
  19 +#define CVCHARTYPE ECPGt_varchar
  20 +#define CINVTYPE 115
  21 +#define CFILETYPE 116
  22 +#define CINT8TYPE ECPGt_long_long
  23 +#define CCOLLTYPE 118
  24 +#define CLVCHARTYPE 119
  25 +#define CFIXBINTYPE 120
  26 +#define CVARBINTYPE 121
  27 +#define CBOOLTYPE ECPGt_bool
  28 +#define CROWTYPE 123
  29 +#define CLVCHARPTRTYPE 124
  30 +#define CTYPEMAX 25
  31 +
  32 +/*
  33 + * Values used in sqlda->sqlvar[i]->sqltype
  34 + */
  35 +#define SQLCHAR ECPGt_char
  36 +#define SQLSMINT ECPGt_short
  37 +#define SQLINT ECPGt_int
  38 +#define SQLFLOAT ECPGt_double
  39 +#define SQLSMFLOAT ECPGt_float
  40 +#define SQLDECIMAL ECPGt_decimal
  41 +#define SQLSERIAL ECPGt_int
  42 +#define SQLDATE ECPGt_date
  43 +#define SQLDTIME ECPGt_timestamp
  44 +#define SQLTEXT ECPGt_char
  45 +#define SQLVCHAR ECPGt_char
  46 +#define SQLINTERVAL ECPGt_interval
  47 +#define SQLNCHAR ECPGt_char
  48 +#define SQLNVCHAR ECPGt_char
  49 +#ifdef HAVE_LONG_LONG_INT_64
  50 +#define SQLINT8 ECPGt_long_long
  51 +#define SQLSERIAL8 ECPGt_long_long
  52 +#else
  53 +#define SQLINT8 ECPGt_long
  54 +#define SQLSERIAL8 ECPGt_long
  55 +#endif
  56 +
  57 +#endif /* ndef ECPG_SQLTYPES_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-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   - * Append PG_USED_FOR_ASSERTS_ONLY to definitions of variables that are only
117   - * used in assert-enabled builds, to avoid compiler warnings about unused
118   - * variables in assert-disabled builds.
119   - */
120   -#ifdef USE_ASSERT_CHECKING
121   -#define PG_USED_FOR_ASSERTS_ONLY
122   -#else
123   -#define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused()
124   -#endif
125   -
126   -/* GCC and XLC support format attributes */
127   -#if defined(__GNUC__) || defined(__IBMC__)
128   -#define pg_attribute_format_arg(a) __attribute__((format_arg(a)))
129   -#define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))
130   -#else
131   -#define pg_attribute_format_arg(a)
132   -#define pg_attribute_printf(f,a)
133   -#endif
134   -
135   -/* GCC, Sunpro and XLC support aligned, packed and noreturn */
136   -#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
137   -#define pg_attribute_aligned(a) __attribute__((aligned(a)))
138   -#define pg_attribute_noreturn() __attribute__((noreturn))
139   -#define pg_attribute_packed() __attribute__((packed))
140   -#define HAVE_PG_ATTRIBUTE_NORETURN 1
141   -#else
142   -/*
143   - * NB: aligned and packed are not given default definitions because they
144   - * affect code functionality; they *must* be implemented by the compiler
145   - * if they are to be used.
146   - */
147   -#define pg_attribute_noreturn()
148   -#endif
149   -
150   -/*
151   - * Use "pg_attribute_always_inline" in place of "inline" for functions that
152   - * we wish to force inlining of, even when the compiler's heuristics would
153   - * choose not to. But, if possible, don't force inlining in unoptimized
154   - * debug builds.
155   - */
156   -#if (defined(__GNUC__) && __GNUC__ > 3 && defined(__OPTIMIZE__)) || defined(__SUNPRO_C) || defined(__IBMC__)
157   -/* GCC > 3, Sunpro and XLC support always_inline via __attribute__ */
158   -#define pg_attribute_always_inline __attribute__((always_inline)) inline
159   -#elif defined(_MSC_VER)
160   -/* MSVC has a special keyword for this */
161   -#define pg_attribute_always_inline __forceinline
162   -#else
163   -/* Otherwise, the best we can do is to say "inline" */
164   -#define pg_attribute_always_inline inline
165   -#endif
166   -
167   -/*
168   - * Forcing a function not to be inlined can be useful if it's the slow path of
169   - * a performance-critical function, or should be visible in profiles to allow
170   - * for proper cost attribution. Note that unlike the pg_attribute_XXX macros
171   - * above, this should be placed before the function's return type and name.
172   - */
173   -/* GCC, Sunpro and XLC support noinline via __attribute__ */
174   -#if (defined(__GNUC__) && __GNUC__ > 2) || defined(__SUNPRO_C) || defined(__IBMC__)
175   -#define pg_noinline __attribute__((noinline))
176   -/* msvc via declspec */
177   -#elif defined(_MSC_VER)
178   -#define pg_noinline __declspec(noinline)
179   -#else
180   -#define pg_noinline
181   -#endif
182   -
183   -/*
184   - * Mark a point as unreachable in a portable fashion. This should preferably
185   - * be something that the compiler understands, to aid code generation.
186   - * In assert-enabled builds, we prefer abort() for debugging reasons.
187   - */
188   -#if defined(HAVE__BUILTIN_UNREACHABLE) && !defined(USE_ASSERT_CHECKING)
189   -#define pg_unreachable() __builtin_unreachable()
190   -#elif defined(_MSC_VER) && !defined(USE_ASSERT_CHECKING)
191   -#define pg_unreachable() __assume(0)
192   -#else
193   -#define pg_unreachable() abort()
194   -#endif
195   -
196   -/*
197   - * Hints to the compiler about the likelihood of a branch. Both likely() and
198   - * unlikely() return the boolean value of the contained expression.
199   - *
200   - * These should only be used sparingly, in very hot code paths. It's very easy
201   - * to mis-estimate likelihoods.
202   - */
203   -#if __GNUC__ >= 3
204   -#define likely(x) __builtin_expect((x) != 0, 1)
205   -#define unlikely(x) __builtin_expect((x) != 0, 0)
206   -#else
207   -#define likely(x) ((x) != 0)
208   -#define unlikely(x) ((x) != 0)
209   -#endif
210   -
211   -/*
212   - * CppAsString
213   - * Convert the argument to a string, using the C preprocessor.
214   - * CppAsString2
215   - * Convert the argument to a string, after one round of macro expansion.
216   - * CppConcat
217   - * Concatenate two arguments together, using the C preprocessor.
218   - *
219   - * Note: There used to be support here for pre-ANSI C compilers that didn't
220   - * support # and ##. Nowadays, these macros are just for clarity and/or
221   - * backward compatibility with existing PostgreSQL code.
222   - */
223   -#define CppAsString(identifier) #identifier
224   -#define CppAsString2(x) CppAsString(x)
225   -#define CppConcat(x, y) x##y
226   -
227   -/*
228   - * dummyret is used to set return values in macros that use ?: to make
229   - * assignments. gcc wants these to be void, other compilers like char
230   - */
231   -#ifdef __GNUC__ /* GNU cc */
232   -#define dummyret void
233   -#else
234   -#define dummyret char
235   -#endif
236   -
237   -/* Which __func__ symbol do we have, if any? */
238   -#ifdef HAVE_FUNCNAME__FUNC
239   -#define PG_FUNCNAME_MACRO __func__
240   -#else
241   -#ifdef HAVE_FUNCNAME__FUNCTION
242   -#define PG_FUNCNAME_MACRO __FUNCTION__
243   -#else
244   -#define PG_FUNCNAME_MACRO NULL
245   -#endif
246   -#endif
247   -
248   -
249   -/* ----------------------------------------------------------------
250   - * Section 2: bool, true, false
251   - * ----------------------------------------------------------------
252   - */
253   -
254   -/*
255   - * bool
256   - * Boolean value, either true or false.
257   - *
258   - * Use stdbool.h if available and its bool has size 1. That's useful for
259   - * better compiler and debugger output and for compatibility with third-party
260   - * libraries. But PostgreSQL currently cannot deal with bool of other sizes;
261   - * there are static assertions around the code to prevent that.
262   - *
263   - * For C++ compilers, we assume the compiler has a compatible built-in
264   - * definition of bool.
265   - */
266   -
267   -#ifndef __cplusplus
268   -
269   -#if defined(HAVE_STDBOOL_H) && SIZEOF_BOOL == 1
270   -#include <stdbool.h>
271   -#define USE_STDBOOL 1
272   -#else
273   -
274   -#ifndef bool
275   -typedef char bool;
276   -#endif
277   -
278   -#ifndef true
279   -#define true ((bool) 1)
280   -#endif
281   -
282   -#ifndef false
283   -#define false ((bool) 0)
284   -#endif
285   -
286   -#endif
287   -#endif /* not C++ */
288   -
289   -
290   -/* ----------------------------------------------------------------
291   - * Section 3: standard system types
292   - * ----------------------------------------------------------------
293   - */
294   -
295   -/*
296   - * Pointer
297   - * Variable holding address of any memory resident object.
298   - *
299   - * XXX Pointer arithmetic is done with this, so it can't be void *
300   - * under "true" ANSI compilers.
301   - */
302   -typedef char *Pointer;
303   -
304   -/*
305   - * intN
306   - * Signed integer, EXACTLY N BITS IN SIZE,
307   - * used for numerical computations and the
308   - * frontend/backend protocol.
309   - */
310   -#ifndef HAVE_INT8
311   -typedef signed char int8; /* == 8 bits */
312   -typedef signed short int16; /* == 16 bits */
313   -typedef signed int int32; /* == 32 bits */
314   -#endif /* not HAVE_INT8 */
315   -
316   -/*
317   - * uintN
318   - * Unsigned integer, EXACTLY N BITS IN SIZE,
319   - * used for numerical computations and the
320   - * frontend/backend protocol.
321   - */
322   -#ifndef HAVE_UINT8
323   -typedef unsigned char uint8; /* == 8 bits */
324   -typedef unsigned short uint16; /* == 16 bits */
325   -typedef unsigned int uint32; /* == 32 bits */
326   -#endif /* not HAVE_UINT8 */
327   -
328   -/*
329   - * bitsN
330   - * Unit of bitwise operation, AT LEAST N BITS IN SIZE.
331   - */
332   -typedef uint8 bits8; /* >= 8 bits */
333   -typedef uint16 bits16; /* >= 16 bits */
334   -typedef uint32 bits32; /* >= 32 bits */
335   -
336   -/*
337   - * 64-bit integers
338   - */
339   -#ifdef HAVE_LONG_INT_64
340   -/* Plain "long int" fits, use it */
341   -
342   -#ifndef HAVE_INT64
343   -typedef long int int64;
344   -#endif
345   -#ifndef HAVE_UINT64
346   -typedef unsigned long int uint64;
347   -#endif
348   -#define INT64CONST(x) (x##L)
349   -#define UINT64CONST(x) (x##UL)
350   -#elif defined(HAVE_LONG_LONG_INT_64)
351   -/* We have working support for "long long int", use that */
352   -
353   -#ifndef HAVE_INT64
354   -typedef long long int int64;
355   -#endif
356   -#ifndef HAVE_UINT64
357   -typedef unsigned long long int uint64;
358   -#endif
359   -#define INT64CONST(x) (x##LL)
360   -#define UINT64CONST(x) (x##ULL)
361   -#else
362   -/* neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 */
363   -#error must have a working 64-bit integer datatype
364   -#endif
365   -
366   -/* snprintf format strings to use for 64-bit integers */
367   -#define INT64_FORMAT "%" INT64_MODIFIER "d"
368   -#define UINT64_FORMAT "%" INT64_MODIFIER "u"
369   -
370   -/*
371   - * 128-bit signed and unsigned integers
372   - * There currently is only limited support for such types.
373   - * E.g. 128bit literals and snprintf are not supported; but math is.
374   - * Also, because we exclude such types when choosing MAXIMUM_ALIGNOF,
375   - * it must be possible to coerce the compiler to allocate them on no
376   - * more than MAXALIGN boundaries.
377   - */
378   -#if defined(PG_INT128_TYPE)
379   -#if defined(pg_attribute_aligned) || ALIGNOF_PG_INT128_TYPE <= MAXIMUM_ALIGNOF
380   -#define HAVE_INT128 1
381   -
382   -typedef PG_INT128_TYPE int128
383   -#if defined(pg_attribute_aligned)
384   -pg_attribute_aligned(MAXIMUM_ALIGNOF)
385   -#endif
386   -;
387   -
388   -typedef unsigned PG_INT128_TYPE uint128
389   -#if defined(pg_attribute_aligned)
390   -pg_attribute_aligned(MAXIMUM_ALIGNOF)
391   -#endif
392   -;
393   -
394   -#endif
395   -#endif
396   -
397   -/*
398   - * stdint.h limits aren't guaranteed to be present and aren't guaranteed to
399   - * have compatible types with our fixed width types. So just define our own.
400   - */
401   -#define PG_INT8_MIN (-0x7F-1)
402   -#define PG_INT8_MAX (0x7F)
403   -#define PG_UINT8_MAX (0xFF)
404   -#define PG_INT16_MIN (-0x7FFF-1)
405   -#define PG_INT16_MAX (0x7FFF)
406   -#define PG_UINT16_MAX (0xFFFF)
407   -#define PG_INT32_MIN (-0x7FFFFFFF-1)
408   -#define PG_INT32_MAX (0x7FFFFFFF)
409   -#define PG_UINT32_MAX (0xFFFFFFFFU)
410   -#define PG_INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1)
411   -#define PG_INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF)
412   -#define PG_UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF)
413   -
414   -/* Max value of size_t might also be missing if we don't have stdint.h */
415   -#ifndef SIZE_MAX
416   -#if SIZEOF_SIZE_T == 8
417   -#define SIZE_MAX PG_UINT64_MAX
418   -#else
419   -#define SIZE_MAX PG_UINT32_MAX
420   -#endif
421   -#endif
422   -
423   -/*
424   - * We now always use int64 timestamps, but keep this symbol defined for the
425   - * benefit of external code that might test it.
426   - */
427   -#define HAVE_INT64_TIMESTAMP
428   -
429   -/*
430   - * Size
431   - * Size of any memory resident object, as returned by sizeof.
432   - */
433   -typedef size_t Size;
434   -
435   -/*
436   - * Index
437   - * Index into any memory resident array.
438   - *
439   - * Note:
440   - * Indices are non negative.
441   - */
442   -typedef unsigned int Index;
443   -
444   -/*
445   - * Offset
446   - * Offset into any memory resident array.
447   - *
448   - * Note:
449   - * This differs from an Index in that an Index is always
450   - * non negative, whereas Offset may be negative.
451   - */
452   -typedef signed int Offset;
453   -
454   -/*
455   - * Common Postgres datatype names (as used in the catalogs)
456   - */
457   -typedef float float4;
458   -typedef double float8;
459   -
460   -/*
461   - * Oid, RegProcedure, TransactionId, SubTransactionId, MultiXactId,
462   - * CommandId
463   - */
464   -
465   -/* typedef Oid is in postgres_ext.h */
466   -
467   -/*
468   - * regproc is the type name used in the include/catalog headers, but
469   - * RegProcedure is the preferred name in C code.
470   - */
471   -typedef Oid regproc;
472   -typedef regproc RegProcedure;
473   -
474   -typedef uint32 TransactionId;
475   -
476   -typedef uint32 LocalTransactionId;
477   -
478   -typedef uint32 SubTransactionId;
479   -
480   -#define InvalidSubTransactionId ((SubTransactionId) 0)
481   -#define TopSubTransactionId ((SubTransactionId) 1)
482   -
483   -/* MultiXactId must be equivalent to TransactionId, to fit in t_xmax */
484   -typedef TransactionId MultiXactId;
485   -
486   -typedef uint32 MultiXactOffset;
487   -
488   -typedef uint32 CommandId;
489   -
490   -#define FirstCommandId ((CommandId) 0)
491   -#define InvalidCommandId (~(CommandId)0)
492   -
493   -/*
494   - * Array indexing support
495   - */
496   -#define MAXDIM 6
497   -typedef struct
498   -{
499   - int indx[MAXDIM];
500   -} IntArray;
501   -
502   -/* ----------------
503   - * Variable-length datatypes all share the 'struct varlena' header.
504   - *
505   - * NOTE: for TOASTable types, this is an oversimplification, since the value
506   - * may be compressed or moved out-of-line. However datatype-specific routines
507   - * are mostly content to deal with de-TOASTed values only, and of course
508   - * client-side routines should never see a TOASTed value. But even in a
509   - * de-TOASTed value, beware of touching vl_len_ directly, as its
510   - * representation is no longer convenient. It's recommended that code always
511   - * use macros VARDATA_ANY, VARSIZE_ANY, VARSIZE_ANY_EXHDR, VARDATA, VARSIZE,
512   - * and SET_VARSIZE instead of relying on direct mentions of the struct fields.
513   - * See postgres.h for details of the TOASTed form.
514   - * ----------------
515   - */
516   -struct varlena
517   -{
518   - char vl_len_[4]; /* Do not touch this field directly! */
519   - char vl_dat[FLEXIBLE_ARRAY_MEMBER]; /* Data content is here */
520   -};
521   -
522   -#define VARHDRSZ ((int32) sizeof(int32))
523   -
524   -/*
525   - * These widely-used datatypes are just a varlena header and the data bytes.
526   - * There is no terminating null or anything like that --- the data length is
527   - * always VARSIZE_ANY_EXHDR(ptr).
528   - */
529   -typedef struct varlena bytea;
530   -typedef struct varlena text;
531   -typedef struct varlena BpChar; /* blank-padded char, ie SQL char(n) */
532   -typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */
533   -
534   -/*
535   - * Specialized array types. These are physically laid out just the same
536   - * as regular arrays (so that the regular array subscripting code works
537   - * with them). They exist as distinct types mostly for historical reasons:
538   - * they have nonstandard I/O behavior which we don't want to change for fear
539   - * of breaking applications that look at the system catalogs. There is also
540   - * an implementation issue for oidvector: it's part of the primary key for
541   - * pg_proc, and we can't use the normal btree array support routines for that
542   - * without circularity.
543   - */
544   -typedef struct
545   -{
546   - int32 vl_len_; /* these fields must match ArrayType! */
547   - int ndim; /* always 1 for int2vector */
548   - int32 dataoffset; /* always 0 for int2vector */
549   - Oid elemtype;
550   - int dim1;
551   - int lbound1;
552   - int16 values[FLEXIBLE_ARRAY_MEMBER];
553   -} int2vector;
554   -
555   -typedef struct
556   -{
557   - int32 vl_len_; /* these fields must match ArrayType! */
558   - int ndim; /* always 1 for oidvector */
559   - int32 dataoffset; /* always 0 for oidvector */
560   - Oid elemtype;
561   - int dim1;
562   - int lbound1;
563   - Oid values[FLEXIBLE_ARRAY_MEMBER];
564   -} oidvector;
565   -
566   -/*
567   - * Representation of a Name: effectively just a C string, but null-padded to
568   - * exactly NAMEDATALEN bytes. The use of a struct is historical.
569   - */
570   -typedef struct nameData
571   -{
572   - char data[NAMEDATALEN];
573   -} NameData;
574   -typedef NameData *Name;
575   -
576   -#define NameStr(name) ((name).data)
577   -
578   -
579   -/* ----------------------------------------------------------------
580   - * Section 4: IsValid macros for system types
581   - * ----------------------------------------------------------------
582   - */
583   -/*
584   - * BoolIsValid
585   - * True iff bool is valid.
586   - */
587   -#define BoolIsValid(boolean) ((boolean) == false || (boolean) == true)
588   -
589   -/*
590   - * PointerIsValid
591   - * True iff pointer is valid.
592   - */
593   -#define PointerIsValid(pointer) ((const void*)(pointer) != NULL)
594   -
595   -/*
596   - * PointerIsAligned
597   - * True iff pointer is properly aligned to point to the given type.
598   - */
599   -#define PointerIsAligned(pointer, type) \
600   - (((uintptr_t)(pointer) % (sizeof (type))) == 0)
601   -
602   -#define OffsetToPointer(base, offset) \
603   - ((void *)((char *) base + offset))
604   -
605   -#define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))
606   -
607   -#define RegProcedureIsValid(p) OidIsValid(p)
608   -
609   -
610   -/* ----------------------------------------------------------------
611   - * Section 5: offsetof, lengthof, alignment
612   - * ----------------------------------------------------------------
613   - */
614   -/*
615   - * offsetof
616   - * Offset of a structure/union field within that structure/union.
617   - *
618   - * XXX This is supposed to be part of stddef.h, but isn't on
619   - * some systems (like SunOS 4).
620   - */
621   -#ifndef offsetof
622   -#define offsetof(type, field) ((long) &((type *)0)->field)
623   -#endif /* offsetof */
624   -
625   -/*
626   - * lengthof
627   - * Number of elements in an array.
628   - */
629   -#define lengthof(array) (sizeof (array) / sizeof ((array)[0]))
630   -
631   -/* ----------------
632   - * Alignment macros: align a length or address appropriately for a given type.
633   - * The fooALIGN() macros round up to a multiple of the required alignment,
634   - * while the fooALIGN_DOWN() macros round down. The latter are more useful
635   - * for problems like "how many X-sized structures will fit in a page?".
636   - *
637   - * NOTE: TYPEALIGN[_DOWN] will not work if ALIGNVAL is not a power of 2.
638   - * That case seems extremely unlikely to be needed in practice, however.
639   - *
640   - * NOTE: MAXIMUM_ALIGNOF, and hence MAXALIGN(), intentionally exclude any
641   - * larger-than-8-byte types the compiler might have.
642   - * ----------------
643   - */
644   -
645   -#define TYPEALIGN(ALIGNVAL,LEN) \
646   - (((uintptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((uintptr_t) ((ALIGNVAL) - 1)))
647   -
648   -#define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN))
649   -#define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN))
650   -#define LONGALIGN(LEN) TYPEALIGN(ALIGNOF_LONG, (LEN))
651   -#define DOUBLEALIGN(LEN) TYPEALIGN(ALIGNOF_DOUBLE, (LEN))
652   -#define MAXALIGN(LEN) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))
653   -/* MAXALIGN covers only built-in types, not buffers */
654   -#define BUFFERALIGN(LEN) TYPEALIGN(ALIGNOF_BUFFER, (LEN))
655   -#define CACHELINEALIGN(LEN) TYPEALIGN(PG_CACHE_LINE_SIZE, (LEN))
656   -
657   -#define TYPEALIGN_DOWN(ALIGNVAL,LEN) \
658   - (((uintptr_t) (LEN)) & ~((uintptr_t) ((ALIGNVAL) - 1)))
659   -
660   -#define SHORTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN))
661   -#define INTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT, (LEN))
662   -#define LONGALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_LONG, (LEN))
663   -#define DOUBLEALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_DOUBLE, (LEN))
664   -#define MAXALIGN_DOWN(LEN) TYPEALIGN_DOWN(MAXIMUM_ALIGNOF, (LEN))
665   -#define BUFFERALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_BUFFER, (LEN))
666   -
667   -/*
668   - * The above macros will not work with types wider than uintptr_t, like with
669   - * uint64 on 32-bit platforms. That's not problem for the usual use where a
670   - * pointer or a length is aligned, but for the odd case that you need to
671   - * align something (potentially) wider, use TYPEALIGN64.
672   - */
673   -#define TYPEALIGN64(ALIGNVAL,LEN) \
674   - (((uint64) (LEN) + ((ALIGNVAL) - 1)) & ~((uint64) ((ALIGNVAL) - 1)))
675   -
676   -/* we don't currently need wider versions of the other ALIGN macros */
677   -#define MAXALIGN64(LEN) TYPEALIGN64(MAXIMUM_ALIGNOF, (LEN))
678   -
679   -
680   -/* ----------------------------------------------------------------
681   - * Section 6: assertions
682   - * ----------------------------------------------------------------
683   - */
684   -
685   -/*
686   - * USE_ASSERT_CHECKING, if defined, turns on all the assertions.
687   - * - plai 9/5/90
688   - *
689   - * It should _NOT_ be defined in releases or in benchmark copies
690   - */
691   -
692   -/*
693   - * Assert() can be used in both frontend and backend code. In frontend code it
694   - * just calls the standard assert, if it's available. If use of assertions is
695   - * not configured, it does nothing.
696   - */
697   -#ifndef USE_ASSERT_CHECKING
698   -
699   -#define Assert(condition) ((void)true)
700   -#define AssertMacro(condition) ((void)true)
701   -#define AssertArg(condition) ((void)true)
702   -#define AssertState(condition) ((void)true)
703   -#define AssertPointerAlignment(ptr, bndr) ((void)true)
704   -#define Trap(condition, errorType) ((void)true)
705   -#define TrapMacro(condition, errorType) (true)
706   -
707   -#elif defined(FRONTEND)
708   -
709   -#include <assert.h>
710   -#define Assert(p) assert(p)
711   -#define AssertMacro(p) ((void) assert(p))
712   -#define AssertArg(condition) assert(condition)
713   -#define AssertState(condition) assert(condition)
714   -#define AssertPointerAlignment(ptr, bndr) ((void)true)
715   -
716   -#else /* USE_ASSERT_CHECKING && !FRONTEND */
717   -
718   -/*
719   - * Trap
720   - * Generates an exception if the given condition is true.
721   - */
722   -#define Trap(condition, errorType) \
723   - do { \
724   - if (condition) \
725   - ExceptionalCondition(CppAsString(condition), (errorType), \
726   - __FILE__, __LINE__); \
727   - } while (0)
728   -
729   -/*
730   - * TrapMacro is the same as Trap but it's intended for use in macros:
731   - *
732   - * #define foo(x) (AssertMacro(x != 0), bar(x))
733   - *
734   - * Isn't CPP fun?
735   - */
736   -#define TrapMacro(condition, errorType) \
737   - ((bool) (! (condition) || \
738   - (ExceptionalCondition(CppAsString(condition), (errorType), \
739   - __FILE__, __LINE__), 0)))
740   -
741   -#define Assert(condition) \
742   - Trap(!(condition), "FailedAssertion")
743   -
744   -#define AssertMacro(condition) \
745   - ((void) TrapMacro(!(condition), "FailedAssertion"))
746   -
747   -#define AssertArg(condition) \
748   - Trap(!(condition), "BadArgument")
749   -
750   -#define AssertState(condition) \
751   - Trap(!(condition), "BadState")
752   -
753   -/*
754   - * Check that `ptr' is `bndr' aligned.
755   - */
756   -#define AssertPointerAlignment(ptr, bndr) \
757   - Trap(TYPEALIGN(bndr, (uintptr_t)(ptr)) != (uintptr_t)(ptr), \
758   - "UnalignedPointer")
759   -
760   -#endif /* USE_ASSERT_CHECKING && !FRONTEND */
761   -
762   -/*
763   - * ExceptionalCondition is compiled into the backend whether or not
764   - * USE_ASSERT_CHECKING is defined, so as to support use of extensions
765   - * that are built with that #define with a backend that isn't. Hence,
766   - * we should declare it as long as !FRONTEND.
767   - */
768   -#ifndef FRONTEND
769   -extern void ExceptionalCondition(const char *conditionName,
770   - const char *errorType,
771   - const char *fileName, int lineNumber) pg_attribute_noreturn();
772   -#endif
773   -
774   -/*
775   - * Macros to support compile-time assertion checks.
776   - *
777   - * If the "condition" (a compile-time-constant expression) evaluates to false,
778   - * throw a compile error using the "errmessage" (a string literal).
779   - *
780   - * gcc 4.6 and up supports _Static_assert(), but there are bizarre syntactic
781   - * placement restrictions. These macros make it safe to use as a statement
782   - * or in an expression, respectively.
783   - *
784   - * Otherwise we fall back on a kluge that assumes the compiler will complain
785   - * about a negative width for a struct bit-field. This will not include a
786   - * helpful error message, but it beats not getting an error at all.
787   - */
788   -#ifndef __cplusplus
789   -#ifdef HAVE__STATIC_ASSERT
790   -#define StaticAssertStmt(condition, errmessage) \
791   - do { _Static_assert(condition, errmessage); } while(0)
792   -#define StaticAssertExpr(condition, errmessage) \
793   - ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
794   -#else /* !HAVE__STATIC_ASSERT */
795   -#define StaticAssertStmt(condition, errmessage) \
796   - ((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; }))
797   -#define StaticAssertExpr(condition, errmessage) \
798   - StaticAssertStmt(condition, errmessage)
799   -#endif /* HAVE__STATIC_ASSERT */
800   -#else /* C++ */
801   -#if defined(__cpp_static_assert) && __cpp_static_assert >= 200410
802   -#define StaticAssertStmt(condition, errmessage) \
803   - static_assert(condition, errmessage)
804   -#define StaticAssertExpr(condition, errmessage) \
805   - ({ static_assert(condition, errmessage); })
806   -#else
807   -#define StaticAssertStmt(condition, errmessage) \
808   - do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0)
809   -#define StaticAssertExpr(condition, errmessage) \
810   - ((void) ({ StaticAssertStmt(condition, errmessage); }))
811   -#endif
812   -#endif /* C++ */
813   -
814   -
815   -/*
816   - * Compile-time checks that a variable (or expression) has the specified type.
817   - *
818   - * AssertVariableIsOfType() can be used as a statement.
819   - * AssertVariableIsOfTypeMacro() is intended for use in macros, eg
820   - * #define foo(x) (AssertVariableIsOfTypeMacro(x, int), bar(x))
821   - *
822   - * If we don't have __builtin_types_compatible_p, we can still assert that
823   - * the types have the same size. This is far from ideal (especially on 32-bit
824   - * platforms) but it provides at least some coverage.
825   - */
826   -#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P
827   -#define AssertVariableIsOfType(varname, typename) \
828   - StaticAssertStmt(__builtin_types_compatible_p(__typeof__(varname), typename), \
829   - CppAsString(varname) " does not have type " CppAsString(typename))
830   -#define AssertVariableIsOfTypeMacro(varname, typename) \
831   - (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
832   - CppAsString(varname) " does not have type " CppAsString(typename)))
833   -#else /* !HAVE__BUILTIN_TYPES_COMPATIBLE_P */
834   -#define AssertVariableIsOfType(varname, typename) \
835   - StaticAssertStmt(sizeof(varname) == sizeof(typename), \
836   - CppAsString(varname) " does not have type " CppAsString(typename))
837   -#define AssertVariableIsOfTypeMacro(varname, typename) \
838   - (StaticAssertExpr(sizeof(varname) == sizeof(typename), \
839   - CppAsString(varname) " does not have type " CppAsString(typename)))
840   -#endif /* HAVE__BUILTIN_TYPES_COMPATIBLE_P */
841   -
842   -
843   -/* ----------------------------------------------------------------
844   - * Section 7: widely useful macros
845   - * ----------------------------------------------------------------
846   - */
847   -/*
848   - * Max
849   - * Return the maximum of two numbers.
850   - */
851   -#define Max(x, y) ((x) > (y) ? (x) : (y))
852   -
853   -/*
854   - * Min
855   - * Return the minimum of two numbers.
856   - */
857   -#define Min(x, y) ((x) < (y) ? (x) : (y))
858   -
859   -/*
860   - * Abs
861   - * Return the absolute value of the argument.
862   - */
863   -#define Abs(x) ((x) >= 0 ? (x) : -(x))
864   -
865   -/*
866   - * StrNCpy
867   - * Like standard library function strncpy(), except that result string
868   - * is guaranteed to be null-terminated --- that is, at most N-1 bytes
869   - * of the source string will be kept.
870   - * Also, the macro returns no result (too hard to do that without
871   - * evaluating the arguments multiple times, which seems worse).
872   - *
873   - * BTW: when you need to copy a non-null-terminated string (like a text
874   - * datum) and add a null, do not do it with StrNCpy(..., len+1). That
875   - * might seem to work, but it fetches one byte more than there is in the
876   - * text object. One fine day you'll have a SIGSEGV because there isn't
877   - * another byte before the end of memory. Don't laugh, we've had real
878   - * live bug reports from real live users over exactly this mistake.
879   - * Do it honestly with "memcpy(dst,src,len); dst[len] = '\0';", instead.
880   - */
881   -#define StrNCpy(dst,src,len) \
882   - do \
883   - { \
884   - char * _dst = (dst); \
885   - Size _len = (len); \
886   -\
887   - if (_len > 0) \
888   - { \
889   - strncpy(_dst, (src), _len); \
890   - _dst[_len-1] = '\0'; \
891   - } \
892   - } while (0)
893   -
894   -
895   -/* Get a bit mask of the bits set in non-long aligned addresses */
896   -#define LONG_ALIGN_MASK (sizeof(long) - 1)
897   -
898   -/*
899   - * MemSet
900   - * Exactly the same as standard library function memset(), but considerably
901   - * faster for zeroing small word-aligned structures (such as parsetree nodes).
902   - * This has to be a macro because the main point is to avoid function-call
903   - * overhead. However, we have also found that the loop is faster than
904   - * native libc memset() on some platforms, even those with assembler
905   - * memset() functions. More research needs to be done, perhaps with
906   - * MEMSET_LOOP_LIMIT tests in configure.
907   - */
908   -#define MemSet(start, val, len) \
909   - do \
910   - { \
911   - /* must be void* because we don't know if it is integer aligned yet */ \
912   - void *_vstart = (void *) (start); \
913   - int _val = (val); \
914   - Size _len = (len); \
915   -\
916   - if ((((uintptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \
917   - (_len & LONG_ALIGN_MASK) == 0 && \
918   - _val == 0 && \
919   - _len <= MEMSET_LOOP_LIMIT && \
920   - /* \
921   - * If MEMSET_LOOP_LIMIT == 0, optimizer should find \
922   - * the whole "if" false at compile time. \
923   - */ \
924   - MEMSET_LOOP_LIMIT != 0) \
925   - { \
926   - long *_start = (long *) _vstart; \
927   - long *_stop = (long *) ((char *) _start + _len); \
928   - while (_start < _stop) \
929   - *_start++ = 0; \
930   - } \
931   - else \
932   - memset(_vstart, _val, _len); \
933   - } while (0)
934   -
935   -/*
936   - * MemSetAligned is the same as MemSet except it omits the test to see if
937   - * "start" is word-aligned. This is okay to use if the caller knows a-priori
938   - * that the pointer is suitably aligned (typically, because he just got it
939   - * from palloc(), which always delivers a max-aligned pointer).
940   - */
941   -#define MemSetAligned(start, val, len) \
942   - do \
943   - { \
944   - long *_start = (long *) (start); \
945   - int _val = (val); \
946   - Size _len = (len); \
947   -\
948   - if ((_len & LONG_ALIGN_MASK) == 0 && \
949   - _val == 0 && \
950   - _len <= MEMSET_LOOP_LIMIT && \
951   - MEMSET_LOOP_LIMIT != 0) \
952   - { \
953   - long *_stop = (long *) ((char *) _start + _len); \
954   - while (_start < _stop) \
955   - *_start++ = 0; \
956   - } \
957   - else \
958   - memset(_start, _val, _len); \
959   - } while (0)
960   -
961   -
962   -/*
963   - * MemSetTest/MemSetLoop are a variant version that allow all the tests in
964   - * MemSet to be done at compile time in cases where "val" and "len" are
965   - * constants *and* we know the "start" pointer must be word-aligned.
966   - * If MemSetTest succeeds, then it is okay to use MemSetLoop, otherwise use
967   - * MemSetAligned. Beware of multiple evaluations of the arguments when using
968   - * this approach.
969   - */
970   -#define MemSetTest(val, len) \
971   - ( ((len) & LONG_ALIGN_MASK) == 0 && \
972   - (len) <= MEMSET_LOOP_LIMIT && \
973   - MEMSET_LOOP_LIMIT != 0 && \
974   - (val) == 0 )
975   -
976   -#define MemSetLoop(start, val, len) \
977   - do \
978   - { \
979   - long * _start = (long *) (start); \
980   - long * _stop = (long *) ((char *) _start + (Size) (len)); \
981   - \
982   - while (_start < _stop) \
983   - *_start++ = 0; \
984   - } while (0)
985   -
986   -
987   -/* ----------------------------------------------------------------
988   - * Section 8: random stuff
989   - * ----------------------------------------------------------------
990   - */
991   -
992   -/*
993   - * Invert the sign of a qsort-style comparison result, ie, exchange negative
994   - * and positive integer values, being careful not to get the wrong answer
995   - * for INT_MIN. The argument should be an integral variable.
996   - */
997   -#define INVERT_COMPARE_RESULT(var) \
998   - ((var) = ((var) < 0) ? 1 : -(var))
999   -
1000   -/*
1001   - * Use this, not "char buf[BLCKSZ]", to declare a field or local variable
1002   - * holding a page buffer, if that page might be accessed as a page and not
1003   - * just a string of bytes. Otherwise the variable might be under-aligned,
1004   - * causing problems on alignment-picky hardware. (In some places, we use
1005   - * this to declare buffers even though we only pass them to read() and
1006   - * write(), because copying to/from aligned buffers is usually faster than
1007   - * using unaligned buffers.) We include both "double" and "int64" in the
1008   - * union to ensure that the compiler knows the value must be MAXALIGN'ed
1009   - * (cf. configure's computation of MAXIMUM_ALIGNOF).
1010   - */
1011   -typedef union PGAlignedBlock
1012   -{
1013   - char data[BLCKSZ];
1014   - double force_align_d;
1015   - int64 force_align_i64;
1016   -} PGAlignedBlock;
1017   -
1018   -/* Same, but for an XLOG_BLCKSZ-sized buffer */
1019   -typedef union PGAlignedXLogBlock
1020   -{
1021   - char data[XLOG_BLCKSZ];
1022   - double force_align_d;
1023   - int64 force_align_i64;
1024   -} PGAlignedXLogBlock;
1025   -
1026   -/* msb for char */
1027   -#define HIGHBIT (0x80)
1028   -#define IS_HIGHBIT_SET(ch) ((unsigned char)(ch) & HIGHBIT)
1029   -
1030   -/*
1031   - * Support macros for escaping strings. escape_backslash should be true
1032   - * if generating a non-standard-conforming string. Prefixing a string
1033   - * with ESCAPE_STRING_SYNTAX guarantees it is non-standard-conforming.
1034   - * Beware of multiple evaluation of the "ch" argument!
1035   - */
1036   -#define SQL_STR_DOUBLE(ch, escape_backslash) \
1037   - ((ch) == '\'' || ((ch) == '\\' && (escape_backslash)))
1038   -
1039   -#define ESCAPE_STRING_SYNTAX 'E'
1040   -
1041   -
1042   -#define STATUS_OK (0)
1043   -#define STATUS_ERROR (-1)
1044   -#define STATUS_EOF (-2)
1045   -#define STATUS_FOUND (1)
1046   -#define STATUS_WAITING (2)
1047   -
1048   -/*
1049   - * gettext support
1050   - */
1051   -
1052   -#ifndef ENABLE_NLS
1053   -/* stuff we'd otherwise get from <libintl.h> */
1054   -#define gettext(x) (x)
1055   -#define dgettext(d,x) (x)
1056   -#define ngettext(s,p,n) ((n) == 1 ? (s) : (p))
1057   -#define dngettext(d,s,p,n) ((n) == 1 ? (s) : (p))
1058   -#endif
1059   -
1060   -#define _(x) gettext(x)
1061   -
1062   -/*
1063   - * Use this to mark string constants as needing translation at some later
1064   - * time, rather than immediately. This is useful for cases where you need
1065   - * access to the original string and translated string, and for cases where
1066   - * immediate translation is not possible, like when initializing global
1067   - * variables.
1068   - * http://www.gnu.org/software/autoconf/manual/gettext/Special-cases.html
1069   - */
1070   -#define gettext_noop(x) (x)
1071   -
1072   -/*
1073   - * To better support parallel installations of major PostgreSQL
1074   - * versions as well as parallel installations of major library soname
1075   - * versions, we mangle the gettext domain name by appending those
1076   - * version numbers. The coding rule ought to be that wherever the
1077   - * domain name is mentioned as a literal, it must be wrapped into
1078   - * PG_TEXTDOMAIN(). The macros below do not work on non-literals; but
1079   - * that is somewhat intentional because it avoids having to worry
1080   - * about multiple states of premangling and postmangling as the values
1081   - * are being passed around.
1082   - *
1083   - * Make sure this matches the installation rules in nls-global.mk.
1084   - */
1085   -#ifdef SO_MAJOR_VERSION
1086   -#define PG_TEXTDOMAIN(domain) (domain CppAsString2(SO_MAJOR_VERSION) "-" PG_MAJORVERSION)
1087   -#else
1088   -#define PG_TEXTDOMAIN(domain) (domain "-" PG_MAJORVERSION)
1089   -#endif
1090   -
1091   -
1092   -/* ----------------------------------------------------------------
1093   - * Section 9: system-specific hacks
1094   - *
1095   - * This should be limited to things that absolutely have to be
1096   - * included in every source file. The port-specific header file
1097   - * is usually a better place for this sort of thing.
1098   - * ----------------------------------------------------------------
1099   - */
1100   -
1101   -/*
1102   - * NOTE: this is also used for opening text files.
1103   - * WIN32 treats Control-Z as EOF in files opened in text mode.
1104   - * Therefore, we open files in binary mode on Win32 so we can read
1105   - * literal control-Z. The other affect is that we see CRLF, but
1106   - * that is OK because we can already handle those cleanly.
1107   - */
1108   -#if defined(WIN32) || defined(__CYGWIN__)
1109   -#define PG_BINARY O_BINARY
1110   -#define PG_BINARY_A "ab"
1111   -#define PG_BINARY_R "rb"
1112   -#define PG_BINARY_W "wb"
1113   -#else
1114   -#define PG_BINARY 0
1115   -#define PG_BINARY_A "a"
1116   -#define PG_BINARY_R "r"
1117   -#define PG_BINARY_W "w"
1118   -#endif
1119   -
1120   -/*
1121   - * Provide prototypes for routines not present in a particular machine's
1122   - * standard C library.
1123   - */
1124   -
1125   -#if !HAVE_DECL_SNPRINTF
1126   -extern int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3, 4);
1127   -#endif
1128   -
1129   -#if !HAVE_DECL_VSNPRINTF
1130   -extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
1131   -#endif
1132   -
1133   -#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
1134   -extern int fdatasync(int fildes);
1135   -#endif
1136   -
1137   -#ifdef HAVE_LONG_LONG_INT
1138   -/* Older platforms may provide strto[u]ll functionality under other names */
1139   -#if !defined(HAVE_STRTOLL) && defined(HAVE___STRTOLL)
1140   -#define strtoll __strtoll
1141   -#define HAVE_STRTOLL 1
1142   -#endif
1143   -
1144   -#if !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
1145   -#define strtoll strtoq
1146   -#define HAVE_STRTOLL 1
1147   -#endif
1148   -
1149   -#if !defined(HAVE_STRTOULL) && defined(HAVE___STRTOULL)
1150   -#define strtoull __strtoull
1151   -#define HAVE_STRTOULL 1
1152   -#endif
1153   -
1154   -#if !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
1155   -#define strtoull strtouq
1156   -#define HAVE_STRTOULL 1
1157   -#endif
1158   -
1159   -#if defined(HAVE_STRTOLL) && !HAVE_DECL_STRTOLL
1160   -extern long long strtoll(const char *str, char **endptr, int base);
1161   -#endif
1162   -
1163   -#if defined(HAVE_STRTOULL) && !HAVE_DECL_STRTOULL
1164   -extern unsigned long long strtoull(const char *str, char **endptr, int base);
1165   -#endif
1166   -#endif /* HAVE_LONG_LONG_INT */
1167   -
1168   -#if !defined(HAVE_MEMMOVE) && !defined(memmove)
1169   -#define memmove(d, s, c) bcopy(s, d, c)
1170   -#endif
1171   -
1172   -/* no special DLL markers on most ports */
1173   -#ifndef PGDLLIMPORT
1174   -#define PGDLLIMPORT
1175   -#endif
1176   -#ifndef PGDLLEXPORT
1177   -#define PGDLLEXPORT
1178   -#endif
1179   -
1180   -/*
1181   - * The following is used as the arg list for signal handlers. Any ports
1182   - * that take something other than an int argument should override this in
1183   - * their pg_config_os.h file. Note that variable names are required
1184   - * because it is used in both the prototypes as well as the definitions.
1185   - * Note also the long name. We expect that this won't collide with
1186   - * other names causing compiler warnings.
1187   - */
1188   -
1189   -#ifndef SIGNAL_ARGS
1190   -#define SIGNAL_ARGS int postgres_signal_arg
1191   -#endif
1192   -
1193   -/*
1194   - * When there is no sigsetjmp, its functionality is provided by plain
1195   - * setjmp. Incidentally, nothing provides setjmp's functionality in
1196   - * that case. We now support the case only on Windows.
1197   - */
1198   -#ifdef WIN32
1199   -#define sigjmp_buf jmp_buf
1200   -#define sigsetjmp(x,y) setjmp(x)
1201   -#define siglongjmp longjmp
1202   -#endif
1203   -
1204   -/* EXEC_BACKEND defines */
1205   -#ifdef EXEC_BACKEND
1206   -#define NON_EXEC_STATIC
1207   -#else
1208   -#define NON_EXEC_STATIC static
1209   -#endif
1210   -
1211   -/* /port compatibility functions */
1212   -#include "port.h"
1213   -
1214   -#endif /* 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-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 + * Append PG_USED_FOR_ASSERTS_ONLY to definitions of variables that are only
  117 + * used in assert-enabled builds, to avoid compiler warnings about unused
  118 + * variables in assert-disabled builds.
  119 + */
  120 +#ifdef USE_ASSERT_CHECKING
  121 +#define PG_USED_FOR_ASSERTS_ONLY
  122 +#else
  123 +#define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused()
  124 +#endif
  125 +
  126 +/* GCC and XLC support format attributes */
  127 +#if defined(__GNUC__) || defined(__IBMC__)
  128 +#define pg_attribute_format_arg(a) __attribute__((format_arg(a)))
  129 +#define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))
  130 +#else
  131 +#define pg_attribute_format_arg(a)
  132 +#define pg_attribute_printf(f,a)
  133 +#endif
  134 +
  135 +/* GCC, Sunpro and XLC support aligned, packed and noreturn */
  136 +#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
  137 +#define pg_attribute_aligned(a) __attribute__((aligned(a)))
  138 +#define pg_attribute_noreturn() __attribute__((noreturn))
  139 +#define pg_attribute_packed() __attribute__((packed))
  140 +#define HAVE_PG_ATTRIBUTE_NORETURN 1
  141 +#else
  142 +/*
  143 + * NB: aligned and packed are not given default definitions because they
  144 + * affect code functionality; they *must* be implemented by the compiler
  145 + * if they are to be used.
  146 + */
  147 +#define pg_attribute_noreturn()
  148 +#endif
  149 +
  150 +/*
  151 + * Use "pg_attribute_always_inline" in place of "inline" for functions that
  152 + * we wish to force inlining of, even when the compiler's heuristics would
  153 + * choose not to. But, if possible, don't force inlining in unoptimized
  154 + * debug builds.
  155 + */
  156 +#if (defined(__GNUC__) && __GNUC__ > 3 && defined(__OPTIMIZE__)) || defined(__SUNPRO_C) || defined(__IBMC__)
  157 +/* GCC > 3, Sunpro and XLC support always_inline via __attribute__ */
  158 +#define pg_attribute_always_inline __attribute__((always_inline)) inline
  159 +#elif defined(_MSC_VER)
  160 +/* MSVC has a special keyword for this */
  161 +#define pg_attribute_always_inline __forceinline
  162 +#else
  163 +/* Otherwise, the best we can do is to say "inline" */
  164 +#define pg_attribute_always_inline inline
  165 +#endif
  166 +
  167 +/*
  168 + * Forcing a function not to be inlined can be useful if it's the slow path of
  169 + * a performance-critical function, or should be visible in profiles to allow
  170 + * for proper cost attribution. Note that unlike the pg_attribute_XXX macros
  171 + * above, this should be placed before the function's return type and name.
  172 + */
  173 +/* GCC, Sunpro and XLC support noinline via __attribute__ */
  174 +#if (defined(__GNUC__) && __GNUC__ > 2) || defined(__SUNPRO_C) || defined(__IBMC__)
  175 +#define pg_noinline __attribute__((noinline))
  176 +/* msvc via declspec */
  177 +#elif defined(_MSC_VER)
  178 +#define pg_noinline __declspec(noinline)
  179 +#else
  180 +#define pg_noinline
  181 +#endif
  182 +
  183 +/*
  184 + * Mark a point as unreachable in a portable fashion. This should preferably
  185 + * be something that the compiler understands, to aid code generation.
  186 + * In assert-enabled builds, we prefer abort() for debugging reasons.
  187 + */
  188 +#if defined(HAVE__BUILTIN_UNREACHABLE) && !defined(USE_ASSERT_CHECKING)
  189 +#define pg_unreachable() __builtin_unreachable()
  190 +#elif defined(_MSC_VER) && !defined(USE_ASSERT_CHECKING)
  191 +#define pg_unreachable() __assume(0)
  192 +#else
  193 +#define pg_unreachable() abort()
  194 +#endif
  195 +
  196 +/*
  197 + * Hints to the compiler about the likelihood of a branch. Both likely() and
  198 + * unlikely() return the boolean value of the contained expression.
  199 + *
  200 + * These should only be used sparingly, in very hot code paths. It's very easy
  201 + * to mis-estimate likelihoods.
  202 + */
  203 +#if __GNUC__ >= 3
  204 +#define likely(x) __builtin_expect((x) != 0, 1)
  205 +#define unlikely(x) __builtin_expect((x) != 0, 0)
  206 +#else
  207 +#define likely(x) ((x) != 0)
  208 +#define unlikely(x) ((x) != 0)
  209 +#endif
  210 +
  211 +/*
  212 + * CppAsString
  213 + * Convert the argument to a string, using the C preprocessor.
  214 + * CppAsString2
  215 + * Convert the argument to a string, after one round of macro expansion.
  216 + * CppConcat
  217 + * Concatenate two arguments together, using the C preprocessor.
  218 + *
  219 + * Note: There used to be support here for pre-ANSI C compilers that didn't
  220 + * support # and ##. Nowadays, these macros are just for clarity and/or
  221 + * backward compatibility with existing PostgreSQL code.
  222 + */
  223 +#define CppAsString(identifier) #identifier
  224 +#define CppAsString2(x) CppAsString(x)
  225 +#define CppConcat(x, y) x##y
  226 +
  227 +/*
  228 + * dummyret is used to set return values in macros that use ?: to make
  229 + * assignments. gcc wants these to be void, other compilers like char
  230 + */
  231 +#ifdef __GNUC__ /* GNU cc */
  232 +#define dummyret void
  233 +#else
  234 +#define dummyret char
  235 +#endif
  236 +
  237 +/* Which __func__ symbol do we have, if any? */
  238 +#ifdef HAVE_FUNCNAME__FUNC
  239 +#define PG_FUNCNAME_MACRO __func__
  240 +#else
  241 +#ifdef HAVE_FUNCNAME__FUNCTION
  242 +#define PG_FUNCNAME_MACRO __FUNCTION__
  243 +#else
  244 +#define PG_FUNCNAME_MACRO NULL
  245 +#endif
  246 +#endif
  247 +
  248 +
  249 +/* ----------------------------------------------------------------
  250 + * Section 2: bool, true, false
  251 + * ----------------------------------------------------------------
  252 + */
  253 +
  254 +/*
  255 + * bool
  256 + * Boolean value, either true or false.
  257 + *
  258 + * Use stdbool.h if available and its bool has size 1. That's useful for
  259 + * better compiler and debugger output and for compatibility with third-party
  260 + * libraries. But PostgreSQL currently cannot deal with bool of other sizes;
  261 + * there are static assertions around the code to prevent that.
  262 + *
  263 + * For C++ compilers, we assume the compiler has a compatible built-in
  264 + * definition of bool.
  265 + */
  266 +
  267 +#ifndef __cplusplus
  268 +
  269 +#if defined(HAVE_STDBOOL_H) && SIZEOF_BOOL == 1
  270 +#include <stdbool.h>
  271 +#define USE_STDBOOL 1
  272 +#else
  273 +
  274 +#ifndef bool
  275 +typedef char bool;
  276 +#endif
  277 +
  278 +#ifndef true
  279 +#define true ((bool) 1)
  280 +#endif
  281 +
  282 +#ifndef false
  283 +#define false ((bool) 0)
  284 +#endif
  285 +
  286 +#endif
  287 +#endif /* not C++ */
  288 +
  289 +
  290 +/* ----------------------------------------------------------------
  291 + * Section 3: standard system types
  292 + * ----------------------------------------------------------------
  293 + */
  294 +
  295 +/*
  296 + * Pointer
  297 + * Variable holding address of any memory resident object.
  298 + *
  299 + * XXX Pointer arithmetic is done with this, so it can't be void *
  300 + * under "true" ANSI compilers.
  301 + */
  302 +typedef char *Pointer;
  303 +
  304 +/*
  305 + * intN
  306 + * Signed integer, EXACTLY N BITS IN SIZE,
  307 + * used for numerical computations and the
  308 + * frontend/backend protocol.
  309 + */
  310 +#ifndef HAVE_INT8
  311 +typedef signed char int8; /* == 8 bits */
  312 +typedef signed short int16; /* == 16 bits */
  313 +typedef signed int int32; /* == 32 bits */
  314 +#endif /* not HAVE_INT8 */
  315 +
  316 +/*
  317 + * uintN
  318 + * Unsigned integer, EXACTLY N BITS IN SIZE,
  319 + * used for numerical computations and the
  320 + * frontend/backend protocol.
  321 + */
  322 +#ifndef HAVE_UINT8
  323 +typedef unsigned char uint8; /* == 8 bits */
  324 +typedef unsigned short uint16; /* == 16 bits */
  325 +typedef unsigned int uint32; /* == 32 bits */
  326 +#endif /* not HAVE_UINT8 */
  327 +
  328 +/*
  329 + * bitsN
  330 + * Unit of bitwise operation, AT LEAST N BITS IN SIZE.
  331 + */
  332 +typedef uint8 bits8; /* >= 8 bits */
  333 +typedef uint16 bits16; /* >= 16 bits */
  334 +typedef uint32 bits32; /* >= 32 bits */
  335 +
  336 +/*
  337 + * 64-bit integers
  338 + */
  339 +#ifdef HAVE_LONG_INT_64
  340 +/* Plain "long int" fits, use it */
  341 +
  342 +#ifndef HAVE_INT64
  343 +typedef long int int64;
  344 +#endif
  345 +#ifndef HAVE_UINT64
  346 +typedef unsigned long int uint64;
  347 +#endif
  348 +#define INT64CONST(x) (x##L)
  349 +#define UINT64CONST(x) (x##UL)
  350 +#elif defined(HAVE_LONG_LONG_INT_64)
  351 +/* We have working support for "long long int", use that */
  352 +
  353 +#ifndef HAVE_INT64
  354 +typedef long long int int64;
  355 +#endif
  356 +#ifndef HAVE_UINT64
  357 +typedef unsigned long long int uint64;
  358 +#endif
  359 +#define INT64CONST(x) (x##LL)
  360 +#define UINT64CONST(x) (x##ULL)
  361 +#else
  362 +/* neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 */
  363 +#error must have a working 64-bit integer datatype
  364 +#endif
  365 +
  366 +/* snprintf format strings to use for 64-bit integers */
  367 +#define INT64_FORMAT "%" INT64_MODIFIER "d"
  368 +#define UINT64_FORMAT "%" INT64_MODIFIER "u"
  369 +
  370 +/*
  371 + * 128-bit signed and unsigned integers
  372 + * There currently is only limited support for such types.
  373 + * E.g. 128bit literals and snprintf are not supported; but math is.
  374 + * Also, because we exclude such types when choosing MAXIMUM_ALIGNOF,
  375 + * it must be possible to coerce the compiler to allocate them on no
  376 + * more than MAXALIGN boundaries.
  377 + */
  378 +#if defined(PG_INT128_TYPE)
  379 +#if defined(pg_attribute_aligned) || ALIGNOF_PG_INT128_TYPE <= MAXIMUM_ALIGNOF
  380 +#define HAVE_INT128 1
  381 +
  382 +typedef PG_INT128_TYPE int128
  383 +#if defined(pg_attribute_aligned)
  384 +pg_attribute_aligned(MAXIMUM_ALIGNOF)
  385 +#endif
  386 +;
  387 +
  388 +typedef unsigned PG_INT128_TYPE uint128
  389 +#if defined(pg_attribute_aligned)
  390 +pg_attribute_aligned(MAXIMUM_ALIGNOF)
  391 +#endif
  392 +;
  393 +
  394 +#endif
  395 +#endif
  396 +
  397 +/*
  398 + * stdint.h limits aren't guaranteed to be present and aren't guaranteed to
  399 + * have compatible types with our fixed width types. So just define our own.
  400 + */
  401 +#define PG_INT8_MIN (-0x7F-1)
  402 +#define PG_INT8_MAX (0x7F)
  403 +#define PG_UINT8_MAX (0xFF)
  404 +#define PG_INT16_MIN (-0x7FFF-1)
  405 +#define PG_INT16_MAX (0x7FFF)
  406 +#define PG_UINT16_MAX (0xFFFF)
  407 +#define PG_INT32_MIN (-0x7FFFFFFF-1)
  408 +#define PG_INT32_MAX (0x7FFFFFFF)
  409 +#define PG_UINT32_MAX (0xFFFFFFFFU)
  410 +#define PG_INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1)
  411 +#define PG_INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF)
  412 +#define PG_UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF)
  413 +
  414 +/* Max value of size_t might also be missing if we don't have stdint.h */
  415 +#ifndef SIZE_MAX
  416 +#if SIZEOF_SIZE_T == 8
  417 +#define SIZE_MAX PG_UINT64_MAX
  418 +#else
  419 +#define SIZE_MAX PG_UINT32_MAX
  420 +#endif
  421 +#endif
  422 +
  423 +/*
  424 + * We now always use int64 timestamps, but keep this symbol defined for the
  425 + * benefit of external code that might test it.
  426 + */
  427 +#define HAVE_INT64_TIMESTAMP
  428 +
  429 +/*
  430 + * Size
  431 + * Size of any memory resident object, as returned by sizeof.
  432 + */
  433 +typedef size_t Size;
  434 +
  435 +/*
  436 + * Index
  437 + * Index into any memory resident array.
  438 + *
  439 + * Note:
  440 + * Indices are non negative.
  441 + */
  442 +typedef unsigned int Index;
  443 +
  444 +/*
  445 + * Offset
  446 + * Offset into any memory resident array.
  447 + *
  448 + * Note:
  449 + * This differs from an Index in that an Index is always
  450 + * non negative, whereas Offset may be negative.
  451 + */
  452 +typedef signed int Offset;
  453 +
  454 +/*
  455 + * Common Postgres datatype names (as used in the catalogs)
  456 + */
  457 +typedef float float4;
  458 +typedef double float8;
  459 +
  460 +/*
  461 + * Oid, RegProcedure, TransactionId, SubTransactionId, MultiXactId,
  462 + * CommandId
  463 + */
  464 +
  465 +/* typedef Oid is in postgres_ext.h */
  466 +
  467 +/*
  468 + * regproc is the type name used in the include/catalog headers, but
  469 + * RegProcedure is the preferred name in C code.
  470 + */
  471 +typedef Oid regproc;
  472 +typedef regproc RegProcedure;
  473 +
  474 +typedef uint32 TransactionId;
  475 +
  476 +typedef uint32 LocalTransactionId;
  477 +
  478 +typedef uint32 SubTransactionId;
  479 +
  480 +#define InvalidSubTransactionId ((SubTransactionId) 0)
  481 +#define TopSubTransactionId ((SubTransactionId) 1)
  482 +
  483 +/* MultiXactId must be equivalent to TransactionId, to fit in t_xmax */
  484 +typedef TransactionId MultiXactId;
  485 +
  486 +typedef uint32 MultiXactOffset;
  487 +
  488 +typedef uint32 CommandId;
  489 +
  490 +#define FirstCommandId ((CommandId) 0)
  491 +#define InvalidCommandId (~(CommandId)0)
  492 +
  493 +/*
  494 + * Array indexing support
  495 + */
  496 +#define MAXDIM 6
  497 +typedef struct
  498 +{
  499 + int indx[MAXDIM];
  500 +} IntArray;
  501 +
  502 +/* ----------------
  503 + * Variable-length datatypes all share the 'struct varlena' header.
  504 + *
  505 + * NOTE: for TOASTable types, this is an oversimplification, since the value
  506 + * may be compressed or moved out-of-line. However datatype-specific routines
  507 + * are mostly content to deal with de-TOASTed values only, and of course
  508 + * client-side routines should never see a TOASTed value. But even in a
  509 + * de-TOASTed value, beware of touching vl_len_ directly, as its
  510 + * representation is no longer convenient. It's recommended that code always
  511 + * use macros VARDATA_ANY, VARSIZE_ANY, VARSIZE_ANY_EXHDR, VARDATA, VARSIZE,
  512 + * and SET_VARSIZE instead of relying on direct mentions of the struct fields.
  513 + * See postgres.h for details of the TOASTed form.
  514 + * ----------------
  515 + */
  516 +struct varlena
  517 +{
  518 + char vl_len_[4]; /* Do not touch this field directly! */
  519 + char vl_dat[FLEXIBLE_ARRAY_MEMBER]; /* Data content is here */
  520 +};
  521 +
  522 +#define VARHDRSZ ((int32) sizeof(int32))
  523 +
  524 +/*
  525 + * These widely-used datatypes are just a varlena header and the data bytes.
  526 + * There is no terminating null or anything like that --- the data length is
  527 + * always VARSIZE_ANY_EXHDR(ptr).
  528 + */
  529 +typedef struct varlena bytea;
  530 +typedef struct varlena text;
  531 +typedef struct varlena BpChar; /* blank-padded char, ie SQL char(n) */
  532 +typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */
  533 +
  534 +/*
  535 + * Specialized array types. These are physically laid out just the same
  536 + * as regular arrays (so that the regular array subscripting code works
  537 + * with them). They exist as distinct types mostly for historical reasons:
  538 + * they have nonstandard I/O behavior which we don't want to change for fear
  539 + * of breaking applications that look at the system catalogs. There is also
  540 + * an implementation issue for oidvector: it's part of the primary key for
  541 + * pg_proc, and we can't use the normal btree array support routines for that
  542 + * without circularity.
  543 + */
  544 +typedef struct
  545 +{
  546 + int32 vl_len_; /* these fields must match ArrayType! */
  547 + int ndim; /* always 1 for int2vector */
  548 + int32 dataoffset; /* always 0 for int2vector */
  549 + Oid elemtype;
  550 + int dim1;
  551 + int lbound1;
  552 + int16 values[FLEXIBLE_ARRAY_MEMBER];
  553 +} int2vector;
  554 +
  555 +typedef struct
  556 +{
  557 + int32 vl_len_; /* these fields must match ArrayType! */
  558 + int ndim; /* always 1 for oidvector */
  559 + int32 dataoffset; /* always 0 for oidvector */
  560 + Oid elemtype;
  561 + int dim1;
  562 + int lbound1;
  563 + Oid values[FLEXIBLE_ARRAY_MEMBER];
  564 +} oidvector;
  565 +
  566 +/*
  567 + * Representation of a Name: effectively just a C string, but null-padded to
  568 + * exactly NAMEDATALEN bytes. The use of a struct is historical.
  569 + */
  570 +typedef struct nameData
  571 +{
  572 + char data[NAMEDATALEN];
  573 +} NameData;
  574 +typedef NameData *Name;
  575 +
  576 +#define NameStr(name) ((name).data)
  577 +
  578 +
  579 +/* ----------------------------------------------------------------
  580 + * Section 4: IsValid macros for system types
  581 + * ----------------------------------------------------------------
  582 + */
  583 +/*
  584 + * BoolIsValid
  585 + * True iff bool is valid.
  586 + */
  587 +#define BoolIsValid(boolean) ((boolean) == false || (boolean) == true)
  588 +
  589 +/*
  590 + * PointerIsValid
  591 + * True iff pointer is valid.
  592 + */
  593 +#define PointerIsValid(pointer) ((const void*)(pointer) != NULL)
  594 +
  595 +/*
  596 + * PointerIsAligned
  597 + * True iff pointer is properly aligned to point to the given type.
  598 + */
  599 +#define PointerIsAligned(pointer, type) \
  600 + (((uintptr_t)(pointer) % (sizeof (type))) == 0)
  601 +
  602 +#define OffsetToPointer(base, offset) \
  603 + ((void *)((char *) base + offset))
  604 +
  605 +#define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))
  606 +
  607 +#define RegProcedureIsValid(p) OidIsValid(p)
  608 +
  609 +
  610 +/* ----------------------------------------------------------------
  611 + * Section 5: offsetof, lengthof, alignment
  612 + * ----------------------------------------------------------------
  613 + */
  614 +/*
  615 + * offsetof
  616 + * Offset of a structure/union field within that structure/union.
  617 + *
  618 + * XXX This is supposed to be part of stddef.h, but isn't on
  619 + * some systems (like SunOS 4).
  620 + */
  621 +#ifndef offsetof
  622 +#define offsetof(type, field) ((long) &((type *)0)->field)
  623 +#endif /* offsetof */
  624 +
  625 +/*
  626 + * lengthof
  627 + * Number of elements in an array.
  628 + */
  629 +#define lengthof(array) (sizeof (array) / sizeof ((array)[0]))
  630 +
  631 +/* ----------------
  632 + * Alignment macros: align a length or address appropriately for a given type.
  633 + * The fooALIGN() macros round up to a multiple of the required alignment,
  634 + * while the fooALIGN_DOWN() macros round down. The latter are more useful
  635 + * for problems like "how many X-sized structures will fit in a page?".
  636 + *
  637 + * NOTE: TYPEALIGN[_DOWN] will not work if ALIGNVAL is not a power of 2.
  638 + * That case seems extremely unlikely to be needed in practice, however.
  639 + *
  640 + * NOTE: MAXIMUM_ALIGNOF, and hence MAXALIGN(), intentionally exclude any
  641 + * larger-than-8-byte types the compiler might have.
  642 + * ----------------
  643 + */
  644 +
  645 +#define TYPEALIGN(ALIGNVAL,LEN) \
  646 + (((uintptr_t) (LEN) + ((ALIGNVAL) - 1)) & ~((uintptr_t) ((ALIGNVAL) - 1)))
  647 +
  648 +#define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN))
  649 +#define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN))
  650 +#define LONGALIGN(LEN) TYPEALIGN(ALIGNOF_LONG, (LEN))
  651 +#define DOUBLEALIGN(LEN) TYPEALIGN(ALIGNOF_DOUBLE, (LEN))
  652 +#define MAXALIGN(LEN) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))
  653 +/* MAXALIGN covers only built-in types, not buffers */
  654 +#define BUFFERALIGN(LEN) TYPEALIGN(ALIGNOF_BUFFER, (LEN))
  655 +#define CACHELINEALIGN(LEN) TYPEALIGN(PG_CACHE_LINE_SIZE, (LEN))
  656 +
  657 +#define TYPEALIGN_DOWN(ALIGNVAL,LEN) \
  658 + (((uintptr_t) (LEN)) & ~((uintptr_t) ((ALIGNVAL) - 1)))
  659 +
  660 +#define SHORTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_SHORT, (LEN))
  661 +#define INTALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_INT, (LEN))
  662 +#define LONGALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_LONG, (LEN))
  663 +#define DOUBLEALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_DOUBLE, (LEN))
  664 +#define MAXALIGN_DOWN(LEN) TYPEALIGN_DOWN(MAXIMUM_ALIGNOF, (LEN))
  665 +#define BUFFERALIGN_DOWN(LEN) TYPEALIGN_DOWN(ALIGNOF_BUFFER, (LEN))
  666 +
  667 +/*
  668 + * The above macros will not work with types wider than uintptr_t, like with
  669 + * uint64 on 32-bit platforms. That's not problem for the usual use where a
  670 + * pointer or a length is aligned, but for the odd case that you need to
  671 + * align something (potentially) wider, use TYPEALIGN64.
  672 + */
  673 +#define TYPEALIGN64(ALIGNVAL,LEN) \
  674 + (((uint64) (LEN) + ((ALIGNVAL) - 1)) & ~((uint64) ((ALIGNVAL) - 1)))
  675 +
  676 +/* we don't currently need wider versions of the other ALIGN macros */
  677 +#define MAXALIGN64(LEN) TYPEALIGN64(MAXIMUM_ALIGNOF, (LEN))
  678 +
  679 +
  680 +/* ----------------------------------------------------------------
  681 + * Section 6: assertions
  682 + * ----------------------------------------------------------------
  683 + */
  684 +
  685 +/*
  686 + * USE_ASSERT_CHECKING, if defined, turns on all the assertions.
  687 + * - plai 9/5/90
  688 + *
  689 + * It should _NOT_ be defined in releases or in benchmark copies
  690 + */
  691 +
  692 +/*
  693 + * Assert() can be used in both frontend and backend code. In frontend code it
  694 + * just calls the standard assert, if it's available. If use of assertions is
  695 + * not configured, it does nothing.
  696 + */
  697 +#ifndef USE_ASSERT_CHECKING
  698 +
  699 +#define Assert(condition) ((void)true)
  700 +#define AssertMacro(condition) ((void)true)
  701 +#define AssertArg(condition) ((void)true)
  702 +#define AssertState(condition) ((void)true)
  703 +#define AssertPointerAlignment(ptr, bndr) ((void)true)
  704 +#define Trap(condition, errorType) ((void)true)
  705 +#define TrapMacro(condition, errorType) (true)
  706 +
  707 +#elif defined(FRONTEND)
  708 +
  709 +#include <assert.h>
  710 +#define Assert(p) assert(p)
  711 +#define AssertMacro(p) ((void) assert(p))
  712 +#define AssertArg(condition) assert(condition)
  713 +#define AssertState(condition) assert(condition)
  714 +#define AssertPointerAlignment(ptr, bndr) ((void)true)
  715 +
  716 +#else /* USE_ASSERT_CHECKING && !FRONTEND */
  717 +
  718 +/*
  719 + * Trap
  720 + * Generates an exception if the given condition is true.
  721 + */
  722 +#define Trap(condition, errorType) \
  723 + do { \
  724 + if (condition) \
  725 + ExceptionalCondition(CppAsString(condition), (errorType), \
  726 + __FILE__, __LINE__); \
  727 + } while (0)
  728 +
  729 +/*
  730 + * TrapMacro is the same as Trap but it's intended for use in macros:
  731 + *
  732 + * #define foo(x) (AssertMacro(x != 0), bar(x))
  733 + *
  734 + * Isn't CPP fun?
  735 + */
  736 +#define TrapMacro(condition, errorType) \
  737 + ((bool) (! (condition) || \
  738 + (ExceptionalCondition(CppAsString(condition), (errorType), \
  739 + __FILE__, __LINE__), 0)))
  740 +
  741 +#define Assert(condition) \
  742 + Trap(!(condition), "FailedAssertion")
  743 +
  744 +#define AssertMacro(condition) \
  745 + ((void) TrapMacro(!(condition), "FailedAssertion"))
  746 +
  747 +#define AssertArg(condition) \
  748 + Trap(!(condition), "BadArgument")
  749 +
  750 +#define AssertState(condition) \
  751 + Trap(!(condition), "BadState")
  752 +
  753 +/*
  754 + * Check that `ptr' is `bndr' aligned.
  755 + */
  756 +#define AssertPointerAlignment(ptr, bndr) \
  757 + Trap(TYPEALIGN(bndr, (uintptr_t)(ptr)) != (uintptr_t)(ptr), \
  758 + "UnalignedPointer")
  759 +
  760 +#endif /* USE_ASSERT_CHECKING && !FRONTEND */
  761 +
  762 +/*
  763 + * ExceptionalCondition is compiled into the backend whether or not
  764 + * USE_ASSERT_CHECKING is defined, so as to support use of extensions
  765 + * that are built with that #define with a backend that isn't. Hence,
  766 + * we should declare it as long as !FRONTEND.
  767 + */
  768 +#ifndef FRONTEND
  769 +extern void ExceptionalCondition(const char *conditionName,
  770 + const char *errorType,
  771 + const char *fileName, int lineNumber) pg_attribute_noreturn();
  772 +#endif
  773 +
  774 +/*
  775 + * Macros to support compile-time assertion checks.
  776 + *
  777 + * If the "condition" (a compile-time-constant expression) evaluates to false,
  778 + * throw a compile error using the "errmessage" (a string literal).
  779 + *
  780 + * gcc 4.6 and up supports _Static_assert(), but there are bizarre syntactic
  781 + * placement restrictions. These macros make it safe to use as a statement
  782 + * or in an expression, respectively.
  783 + *
  784 + * Otherwise we fall back on a kluge that assumes the compiler will complain
  785 + * about a negative width for a struct bit-field. This will not include a
  786 + * helpful error message, but it beats not getting an error at all.
  787 + */
  788 +#ifndef __cplusplus
  789 +#ifdef HAVE__STATIC_ASSERT
  790 +#define StaticAssertStmt(condition, errmessage) \
  791 + do { _Static_assert(condition, errmessage); } while(0)
  792 +#define StaticAssertExpr(condition, errmessage) \
  793 + ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
  794 +#else /* !HAVE__STATIC_ASSERT */
  795 +#define StaticAssertStmt(condition, errmessage) \
  796 + ((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; }))
  797 +#define StaticAssertExpr(condition, errmessage) \
  798 + StaticAssertStmt(condition, errmessage)
  799 +#endif /* HAVE__STATIC_ASSERT */
  800 +#else /* C++ */
  801 +#if defined(__cpp_static_assert) && __cpp_static_assert >= 200410
  802 +#define StaticAssertStmt(condition, errmessage) \
  803 + static_assert(condition, errmessage)
  804 +#define StaticAssertExpr(condition, errmessage) \
  805 + ({ static_assert(condition, errmessage); })
  806 +#else
  807 +#define StaticAssertStmt(condition, errmessage) \
  808 + do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0)
  809 +#define StaticAssertExpr(condition, errmessage) \
  810 + ((void) ({ StaticAssertStmt(condition, errmessage); }))
  811 +#endif
  812 +#endif /* C++ */
  813 +
  814 +
  815 +/*
  816 + * Compile-time checks that a variable (or expression) has the specified type.
  817 + *
  818 + * AssertVariableIsOfType() can be used as a statement.
  819 + * AssertVariableIsOfTypeMacro() is intended for use in macros, eg
  820 + * #define foo(x) (AssertVariableIsOfTypeMacro(x, int), bar(x))
  821 + *
  822 + * If we don't have __builtin_types_compatible_p, we can still assert that
  823 + * the types have the same size. This is far from ideal (especially on 32-bit
  824 + * platforms) but it provides at least some coverage.
  825 + */
  826 +#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P
  827 +#define AssertVariableIsOfType(varname, typename) \
  828 + StaticAssertStmt(__builtin_types_compatible_p(__typeof__(varname), typename), \
  829 + CppAsString(varname) " does not have type " CppAsString(typename))
  830 +#define AssertVariableIsOfTypeMacro(varname, typename) \
  831 + (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
  832 + CppAsString(varname) " does not have type " CppAsString(typename)))
  833 +#else /* !HAVE__BUILTIN_TYPES_COMPATIBLE_P */
  834 +#define AssertVariableIsOfType(varname, typename) \
  835 + StaticAssertStmt(sizeof(varname) == sizeof(typename), \
  836 + CppAsString(varname) " does not have type " CppAsString(typename))
  837 +#define AssertVariableIsOfTypeMacro(varname, typename) \
  838 + (StaticAssertExpr(sizeof(varname) == sizeof(typename), \
  839 + CppAsString(varname) " does not have type " CppAsString(typename)))
  840 +#endif /* HAVE__BUILTIN_TYPES_COMPATIBLE_P */
  841 +
  842 +
  843 +/* ----------------------------------------------------------------
  844 + * Section 7: widely useful macros
  845 + * ----------------------------------------------------------------
  846 + */
  847 +/*
  848 + * Max
  849 + * Return the maximum of two numbers.
  850 + */
  851 +#define Max(x, y) ((x) > (y) ? (x) : (y))
  852 +
  853 +/*
  854 + * Min
  855 + * Return the minimum of two numbers.
  856 + */
  857 +#define Min(x, y) ((x) < (y) ? (x) : (y))
  858 +
  859 +/*
  860 + * Abs
  861 + * Return the absolute value of the argument.
  862 + */
  863 +#define Abs(x) ((x) >= 0 ? (x) : -(x))
  864 +
  865 +/*
  866 + * StrNCpy
  867 + * Like standard library function strncpy(), except that result string
  868 + * is guaranteed to be null-terminated --- that is, at most N-1 bytes
  869 + * of the source string will be kept.
  870 + * Also, the macro returns no result (too hard to do that without
  871 + * evaluating the arguments multiple times, which seems worse).
  872 + *
  873 + * BTW: when you need to copy a non-null-terminated string (like a text
  874 + * datum) and add a null, do not do it with StrNCpy(..., len+1). That
  875 + * might seem to work, but it fetches one byte more than there is in the
  876 + * text object. One fine day you'll have a SIGSEGV because there isn't
  877 + * another byte before the end of memory. Don't laugh, we've had real
  878 + * live bug reports from real live users over exactly this mistake.
  879 + * Do it honestly with "memcpy(dst,src,len); dst[len] = '\0';", instead.
  880 + */
  881 +#define StrNCpy(dst,src,len) \
  882 + do \
  883 + { \
  884 + char * _dst = (dst); \
  885 + Size _len = (len); \
  886 +\
  887 + if (_len > 0) \
  888 + { \
  889 + strncpy(_dst, (src), _len); \
  890 + _dst[_len-1] = '\0'; \
  891 + } \
  892 + } while (0)
  893 +
  894 +
  895 +/* Get a bit mask of the bits set in non-long aligned addresses */
  896 +#define LONG_ALIGN_MASK (sizeof(long) - 1)
  897 +
  898 +/*
  899 + * MemSet
  900 + * Exactly the same as standard library function memset(), but considerably
  901 + * faster for zeroing small word-aligned structures (such as parsetree nodes).
  902 + * This has to be a macro because the main point is to avoid function-call
  903 + * overhead. However, we have also found that the loop is faster than
  904 + * native libc memset() on some platforms, even those with assembler
  905 + * memset() functions. More research needs to be done, perhaps with
  906 + * MEMSET_LOOP_LIMIT tests in configure.
  907 + */
  908 +#define MemSet(start, val, len) \
  909 + do \
  910 + { \
  911 + /* must be void* because we don't know if it is integer aligned yet */ \
  912 + void *_vstart = (void *) (start); \
  913 + int _val = (val); \
  914 + Size _len = (len); \
  915 +\
  916 + if ((((uintptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \
  917 + (_len & LONG_ALIGN_MASK) == 0 && \
  918 + _val == 0 && \
  919 + _len <= MEMSET_LOOP_LIMIT && \
  920 + /* \
  921 + * If MEMSET_LOOP_LIMIT == 0, optimizer should find \
  922 + * the whole "if" false at compile time. \
  923 + */ \
  924 + MEMSET_LOOP_LIMIT != 0) \
  925 + { \
  926 + long *_start = (long *) _vstart; \
  927 + long *_stop = (long *) ((char *) _start + _len); \
  928 + while (_start < _stop) \
  929 + *_start++ = 0; \
  930 + } \
  931 + else \
  932 + memset(_vstart, _val, _len); \
  933 + } while (0)
  934 +
  935 +/*
  936 + * MemSetAligned is the same as MemSet except it omits the test to see if
  937 + * "start" is word-aligned. This is okay to use if the caller knows a-priori
  938 + * that the pointer is suitably aligned (typically, because he just got it
  939 + * from palloc(), which always delivers a max-aligned pointer).
  940 + */
  941 +#define MemSetAligned(start, val, len) \
  942 + do \
  943 + { \
  944 + long *_start = (long *) (start); \
  945 + int _val = (val); \
  946 + Size _len = (len); \
  947 +\
  948 + if ((_len & LONG_ALIGN_MASK) == 0 && \
  949 + _val == 0 && \
  950 + _len <= MEMSET_LOOP_LIMIT && \
  951 + MEMSET_LOOP_LIMIT != 0) \
  952 + { \
  953 + long *_stop = (long *) ((char *) _start + _len); \
  954 + while (_start < _stop) \
  955 + *_start++ = 0; \
  956 + } \
  957 + else \
  958 + memset(_start, _val, _len); \
  959 + } while (0)
  960 +
  961 +
  962 +/*
  963 + * MemSetTest/MemSetLoop are a variant version that allow all the tests in
  964 + * MemSet to be done at compile time in cases where "val" and "len" are
  965 + * constants *and* we know the "start" pointer must be word-aligned.
  966 + * If MemSetTest succeeds, then it is okay to use MemSetLoop, otherwise use
  967 + * MemSetAligned. Beware of multiple evaluations of the arguments when using
  968 + * this approach.
  969 + */
  970 +#define MemSetTest(val, len) \
  971 + ( ((len) & LONG_ALIGN_MASK) == 0 && \
  972 + (len) <= MEMSET_LOOP_LIMIT && \
  973 + MEMSET_LOOP_LIMIT != 0 && \
  974 + (val) == 0 )
  975 +
  976 +#define MemSetLoop(start, val, len) \
  977 + do \
  978 + { \
  979 + long * _start = (long *) (start); \
  980 + long * _stop = (long *) ((char *) _start + (Size) (len)); \
  981 + \
  982 + while (_start < _stop) \
  983 + *_start++ = 0; \
  984 + } while (0)
  985 +
  986 +
  987 +/* ----------------------------------------------------------------
  988 + * Section 8: random stuff
  989 + * ----------------------------------------------------------------
  990 + */
  991 +
  992 +/*
  993 + * Invert the sign of a qsort-style comparison result, ie, exchange negative
  994 + * and positive integer values, being careful not to get the wrong answer
  995 + * for INT_MIN. The argument should be an integral variable.
  996 + */
  997 +#define INVERT_COMPARE_RESULT(var) \
  998 + ((var) = ((var) < 0) ? 1 : -(var))
  999 +
  1000 +/*
  1001 + * Use this, not "char buf[BLCKSZ]", to declare a field or local variable
  1002 + * holding a page buffer, if that page might be accessed as a page and not
  1003 + * just a string of bytes. Otherwise the variable might be under-aligned,
  1004 + * causing problems on alignment-picky hardware. (In some places, we use
  1005 + * this to declare buffers even though we only pass them to read() and
  1006 + * write(), because copying to/from aligned buffers is usually faster than
  1007 + * using unaligned buffers.) We include both "double" and "int64" in the
  1008 + * union to ensure that the compiler knows the value must be MAXALIGN'ed
  1009 + * (cf. configure's computation of MAXIMUM_ALIGNOF).
  1010 + */
  1011 +typedef union PGAlignedBlock
  1012 +{
  1013 + char data[BLCKSZ];
  1014 + double force_align_d;
  1015 + int64 force_align_i64;
  1016 +} PGAlignedBlock;
  1017 +
  1018 +/* Same, but for an XLOG_BLCKSZ-sized buffer */
  1019 +typedef union PGAlignedXLogBlock
  1020 +{
  1021 + char data[XLOG_BLCKSZ];
  1022 + double force_align_d;
  1023 + int64 force_align_i64;
  1024 +} PGAlignedXLogBlock;
  1025 +
  1026 +/* msb for char */
  1027 +#define HIGHBIT (0x80)
  1028 +#define IS_HIGHBIT_SET(ch) ((unsigned char)(ch) & HIGHBIT)
  1029 +
  1030 +/*
  1031 + * Support macros for escaping strings. escape_backslash should be true
  1032 + * if generating a non-standard-conforming string. Prefixing a string
  1033 + * with ESCAPE_STRING_SYNTAX guarantees it is non-standard-conforming.
  1034 + * Beware of multiple evaluation of the "ch" argument!
  1035 + */
  1036 +#define SQL_STR_DOUBLE(ch, escape_backslash) \
  1037 + ((ch) == '\'' || ((ch) == '\\' && (escape_backslash)))
  1038 +
  1039 +#define ESCAPE_STRING_SYNTAX 'E'
  1040 +
  1041 +
  1042 +#define STATUS_OK (0)
  1043 +#define STATUS_ERROR (-1)
  1044 +#define STATUS_EOF (-2)
  1045 +#define STATUS_FOUND (1)
  1046 +#define STATUS_WAITING (2)
  1047 +
  1048 +/*
  1049 + * gettext support
  1050 + */
  1051 +
  1052 +#ifndef ENABLE_NLS
  1053 +/* stuff we'd otherwise get from <libintl.h> */
  1054 +#define gettext(x) (x)
  1055 +#define dgettext(d,x) (x)
  1056 +#define ngettext(s,p,n) ((n) == 1 ? (s) : (p))
  1057 +#define dngettext(d,s,p,n) ((n) == 1 ? (s) : (p))
  1058 +#endif
  1059 +
  1060 +#define _(x) gettext(x)
  1061 +
  1062 +/*
  1063 + * Use this to mark string constants as needing translation at some later
  1064 + * time, rather than immediately. This is useful for cases where you need
  1065 + * access to the original string and translated string, and for cases where
  1066 + * immediate translation is not possible, like when initializing global
  1067 + * variables.
  1068 + * http://www.gnu.org/software/autoconf/manual/gettext/Special-cases.html
  1069 + */
  1070 +#define gettext_noop(x) (x)
  1071 +
  1072 +/*
  1073 + * To better support parallel installations of major PostgreSQL
  1074 + * versions as well as parallel installations of major library soname
  1075 + * versions, we mangle the gettext domain name by appending those
  1076 + * version numbers. The coding rule ought to be that wherever the
  1077 + * domain name is mentioned as a literal, it must be wrapped into
  1078 + * PG_TEXTDOMAIN(). The macros below do not work on non-literals; but
  1079 + * that is somewhat intentional because it avoids having to worry
  1080 + * about multiple states of premangling and postmangling as the values
  1081 + * are being passed around.
  1082 + *
  1083 + * Make sure this matches the installation rules in nls-global.mk.
  1084 + */
  1085 +#ifdef SO_MAJOR_VERSION
  1086 +#define PG_TEXTDOMAIN(domain) (domain CppAsString2(SO_MAJOR_VERSION) "-" PG_MAJORVERSION)
  1087 +#else
  1088 +#define PG_TEXTDOMAIN(domain) (domain "-" PG_MAJORVERSION)
  1089 +#endif
  1090 +
  1091 +
  1092 +/* ----------------------------------------------------------------
  1093 + * Section 9: system-specific hacks
  1094 + *
  1095 + * This should be limited to things that absolutely have to be
  1096 + * included in every source file. The port-specific header file
  1097 + * is usually a better place for this sort of thing.
  1098 + * ----------------------------------------------------------------
  1099 + */
  1100 +
  1101 +/*
  1102 + * NOTE: this is also used for opening text files.
  1103 + * WIN32 treats Control-Z as EOF in files opened in text mode.
  1104 + * Therefore, we open files in binary mode on Win32 so we can read
  1105 + * literal control-Z. The other affect is that we see CRLF, but
  1106 + * that is OK because we can already handle those cleanly.
  1107 + */
  1108 +#if defined(WIN32) || defined(__CYGWIN__)
  1109 +#define PG_BINARY O_BINARY
  1110 +#define PG_BINARY_A "ab"
  1111 +#define PG_BINARY_R "rb"
  1112 +#define PG_BINARY_W "wb"
  1113 +#else
  1114 +#define PG_BINARY 0
  1115 +#define PG_BINARY_A "a"
  1116 +#define PG_BINARY_R "r"
  1117 +#define PG_BINARY_W "w"
  1118 +#endif
  1119 +
  1120 +/*
  1121 + * Provide prototypes for routines not present in a particular machine's
  1122 + * standard C library.
  1123 + */
  1124 +
  1125 +#if !HAVE_DECL_SNPRINTF
  1126 +extern int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3, 4);
  1127 +#endif
  1128 +
  1129 +#if !HAVE_DECL_VSNPRINTF
  1130 +extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
  1131 +#endif
  1132 +
  1133 +#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
  1134 +extern int fdatasync(int fildes);
  1135 +#endif
  1136 +
  1137 +#ifdef HAVE_LONG_LONG_INT
  1138 +/* Older platforms may provide strto[u]ll functionality under other names */
  1139 +#if !defined(HAVE_STRTOLL) && defined(HAVE___STRTOLL)
  1140 +#define strtoll __strtoll
  1141 +#define HAVE_STRTOLL 1
  1142 +#endif
  1143 +
  1144 +#if !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
  1145 +#define strtoll strtoq
  1146 +#define HAVE_STRTOLL 1
  1147 +#endif
  1148 +
  1149 +#if !defined(HAVE_STRTOULL) && defined(HAVE___STRTOULL)
  1150 +#define strtoull __strtoull
  1151 +#define HAVE_STRTOULL 1
  1152 +#endif
  1153 +
  1154 +#if !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
  1155 +#define strtoull strtouq
  1156 +#define HAVE_STRTOULL 1
  1157 +#endif
  1158 +
  1159 +#if defined(HAVE_STRTOLL) && !HAVE_DECL_STRTOLL
  1160 +extern long long strtoll(const char *str, char **endptr, int base);
  1161 +#endif
  1162 +
  1163 +#if defined(HAVE_STRTOULL) && !HAVE_DECL_STRTOULL
  1164 +extern unsigned long long strtoull(const char *str, char **endptr, int base);
  1165 +#endif
  1166 +#endif /* HAVE_LONG_LONG_INT */
  1167 +
  1168 +#if !defined(HAVE_MEMMOVE) && !defined(memmove)
  1169 +#define memmove(d, s, c) bcopy(s, d, c)
  1170 +#endif
  1171 +
  1172 +/* no special DLL markers on most ports */
  1173 +#ifndef PGDLLIMPORT
  1174 +#define PGDLLIMPORT
  1175 +#endif
  1176 +#ifndef PGDLLEXPORT
  1177 +#define PGDLLEXPORT
  1178 +#endif
  1179 +
  1180 +/*
  1181 + * The following is used as the arg list for signal handlers. Any ports
  1182 + * that take something other than an int argument should override this in
  1183 + * their pg_config_os.h file. Note that variable names are required
  1184 + * because it is used in both the prototypes as well as the definitions.
  1185 + * Note also the long name. We expect that this won't collide with
  1186 + * other names causing compiler warnings.
  1187 + */
  1188 +
  1189 +#ifndef SIGNAL_ARGS
  1190 +#define SIGNAL_ARGS int postgres_signal_arg
  1191 +#endif
  1192 +
  1193 +/*
  1194 + * When there is no sigsetjmp, its functionality is provided by plain
  1195 + * setjmp. Incidentally, nothing provides setjmp's functionality in
  1196 + * that case. We now support the case only on Windows.
  1197 + */
  1198 +#ifdef WIN32
  1199 +#define sigjmp_buf jmp_buf
  1200 +#define sigsetjmp(x,y) setjmp(x)
  1201 +#define siglongjmp longjmp
  1202 +#endif
  1203 +
  1204 +/* EXEC_BACKEND defines */
  1205 +#ifdef EXEC_BACKEND
  1206 +#define NON_EXEC_STATIC
  1207 +#else
  1208 +#define NON_EXEC_STATIC static
  1209 +#endif
  1210 +
  1211 +/* /port compatibility functions */
  1212 +#include "port.h"
  1213 +
  1214 +#endif /* C_H */
... ...
注册登录 后发表评论