PostgreSQL Source Code
git master
plperl_system.h
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
*
3
* plperl_system.h
4
* Pull in Perl's system header files.
5
*
6
* We break this out as a separate header file to precisely control
7
* the scope of the "system_header" pragma. No Postgres-specific
8
* declarations should be put here. However, we do include some stuff
9
* that is meant to prevent conflicts between our code and Perl.
10
*
11
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
12
* Portions Copyright (c) 1995, Regents of the University of California
13
*
14
* src/pl/plperl/plperl_system.h
15
*/
16
17
#ifndef PL_PERL_SYSTEM_H
18
#define PL_PERL_SYSTEM_H
19
20
/*
21
* Newer versions of the perl headers trigger a lot of warnings with our
22
* preferred compiler flags (at least -Wdeclaration-after-statement,
23
* -Wshadow=compatible-local are known to be problematic). The system_header
24
* pragma hides warnings from within the rest of this file, if supported.
25
*/
26
#ifdef HAVE_PRAGMA_GCC_SYSTEM_HEADER
27
#pragma GCC system_header
28
#endif
29
30
/* stop perl headers from hijacking stdio and other stuff on Windows */
31
#ifdef WIN32
32
#define WIN32IO_IS_STDIO
33
#endif
/* WIN32 */
34
35
/*
36
* Supply a value of PERL_UNUSED_DECL that will satisfy gcc - the one
37
* perl itself supplies doesn't seem to.
38
*/
39
#define PERL_UNUSED_DECL pg_attribute_unused()
40
41
/*
42
* Sometimes perl carefully scribbles on our *printf macros.
43
* So we undefine them here and redefine them after it's done its dirty deed.
44
*/
45
#undef vsnprintf
46
#undef snprintf
47
#undef vsprintf
48
#undef sprintf
49
#undef vfprintf
50
#undef fprintf
51
#undef vprintf
52
#undef printf
53
54
/*
55
* Perl scribbles on the "_" macro too.
56
*/
57
#undef _
58
59
/*
60
* ActivePerl 5.18 and later are MinGW-built, and their headers use GCC's
61
* __inline__. Translate to something MSVC recognizes. Also, perl.h sometimes
62
* defines isnan, so undefine it here and put back the definition later if
63
* perl.h doesn't.
64
*/
65
#ifdef _MSC_VER
66
#define __inline__ inline
67
#ifdef isnan
68
#undef isnan
69
#endif
70
/* Work around for using MSVC and Strawberry Perl >= 5.30. */
71
#define __builtin_expect(expr, val) (expr)
72
#endif
73
74
/*
75
* Regarding bool, both PostgreSQL and Perl might use stdbool.h or not,
76
* depending on configuration. If both agree, things are relatively harmless.
77
* If not, things get tricky. If PostgreSQL does but Perl does not, define
78
* HAS_BOOL here so that Perl does not redefine bool; this avoids compiler
79
* warnings. If PostgreSQL does not but Perl does, we need to undefine bool
80
* after we include the Perl headers; see below.
81
*/
82
#ifdef PG_USE_STDBOOL
83
#define HAS_BOOL 1
84
#endif
85
86
/*
87
* Get the basic Perl API. We use PERL_NO_GET_CONTEXT mode so that our code
88
* can compile against MULTIPLICITY Perl builds without including XSUB.h.
89
*/
90
#define PERL_NO_GET_CONTEXT
91
#include "EXTERN.h"
92
#include "perl.h"
93
94
/*
95
* We want to include XSUB.h only within .xs files, because on some platforms
96
* it undesirably redefines a lot of libc functions. But it must appear
97
* before ppport.h, so use a #define flag to control inclusion here.
98
*/
99
#ifdef PG_NEED_PERL_XSUB_H
100
/*
101
* On Windows, win32_port.h defines macros for a lot of these same functions.
102
* To avoid compiler warnings when XSUB.h redefines them, #undef our versions.
103
*/
104
#ifdef WIN32
105
#undef accept
106
#undef bind
107
#undef connect
108
#undef fopen
109
#undef fstat
110
#undef kill
111
#undef listen
112
#undef lstat
113
#undef mkdir
114
#undef open
115
#undef putenv
116
#undef recv
117
#undef rename
118
#undef select
119
#undef send
120
#undef socket
121
#undef stat
122
#undef unlink
123
#endif
124
125
#include "XSUB.h"
126
#endif
127
128
/* put back our *printf macros ... this must match src/include/port.h */
129
#ifdef vsnprintf
130
#undef vsnprintf
131
#endif
132
#ifdef snprintf
133
#undef snprintf
134
#endif
135
#ifdef vsprintf
136
#undef vsprintf
137
#endif
138
#ifdef sprintf
139
#undef sprintf
140
#endif
141
#ifdef vfprintf
142
#undef vfprintf
143
#endif
144
#ifdef fprintf
145
#undef fprintf
146
#endif
147
#ifdef vprintf
148
#undef vprintf
149
#endif
150
#ifdef printf
151
#undef printf
152
#endif
153
154
#define vsnprintf pg_vsnprintf
155
#define snprintf pg_snprintf
156
#define vsprintf pg_vsprintf
157
#define sprintf pg_sprintf
158
#define vfprintf pg_vfprintf
159
#define fprintf pg_fprintf
160
#define vprintf pg_vprintf
161
#define printf(...) pg_printf(__VA_ARGS__)
162
163
/*
164
* Put back "_" too; but rather than making it just gettext() as the core
165
* code does, make it dgettext() so that the right things will happen in
166
* loadable modules (if they've set up TEXTDOMAIN correctly). Note that
167
* we can't just set TEXTDOMAIN here, because this file is used by more
168
* extensions than just PL/Perl itself.
169
*/
170
#undef _
171
#define _(x) dgettext(TEXTDOMAIN, x)
172
173
/* put back the definition of isnan if needed */
174
#ifdef _MSC_VER
175
#ifndef isnan
176
#define isnan(x) _isnan(x)
177
#endif
178
#endif
179
180
/* perl version and platform portability */
181
#include "
ppport.h
"
182
183
/*
184
* perl might have included stdbool.h. If we also did that earlier (see c.h),
185
* then that's fine. If not, we probably rejected it for some reason. In
186
* that case, undef bool and proceed with our own bool. (Note that stdbool.h
187
* makes bool a macro, but our own replacement is a typedef, so the undef
188
* makes ours visible again).
189
*/
190
#ifndef PG_USE_STDBOOL
191
#ifdef bool
192
#undef bool
193
#endif
194
#endif
195
196
/* supply HeUTF8 if it's missing - ppport.h doesn't supply it, unfortunately */
197
#ifndef HeUTF8
198
#define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \
199
SvUTF8(HeKEY_sv(he)) : \
200
(U32)HeKUTF8(he))
201
#endif
202
203
/* supply GvCV_set if it's missing - ppport.h doesn't supply it, unfortunately */
204
#ifndef GvCV_set
205
#define GvCV_set(gv, cv) (GvCV(gv) = cv)
206
#endif
207
208
/* Perl 5.19.4 changed array indices from I32 to SSize_t */
209
#if PERL_BCDVERSION >= 0x5019004
210
#define AV_SIZE_MAX SSize_t_MAX
211
#else
212
#define AV_SIZE_MAX I32_MAX
213
#endif
214
215
#endif
/* PL_PERL_SYSTEM_H */
ppport.h
src
pl
plperl
plperl_system.h
Generated on Tue Apr 30 2024 00:13:26 for PostgreSQL Source Code by
1.9.1