Adjust some comments about structure properties in pg_stat.h
[pgsql.git] / src / pl / plperl / plperl_system.h
blobd1b9ea17fca2e864c302741b9e72bc124fd81eaf
1 /*-------------------------------------------------------------------------
3 * plperl_system.h
4 * Pull in Perl's system header files.
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.
11 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
12 * Portions Copyright (c) 1995, Regents of the University of California
14 * src/pl/plperl/plperl_system.h
17 #ifndef PL_PERL_SYSTEM_H
18 #define PL_PERL_SYSTEM_H
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.
26 #ifdef HAVE_PRAGMA_GCC_SYSTEM_HEADER
27 #pragma GCC system_header
28 #endif
30 /* stop perl headers from hijacking stdio and other stuff on Windows */
31 #ifdef WIN32
32 #define WIN32IO_IS_STDIO
33 #endif /* WIN32 */
36 * Supply a value of PERL_UNUSED_DECL that will satisfy gcc - the one
37 * perl itself supplies doesn't seem to.
39 #define PERL_UNUSED_DECL pg_attribute_unused()
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.
45 #undef vsnprintf
46 #undef snprintf
47 #undef vsprintf
48 #undef sprintf
49 #undef vfprintf
50 #undef fprintf
51 #undef vprintf
52 #undef printf
55 * Perl scribbles on the "_" macro too.
57 #undef _
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.
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
75 * Define HAS_BOOL here so that Perl does not redefine bool. We included
76 * <stdbool.h> in c.h.
78 #define HAS_BOOL 1
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.
84 #define PERL_NO_GET_CONTEXT
85 #include "EXTERN.h"
86 #include "perl.h"
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.
93 #ifdef PG_NEED_PERL_XSUB_H
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.
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 lstat
107 #undef mkdir
108 #undef open
109 #undef putenv
110 #undef recv
111 #undef rename
112 #undef select
113 #undef send
114 #undef socket
115 #undef stat
116 #undef unlink
117 #endif
119 #include "XSUB.h"
120 #endif
122 /* put back our *printf macros ... this must match src/include/port.h */
123 #ifdef vsnprintf
124 #undef vsnprintf
125 #endif
126 #ifdef snprintf
127 #undef snprintf
128 #endif
129 #ifdef vsprintf
130 #undef vsprintf
131 #endif
132 #ifdef sprintf
133 #undef sprintf
134 #endif
135 #ifdef vfprintf
136 #undef vfprintf
137 #endif
138 #ifdef fprintf
139 #undef fprintf
140 #endif
141 #ifdef vprintf
142 #undef vprintf
143 #endif
144 #ifdef printf
145 #undef printf
146 #endif
148 #define vsnprintf pg_vsnprintf
149 #define snprintf pg_snprintf
150 #define vsprintf pg_vsprintf
151 #define sprintf pg_sprintf
152 #define vfprintf pg_vfprintf
153 #define fprintf pg_fprintf
154 #define vprintf pg_vprintf
155 #define printf(...) pg_printf(__VA_ARGS__)
158 * Put back "_" too; but rather than making it just gettext() as the core
159 * code does, make it dgettext() so that the right things will happen in
160 * loadable modules (if they've set up TEXTDOMAIN correctly). Note that
161 * we can't just set TEXTDOMAIN here, because this file is used by more
162 * extensions than just PL/Perl itself.
164 #undef _
165 #define _(x) dgettext(TEXTDOMAIN, x)
167 /* put back the definition of isnan if needed */
168 #ifdef _MSC_VER
169 #ifndef isnan
170 #define isnan(x) _isnan(x)
171 #endif
172 #endif
174 /* perl version and platform portability */
175 #include "ppport.h"
177 /* supply HeUTF8 if it's missing - ppport.h doesn't supply it, unfortunately */
178 #ifndef HeUTF8
179 #define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \
180 SvUTF8(HeKEY_sv(he)) : \
181 (U32)HeKUTF8(he))
182 #endif
184 /* supply GvCV_set if it's missing - ppport.h doesn't supply it, unfortunately */
185 #ifndef GvCV_set
186 #define GvCV_set(gv, cv) (GvCV(gv) = cv)
187 #endif
189 /* Perl 5.19.4 changed array indices from I32 to SSize_t */
190 #if PERL_BCDVERSION >= 0x5019004
191 #define AV_SIZE_MAX SSize_t_MAX
192 #else
193 #define AV_SIZE_MAX I32_MAX
194 #endif
196 #endif /* PL_PERL_SYSTEM_H */