Skip to content

Commit 8109f20

Browse files
committed
Support platforms where strtoll/strtoull are spelled __strtoll/__strtoull.
Ancient HPUX, for one, does this. We hadn't noticed due to the lack of regression tests that required a working strtoll. (I was slightly tempted to remove the other historical spelling, strto[u]q, since it seems we have no buildfarm members testing that case. But I refrained.) Discussion: https://postgr.es/m/151935568942.1461.14623890240535309745@wrigleys.postgresql.org
1 parent 023aa76 commit 8109f20

File tree

5 files changed

+39
-28
lines changed

5 files changed

+39
-28
lines changed

configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12419,7 +12419,7 @@ $as_echo "#define HAVE_INT_OPTRESET 1" >>confdefs.h
1241912419

1242012420
fi
1242112421

12422-
for ac_func in strtoll strtoq
12422+
for ac_func in strtoll __strtoll strtoq
1242312423
do :
1242412424
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1242512425
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -12431,7 +12431,7 @@ _ACEOF
1243112431
fi
1243212432
done
1243312433

12434-
for ac_func in strtoull strtouq
12434+
for ac_func in strtoull __strtoull strtouq
1243512435
do :
1243612436
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1243712437
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

configure.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,8 +1544,8 @@ if test x"$pgac_cv_var_int_optreset" = x"yes"; then
15441544
AC_DEFINE(HAVE_INT_OPTRESET, 1, [Define to 1 if you have the global variable 'int optreset'.])
15451545
fi
15461546

1547-
AC_CHECK_FUNCS([strtoll strtoq], [break])
1548-
AC_CHECK_FUNCS([strtoull strtouq], [break])
1547+
AC_CHECK_FUNCS([strtoll __strtoll strtoq], [break])
1548+
AC_CHECK_FUNCS([strtoull __strtoull strtouq], [break])
15491549
# strto[u]ll may exist but not be declared
15501550
AC_CHECK_DECLS([strtoll, strtoull])
15511551

src/include/c.h

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -960,13 +960,40 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
960960
extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
961961
#endif
962962

963-
#if defined(HAVE_LONG_LONG_INT) && defined(HAVE_STRTOLL) && !HAVE_DECL_STRTOLL
963+
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
964+
extern int fdatasync(int fildes);
965+
#endif
966+
967+
#ifdef HAVE_LONG_LONG_INT
968+
/* Older platforms may provide strto[u]ll functionality under other names */
969+
#if !defined(HAVE_STRTOLL) && defined(HAVE___STRTOLL)
970+
#define strtoll __strtoll
971+
#define HAVE_STRTOLL 1
972+
#endif
973+
974+
#if !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
975+
#define strtoll strtoq
976+
#define HAVE_STRTOLL 1
977+
#endif
978+
979+
#if !defined(HAVE_STRTOULL) && defined(HAVE___STRTOULL)
980+
#define strtoull __strtoull
981+
#define HAVE_STRTOULL 1
982+
#endif
983+
984+
#if !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
985+
#define strtoull strtouq
986+
#define HAVE_STRTOULL 1
987+
#endif
988+
989+
#if defined(HAVE_STRTOLL) && !HAVE_DECL_STRTOLL
964990
extern long long strtoll(const char *str, char **endptr, int base);
965991
#endif
966992

967-
#if defined(HAVE_LONG_LONG_INT) && defined(HAVE_STRTOULL) && !HAVE_DECL_STRTOULL
993+
#if defined(HAVE_STRTOULL) && !HAVE_DECL_STRTOULL
968994
extern unsigned long long strtoull(const char *str, char **endptr, int base);
969995
#endif
996+
#endif /* HAVE_LONG_LONG_INT */
970997

971998
#if !defined(HAVE_MEMMOVE) && !defined(memmove)
972999
#define memmove(d, s, c) bcopy(s, d, c)
@@ -1004,22 +1031,6 @@ extern unsigned long long strtoull(const char *str, char **endptr, int base);
10041031
#define siglongjmp longjmp
10051032
#endif
10061033

1007-
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
1008-
extern int fdatasync(int fildes);
1009-
#endif
1010-
1011-
/* If strtoq() exists, rename it to the more standard strtoll() */
1012-
#if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
1013-
#define strtoll strtoq
1014-
#define HAVE_STRTOLL 1
1015-
#endif
1016-
1017-
/* If strtouq() exists, rename it to the more standard strtoull() */
1018-
#if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
1019-
#define strtoull strtouq
1020-
#define HAVE_STRTOULL 1
1021-
#endif
1022-
10231034
/*
10241035
* We assume if we have these two functions, we have their friends too, and
10251036
* can use the wide-character functions.

src/include/pg_config.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,12 @@
684684
/* Define to 1 if your compiler understands __VA_ARGS__ in macros. */
685685
#undef HAVE__VA_ARGS
686686

687+
/* Define to 1 if you have the `__strtoll' function. */
688+
#undef HAVE___STRTOLL
689+
690+
/* Define to 1 if you have the `__strtoull' function. */
691+
#undef HAVE___STRTOULL
692+
687693
/* Define to the appropriate snprintf format for 64-bit ints. */
688694
#undef INT64_FORMAT
689695

src/include/pg_config.h.win32

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,6 @@
382382
#endif
383383
#endif
384384

385-
/* Define to 1 if you have the `strtoq' function. */
386-
/* #undef HAVE_STRTOQ */
387-
388385
/* Define to 1 if you have the `strtoull' function. */
389386
#ifdef HAVE_LONG_LONG_INT_64
390387
#define HAVE_STRTOULL 1
@@ -394,9 +391,6 @@
394391
#endif
395392
#endif
396393

397-
/* Define to 1 if you have the `strtouq' function. */
398-
/* #undef HAVE_STRTOUQ */
399-
400394
/* Define to 1 if the system has the type `struct addrinfo'. */
401395
#if (_MSC_VER > 1200)
402396
#define HAVE_STRUCT_ADDRINFO 1

0 commit comments

Comments
 (0)