diff --git a/configure b/configure index c29cb1040e0..e124bfe5cc0 100755 --- a/configure +++ b/configure @@ -12443,6 +12443,28 @@ _ACEOF fi done +# strto[u]ll may exist but not be declared +ac_fn_c_check_decl "$LINENO" "strtoll" "ac_cv_have_decl_strtoll" "$ac_includes_default" +if test "x$ac_cv_have_decl_strtoll" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRTOLL $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default" +if test "x$ac_cv_have_decl_strtoull" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRTOULL $ac_have_decl +_ACEOF + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for builtin locking functions" >&5 $as_echo_n "checking for builtin locking functions... " >&6; } diff --git a/configure.in b/configure.in index 79a2649c52b..5b29f56cf7c 100644 --- a/configure.in +++ b/configure.in @@ -1546,6 +1546,8 @@ fi AC_CHECK_FUNCS([strtoll strtoq], [break]) AC_CHECK_FUNCS([strtoull strtouq], [break]) +# strto[u]ll may exist but not be declared +AC_CHECK_DECLS([strtoll, strtoull]) AC_CACHE_CHECK([for builtin locking functions], pgac_cv_gcc_int_atomics, [AC_TRY_LINK([], 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