From f2a8150e2dc34c4c1b039874b6f88409a1d9737f Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Tue, 19 Dec 1995 19:35:24 +0000 Subject: [PATCH] -cjm 20-Nov-95 Add code for gettimeofday --- src/ca/vms_depen.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/ca/vms_depen.c b/src/ca/vms_depen.c index 23075bcf0..9556ef23c 100644 --- a/src/ca/vms_depen.c +++ b/src/ca/vms_depen.c @@ -26,9 +26,15 @@ * Advanced Photon Source * Argonne National Laboratory * + * * Modification Log: * ----------------- + * cjm 20-Nov-95 Add code for gettimeofday + * * $Log$ + * Revision 1.18 1995/10/12 01:35:30 jhill + * Moved cac_mux_io() to iocinf.c + * * Revision 1.17 1995/08/22 00:27:56 jhill * added cvs style mod log * @@ -44,7 +50,13 @@ #include "iocinf.h" +#ifdef UCX +#include "ucx.h" +#endif + +#if 0 #define CONNECTION_TIMER_ID 56 +#endif /* @@ -59,6 +71,51 @@ void cac_gettimeval(struct timeval *pt) assert(status==0); } + +/* + * gettimeofday + */ +#ifndef MULTINET +int gettimeofday(struct timeval *tp, struct timezone *tzp) +{ + + unsigned int quadtime[2] ; + int status ; + int nanosecs ; + double secs ; + int bit31 ; + double dtime ; /* vax 64 bit integer as a double */ + + if (tp != (struct timeval *)NULL) + { + status = sys$gettim(&quadtime) ; + if (status != SS$_NORMAL) + return -1 ; + else + { + bit31 = quadtime[0] & 0x80000000 ; + dtime = quadtime[1]*TWOPOWER32 + (quadtime[0] & 0x7fffffff) ; + if (bit31 != 0) + dtime = (dtime + TWOPOWER31)/ 10000000.0 ; + else + dtime = dtime / 10000000.0 ; + secs = dtime - UNIX_EPOCH_AS_MJD * 86400. ; + tp->tv_sec = (int)secs ; + tp->tv_usec = (int)((secs - tp->tv_sec)*1000000.0) ; + } + } + + if (tzp != (struct timezone *)NULL) + { + tzp->tz_minuteswest = 0 ; + tzp->tz_dsttime = 0 ; + } + + return 0 ; + +} +#endif + /* * cac_block_for_io_completion()