Skip to content

Commit 22d22e4

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 4ffd790 commit 22d22e4

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

1338513385
fi
1338613386

13387-
for ac_func in strtoll strtoq
13387+
for ac_func in strtoll __strtoll strtoq
1338813388
do :
1338913389
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1339013390
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -13396,7 +13396,7 @@ _ACEOF
1339613396
fi
1339713397
done
1339813398

13399-
for ac_func in strtoull strtouq
13399+
for ac_func in strtoull __strtoull strtouq
1340013400
do :
1340113401
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1340213402
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
@@ -1684,8 +1684,8 @@ if test x"$pgac_cv_var_int_optreset" = x"yes"; then
16841684
AC_DEFINE(HAVE_INT_OPTRESET, 1, [Define to 1 if you have the global variable 'int optreset'.])
16851685
fi
16861686

1687-
AC_CHECK_FUNCS([strtoll strtoq], [break])
1688-
AC_CHECK_FUNCS([strtoull strtouq], [break])
1687+
AC_CHECK_FUNCS([strtoll __strtoll strtoq], [break])
1688+
AC_CHECK_FUNCS([strtoull __strtoull strtouq], [break])
16891689
# strto[u]ll may exist but not be declared
16901690
AC_CHECK_DECLS([strtoll, strtoull])
16911691

src/include/c.h

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

1059-
#if defined(HAVE_LONG_LONG_INT) && defined(HAVE_STRTOLL) && !HAVE_DECL_STRTOLL
1059+
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
1060+
extern int fdatasync(int fildes);
1061+
#endif
1062+
1063+
#ifdef HAVE_LONG_LONG_INT
1064+
/* Older platforms may provide strto[u]ll functionality under other names */
1065+
#if !defined(HAVE_STRTOLL) && defined(HAVE___STRTOLL)
1066+
#define strtoll __strtoll
1067+
#define HAVE_STRTOLL 1
1068+
#endif
1069+
1070+
#if !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
1071+
#define strtoll strtoq
1072+
#define HAVE_STRTOLL 1
1073+
#endif
1074+
1075+
#if !defined(HAVE_STRTOULL) && defined(HAVE___STRTOULL)
1076+
#define strtoull __strtoull
1077+
#define HAVE_STRTOULL 1
1078+
#endif
1079+
1080+
#if !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
1081+
#define strtoull strtouq
1082+
#define HAVE_STRTOULL 1
1083+
#endif
1084+
1085+
#if defined(HAVE_STRTOLL) && !HAVE_DECL_STRTOLL
10601086
extern long long strtoll(const char *str, char **endptr, int base);
10611087
#endif
10621088

1063-
#if defined(HAVE_LONG_LONG_INT) && defined(HAVE_STRTOULL) && !HAVE_DECL_STRTOULL
1089+
#if defined(HAVE_STRTOULL) && !HAVE_DECL_STRTOULL
10641090
extern unsigned long long strtoull(const char *str, char **endptr, int base);
10651091
#endif
1092+
#endif /* HAVE_LONG_LONG_INT */
10661093

10671094
#if !defined(HAVE_MEMMOVE) && !defined(memmove)
10681095
#define memmove(d, s, c) bcopy(s, d, c)
@@ -1100,22 +1127,6 @@ extern unsigned long long strtoull(const char *str, char **endptr, int base);
11001127
#define siglongjmp longjmp
11011128
#endif
11021129

1103-
#if defined(HAVE_FDATASYNC) && !HAVE_DECL_FDATASYNC
1104-
extern int fdatasync(int fildes);
1105-
#endif
1106-
1107-
/* If strtoq() exists, rename it to the more standard strtoll() */
1108-
#if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOLL) && defined(HAVE_STRTOQ)
1109-
#define strtoll strtoq
1110-
#define HAVE_STRTOLL 1
1111-
#endif
1112-
1113-
/* If strtouq() exists, rename it to the more standard strtoull() */
1114-
#if defined(HAVE_LONG_LONG_INT_64) && !defined(HAVE_STRTOULL) && defined(HAVE_STRTOUQ)
1115-
#define strtoull strtouq
1116-
#define HAVE_STRTOULL 1
1117-
#endif
1118-
11191130
/*
11201131
* We assume if we have these two functions, we have their friends too, and
11211132
* 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
@@ -718,6 +718,12 @@
718718
/* Define to 1 if your compiler understands __VA_ARGS__ in macros. */
719719
#undef HAVE__VA_ARGS
720720

721+
/* Define to 1 if you have the `__strtoll' function. */
722+
#undef HAVE___STRTOLL
723+
724+
/* Define to 1 if you have the `__strtoull' function. */
725+
#undef HAVE___STRTOULL
726+
721727
/* Define to the appropriate snprintf length modifier for 64-bit ints. */
722728
#undef INT64_MODIFIER
723729

src/include/pg_config.h.win32

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,6 @@
370370
#endif
371371
#endif
372372

373-
/* Define to 1 if you have the `strtoq' function. */
374-
/* #undef HAVE_STRTOQ */
375-
376373
/* Define to 1 if you have the `strtoull' function. */
377374
#ifdef HAVE_LONG_LONG_INT_64
378375
#define HAVE_STRTOULL 1
@@ -382,9 +379,6 @@
382379
#endif
383380
#endif
384381

385-
/* Define to 1 if you have the `strtouq' function. */
386-
/* #undef HAVE_STRTOUQ */
387-
388382
/* Define to 1 if the system has the type `struct addrinfo'. */
389383
#if (_MSC_VER > 1200)
390384
#define HAVE_STRUCT_ADDRINFO 1

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy