Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_FS_1_19910112 - c/lib5/usys/old-gettim.save
There are no other files named old-gettim.save in the archive.
/*
** gettimeofday(2) - get/set date and time
** Bill Palmer / Stanford University / 28 June 1985
*/

#include "c-env.h"
#include "sys/time.h"

#if SYS_T20+SYS_10X
#include "jsys.h"
#endif

#define EPOCH 0117213252525		/* Jan 1, 1970 0:00 in T20 TAD form */
#define SECPERDAY 24*60*60		/* this many seconds in a day */

gettimeofday(tp,tzp)
struct timeval *tp;
struct timezone *tzp;
{
#if SYS_T20 
    unsigned acs[5];
    unsigned i, j;

    if (!jsys(GTAD,acs)) return -1;	/* jsys error */
    if (acs[1] == -1) return -1;	/* or time not set */
    i = ((acs[1] - EPOCH) >> 18);	/* get number of days into i */
    j = ((acs[1] - EPOCH) & RH);	/* fractions of a second */
    j *= SECPERDAY;
    j /= RH;
    i *= SECPERDAY;
    tp->tv_sec = (long)(i + j);		/* seconds since EPOCH */
    tp->tv_usec = 0L;			/* can't be believed */

    acs[2] = acs[1];			/* current TAD to ac1 */
    if (!jsys(ODCNV,acs)) return -1;	/* jsys error */
        
    tzp->tz_dsttime = (int)(acs[4] & ICADS);
    tzp->tz_minuteswest = (int)((acs[4] & ICTMZ ) >> 18) * 60;
    return 0;				/* success return */
#else
#error gettimeofday() not supported for this system.
#endif
}