rx: Use a red black tree for the event stack
[openafs.git] / src / rx / rx_clock.h
index 01d1c54..648d571 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -14,7 +14,7 @@
 #define _CLOCK_
 
 #ifdef KERNEL
-#if defined(AFS_AIX_ENV) || defined(AFS_AUX_ENV)
+#if defined(AFS_AIX_ENV) || defined(AFS_AUX_ENV) || defined(AFS_SUN5_ENV)
 #include "h/systm.h"
 #include "h/time.h"
 #endif /* System V */
@@ -42,8 +42,11 @@ struct clock {
     afs_int32 usec;            /* Microseconds since clock_Init */
 };
 
-#ifndef        KERNEL
-#if defined(AFS_USE_GETTIMEOFDAY) || defined(AFS_PTHREAD_ENV)
+#if defined(KERNEL)
+#include "afs/afs_osi.h"
+#endif
+#if !defined(KERNEL) || defined(UKERNEL)
+#if defined(AFS_USE_GETTIMEOFDAY) || defined(AFS_PTHREAD_ENV) || defined(UKERNEL)
 #define clock_Init()
 #define clock_NewTime()
 #define clock_UpdateTime()
@@ -83,14 +86,18 @@ extern int clock_nUpdates;
 
 /* Current clock time, truncated to seconds */
 #define        clock_Sec() ((!clock_haveCurrentTime)? clock_UpdateTime(), clock_now.sec:clock_now.sec)
+
+extern void clock_Init(void);
+extern int clock_UnInit(void);
+extern void clock_UpdateTime(void);
+
 #endif /* AFS_USE_GETTIMEOFDAY || AFS_PTHREAD_ENV */
 #else /* KERNEL */
-#include "afs/afs_osi.h"
 #define clock_Init()
 #if defined(AFS_SGI61_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX_64BIT_KERNEL)
 #define clock_GetTime(cv) osi_GetTime((osi_timeval_t *)cv)
 #else
-#if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
+#if (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) || (defined(AFS_DARWIN100_ENV) && defined(__amd64__)) || defined(AFS_NBSD_ENV)
 #define        clock_GetTime(cv)                               \
     BEGIN                                              \
        struct timeval tv;                              \
@@ -99,7 +106,7 @@ extern int clock_nUpdates;
        (cv)->usec = (afs_int32)tv.tv_usec;             \
     END
 #else /* defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) */
-#define clock_GetTime(cv) osi_GetTime((struct timeval *)cv)
+#define clock_GetTime(cv) osi_GetTime((osi_timeval_t *)(cv))
 #endif /* defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) */
 #endif
 #define clock_Sec() osi_Time()
@@ -126,14 +133,17 @@ extern int clock_nUpdates;
 /* Add time c2 to time c1.  Both c2 and c1 must be positive times. */
 #define        clock_Add(c1, c2)                                       \
     BEGIN                                                      \
+       (c1)->sec += (c2)->sec;                                 \
        if (((c1)->usec += (c2)->usec) >= 1000000) {            \
            (c1)->usec -= 1000000;                              \
            (c1)->sec++;                                        \
        }                                                       \
-       (c1)->sec += (c2)->sec;                                 \
     END
 
-#define MSEC(cp)       ((cp->sec * 1000) + (cp->usec / 1000))
+#define USEC(cp)        (((cp)->sec * 1000000) + (cp)->usec)
+#define MSEC(cp)       (((cp)->sec * 1000) + ((cp)->usec / 1000))
+#define _4THMSEC(cp)    (((cp)->sec * 4000) + ((cp)->usec / 250))
+#define _8THMSEC(cp)    (((cp)->sec * 8000) + ((cp)->usec / 125))
 
 /* Add ms milliseconds to time c1.  Both ms and c1 must be positive */
 #define        clock_Addmsec(c1, ms)                                    \