summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/utils/adt/tsginidx.c4
-rw-r--r--src/include/access/gin.h4
-rw-r--r--src/include/c.h14
-rw-r--r--src/include/pg_config.h.win329
-rw-r--r--src/pl/plperl/plperl.h10
5 files changed, 31 insertions, 10 deletions
diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c
index de59e6417e..00e32b2570 100644
--- a/src/backend/utils/adt/tsginidx.c
+++ b/src/backend/utils/adt/tsginidx.c
@@ -309,7 +309,9 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS)
* query.
*/
gcv.first_item = GETQUERY(query);
- gcv.check = check;
+ StaticAssertStmt(sizeof(GinTernaryValue) == sizeof(bool),
+ "sizes of GinTernaryValue and bool are not equal");
+ gcv.check = (GinTernaryValue *) check;
gcv.map_item_operand = (int *) (extra_data[0]);
gcv.need_recheck = recheck;
diff --git a/src/include/access/gin.h b/src/include/access/gin.h
index 0acdb88241..3d8a130b69 100644
--- a/src/include/access/gin.h
+++ b/src/include/access/gin.h
@@ -51,8 +51,8 @@ typedef struct GinStatsData
/*
* A ternary value used by tri-consistent functions.
*
- * For convenience, this is compatible with booleans. A boolean can be
- * safely cast to a GinTernaryValue.
+ * This must be of the same size as a bool because some code will cast a
+ * pointer to a bool to a pointer to a GinTernaryValue.
*/
typedef char GinTernaryValue;
diff --git a/src/include/c.h b/src/include/c.h
index 37c0c39199..107f4f6bcd 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -255,12 +255,21 @@
* bool
* Boolean value, either true or false.
*
- * XXX for C++ compilers, we assume the compiler has a compatible
- * built-in definition of bool.
+ * Use stdbool.h if available and its bool has size 1. That's useful for
+ * better compiler and debugger output and for compatibility with third-party
+ * libraries. But PostgreSQL currently cannot deal with bool of other sizes;
+ * there are static assertions around the code to prevent that.
+ *
+ * For C++ compilers, we assume the compiler has a compatible built-in
+ * definition of bool.
*/
#ifndef __cplusplus
+#if defined(HAVE_STDBOOL_H) && SIZEOF_BOOL == 1
+#include <stdbool.h>
+#else
+
#ifndef bool
typedef char bool;
#endif
@@ -273,6 +282,7 @@ typedef char bool;
#define false ((bool) 0)
#endif
+#endif
#endif /* not C++ */
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index e934cf87bd..b0477f0231 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -356,6 +356,9 @@
/* Define to 1 if you have the `SSL_get_current_compression' function. */
#define HAVE_SSL_GET_CURRENT_COMPRESSION 1
+/* Define to 1 if stdbool.h conforms to C99. */
+/* #undef HAVE_STDBOOL_H */
+
/* Define to 1 if you have the <stdint.h> header file. */
/* #undef HAVE_STDINT_H */
@@ -524,6 +527,9 @@
/* Define to 1 if you have the <winldap.h> header file. */
/* #undef HAVE_WINLDAP_H */
+/* Define to 1 if the system has the type `_Bool'. */
+/* #undef HAVE__BOOL */
+
/* Define to 1 if your compiler understands __builtin_bswap16. */
/* #undef HAVE__BUILTIN_BSWAP16 */
@@ -606,6 +612,9 @@
/* A string containing the version number, platform, and C compiler */
#define PG_VERSION_STR "Uninitialized version string (win32)"
+/* The size of `bool', as computed by sizeof. */
+#define SIZEOF_BOOL 0
+
/* The size of `long', as computed by sizeof. */
#define SIZEOF_LONG 4
diff --git a/src/pl/plperl/plperl.h b/src/pl/plperl/plperl.h
index 6fe7803088..a85aefea6c 100644
--- a/src/pl/plperl/plperl.h
+++ b/src/pl/plperl/plperl.h
@@ -50,6 +50,11 @@
#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
@@ -91,11 +96,6 @@
#define NEED_sv_2pv_flags
#include "ppport.h"
-/* perl may have a different width of "bool", don't buy it */
-#ifdef bool
-#undef bool
-#endif
-
/* supply HeUTF8 if it's missing - ppport.h doesn't supply it, unfortunately */
#ifndef HeUTF8
#define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \