Skip to content

Commit a5be529

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 c964c21 commit a5be529

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
@@ -13891,7 +13891,7 @@ $as_echo "#define HAVE_INT_OPTRESET 1" >>confdefs.h
1389113891

1389213892
fi
1389313893

13894-
for ac_func in strtoll strtoq
13894+
for ac_func in strtoll __strtoll strtoq
1389513895
do :
1389613896
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1389713897
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -13903,7 +13903,7 @@ _ACEOF
1390313903
fi
1390413904
done
1390513905

13906-
for ac_func in strtoull strtouq
13906+
for ac_func in strtoull __strtoull strtouq
1390713907
do :
1390813908
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1390913909
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
@@ -1657,8 +1657,8 @@ if test x"$pgac_cv_var_int_optreset" = x"yes"; then
16571657
AC_DEFINE(HAVE_INT_OPTRESET, 1, [Define to 1 if you have the global variable 'int optreset'.])
16581658
fi
16591659

1660-
AC_CHECK_FUNCS([strtoll strtoq], [break])
1661-
AC_CHECK_FUNCS([strtoull strtouq], [break])
1660+
AC_CHECK_FUNCS([strtoll __strtoll strtoq], [break])
1661+
AC_CHECK_FUNCS([strtoull __strtoull strtouq], [break])
16621662
# strto[u]ll may exist but not be declared
16631663
AC_CHECK_DECLS([strtoll, strtoull])
16641664

src/include/c.h

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,13 +1076,40 @@ extern int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_p
10761076
extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
10771077
#endif
10781078

1079-
#if defined(HAVE_LONG_LONG_INT) && defined(HAVE_STRTOLL) && !HAVE_DECL_STRTOLL
1079+
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
1080+
extern int fdatasync(int fildes);
1081+
#endif
1082+
1083+
#ifdef HAVE_LONG_LONG_INT
1084+
/* Older platforms may provide strto[u]ll functionality under other names */
1085+
#if !defined(HAVE_STRTOLL) && defined(HAVE___STRTOLL)
1086+
#define strtoll __strtoll
1087+
#define HAVE_STRTOLL 1
1088+
#endif
1089+
1090+
#if !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
1091+
#define strtoll strtoq
1092+
#define HAVE_STRTOLL 1
1093+
#endif
1094+
1095+
#if !defined(HAVE_STRTOULL) && defined(HAVE___STRTOULL)
1096+
#define strtoull __strtoull
1097+
#define HAVE_STRTOULL 1
1098+
#endif
1099+
1100+
#if !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
1101+
#define strtoull strtouq
1102+
#define HAVE_STRTOULL 1
1103+
#endif
1104+
1105+
#if defined(HAVE_STRTOLL) && !HAVE_DECL_STRTOLL
10801106
extern long long strtoll(const char *str, char **endptr, int base);
10811107
#endif
10821108

1083-
#if defined(HAVE_LONG_LONG_INT) && defined(HAVE_STRTOULL) && !HAVE_DECL_STRTOULL
1109+
#if defined(HAVE_STRTOULL) && !HAVE_DECL_STRTOULL
10841110
extern unsigned long long strtoull(const char *str, char **endptr, int base);
10851111
#endif
1112+
#endif /* HAVE_LONG_LONG_INT */
10861113

10871114
#if !defined(HAVE_MEMMOVE) && !defined(memmove)
10881115
#define memmove(d, s, c) bcopy(s, d, c)
@@ -1120,22 +1147,6 @@ extern unsigned long long strtoull(const char *str, char **endptr, int base);
11201147
#define siglongjmp longjmp
11211148
#endif
11221149

1123-
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
1124-
extern int fdatasync(int fildes);
1125-
#endif
1126-
1127-
/* If strtoq() exists, rename it to the more standard strtoll() */
1128-
#if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
1129-
#define strtoll strtoq
1130-
#define HAVE_STRTOLL 1
1131-
#endif
1132-
1133-
/* If strtouq() exists, rename it to the more standard strtoull() */
1134-
#if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
1135-
#define strtoull strtouq
1136-
#define HAVE_STRTOULL 1
1137-
#endif
1138-
11391150
/*
11401151
* We assume if we have these two functions, we have their friends too, and
11411152
* 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
@@ -712,6 +712,12 @@
712712
/* Define to 1 if your compiler understands __VA_ARGS__ in macros. */
713713
#undef HAVE__VA_ARGS
714714

715+
/* Define to 1 if you have the `__strtoll' function. */
716+
#undef HAVE___STRTOLL
717+
718+
/* Define to 1 if you have the `__strtoull' function. */
719+
#undef HAVE___STRTOULL
720+
715721
/* Define to the appropriate snprintf length modifier for 64-bit ints. */
716722
#undef INT64_MODIFIER
717723

src/include/pg_config.h.win32

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,6 @@
373373
#endif
374374
#endif
375375

376-
/* Define to 1 if you have the `strtoq' function. */
377-
/* #undef HAVE_STRTOQ */
378-
379376
/* Define to 1 if you have the `strtoull' function. */
380377
#ifdef HAVE_LONG_LONG_INT_64
381378
#define HAVE_STRTOULL 1
@@ -385,9 +382,6 @@
385382
#endif
386383
#endif
387384

388-
/* Define to 1 if you have the `strtouq' function. */
389-
/* #undef HAVE_STRTOUQ */
390-
391385
/* Define to 1 if the system has the type `struct addrinfo'. */
392386
#if (_MSC_VER > 1200)
393387
#define HAVE_STRUCT_ADDRINFO 1

0 commit comments

Comments
 (0)