summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2019-03-22 11:52:22 +0000
committerylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2019-03-22 11:52:22 +0000
commit6bb6ce6b36efa887d53b25fa1f793770f6de1cf5 (patch)
tree9acd70286789fc75ed26dc6c7d51d59c18441437
parent86b73a00bf9c0f23546595caa0ddc46bebca885a (diff)
downloadlibapr-6bb6ce6b36efa887d53b25fa1f793770f6de1cf5.tar.gz
Use stdint/inttypes 64bit types/formats when both available.
Which should be the case on modern platforms, no change for others. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1856042 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--build/apr_common.m46
-rw-r--r--configure.in45
-rw-r--r--include/apr.h.in9
3 files changed, 46 insertions, 14 deletions
diff --git a/build/apr_common.m4 b/build/apr_common.m4
index 9d4e686e7..208017116 100644
--- a/build/apr_common.m4
+++ b/build/apr_common.m4
@@ -985,7 +985,11 @@ AC_DEFUN([APR_CHECK_TYPES_FMT_COMPATIBLE], [
define([apr_cvname], apr_cv_typematch_[]translit([$1], [ ], [_])_[]translit([$2], [ ], [_])_[][$3])
AC_CACHE_CHECK([whether $1 and $2 use fmt %$3], apr_cvname, [
APR_TRY_COMPILE_NO_WARNING([#include <sys/types.h>
-#include <stdio.h>], [
+#include <stdio.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+], [
$1 chk1, *ptr1;
$2 chk2, *ptr2 = &chk1;
ptr1 = &chk2;
diff --git a/configure.in b/configure.in
index be06e39cb..e3dab520b 100644
--- a/configure.in
+++ b/configure.in
@@ -1401,7 +1401,8 @@ APR_FLAG_HEADERS(
errno.h \
fcntl.h \
grp.h \
- ifaddrs.h \
+ ifaddrs.h \
+ inttypes.h \
io.h \
limits.h \
mach-o/dyld.h \
@@ -1495,8 +1496,9 @@ AC_SUBST(crypth)
AC_SUBST(errnoh)
AC_SUBST(direnth)
AC_SUBST(fcntlh)
-AC_SUBST(ioh)
AC_SUBST(ifaddrsh)
+AC_SUBST(inttypesh)
+AC_SUBST(ioh)
AC_SUBST(limitsh)
AC_SUBST(mswsockh)
AC_SUBST(netdbh)
@@ -1594,9 +1596,9 @@ fi
dnl Checks for integer size
AC_CHECK_SIZEOF(char, 1)
+AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
-AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long long, 8)
if test "$ac_cv_sizeof_short" = "2"; then
@@ -1605,16 +1607,37 @@ fi
if test "$ac_cv_sizeof_int" = "4"; then
int_value=int
fi
+
# Now we need to find what apr_int64_t (sizeof == 8) will be.
-# The first match is our preference.
-if test "$ac_cv_sizeof_int" = "8"; then
+# The first match is our preference (use inttypes if available).
+APR_IFALLYES(header:stdint.h header:inttypes.h, hasinttypes="1", hasinttypes="0")
+if test "$hasinttypes" = "1"; then
+ int64_literal='#define APR_INT64_C(val) INT64_C(val)'
+ uint64_literal='#define APR_UINT64_C(val) UINT64_C(val)'
+ int64_t_fmt='#define APR_INT64_T_FMT PRId64'
+ uint64_t_fmt='#define APR_UINT64_T_FMT PRIu64'
+ uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT PRIx64'
+ int64_value="int64_t"
+ uint64_value="uint64_t"
+ APR_CHECK_TYPES_FMT_COMPATIBLE(int64_t, int, d, [
+ int64_strfn="strtoi"
+ ], [
+ APR_CHECK_TYPES_FMT_COMPATIBLE(int64_t, long, ld, [
+ int64_strfn="strtol"
+ ], [
+ APR_CHECK_TYPES_FMT_COMPATIBLE(int64_t, long long, lld, [
+ int64_strfn="strtoll"
+ ], [
+ AC_ERROR([could not determine the string function for int64_t])
+ ])])])
+elif test "$ac_cv_sizeof_int" = "8"; then
int64_literal='#define APR_INT64_C(val) (val)'
uint64_literal='#define APR_UINT64_C(val) (val##U)'
int64_t_fmt='#define APR_INT64_T_FMT "d"'
uint64_t_fmt='#define APR_UINT64_T_FMT "u"'
uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "x"'
int64_value="int"
- long_value=int
+ uint64_value="unsigned int"
int64_strfn="strtoi"
elif test "$ac_cv_sizeof_long" = "8"; then
int64_literal='#define APR_INT64_C(val) (val##L)'
@@ -1623,7 +1646,7 @@ elif test "$ac_cv_sizeof_long" = "8"; then
uint64_t_fmt='#define APR_UINT64_T_FMT "lu"'
uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "lx"'
int64_value="long"
- long_value=long
+ uint64_value="unsigned long"
int64_strfn="strtol"
elif test "$ac_cv_sizeof_long_long" = "8"; then
int64_literal='#define APR_INT64_C(val) (val##LL)'
@@ -1636,7 +1659,7 @@ elif test "$ac_cv_sizeof_long_long" = "8"; then
uint64_t_fmt='#define APR_UINT64_T_FMT "llu"'
uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "llx"'
int64_value="long long"
- long_value="long long"
+ uint64_value="unsigned long long"
int64_strfn="strtoll"
elif test "$ac_cv_sizeof_longlong" = "8"; then
int64_literal='#define APR_INT64_C(val) (val##LL)'
@@ -1645,7 +1668,7 @@ elif test "$ac_cv_sizeof_longlong" = "8"; then
uint64_t_fmt='#define APR_UINT64_T_FMT "qu"'
uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "qx"'
int64_value="__int64"
- long_value="__int64"
+ uint64_value="unsigned __int64"
int64_strfn="strtoll"
else
# int64_literal may be overriden if your compiler thinks you have
@@ -1763,7 +1786,7 @@ case $host in
uint64_t_fmt='#define APR_UINT64_T_FMT "I64u"'
uint64_t_hex_fmt='#define APR_UINT64_T_HEX_FMT "I64x"'
int64_value="__int64"
- long_value="__int64"
+ uint64_value="unsigned __int64"
int64_strfn="_strtoi64"
;;
esac
@@ -1943,8 +1966,8 @@ fi
AC_SUBST(voidp_size)
AC_SUBST(short_value)
AC_SUBST(int_value)
-AC_SUBST(long_value)
AC_SUBST(int64_value)
+AC_SUBST(uint64_value)
AC_SUBST(off_t_value)
AC_SUBST(size_t_value)
AC_SUBST(ssize_t_value)
diff --git a/include/apr.h.in b/include/apr.h.in
index 85b4631b6..130f162b5 100644
--- a/include/apr.h.in
+++ b/include/apr.h.in
@@ -96,6 +96,7 @@
#define APR_HAVE_STDLIB_H @stdlibh@
#define APR_HAVE_STRING_H @stringh@
#define APR_HAVE_STRINGS_H @stringsh@
+#define APR_HAVE_INTTYPES_H @inttypesh@
#define APR_HAVE_SYS_IOCTL_H @sys_ioctlh@
#define APR_HAVE_SYS_SENDFILE_H @sys_sendfileh@
#define APR_HAVE_SYS_SIGNAL_H @sys_signalh@
@@ -196,6 +197,10 @@
#include <stdint.h>
#endif
+#if APR_HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
#if APR_HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
@@ -376,8 +381,8 @@ typedef unsigned @int_value@ apr_uint32_t;
#define UINT64_C(v) (v ## ULL)
#endif
#else
- typedef @long_value@ apr_int64_t;
- typedef unsigned @long_value@ apr_uint64_t;
+ typedef @int64_value@ apr_int64_t;
+ typedef @uint64_value@ apr_uint64_t;
#endif
typedef @size_t_value@ apr_size_t;