From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Thu, 7 Mar 1996 14:57:08 -0500 From: Scott Schwartz schwartz@galapagos.cse.psu.edu Subject: ape, gettimeofday.c Topicbox-Message-UUID: 3f6c35bc-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <19960307195708._zzAiijAV6IgbpYr--wF3KdTxABrb5KcP7vEk0OcO00@z> Pgp is much happier if gettimeofday returns something for the usec field. Here's a version that tries to do that. #include #include #include #include #include #include #include static int ms(void) { char b[20]; static int f = -1; /* XXX - should use native plan9 syscalls herein */ memset(b, 0, sizeof(b)); if (f < 0) { f = open("/dev/msec", O_RDONLY); fcntl(f, FD_CLOEXEC, 1); } if (f >= 0) { lseek(f, 0, 0); read(f, b, sizeof(b)); } return atol(b) % 1000; } int gettimeofday(struct timeval *tp, struct timezone *tzp) { tp->tv_sec = time(0); tp->tv_usec = ms() * 1000; if(tzp) { tzp->tz_minuteswest = 240; tzp->tz_dsttime = 1; } return 0; }