Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1613e2f

Browse files
committed
Hide warnings from Python headers when using gcc-compatible compiler.
Like commit 388e801, use "#pragma GCC system_header" to silence warnings appearing within the Python headers, since newer Python versions no longer worry about some restrictions we still use like -Wdeclaration-after-statement. This patch improves on 388e801 by inventing a separate wrapper header file, allowing the pragma to be tightly scoped to just the Python headers and not other stuff we have laying about in plpython.h. I applied the same technique to plperl for the same reason: the original patch suppressed warnings for a good deal of our own code, not only the Perl headers. Like the previous commit, back-patch to supported branches. Peter Eisentraut and Tom Lane Discussion: https://postgr.es/m/ae523163-6d2a-4b81-a875-832e48dec502@eisentraut.org
1 parent aede916 commit 1613e2f

File tree

6 files changed

+388
-325
lines changed

6 files changed

+388
-325
lines changed

src/pl/plperl/GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ uninstall: uninstall-lib uninstall-data
101101

102102
install-data: installdirs
103103
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) '$(DESTDIR)$(datadir)/extension/'
104-
$(INSTALL_DATA) $(srcdir)/plperl.h $(srcdir)/ppport.h $(srcdir)/plperl_helpers.h '$(DESTDIR)$(includedir_server)'
104+
$(INSTALL_DATA) $(srcdir)/plperl.h $(srcdir)/plperl_system.h $(srcdir)/ppport.h $(srcdir)/plperl_helpers.h '$(DESTDIR)$(includedir_server)'
105105

106106
uninstall-data:
107107
rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(DATA)))
108-
rm -f $(addprefix '$(DESTDIR)$(includedir_server)'/, plperl.h ppport.h)
108+
rm -f $(addprefix '$(DESTDIR)$(includedir_server)'/, plperl.h plperl_system.h ppport.h)
109109

110110
.PHONY: install-data uninstall-data
111111

src/pl/plperl/plperl.h

Lines changed: 3 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -14,199 +14,11 @@
1414
#ifndef PL_PERL_H
1515
#define PL_PERL_H
1616

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

21123
/* declare routines from plperl.c for access by .xs files */
21224
HV *plperl_spi_exec(char *, int);

0 commit comments

Comments
 (0)