You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@hyperreal.org on 1999/08/09 17:52:32 UTC

cvs commit: apache-apr/include apr_portable.h

rbb         99/08/09 08:52:32

  Modified:    apr/include apr_config.h.in
               apr/test ab_apr.c
               apr/time/unix access.c atime.h time.c
               include  apr_portable.h
  Log:
  Update Unix side to match Windows side from the work done this weekend.
  All the test program compile now, and the simple ones still work.  I am
  still working on the more complex programs.
  
  Revision  Changes    Path
  1.14      +1 -0      apache-apr/apr/include/apr_config.h.in
  
  Index: apr_config.h.in
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/include/apr_config.h.in,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- apr_config.h.in	1999/08/04 17:51:56	1.13
  +++ apr_config.h.in	1999/08/09 15:52:29	1.14
  @@ -248,6 +248,7 @@
   #undef HAVE_LIBPTHREAD
   #define API_EXPORT(type) type
   #define API_EXPORT_NONSTD(type) type
  +#define API_VAR_IMPORT extern
   
   /* Make sure we have ssize_t defined to be somethine */
   #undef ssize_t
  
  
  
  1.15      +0 -14     apache-apr/apr/test/ab_apr.c
  
  Index: ab_apr.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/test/ab_apr.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ab_apr.c	1999/08/08 21:19:45	1.14
  +++ ab_apr.c	1999/08/09 15:52:29	1.15
  @@ -233,20 +233,6 @@
   }
   
           /* --------------------------------------------------------- */
  -        /* returns the time in ms between two timevals */
  -
  -static int timedif(struct timeval a, struct timeval b)
  -{
  -    register int us, s;
  -
  -    us = a.tv_usec - b.tv_usec;
  -    us /= 1000;
  -    s = a.tv_sec - b.tv_sec;
  -    s *= 1000;
  -    return s + us;
  -}
  -
  -        /* --------------------------------------------------------- */
   
           /* calculate and output results */
   
  
  
  
  1.8       +1 -1      apache-apr/apr/time/unix/access.c
  
  Index: access.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/time/unix/access.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- access.c	1999/07/30 15:35:57	1.7
  +++ access.c	1999/08/09 15:52:30	1.8
  @@ -69,7 +69,7 @@
   ap_status_t ap_get_curtime(struct atime_t *time, ap_int64_t *rv)
   {
       if (time) {
  -        (*rv) = time->currtime;
  +        (*rv) = time->currtime->tv_sec;
           return APR_SUCCESS;
       }
       return APR_ENOTIME;    
  
  
  
  1.3       +2 -2      apache-apr/apr/time/unix/atime.h
  
  Index: atime.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/time/unix/atime.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- atime.h	1999/05/21 19:54:04	1.2
  +++ atime.h	1999/08/09 15:52:30	1.3
  @@ -57,11 +57,11 @@
   #define ATIME_H
   
   #include "apr_time.h"
  -#include <time.h>
  +#include <sys/time.h>
   
   struct atime_t {
       ap_context_t *cntxt;
  -    time_t currtime;
  +    struct timeval *currtime;
       struct tm *explodedtime;
   };
       
  
  
  
  1.9       +38 -18    apache-apr/apr/time/unix/time.c
  
  Index: time.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/time/unix/time.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- time.c	1999/07/30 15:35:57	1.8
  +++ time.c	1999/08/09 15:52:31	1.9
  @@ -78,7 +78,7 @@
   
       (*new)->cntxt = cont;
       (*new)->explodedtime = NULL;
  -    (*new)->currtime = -1;
  +    (*new)->currtime = NULL;
       return APR_SUCCESS;
   }
   
  @@ -89,9 +89,9 @@
    */
   ap_status_t ap_current_time(struct atime_t *new)
   {
  -    if (time(&new->currtime) == -1) {
  -        return errno;
  -    }
  +    struct timeval newtime;
  +    new->currtime = ap_palloc(new->cntxt, sizeof(struct timeval));
  +    gettimeofday(new->currtime, NULL);
       return APR_SUCCESS; 
   }       
   
  @@ -104,15 +104,15 @@
    *            APR_LOCALTIME  -- Use local time
    *            APR_UTCTIME    -- Use UTC time
    */
  -ap_status_t ap_explode_time(struct atime_t *time, ap_timetype_e type)
  +ap_status_t ap_explode_time(struct atime_t *atime, ap_timetype_e type)
   {
       switch (type) {
       case APR_LOCALTIME: {
  -        time->explodedtime = localtime(&time->currtime);
  +        atime->explodedtime = localtime(&atime->currtime->tv_sec);
           break;
       }
       case APR_UTCTIME: {
  -        time->explodedtime = gmtime(&time->currtime);
  +        atime->explodedtime = gmtime(&atime->currtime->tv_sec);
           break;
       }
       }
  @@ -125,14 +125,14 @@
    *    since epoch
    * arg 1) The time entity to reference.
    */
  -ap_status_t ap_implode_time(struct atime_t *time)
  +ap_status_t ap_implode_time(struct atime_t *atime)
   {
       int year;
       time_t days;
       static const int dayoffset[12] =
       {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
   
  -    year = time->explodedtime->tm_year;
  +    year = atime->explodedtime->tm_year;
   
       if (year < 70 || ((sizeof(time_t) <= 4) && (year >= 138))) {
           return APR_EBADDATE;
  @@ -140,23 +140,25 @@
   
       /* shift new year to 1st March in order to make leap year calc easy */
   
  -    if (time->explodedtime->tm_mon < 2)
  +    if (atime->explodedtime->tm_mon < 2)
           year--;
   
       /* Find number of days since 1st March 1900 (in the Gregorian calendar). */
   
       days = year * 365 + year / 4 - year / 100 + (year / 100 + 3) / 4;
  -    days += dayoffset[time->explodedtime->tm_mon] + 
  -            time->explodedtime->tm_mday - 1;
  +    days += dayoffset[atime->explodedtime->tm_mon] + 
  +            atime->explodedtime->tm_mday - 1;
       days -= 25508;              /* 1 jan 1970 is 25508 days since 1 mar 1900 */
   
  -    days = ((days * 24 + time->explodedtime->tm_hour) * 60 + 
  -             time->explodedtime->tm_min) * 60 + time->explodedtime->tm_sec;
  +    days = ((days * 24 + atime->explodedtime->tm_hour) * 60 + 
  +             atime->explodedtime->tm_min) * 60 + atime->explodedtime->tm_sec;
   
       if (days < 0) {
           return APR_EBADDATE;
       }
  -    time->currtime = days;            /* must be a valid time */
  +    atime->currtime = ap_palloc(atime->cntxt, sizeof(struct timeval));
  +    atime->currtime->tv_sec = days;            /* must be a valid time */
  +    atime->currtime->tv_usec = 0;
       return APR_SUCCESS;
   }
   
  @@ -166,12 +168,12 @@
    * arg 1) The time value to convert.
    * arg 2) The OS specific value to convert to.
    */
  -ap_status_t ap_get_os_time(struct atime_t *thetime, ap_os_time_t *atime)
  +ap_status_t ap_get_os_time(struct atime_t *thetime, ap_os_time_t **atime)
   {
       if (thetime == NULL) {
           return APR_ENOTIME;
       }
  -    if (thetime->currtime == -1) {
  +    if (thetime->currtime == NULL) {
           ap_implode_time(thetime); 
       }
       atime = &(thetime->currtime);
  @@ -195,7 +197,25 @@
           (*thetime) = (struct atime_t *)ap_palloc(cont, sizeof(struct atime_t));
           (*thetime)->cntxt = cont;
       }
  -    (*thetime)->currtime = *atime;
  +    (*thetime)->currtime = atime;
       return APR_SUCCESS;
   }
   
  +/* ***APRDOC********************************************************
  + * ap_status_t ap_timediff(ap_time_t *, ap_time_t *, ap_int32_t *)
  + *    Retrieve the difference between two time structures in milliseconds.
  + * arg 1) The first time value
  + * arg 2) The second timevalue
  + * arg 3) The difference to return.
  + */
  +ap_status_t ap_timediff(struct atime_t *a, struct atime_t *b, ap_int32_t *rv)
  +{
  +    register int us, s;
  +
  +    us = a->currtime->tv_usec - b->currtime->tv_usec;
  +    us /= 1000;
  +    s = a->currtime->tv_sec - b->currtime->tv_sec;
  +    s *= 1000;
  +    return s + us;
  +}
  + 
  
  
  
  1.5       +2 -2      apache-apr/include/apr_portable.h
  
  Index: apr_portable.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/include/apr_portable.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- apr_portable.h	1999/07/13 19:51:41	1.4
  +++ apr_portable.h	1999/08/09 15:52:31	1.5
  @@ -137,7 +137,7 @@
   typedef pthread_t             ap_os_thread_t;
   typedef pid_t                 ap_os_proc_t;
   typedef pthread_key_t         ap_os_threadkey_t;
  -typedef time_t                ap_os_time_t;
  +typedef struct timeval        ap_os_time_t;
   #endif
   
   ap_status_t ap_get_os_file(ap_file_t *, ap_os_file_t *);     
  @@ -146,7 +146,7 @@
   ap_status_t ap_get_os_lock(ap_lock_t *, ap_os_lock_t *);     
   ap_status_t ap_get_os_thread(ap_thread_t *, ap_os_thread_t *);
   ap_status_t ap_get_os_proc(ap_proc_t *, ap_os_proc_t *);     
  -ap_status_t ap_get_os_time(ap_time_t *, ap_os_time_t *);     
  +ap_status_t ap_get_os_time(ap_time_t *, ap_os_time_t **);     
   ap_status_t ap_get_os_threadkey(ap_key_t *, ap_os_threadkey_t *);
   
   ap_status_t ap_put_os_file(ap_context_t *, ap_file_t **, ap_os_file_t *);