fielding 01/04/12 00:05:51
Modified: . CHANGES acconfig.h configure.in
include apr.h.in apr.hw apr_time.h
Log:
Carefully select an appropriate native type for apr_int64_t and
define its format as APR_INT64_T_FMT and literal using APR_INT64_C().
Submitted by: Justin Erenkrantz, William Rowe
Reviewed by: Roy Fielding
Revision Changes Path
1.92 +4 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- CHANGES 2001/04/11 06:16:32 1.91
+++ CHANGES 2001/04/12 07:05:45 1.92
@@ -1,5 +1,9 @@
Changes with APR b1
+ *) Carefully select an appropriate native type for apr_int64_t and
+ define its format as APR_INT64_T_FMT and literal using APR_INT64_C().
+ [Justin Erenkrantz, William Rowe]
+
*) Make clean, distclean, and extraclean consistently according to the
Gnu makefile guidelines. [Justin Erenkrantz <[EMAIL PROTECTED]>]
1.41 +2 -0 apr/acconfig.h
Index: acconfig.h
===================================================================
RCS file: /home/cvs/apr/acconfig.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- acconfig.h 2001/04/03 00:41:03 1.40
+++ acconfig.h 2001/04/12 07:05:45 1.41
@@ -34,6 +34,8 @@
#undef SIZEOF_OFF_T
#undef SIZEOF_PID_T
+#undef HAVE_INT64_C
+
#undef HAVE_MM_SHMT_MMFILE
/* BeOS specific flag */
1.289 +44 -12 apr/configure.in
Index: configure.in
===================================================================
RCS file: /home/cvs/apr/configure.in,v
retrieving revision 1.288
retrieving revision 1.289
diff -u -r1.288 -r1.289
--- configure.in 2001/04/09 16:40:19 1.288
+++ configure.in 2001/04/12 07:05:46 1.289
@@ -608,21 +608,49 @@
if test "$ac_cv_sizeof_int" = "4"; then
int_value=int
fi
-if test "$ac_cv_sizeof_long" = "8"; then
+dnl # Now we need to find what apr_int64_t (sizeof == 8) will be.
+dnl # The first match is our preference.
+if test "$ac_cv_sizeof_int" = "8"; then
+ int64_literal='#define APR_INT64_C(val) (val)'
+ int64_t_fmt='#define APR_INT64_T_FMT "d"'
+ int64_value="int"
+ long_value=int
+elif test "$ac_cv_sizeof_long" = "8"; then
+ int64_literal='#define APR_INT64_C(val) (val##L)'
+ int64_t_fmt='#define APR_INT64_T_FMT "ld"'
+ int64_value="long"
long_value=long
-fi
-if test "$ac_cv_sizeof_long_double" = "8"; then
+elif test "$ac_cv_sizeof_long_long" = "8"; then
+ int64_literal='#define APR_INT64_C(val) (val##LL)'
+ dnl Linux, Solaris, FreeBSD all support ll with printf.
+ dnl BSD 4.4 originated 'q'. Solaris is more popular and
+ dnl doesn't support 'q'. Solaris wins. Exceptions can
+ dnl go to the OS-dependent section.
+ int64_t_fmt='#define APR_INT64_T_FMT "lld"'
+ int64_value="long long"
+ long_value="long long"
+elif test "$ac_cv_sizeof_long_double" = "8"; then
+ int64_literal='#define APR_INT64_C(val) (val##LD)'
+ int64_t_fmt='#define APR_INT64_T_FMT "Ld"'
+ int64_value="long double"
long_value="long double"
-fi
-if test "$ac_cv_sizeof_long_long" = "8"; then
- if test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_long"; then
- long_value="long"
- else
- long_value="long long"
- fi
-fi
-if test "$ac_cv_sizeof_longlong" = "8"; then
+elif test "$ac_cv_sizeof_longlong" = "8"; then
+ int64_literal='#define APR_INT64_C(val) (val##LL)'
+ int64_t_fmt='#define APR_INT64_T_FMT "qd"'
+ int64_value="__int64"
long_value="__int64"
+else
+ dnl # int64_literal may be overriden if your compiler thinks you have
+ dnl # a 64-bit value but APR does not agree.
+ int64_literal='#error Can not determine the proper size for apr_int64_t'
+ int64_t_fmt='#error Can not determine the proper size for apr_int64_t'
+fi
+
+dnl # If present, allow the C99 macro INT64_C to override our conversion.
+APR_CHECK_DEFINE(INT64_C, stdint.h)
+if test "$ac_cv_define_INT64_C" = "yes"; then
+ int64_literal='#define APR_INT64_C(val) INT64_C(val)'
+ stdint=1
fi
if test "$ac_cv_type_off_t" = "yes"; then
@@ -716,14 +744,18 @@
AC_SUBST(short_value)
AC_SUBST(int_value)
AC_SUBST(long_value)
+AC_SUBST(int64_value)
AC_SUBST(off_t_value)
AC_SUBST(size_t_value)
AC_SUBST(ssize_t_value)
AC_SUBST(socklen_t_value)
+AC_SUBST(int64_t_fmt)
AC_SUBST(ssize_t_fmt)
AC_SUBST(size_t_fmt)
AC_SUBST(off_t_fmt)
AC_SUBST(os_proc_t_fmt)
+AC_SUBST(int64_literal)
+AC_SUBST(stdint)
dnl #----------------------------- Checking for string functions
AC_CHECK_FUNCS(strnicmp, have_strnicmp="1", have_strnicmp="0")
1.79 +9 -8 apr/include/apr.h.in
Index: apr.h.in
===================================================================
RCS file: /home/cvs/apr/include/apr.h.in,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- apr.h.in 2001/04/05 18:56:07 1.78
+++ apr.h.in 2001/04/12 07:05:48 1.79
@@ -43,6 +43,7 @@
#define APR_HAVE_PTHREAD_H @pthreadh@
#define APR_HAVE_STDARG_H @stdargh@
#define APR_HAVE_STDIO_H @stdioh@
+#define APR_HAVE_STDINT_H @stdint@
#define APR_HAVE_STDLIB_H @stdlibh@
#define APR_HAVE_SIGNAL_H @signalh@
#define APR_HAVE_STRING_H @stringh@
@@ -107,6 +108,10 @@
#include <sys/socket.h>
#endif
+#if APR_HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
/* APR Feature Macros */
#define APR_HAS_SHARED_MEMORY @sharedmem@
#define APR_HAS_THREADS @threads@
@@ -170,16 +175,9 @@
/* Mechanisms to properly type numeric literals */
[EMAIL PROTECTED]@
-/* XXX: this is wrong -- the LL is only required if int64 is implemented as
- * a long long, it could be just a long on some platforms. the C99
- * correct way of doing this is to use INT64_C(1000000) which comes
- * from stdint.h. we'd probably be doing a Good Thing to check for
- * INT64_C in autoconf... or otherwise define an APR_INT64_C(). -dean
- */
-#define APR_INT64_C(val) (val##LL)
-
/* Definitions that APR programs need to work properly. */
#define APR_THREAD_FUNC
@@ -242,6 +240,9 @@
/* And APR_OS_PROC_T_FMT */
@os_proc_t_fmt@
+
+/* And APR_INT64_T_FMT */
[EMAIL PROTECTED]@
/* Local machine definition for console and log output. */
#define APR_EOL_STR "@eolstr@"
1.60 +0 -2 apr/include/apr.hw
Index: apr.hw
===================================================================
RCS file: /home/cvs/apr/include/apr.hw,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- apr.hw 2001/04/08 08:01:38 1.59
+++ apr.hw 2001/04/12 07:05:49 1.60
@@ -294,8 +294,6 @@
#define APR_INT64_T_FMT "I64d"
-#define APR_TIME_T_FMT APR_INT64_T_FMT
-
/* Local machine definition for console and log output. */
#define APR_EOL_STR "\r\n"
1.35 +2 -0 apr/include/apr_time.h
Index: apr_time.h
===================================================================
RCS file: /home/cvs/apr/include/apr_time.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- apr_time.h 2001/04/02 19:00:32 1.34
+++ apr_time.h 2001/04/12 07:05:49 1.35
@@ -78,6 +78,8 @@
/* mechanism to properly type apr_time_t literals */
#define APR_TIME_C(val) APR_INT64_C(val)
+/* mechanism to properly print apr_time_t values */
+#define APR_TIME_T_FMT APR_INT64_T_FMT
/* intervals for I/O timeouts, in microseconds */
typedef apr_int64_t apr_interval_time_t;