FreeBSD/sys/cddl/dev/dtrace/i386/dtrace_subr.c
/*
 * DTrace needs a high resolution time function which can
 * be called from a probe context and guaranteed not to have
 * instrumented with probes itself.
 *
 * Returns nanoseconds since boot.
 */
DTrace needs a high resolution time function which can
be called from a probe context and guaranteed not to have
instrumented with probes itself.

Returns nanoseconds since boot.
DTrace needs a high resolution time function which can be called from a probe context and guaranteed not to have instrumented with probes itself . Returns nanoseconds since boot .
uint64_t
dtrace_gethrtime()
{
	uint64_t tsc;
	uint32_t lo;
	uint32_t hi;
	tsc = rdtsc() - tsc_skew[curcpu];
	lo = tsc;
	hi = tsc >> 32;
	return (((lo * nsec_scale) >> SCALE_SHIFT) +
	    ((hi * nsec_scale) << (32 - SCALE_SHIFT)));
}
uint64_t dtrace_gethrtime ( ) { uint64_t tsc ; uint32_t lo ; uint32_t hi ; tsc = rdtsc ( ) - tsc_skew [ curcpu ] ; lo = tsc ; hi = tsc >> 32 ; return ( ( ( lo * nsec_scale ) >> SCALE_SHIFT ) + ( ( hi * nsec_scale ) << ( 32 - SCALE_SHIFT ) ) ) ; }
DTrace needs a high resolution time function which can
 be called from a probe context and guaranteed not to have
 instrumented with probes itself.
DTrace needs a high resolution time function which can be called from a probe context and guaranteed not to have instrumented with probes itself .
/*
	 * We split TSC value into lower and higher 32-bit halves and separately
	 * scale them with nsec_scale, then we scale them down by 2^28
	 * (see nsec_scale calculations) taking into account 32-bit shift of
	 * the higher half and finally add.
	 */