From e384388db83626bb1c901dcd2426e44b5bf428d8 Mon Sep 17 00:00:00 2001 From: Jim Rees Date: Fri, 4 Jan 2008 17:53:36 +0000 Subject: [PATCH] STABLE14-obsd-time-20080104 update kernel time functions for OpenBSD 4.2 (cherry picked from commit d2c62877ebd9b8481d7822fcd64f0803eaef9e9f) --- src/afs/OBSD/osi_machdep.h | 2 +- src/afs/OBSD/osi_sleep.c | 25 +++++++++++++++++++++---- src/afs/afs_osi.c | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/afs/OBSD/osi_machdep.h b/src/afs/OBSD/osi_machdep.h index a387f3bab..576facfed 100644 --- a/src/afs/OBSD/osi_machdep.h +++ b/src/afs/OBSD/osi_machdep.h @@ -69,7 +69,7 @@ /* time */ #define afs_hz hz #define osi_GetTime(x) microtime(x) -#define osi_Time() (time.tv_sec) +extern time_t osi_Time(); /* str */ #define afs_strcasecmp(s1, s2) strncasecmp((s1), (s2), 65535) diff --git a/src/afs/OBSD/osi_sleep.c b/src/afs/OBSD/osi_sleep.c index 5010a317e..a55fa7e6a 100644 --- a/src/afs/OBSD/osi_sleep.c +++ b/src/afs/OBSD/osi_sleep.c @@ -54,6 +54,21 @@ RCSID static char waitV; +time_t +osi_Time() +{ + struct timeval now; + + getmicrotime(&now); + return now.tv_sec; +} + +void +afs_osi_SetTime(osi_timeval_t * atv) +{ + printf("afs attempted to set clock; use \"afsd -nosettime\"\n"); +} + /* cancel osi_Wait */ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle) @@ -76,13 +91,14 @@ int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) { int timo, code = 0; - struct timeval atv, endTime; + struct timeval atv, now, endTime; AFS_STATCNT(osi_Wait); atv.tv_sec = ams / 1000; atv.tv_usec = (ams % 1000) * 1000; - timeradd(&atv, &time, &endTime); + getmicrotime(&now); + timeradd(&atv, &now, &endTime); if (ahandle) ahandle->proc = (caddr_t) curproc; @@ -90,7 +106,7 @@ afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) AFS_GUNLOCK(); do { - timersub(&endTime, &time, &atv); + timersub(&endTime, &now, &atv); timo = atv.tv_sec * hz + atv.tv_usec * hz / 1000000 + 1; if (aintok) { code = tsleep(&waitV, PCATCH | PVFS, "afs_W1", timo); @@ -104,7 +120,8 @@ afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok) /* we've been signalled */ break; } - } while (timercmp(&time, &endTime, <)); + getmicrotime(&now); + } while (timercmp(&now, &endTime, <)); AFS_GLOCK(); return code; diff --git a/src/afs/afs_osi.c b/src/afs/afs_osi.c index ff26d1908..07326e492 100644 --- a/src/afs/afs_osi.c +++ b/src/afs/afs_osi.c @@ -309,7 +309,7 @@ afs_osi_Invisible(void) } -#if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV) +#if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV) /* set the real time */ void afs_osi_SetTime(osi_timeval_t * atv) -- 2.39.5