rx-cleanup-gettimeofday-use-20020120
authorLove Hörnquist-Åstrand <lha@e.kth.se>
Sun, 20 Jan 2002 10:35:21 +0000 (10:35 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sun, 20 Jan 2002 10:35:21 +0000 (10:35 +0000)
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

src/rx/rx_clock.c
src/rx/rx_clock.h

index 5d94973..a37fc6e 100644 (file)
@@ -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
index e7d9e66..a8665fa 100644 (file)
@@ -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 */