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