Esempio n. 1
0
/*
 * 	_sysclock_nowrap
 *
 *	If the HW clock is 64 bits, use it.  Else use gettimeofday().
 */
long long
_sysclock_nowrap(void)
{
        static struct timeval  firstcall;
        static struct timezone  firstcallz;
        struct timeval  buf;
        struct timezone buf2;
        long long cval, highbits;

	if (_init_hw_clock_called == 0)
		_init_hw_clock();

#if	defined(__mips)
	if (_rtc_clockaddr != NULL)
		return *_rtc_clockaddr;
#endif

	if (firstcall.tv_usec == 0) 
        	(void) gettimeofday (&firstcall, &firstcallz);

        (void) gettimeofday (&buf, &buf2);
        cval = (long long)(buf.tv_sec - firstcall.tv_sec) * 1000000LL
		+ (long long)(buf.tv_usec - firstcall.tv_usec);

	return cval;
}
Esempio n. 2
0
_f_real8
timef_(void)
{
	static int64	initial_rt = -1; /* Clock value from initial call */
	int64		rt, rtdif;
        static double msec_per_cycle;    /* reciprocal so we can multiply */

        if (msec_per_cycle == 0.0) {
                _init_hw_clock();
                msec_per_cycle = 1000.0 / _nowrap_cycles_per_sec;
        }

	rt = _sysclock_nowrap();

	if (initial_rt < 0) {
		initial_rt	= rt;
		rtdif		= 0;
		/*
		 * force rtdif to 0 to prevent anomalies due to possible
		 * race conditions between 2 or more tasks calling TIMEF
		 * concurrently on the initial call.
		 */
	}
	else
		rtdif		= rt - initial_rt;

	return  (_f_real8)rtdif * msec_per_cycle;
}
Esempio n. 3
0
/*
 *	On MIPS systems, use 64 bit clock if available.  Else use gettimeofday.
 */
_f_real8
secondr_(void)
{
	static double sec_per_cycle;	/* reciprocal so we can multiply */

	if (sec_per_cycle == 0.0) {
		_init_hw_clock();
		sec_per_cycle = 1.0 / _nowrap_cycles_per_sec;
	}

	return (_f_real8)_sysclock_nowrap() * sec_per_cycle;

}
Esempio n. 4
0
/*
 * 	_sysclock_fast
 *
 *	If the HW clock exists, use it.  Else use gettimeofday().
 */
long long
_sysclock_fast(void)
{
	if (_init_hw_clock_called == 0)
		_init_hw_clock();

#if	defined(__mips)
	if (_rtc_clockaddr != NULL)
		return *_rtc_clockaddr;
	else if (_rtc_clockaddr32 != NULL)
		return (long long) *_rtc_clockaddr32;
#endif

	return _sysclock_nowrap();
}