diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2018-03-23 10:31:10 -0400 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2018-03-23 10:31:10 -0400 |
commit | 7ba7986fb4364e889a705c9973fefa138650091c (patch) | |
tree | ec4b65272c7cfad83b4378ce38ee909f664e5319 /src | |
parent | f1a074b146c900bd439b6ef1953866f41b61a669 (diff) | |
download | postgresql-7ba7986fb4364e889a705c9973fefa138650091c.tar.gz postgresql-7ba7986fb4364e889a705c9973fefa138650091c.zip |
Fix interaction of Perl and stdbool.h
Revert the PL/Perl-specific change in
9a95a77d9d5d3003d2d67121f2731b6e5fc37336. We must not prevent Perl from
using stdbool.h when it has been built to do so, even if it uses an
incompatible size. Otherwise, we would be imposing our bool on Perl,
which will lead to crashes because of the size mismatch.
Instead, we undef bool after including the Perl headers, as we did
previously, but now only if we are not using stdbool.h ourselves.
Record that choice in c.h as USE_STDBOOL. This will also make it easier
to apply that coding pattern elsewhere if necessary.
Diffstat (limited to 'src')
-rw-r--r-- | src/include/c.h | 1 | ||||
-rw-r--r-- | src/pl/plperl/plperl.h | 18 |
2 files changed, 14 insertions, 5 deletions
diff --git a/src/include/c.h b/src/include/c.h index 107f4f6bcd7..95e9aeded9d 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -268,6 +268,7 @@ #if defined(HAVE_STDBOOL_H) && SIZEOF_BOOL == 1 #include <stdbool.h> +#define USE_STDBOOL 1 #else #ifndef bool diff --git a/src/pl/plperl/plperl.h b/src/pl/plperl/plperl.h index a85aefea6c1..05bdf7c1157 100644 --- a/src/pl/plperl/plperl.h +++ b/src/pl/plperl/plperl.h @@ -50,11 +50,6 @@ #define __inline__ inline #endif -/* - * Prevent perl from redefining "bool". - */ -#define HAS_BOOL 1 - /* * Get the basic Perl API. We use PERL_NO_GET_CONTEXT mode so that our code @@ -96,6 +91,19 @@ #define NEED_sv_2pv_flags #include "ppport.h" +/* + * perl might have included stdbool.h. If we also did that earlier (see c.h), + * then that's fine. If not, we probably rejected it for some reason. In + * that case, undef bool and proceed with our own bool. (Note that stdbool.h + * makes bool a macro, but our own replacement is a typedef, so the undef + * makes ours visible again). + */ +#ifndef USE_STDBOOL +#ifdef bool +#undef bool +#endif +#endif + /* supply HeUTF8 if it's missing - ppport.h doesn't supply it, unfortunately */ #ifndef HeUTF8 #define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \ |