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-2025, 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
* Define HAS_BOOL here so that Perl does not redefine bool. We included
76
* <stdbool.h> in c.h.
77
*/
78
#define HAS_BOOL 1
79
80
/*
81
* Get the basic Perl API. We use PERL_NO_GET_CONTEXT mode so that our code
82
* can compile against MULTIPLICITY Perl builds without including XSUB.h.
83
*/
84
#define PERL_NO_GET_CONTEXT
85
#include "EXTERN.h"
86
#include "perl.h"
87
88
/*
89
* We want to include XSUB.h only within .xs files, because on some platforms
90
* it undesirably redefines a lot of libc functions. But it must appear
91
* before ppport.h, so use a #define flag to control inclusion here.
92
*/
93
#ifdef PG_NEED_PERL_XSUB_H
94
/*
95
* On Windows, win32_port.h defines macros for a lot of these same functions.
96
* To avoid compiler warnings when XSUB.h redefines them, #undef our versions.
97
*/
98
#ifdef WIN32
99
#undef accept
100
#undef bind
101
#undef connect
102
#undef fopen
103
#undef fstat
104
#undef kill
105
#undef listen
106
#undef lseek
107
#undef lstat
108
#undef mkdir
109
#undef open
110
#undef putenv
111
#undef recv
112
#undef rename
113
#undef select
114
#undef send
115
#undef socket
116
#undef stat
117
#undef unlink
118
#endif
119
120
#include "XSUB.h"
121
#endif
122
123
/* put back our *printf macros ... this must match src/include/port.h */
124
#ifdef vsnprintf
125
#undef vsnprintf
126
#endif
127
#ifdef snprintf
128
#undef snprintf
129
#endif
130
#ifdef vsprintf
131
#undef vsprintf
132
#endif
133
#ifdef sprintf
134
#undef sprintf
135
#endif
136
#ifdef vfprintf
137
#undef vfprintf
138
#endif
139
#ifdef fprintf
140
#undef fprintf
141
#endif
142
#ifdef vprintf
143
#undef vprintf
144
#endif
145
#ifdef printf
146
#undef printf
147
#endif
148
149
#define vsnprintf pg_vsnprintf
150
#define snprintf pg_snprintf
151
#define vsprintf pg_vsprintf
152
#define sprintf pg_sprintf
153
#define vfprintf pg_vfprintf
154
#define fprintf pg_fprintf
155
#define vprintf pg_vprintf
156
#define printf(...) pg_printf(__VA_ARGS__)
157
158
/*
159
* Put back "_" too; but rather than making it just gettext() as the core
160
* code does, make it dgettext() so that the right things will happen in
161
* loadable modules (if they've set up TEXTDOMAIN correctly). Note that
162
* we can't just set TEXTDOMAIN here, because this file is used by more
163
* extensions than just PL/Perl itself.
164
*/
165
#undef _
166
#define _(x) dgettext(TEXTDOMAIN, x)
167
168
/* put back the definition of isnan if needed */
169
#ifdef _MSC_VER
170
#ifndef isnan
171
#define isnan(x) _isnan(x)
172
#endif
173
#endif
174
175
/* perl version and platform portability */
176
#include "
ppport.h
"
177
178
/* supply HeUTF8 if it's missing - ppport.h doesn't supply it, unfortunately */
179
#ifndef HeUTF8
180
#define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \
181
SvUTF8(HeKEY_sv(he)) : \
182
(U32)HeKUTF8(he))
183
#endif
184
185
/* supply GvCV_set if it's missing - ppport.h doesn't supply it, unfortunately */
186
#ifndef GvCV_set
187
#define GvCV_set(gv, cv) (GvCV(gv) = cv)
188
#endif
189
190
/* Perl 5.19.4 changed array indices from I32 to SSize_t */
191
#if PERL_BCDVERSION >= 0x5019004
192
#define AV_SIZE_MAX SSize_t_MAX
193
#else
194
#define AV_SIZE_MAX I32_MAX
195
#endif
196
197
#endif
/* PL_PERL_SYSTEM_H */
ppport.h
src
pl
plperl
plperl_system.h
Generated on Thu Feb 13 2025 06:13:26 for PostgreSQL Source Code by
1.9.4