1 /*-------------------------------------------------------------------------
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
30 /* stop perl headers from hijacking stdio and other stuff on Windows */
32 #define WIN32IO_IS_STDIO
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.
55 * Perl scribbles on the "_" macro too.
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
66 #define __inline__ inline
70 /* Work around for using MSVC and Strawberry Perl >= 5.30. */
71 #define __builtin_expect(expr, val) (expr)
75 * Define HAS_BOOL here so that Perl does not redefine bool. We included
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
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.
122 /* put back our *printf macros ... this must match src/include/port.h */
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.
165 #define _(x) dgettext(TEXTDOMAIN, x)
167 /* put back the definition of isnan if needed */
170 #define isnan(x) _isnan(x)
174 /* perl version and platform portability */
177 /* supply HeUTF8 if it's missing - ppport.h doesn't supply it, unfortunately */
179 #define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \
180 SvUTF8(HeKEY_sv(he)) : \
184 /* supply GvCV_set if it's missing - ppport.h doesn't supply it, unfortunately */
186 #define GvCV_set(gv, cv) (GvCV(gv) = cv)
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
193 #define AV_SIZE_MAX I32_MAX
196 #endif /* PL_PERL_SYSTEM_H */