OS_NSEC_TO_CYCLES OS_NSEC_TO_CYCLES (Macro)

OS_NSEC_TO_CYCLES, OS_USEC_TO_CYCLES

Converts from nanoseconds or microseconds to CPU count register cycles

Syntax

#include <ultra64.h>     /* ultra64.h */
OSTime OS_NSEC_TO_CYCLES(u64 nsecs);
OSTime OS_USEC_TO_CYCLES(u64 usecs);

Description

The OS_NSEC_TO_CYCLES and OS_USEC_TO_CYCLES macros convert time (nanoseconds or microseconds) into the number of CPU count register cycles.

The count in the CPU's count register is the unit used by the functions osGetTime and osSetTimer. Irregardless of whether the system is NTSC or PAL, this counter increments at 46.875 MHz, with 1 cycle equal to approximately 21.33 nanoseconds.

Note that the return value type OSTime is defined as u64 (unsigned long long), so you should specify "%llu" for the conversion format if the returned value is to be output by a printf function.

See Also

OS_CYCLES_TO_NSEC, osGetCount

Revision history

1999/06/15 Completely revised