69cf32a782
to avoid unnecessary 64 bit ops which would make binaries larger: satime_t (currently unsigned int): numbers in seconds returned by the machine dependent getsecs() function which are used to measure relative time saseconds_t (currently int): numbers in seconds used to specify timeout to network drivers Per discussion on current-users.
42 lines
869 B
C
42 lines
869 B
C
/* $NetBSD: getsecs.c,v 1.9 2009/01/12 11:32:43 tsutsui Exp $ */
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <netinet/in.h>
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <lib/libsa/stand.h>
|
|
#include <lib/libsa/net.h>
|
|
|
|
#include "include/prom.h"
|
|
#include "include/rpb.h"
|
|
|
|
satime_t
|
|
getsecs(void)
|
|
{
|
|
static uint64_t tnsec;
|
|
static uint64_t lastpcc, wrapsecs;
|
|
uint64_t curpcc;
|
|
|
|
if (tnsec == 0) {
|
|
tnsec = 1;
|
|
lastpcc = alpha_rpcc() & 0xffffffff;
|
|
wrapsecs = (0xffffffff /
|
|
((struct rpb *)HWRPB_ADDR)->rpb_cc_freq) + 1;
|
|
|
|
#if 0
|
|
printf("getsecs: cc freq = %lu, time to wrap = %lu\n",
|
|
((struct rpb *)HWRPB_ADDR)->rpb_cc_freq, wrapsecs);
|
|
#endif
|
|
}
|
|
|
|
curpcc = alpha_rpcc() & 0xffffffff;
|
|
if (curpcc < lastpcc)
|
|
curpcc += 0x100000000;
|
|
|
|
tnsec += ((curpcc - lastpcc) * 1000000000) / ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq;
|
|
lastpcc = curpcc;
|
|
|
|
return (tnsec / 1000000000);
|
|
}
|