summaryrefslogtreecommitdiff
path: root/libpq/libpq/pg_config.h
blob: 12d418edc308c0d041fe46add176a26474e62d7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/* file      : libpq/pg_config.h -*- C -*-
 * copyright : Copyright (c) 2016-2019 Code Synthesis Ltd
 * license   : PostgreSQL License; see accompanying COPYRIGHT file
 */

/*
 * For the semantics of the following macros refer to pg_config.h.in.orig,
 * pg_config.h.win32.orig, and the upstream's configure.in.
 *
 * Note that we will explicitly undefine macros that are present in the libpq
 * source code but should not be defined. While this is not technically
 * required, it simplifies the change tracking (see README-DEV). As a bonus we
 * also make sure that they are not get eventually defined by some system
 * headers.
 */

#include <stddef.h> /* offsetof() */

#include <openssl/opensslv.h> /* OPENSSL_VERSION_NUMBER */

/*
 * Version.
 */
#undef   PG_VERSION
#undef   PG_VERSION_NUM
#undef   PG_MAJORVERSION
#include <libpq/version.h>

/*
 * Endianess.
 */
#ifdef __FreeBSD__
#  include <sys/endian.h> /* BYTE_ORDER */
#else
#  if defined(_WIN32)
#    ifndef BYTE_ORDER
#      define BIG_ENDIAN    4321
#      define LITTLE_ENDIAN 1234
#      define BYTE_ORDER    LITTLE_ENDIAN
#    endif
#  else
#    include <sys/param.h>  /* BYTE_ORDER/__BYTE_ORDER */
#    ifndef BYTE_ORDER
#      ifdef __BYTE_ORDER
#        define BYTE_ORDER    __BYTE_ORDER
#        define BIG_ENDIAN    __BIG_ENDIAN
#        define LITTLE_ENDIAN __LITTLE_ENDIAN
#      else
#        error no BYTE_ORDER/__BYTE_ORDER define
#      endif
#    endif
#  endif
#endif

#if BYTE_ORDER == BIG_ENDIAN
# define WORDS_BIGENDIAN 1
#endif

/*
 * Types, type sizes and alignments.
 */
#define ALIGNOF_(type) offsetof (struct {char c; type m;}, m)
#define ALIGNOF_DOUBLE ALIGNOF_ (double)
#define ALIGNOF_INT    ALIGNOF_ (int)
#define ALIGNOF_LONG   ALIGNOF_ (long)
#define ALIGNOF_SHORT  ALIGNOF_ (short)

/*
 * GCC and Clang provide __SIZEOF_*__ and  __*_TYPE__ predefined macros that we
 * use to define the required libpq macros. Note that on Windows long and
 * long long types are always of 32 and 64 bits width respectively.
 */
#ifndef _WIN32
#  if __SIZEOF_LONG__ == 8
#    define HAVE_LONG_INT_64 1
#  endif
#  ifdef __SIZEOF_LONG_LONG__
#    define HAVE_LONG_LONG_INT 1
#  endif
#  if __SIZEOF_LONG_LONG__ == 8
#    define HAVE_LONG_LONG_INT_64 1
#  endif
#  if __SIZEOF_LONG_LONG__ > __SIZEOF_DOUBLE__
#    define MAXIMUM_ALIGNOF __SIZEOF_LONG_LONG__
#  else
#    define MAXIMUM_ALIGNOF __SIZEOF_DOUBLE__
#  endif
#  ifdef __SIZEOF_INT128__
#    define PG_INT128_TYPE         __int128
#    define ALIGNOF_PG_INT128_TYPE 16
#  endif
#  define PG_INT64_TYPE    __INT64_TYPE__
#  define ACCEPT_TYPE_ARG3 socklen_t
#  define SIZEOF_SIZE_T    __SIZEOF_SIZE_T__
#else
#  define HAVE_LONG_LONG_INT    1
#  define HAVE_LONG_LONG_INT_64 1
#  define MAXIMUM_ALIGNOF       8
#  define PG_INT64_TYPE         long long int
#  define ACCEPT_TYPE_ARG3      int
#  ifdef _WIN64
#    define SIZEOF_SIZE_T 8
#  else
#    define SIZEOF_SIZE_T 4
#  endif
#endif

#define INT64_MODIFIER "ll"
#define SIZEOF_BOOL    1

/*
 * Specific for FreeBSD.
 */
#ifdef __FreeBSD__
#  define HAVE_STRUCT_CMSGCRED 1
#endif

/*
 * Specific for Mac OS.
 */
#ifdef __APPLE__
#  define HAVE_DECL_F_FULLFSYNC 1
#else
#  define HAVE_DECL_F_FULLFSYNC 0
#endif

/*
 * Specific for FreeBSD and Linux.
 */
#if defined(__FreeBSD__) || defined(__linux__)
#  define HAVE_STRCHRNUL 1
#endif

/*
 * Specific for FreeBSD and Mac OS.
 */
#if defined(__FreeBSD__) || defined(__APPLE__)
#  define HAVE_DECL_STRLCAT                   1
#  define HAVE_DECL_STRLCPY                   1
#  define STRERROR_R_INT                      1
#  define HAVE_FLS                            1
#  define HAVE_GETPEEREID                     1
#  define HAVE_STRTOQ                         1
#  define HAVE_STRTOUQ                        1
#  define HAVE_STRUCT_SOCKADDR_SA_LEN         1
#  define HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN 1
#  define HAVE_SYS_SOCKIO_H                   1
#  define HAVE_SYS_UCRED_H                    1
#  define HAVE_UNION_SEMUN                    1
#else
#  define HAVE_DECL_STRLCAT                   0
#  define HAVE_DECL_STRLCPY                   0
#endif

/*
 * Specific for POSIX.
 */
#ifndef _WIN32
#  define HAVE_CRYPT              1
#  define HAVE_DECL_FDATASYNC     1
#  define HAVE_DECL_RTLD_GLOBAL   1
#  define HAVE_DECL_RTLD_NOW      1
#  define HAVE_FDATASYNC          1
#  define HAVE_GETADDRINFO        1
#  define HAVE_GETIFADDRS         1
#  define HAVE_IFADDRS_H          1
#  define HAVE_GETPWUID_R         1
#  define HAVE_INET_ATON          1
#  define HAVE_LANGINFO_H         1
#  define HAVE_MKDTEMP            1
#  define HAVE_NETINET_TCP_H      1
#  define HAVE_NET_IF_H           1
#  define HAVE_DECL_POSIX_FADVISE 1
#  define HAVE_POSIX_FADVISE      1
#  define HAVE_RANDOM             1
#  define HAVE_SRANDOM            1
#  define HAVE_STRERROR_R         1
#  define HAVE_STRINGS_H          1
#  define HAVE_SYS_IOCTL_H        1
#  define HAVE_POLL               1
#  define HAVE_POLL_H             1
#  define HAVE_SYS_POLL_H         1
#  define HAVE_SYS_SELECT_H       1
#  define HAVE_SYS_UN_H           1
#  define HAVE_TERMIOS_H          1
#  define HAVE_UNIX_SOCKETS       1
#  define HAVE_UNSETENV           1
#  define USE_INTEGER_DATETIMES   1
#  define HAVE_DLOPEN             1
#  define HAVE_PREAD              1
#  define HAVE_PWRITE             1
/*
 * Specific for Windows.
 */
#else
#  define HAVE_DECL_FDATASYNC     0
#  define HAVE_DECL_RTLD_GLOBAL   0
#  define HAVE_DECL_RTLD_NOW      0
#  define HAVE_DECL_POSIX_FADVISE 0
#  define HAVE_GETTIMEOFDAY       1
#  define HAVE_ISINF              1
#  define HAVE_FUNCNAME__FUNCTION 1
#  define USE_REPL_SNPRINTF       1
#endif

/*
 * Specific for GNU C Library.
 */
#ifdef __GLIBC__
# define HAVE_GETHOSTBYNAME_R 1
#endif

/*
 * Specific for (non-) VC.
 */
#ifndef _MSC_VER
#  define HAVE__BUILTIN_TYPES_COMPATIBLE_P 1
#  define HAVE__BUILTIN_UNREACHABLE        1
#  define HAVE__BUILTIN_BSWAP16            1
#  define HAVE__BUILTIN_BSWAP32            1
#  define HAVE__BUILTIN_BSWAP64            1
#  define HAVE__BUILTIN_OP_OVERFLOW        1
#endif

/*
 * Relates to the enabled OpenSSL.
 */
#define USE_OPENSSL                1
#define HAVE_OPENSSL_INIT_SSL      1
#define HAVE_ASN1_STRING_GET0_DATA 1
#define HAVE_BIO_GET_DATA          1
#define HAVE_BIO_METH_NEW          1
#define HAVE_SSL_CLEAR_OPTIONS     1

#if OPENSSL_VERSION_NUMBER < 0x10100000L
#  define HAVE_CRYPTO_LOCK 1
#endif

#if OPENSSL_VERSION_NUMBER >= 0x10002000L
#  define HAVE_X509_GET_SIGNATURE_NID 1
#endif

#define USE_OPENSSL_RANDOM 1
#undef  USE_DEV_URANDOM
#undef  USE_WIN32_RANDOM

/*
 * Common for all supported OSes/compilers.
 */
#define ENABLE_THREAD_SAFETY                   1
#define HAVE_MEMMOVE                           1
#define HAVE_RINT                              1
#define HAVE_DECL_SNPRINTF                     1
#define HAVE_DECL_VSNPRINTF                    1
#define HAVE_DECL_STRNLEN                      1
#define HAVE_DECL_STRTOLL                      1
#define HAVE_DECL_STRTOULL                     1
#define HAVE_FSEEKO                            1
#define HAVE_FUNCNAME__FUNC                    1
#define HAVE_IPV6                              1
#define HAVE_STDINT_H                          1
#define HAVE_STDBOOL_H                         1
#define HAVE_STRTOLL                           1
#define HAVE_STRTOULL                          1
#define HAVE_STRTOF                            1
#define HAVE_TOWLOWER                          1
#define HAVE_WCSTOMBS                          1
#define HAVE_SSL_GET_CURRENT_COMPRESSION       1
#define HAVE_STRUCT_ADDRINFO                   1
#define HAVE_STRUCT_SOCKADDR_STORAGE           1
#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1
#define BLCKSZ                                 8192
#define XLOG_BLCKSZ                            8192
#define PG_KRB_SRVNAM                          "postgres"
#define PG_PRINTF_ATTRIBUTE                    printf
#define FLEXIBLE_ARRAY_MEMBER
#define MEMSET_LOOP_LIMIT                      1024
#define DEF_PGPORT                             5432
#define DEF_PGPORT_STR                         "5432"

/*
 * _Static_assert() was introduced in C11. However, all the latest major
 * compilers support it for C99 as well.
 */
#define HAVE__STATIC_ASSERT 1

/*
 * Undefined macros.
 */

/*
 * The following features are disabled.
 */
#undef USE_ASSERT_CHECKING
#undef ENABLE_NLS
#undef ENABLE_GSS
#undef USE_LDAP

/*
 * Is meaningless if NLS support is disabled (see above and libpq/buildfile for
 * details).
 */
#undef LOCALEDIR

/*
 * Is meaningless if GSSAPI support is disabled (see above). It also seems that
 * for modern systems including <gssapi.h> or <gssapi/gssapi.h> will work both
 * (<gssapi.h> just includes <gssapi/gssapi.h>).
 */
#undef HAVE_GSSAPI_H

/*
 * Integer literal LL suffix is optional for C99.
 */
#undef HAVE_LL_CONSTANTS

/*
 * Windows-specific. <crtdefs.h> is included for the latest (>= 1400) VC
 * unconditionally.
 */
#undef HAVE_CRTDEFS_H

/*
 * Solaris-specific (getpeerucred() function).
 */
#undef HAVE_GETPEERUCRED

/*
 * Hard to even find any records of these types.
 */
#undef HAVE_INT64
#undef HAVE_INT8
#undef HAVE_UINT64
#undef HAVE_UINT8

/*
 * Something optimization-related for PowerPC machines (see
 * libpq/include/pg_config_manual.h for more details).
 */
#undef HAVE_PPC_LWARX_MUTEX_HINT

/*
 * None of the supported platforms has the '__' prefix for the mentioned
 * sockaddr_storage struct members.
 */
#undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY
#undef HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN

/*
 * Let's follow Linux man page advise for sync_file_range() function:
 *
 * This system call is Linux-specific, and should be avoided in portable
 * programs.
 *
 * The macro also seems to be backend-specific.
 */
#undef HAVE_SYNC_FILE_RANGE

/*
 * None of the supported OSes have <ucred.h>. FreeBSD and Mac OS have
 * <sys/ucred.h> (HAVE_SYS_UCRED_H macro).
 */
#undef HAVE_UCRED_H

/*
 * Meaningless as HAVE_STRTOULL and HAVE_STRTOULL are always defined.
 */
#undef HAVE___STRTOLL
#undef HAVE___STRTOULL