summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2018-05-19 02:42:10 +0000
committerTom Lane2018-05-19 02:42:10 +0000
commit023aa76e19529bf3f00f1815262fc78186c01636 (patch)
treeadfef0b74da19ee5d857fdd1b3e566040cd9ec94 /src/include
parent54ae787ca732f7627ca2e5e000b21d42aec1c17b (diff)
Arrange to supply declarations for strtoll/strtoull if needed.
Buildfarm member dromedary is still unhappy about the recently-added ecpg "long long" tests. The reason turns out to be that it includes "-ansi" in its CFLAGS, and in their infinite wisdom Apple have decided to hide the declarations of strtoll/strtoull in C89-compliant builds. (I find it pretty curious that they hide those function declarations when you can nonetheless declare a "long long" variable, but anyway that is their behavior, both on dromedary's obsolete macOS version and the newest and shiniest.) As a result, gcc assumes these functions return "int", leading naturally to wrong results. (Looking at dromedary's past build results, it's evident that this problem also breaks pg_strtouint64() on 32-bit platforms; but we evidently have no regression tests that exercise that function with values above 32 bits.) To fix, supply declarations for these functions when the platform provides the functions but not the declarations, using the same type of mechanism as we use for some other similar cases. Discussion: https://postgr.es/m/151935568942.1461.14623890240535309745@wrigleys.postgresql.org
Diffstat (limited to 'src/include')
-rw-r--r--src/include/c.h8
-rw-r--r--src/include/pg_config.h.in8
-rw-r--r--src/include/pg_config.h.win328
3 files changed, 24 insertions, 0 deletions
diff --git a/src/include/c.h b/src/include/c.h
index 0976ddffd87..f4480a80bdb 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -960,6 +960,14 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif
+#if defined(HAVE_LONG_LONG_INT) && defined(HAVE_STRTOLL) && !HAVE_DECL_STRTOLL
+extern long long strtoll(const char *str, char **endptr, int base);
+#endif
+
+#if defined(HAVE_LONG_LONG_INT) && defined(HAVE_STRTOULL) && !HAVE_DECL_STRTOULL
+extern unsigned long long strtoull(const char *str, char **endptr, int base);
+#endif
+
#if !defined(HAVE_MEMMOVE) && !defined(memmove)
#define memmove(d, s, c) bcopy(s, d, c)
#endif
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 4c8aa0c571b..04cc3f0e37b 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -135,6 +135,14 @@
don't. */
#undef HAVE_DECL_STRLCPY
+/* Define to 1 if you have the declaration of `strtoll', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOLL
+
+/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOULL
+
/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you
don't. */
#undef HAVE_DECL_SYS_SIGLIST
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index a39c0a547b3..e3d9bae35fd 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -96,6 +96,14 @@
don't. */
#define HAVE_DECL_SNPRINTF 1
+/* Define to 1 if you have the declaration of `strtoll', and to 0 if you
+ don't. */
+#define HAVE_DECL_STRTOLL 1
+
+/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
+ don't. */
+#define HAVE_DECL_STRTOULL 1
+
/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you
don't. */
#define HAVE_DECL_VSNPRINTF 1