> I put out this patch a week ago, I don't know if it will so much as compile,
> but you can hack your work above with the __int64 stuff and I think we should
> be all rounded out :-)

Whoops, I must have missed that post.
  
Okay, this works on Solaris, FreeBSD, and Linux.  

I think we are getting closer.  Comments?  

I also tried to add support for the INT64_C macro.  Ideally, INT64_C (if 
present) is always right - so the preference is to use INT64_C.  But, I guess 
it is possible for APR to make a different decision.

So, assume stdint.h says:

#define INT64_C(c) c ## LL

This would use a long long, but let's also assume that sizeof(int) == 8 - 
this patch would generate somewhere: 

typedef int apr_int64_t;
#define APR_INT64_C(c) INT64_C(c)

rather than the slightly more intuitive:

typedef int apr_int64_t;
#define APR_INT64_C(c) c

That may not be ideal.  But, this isn't a big deal and can be tweaked.

Wouldn't shock me if I get the HAVE v. HAS thing wrong...  -- justin
Index: acconfig.h
===================================================================
RCS file: /home/cvspublic/apr/acconfig.h,v
retrieving revision 1.40
diff -u -r1.40 acconfig.h
--- acconfig.h  2001/04/03 00:41:03     1.40
+++ acconfig.h  2001/04/12 03:46:03
@@ -34,6 +34,8 @@
 #undef SIZEOF_OFF_T
 #undef SIZEOF_PID_T
 
+#undef HAVE_INT64_C
+
 #undef HAVE_MM_SHMT_MMFILE
 
 /* BeOS specific flag */
Index: configure.in
===================================================================
RCS file: /home/cvspublic/apr/configure.in,v
retrieving revision 1.288
diff -u -r1.288 configure.in
--- configure.in        2001/04/09 16:40:19     1.288
+++ configure.in        2001/04/12 03:46:05
@@ -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")
Index: include/apr.h.in
===================================================================
RCS file: /home/cvspublic/apr/include/apr.h.in,v
retrieving revision 1.78
diff -u -r1.78 apr.h.in
--- include/apr.h.in    2001/04/05 18:56:07     1.78
+++ include/apr.h.in    2001/04/12 03:46:08
@@ -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@"
Index: include/apr.hw
===================================================================
RCS file: /home/cvspublic/apr/include/apr.hw,v
retrieving revision 1.59
diff -u -r1.59 apr.hw
--- include/apr.hw      2001/04/08 08:01:38     1.59
+++ include/apr.hw      2001/04/12 03:46:08
@@ -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"
 
Index: include/apr_time.h
===================================================================
RCS file: /home/cvspublic/apr/include/apr_time.h,v
retrieving revision 1.34
diff -u -r1.34 apr_time.h
--- include/apr_time.h  2001/04/02 19:00:32     1.34
+++ include/apr_time.h  2001/04/12 03:46:08
@@ -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;
Index: support/ab.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/support/ab.c,v
retrieving revision 1.69
diff -u -r1.69 ab.c
--- support/ab.c        2001/04/03 16:49:25     1.69
+++ support/ab.c        2001/04/12 03:43:43
@@ -187,6 +187,12 @@
 
 /* ------------------- DEFINITIONS -------------------------- */
 
+#ifndef LLONG_MAX
+#define AB_MAX APR_INT64_C(0x7fffffffffffffff)
+#else
+#define AB_MAX LLONG_MAX
+#endif
+
 /* maximum number of requests on a time limited test */
 #define MAX_REQUESTS 50000
 
@@ -226,13 +232,13 @@
 #ifdef USE_SSL
     /* XXXX insert SSL timings */
 #endif
-    int read;                  /* number of bytes read */
-    long starttime;            /* start time of connection in seconds since
-                                * Jan. 1, 1970 */
-    long waittime;             /* Between writing request and reading
-                                * response */
-    long ctime;                        /* time in ms to connect */
-    long time;                 /* time in ms for connection */
+    int read;              /* number of bytes read */
+    apr_time_t starttime;  /* start time of connection in seconds since
+                            * Jan. 1, 1970 */
+    apr_interval_time_t waittime;   /* Between writing request and reading
+                                     * response */
+    apr_interval_time_t ctime;      /* time in ms to connect */
+    apr_interval_time_t time;       /* time in ms for connection */
 };
 
 #define ap_min(a,b) ((a)<(b))?(a):(b)
@@ -324,8 +330,6 @@
 #endif
 
 static void close_connection(struct connection * c);
-
-static void close_connection(struct connection * c);
 /* --------------------------------------------------------- */
 
 /* simple little function to write an error string and exit */
@@ -430,8 +434,8 @@
 
 static int compri(struct data * a, struct data * b)
 {
-    int p = a->time - a->ctime;
-    int q = b->time - b->ctime;
+    apr_interval_time_t p = a->time - a->ctime;
+    apr_interval_time_t q = b->time - b->ctime;
     if (p < q)
        return -1;
     if (p > q)
@@ -450,11 +454,13 @@
 
 static void output_results(void)
 {
-    long timetaken;
+    apr_interval_time_t timetakenusec;
+    float timetaken;
 
     endtime = apr_time_now();
-    timetaken = (endtime - start) / 1000;
-
+    timetakenusec = endtime - start;
+    timetaken = (float) timetakenusec / APR_USEC_PER_SEC;
+    
     printf("\r                                                                 
          \r");
     printf("Server Software:        %s\n", servername);
     printf("Server Hostname:        %s\n", hostname);
@@ -464,8 +470,9 @@
     printf("Document Length:        %d bytes\n", doclen);
     printf("\n");
     printf("Concurrency Level:      %d\n", concurrency);
-    printf("Time taken for tests:   %qd.%03qd seconds\n",
-          timetaken / APR_USEC_PER_SEC, timetaken % APR_USEC_PER_SEC);
+    printf("Time taken for tests:   %" APR_TIME_T_FMT ".%03" APR_TIME_T_FMT " 
seconds\n",
+           (apr_interval_time_t) timetakenusec / APR_USEC_PER_SEC,
+           (apr_interval_time_t) timetakenusec % APR_USEC_PER_SEC);
     printf("Complete requests:      %ld\n", done);
     printf("Failed requests:        %ld\n", bad);
     if (bad)
@@ -483,17 +490,17 @@
 
     /* avoid divide by zero */
     if (timetaken) {
-       printf("Requests per second:    %.2f [#/sec] (mean)\n", 1000 * (float) 
(done) / timetaken);
-       printf("Time per request:       %.2f [ms] (mean)\n", concurrency * 
timetaken / (float) done);
-       printf("Time per request:       %.2f [ms] (mean, across all concurent 
requests)\n",
-              timetaken / (float) done);
+       printf("Requests per second:    %.2f [#/sec] (mean)\n", done / 
timetaken);
+       printf("Time per request:       %.3f [ms] (mean)\n", concurrency * 
timetaken / done);
+       printf("Time per request:       %.3f [ms] (mean, across all concurent 
requests)\n",
+              timetaken / done);
        printf("Transfer rate:          %.2f [Kbytes/sec] received\n",
-              (float) (totalread) / timetaken);
+              totalread / 1024 / timetaken);
        if (posting > 0) {
            printf("                        %.2f kb/s sent\n",
-                  (float) (totalposted) / timetaken);
+                  (float) totalposted / timetaken / 1024);
            printf("                        %.2f kb/s total\n",
-                  (float) (totalread + totalposted) / timetaken);
+                  (float) (totalread + totalposted) / timetaken / 1024);
        }
     }
 
@@ -501,19 +508,19 @@
        /* work out connection times */
        long i;
        double totalcon = 0, total = 0, totald = 0, totalwait = 0;
-       long mincon = 9999999, mintot = 999999, mind = 99999, minwait = 99999;
-       long maxcon = 0, maxtot = 0, maxd = 0, maxwait = 0;
-       long meancon = 0, meantot = 0, meand = 0, meanwait = 0;
-       double sdtot = 0, sdcon = 0, sdd = 0, sdwait = 0;
+   apr_interval_time_t mincon = AB_MAX, mintot = AB_MAX, mind = AB_MAX, 
+                       minwait = AB_MAX;
+   apr_interval_time_t maxcon = 0, maxtot = 0, maxd = 0, maxwait = 0;
+   apr_interval_time_t meancon = 0, meantot = 0, meand = 0, meanwait = 0;
+   double sdtot = 0, sdcon = 0, sdd = 0, sdwait = 0;
 
        for (i = 0; i < requests; i++) {
            struct data s = stats[i];
            mincon = ap_min(mincon, s.ctime);
            mintot = ap_min(mintot, s.time);
-           mind = ap_min(mintot, s.time - s.ctime);
+           mind = ap_min(mind, s.time - s.ctime);
            minwait = ap_min(minwait, s.waittime);
 
-           maxtot = ap_max(maxtot, s.time);
            maxcon = ap_max(maxcon, s.ctime);
            maxtot = ap_max(maxtot, s.time);
            maxd = ap_max(maxd, s.time - s.ctime);
@@ -531,7 +538,7 @@
 
        for (i = 0; i < requests; i++) {
            struct data s = stats[i];
-           int a;
+        apr_interval_time_t a;
            a = (s.time - total);
            sdtot += a * a;
            a = (s.ctime - totalcon);
@@ -550,7 +557,7 @@
        if (gnuplot) {
            FILE *out = fopen(gnuplot, "w");
            long i;
-           long sttime;
+           apr_time_t sttime;
            char tmstring[1024];/* XXXX */
            if (!out) {
                perror("Cannot open gnuplot output file");
@@ -563,7 +570,7 @@
                tmstring[strlen(tmstring) - 1] = '\0';  /* ctime returns a
                                                         * string with a
                                                         * trailing newline */
-               fprintf(out, "%s\t%ld\t%ld\t%ld\t%ld\t%ld\n",
+               fprintf(out, "%s\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\t%" 
APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\n",
                        tmstring,
                        sttime,
                        stats[i].ctime,
@@ -573,11 +580,11 @@
            }
            fclose(out);
        };
-       /*
-         * XXX: what is better; this hideous cast of the copare function; or
-         * the four warnings during compile ? dirkx just does not know and
-         * hates both/
-         */
+    /*
+     * XXX: what is better; this hideous cast of the copare function; or
+     * the four warnings during compile ? dirkx just does not know and
+     * hates both/
+     */
        qsort(stats, requests, sizeof(struct data),
              (int (*) (const void *, const void *)) compradre);
        if ((requests > 1) && (requests % 2))
@@ -606,20 +613,21 @@
            meantot = (stats[requests / 2].time + stats[requests / 2 + 1].time) 
/ 2;
        else
            meantot = stats[requests / 2].time;
-
-       printf("\nConnnection Times (ms)\n");
 
+       printf("\nConnection Times (ms)\n");
 
        if (confidence) {
-           printf("              min  mean[+/-sd] median   max\n");
-           printf("Connect:    %5ld %5d %6.1f  %5ld %5ld\n",
-                  mincon, (int) (totalcon + 0.5), sdcon, meancon, maxcon);
-           printf("Processing: %5ld %5d %6.1f  %5ld %5ld\n",
+#define CONF_FMT_STRING "%" APR_TIME_T_FMT " %5d %6.1f %" APR_TIME_T_FMT " %" 
APR_TIME_T_FMT "\n"
+           printf("            min  mean[+/-sd] median   max\n");
+           printf("Connect:    " CONF_FMT_STRING, 
+           mincon, (int) (totalcon + 0.5), sdcon, meancon, maxcon);
+           printf("Processing: " CONF_FMT_STRING,
                   mind, (int) (totald + 0.5), sdd, meand, maxd);
-           printf("Waiting:    %5ld %5d %6.1f  %5ld %5ld\n",
+           printf("Waiting:    " CONF_FMT_STRING,
               minwait, (int) (totalwait + 0.5), sdwait, meanwait, maxwait);
-           printf("Total:      %5ld %5d %6.1f  %5ld %5ld\n",
+           printf("Total:      " CONF_FMT_STRING,
                   mintot, (int) (total + 0.5), sdtot, meantot, maxtot);
+#undef CONF_FMT_STRING
 
 #define     SANE(what,avg,mean,sd) \
               { \
@@ -639,11 +647,14 @@
        }
        else {
            printf("              min   avg   max\n");
-           printf("Connect:    %5ld %5e %5ld\n", mincon, totalcon / requests, 
maxcon);
-           printf("Processing: %5ld %5e %5ld\n",
-               mintot - mincon, (total / requests) - (totalcon / requests),
-                  maxtot - maxcon);
-           printf("Total:      %5ld %5e %5ld\n", mintot, total / requests, 
maxtot);
+#define CONF_FMT_STRING "%5" APR_TIME_T_FMT " %5e %5" APR_TIME_T_FMT "\n"
+           printf("Connect:    " CONF_FMT_STRING, mincon, totalcon / requests, 
+           maxcon);
+           printf("Processing: " CONF_FMT_STRING, mintot - mincon, 
+           (total / requests) - (totalcon / requests), maxtot - maxcon);
+           printf("Total:      " CONF_FMT_STRING, mintot, total / requests, 
+           maxtot);
+#undef CONF_FMT_STRING
        }
 
 
@@ -654,9 +665,10 @@
                if (percs[i] <= 0)
                    printf(" 0%%  <0> (never)\n");
                else if (percs[i] >= 100)
-                   printf(" 100%%  %5ld (last request)\n", stats[(int) 
(requests - 1)].time);
+                   printf(" 100%%  %5" APR_TIME_T_FMT " (longest request)\n", 
+               stats[requests - 1].time);
                else
-                   printf("  %d%%  %5ld\n",
+                   printf("  %d%%  %5" APR_TIME_T_FMT "\n",
                    percs[i], stats[(int) (requests * percs[i] / 100)].time);
        };
        if (csvperc) {
@@ -765,9 +777,9 @@
     } {
        /* work out connection times */
        long i;
-       long totalcon = 0, total = 0;
-       long mincon = 9999999, mintot = 999999;
-       long maxcon = 0, maxtot = 0;
+       apr_interval_time_t totalcon = 0, total = 0;
+       apr_interval_time_t mincon = AB_MAX, mintot = AB_MAX;
+       apr_interval_time_t maxcon = 0, maxtot = 0;
 
        for (i = 0; i < requests; i++) {
            struct data s = stats[i];
@@ -785,20 +797,20 @@
            printf("<tr %s><th %s>&nbsp;</th> <th %s>min</th>   <th %s>avg</th> 
  <th %s>max</th></tr>\n",
                   trstring, tdstring, tdstring, tdstring, tdstring);
            printf("<tr %s><th %s>Connect:</th>"
-                  "<td %s>%5ld</td>"
-                  "<td %s>%5ld</td>"
-                  "<td %s>%5ld</td></tr>\n",
+                  "<td %s>%5" APR_TIME_T_FMT "</td>"
+                  "<td %s>%5" APR_TIME_T_FMT "</td>"
+                  "<td %s>%5" APR_TIME_T_FMT "</td></tr>\n",
                   trstring, tdstring, tdstring, mincon, tdstring, totalcon / 
requests, tdstring, maxcon);
            printf("<tr %s><th %s>Processing:</th>"
-                  "<td %s>%5ld</td>"
-                  "<td %s>%5ld</td>"
-                  "<td %s>%5ld</td></tr>\n",
+                  "<td %s>%5" APR_TIME_T_FMT "</td>"
+                  "<td %s>%5" APR_TIME_T_FMT "</td>"
+                  "<td %s>%5" APR_TIME_T_FMT "</td></tr>\n",
                   trstring, tdstring, tdstring, mintot - mincon, tdstring,
                   (total / requests) - (totalcon / requests), tdstring, maxtot 
- maxcon);
            printf("<tr %s><th %s>Total:</th>"
-                  "<td %s>%5ld</td>"
-                  "<td %s>%5ld</td>"
-                  "<td %s>%5ld</td></tr>\n",
+                  "<td %s>%5" APR_TIME_T_FMT "</td>"
+                  "<td %s>%5" APR_TIME_T_FMT "</td>"
+                  "<td %s>%5" APR_TIME_T_FMT "</td></tr>\n",
                   trstring, tdstring, tdstring, mintot, tdstring, total / 
requests, tdstring, maxtot);
        }
        printf("</table>\n");

Reply via email to