From: Love Hörnquist-Åstrand Date: Sun, 20 Jan 2002 10:35:21 +0000 (+0000) Subject: rx-cleanup-gettimeofday-use-20020120 X-Git-Tag: openafs-devel-1_3_0~45 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e44d1b4232a861030f1262bcbd2a41f5c0154283;p=packages%2Fo%2Fopenafs.git rx-cleanup-gettimeofday-use-20020120 don't blindly make assumptions about gettimeofday ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== redo in a way that doesn't screw up with respect to libafsrpc and libafsrpc- using suites ==================== redo in a way that doesn't screw up with respect to libafsrpc and libafsrpc- using suites --- diff --git a/src/rx/rx_clock.c b/src/rx/rx_clock.c index 5d94973a6..a37fc6ee1 100644 --- a/src/rx/rx_clock.c +++ b/src/rx/rx_clock.c @@ -37,7 +37,7 @@ RCSID("$Header$"); #include "rx_clock.h" #endif -#if !defined(AFS_USE_GETTIMEOFDAY) +#if !defined(AFS_USE_GETTIMEOFDAY) /*use this package only if gettimeofday is much much costlier than getitime */ #ifndef KERNEL diff --git a/src/rx/rx_clock.h b/src/rx/rx_clock.h index e7d9e664c..a8665faef 100644 --- a/src/rx/rx_clock.h +++ b/src/rx/rx_clock.h @@ -47,9 +47,17 @@ struct clock { #define clock_Init() #define clock_NewTime() #define clock_UpdateTime() -#define clock_GetTime(cv) (gettimeofday((struct timeval *)cv, NULL)) #define clock_Sec() (time(NULL)) #define clock_haveCurrentTime 1 + +#define clock_GetTime(cv) \ + BEGIN \ + struct timeval tv; \ + gettimeofday(&tv, NULL); \ + (cv)->sec = (afs_int32)tv.tv_sec; \ + (cv)->usec = (afs_int32)tv.tv_usec; \ + END + #else /* AFS_USE_GETTIMEOFDAY || AFS_PTHREAD_ENV */ /* For internal use. The last value returned from clock_GetTime() */ @@ -70,11 +78,11 @@ extern void clock_Init(); extern void clock_UpdateTime(); /* Return the current clock time. If the clock value has not been updated since the last call to clock_NewTime, it is updated now */ -#define clock_GetTime(cv) \ - BEGIN \ - if (!clock_haveCurrentTime) clock_UpdateTime(); \ - (cv)->sec = clock_now.sec; \ - (cv)->usec = clock_now.usec; \ +#define clock_GetTime(cv) \ + BEGIN \ + if (!clock_haveCurrentTime) clock_UpdateTime(); \ + (cv)->sec = clock_now.sec; \ + (cv)->usec = clock_now.usec; \ END /* Current clock time, truncated to seconds */