TEMU  4.4
The Terma Emulator
Time.h File Reference
#include "temu-c/Support/Temu3Compat.h"
#include "temu-c/Support/Attributes.h"
#include "temu-c/Support/Events.h"
#include <stdint.h>
Include dependency graph for Time.h:

Go to the source code of this file.

Functions

TEMU_API uint64_t temu_timeGetMonotonicWct (void)
 
TEMU_API uint64_t temu_timeGetThreadWct (void)
 
TEMU_API uint64_t temu_timeGetCurrentSrtNanos (temu_TimeSource_ *TS)
 
TEMU_API uint64_t temu_cyclesToStepsRoundedUp (temu_TimeSource *TS, uint64_t Cycles)
 
TEMU_API uint64_t temu_stepsToCyclesRoundedUp (temu_TimeSource *TS, uint64_t Steps)
 
TEMU_API uint64_t temu_cyclesToSteps (temu_TimeSource *TS, uint64_t Cycles)
 
TEMU_API uint64_t temu_stepsToCycles (temu_TimeSource *TS, uint64_t Steps)
 
TEMU_API int64_t temu_getSteps (temu_TimeSource *TS)
 
TEMU_API int64_t temu_getCycles (temu_TimeSource_ *TS)
 
TEMU_API int64_t temu_getNanos (temu_TimeSource_ *TS)
 
TEMU_API double temu_getSecs (temu_TimeSource_ *TS)
 
TEMU_API int64_t temu_cyclesToNanos (int64_t Cycles, int64_t Freq)
 
TEMU_API int64_t temu_cyclesToOtherFreqTruncated (int64_t Cycles, int64_t SourceFreq, int64_t TargetFreq)
 
TEMU_API int64_t temu_cyclesToOtherFreqRoundedUp (int64_t Cycles, int64_t SourceFreq, int64_t TargetFreq)
 
TEMU_API double temu_cyclesToSecs (int64_t Cycles, int64_t Freq)
 
TEMU_API int64_t temu_nanosToCycles (int64_t Nanos, int64_t Freq)
 
TEMU_API int64_t temu_nanosToCyclesRoundedUp (int64_t Nanos, int64_t Freq)
 
TEMU_API double temu_nanosToSecs (int64_t Nanos)
 
TEMU_API int64_t temu_secsToNanos (double Secs)
 
TEMU_API int64_t temu_secsToCycles (double Secs, int64_t Freq)
 

Function Documentation

◆ temu_cyclesToNanos()

TEMU_API int64_t temu_cyclesToNanos ( int64_t  Cycles,
int64_t  Freq 
)

Convert cycles to nanoseconds

Parameters
CyclesCycle count to convert
FreqFrequency in Hz
Returns
Cycles converted to nanoseconds

◆ temu_cyclesToOtherFreqRoundedUp()

TEMU_API int64_t temu_cyclesToOtherFreqRoundedUp ( int64_t  Cycles,
int64_t  SourceFreq,
int64_t  TargetFreq 
)

Convert cycles to another frequency base, rounding upwards

Parameters
CyclesCycle count in source frequency ticks
SourceFreqFrequency in Hz of the source
TargetFreqFrequency in Hz for the converted value
Returns
Cycles, converted from source frequency to target frequency

◆ temu_cyclesToOtherFreqTruncated()

TEMU_API int64_t temu_cyclesToOtherFreqTruncated ( int64_t  Cycles,
int64_t  SourceFreq,
int64_t  TargetFreq 
)

Convert cycles to another frequency base, with truncated result

Parameters
CyclesCycle count in source frequency ticks
SourceFreqFrequency in Hz of the source
TargetFreqFrequency in Hz for the converted value
Returns
Cycles, converted from source frequency to target frequency

◆ temu_cyclesToSecs()

TEMU_API double temu_cyclesToSecs ( int64_t  Cycles,
int64_t  Freq 
)

Convert cycles to seconds

Parameters
CyclesCycle count to convert
FreqFrequency in Hz
Returns
Cycles converted to seconds

◆ temu_cyclesToSteps()

TEMU_API uint64_t temu_cyclesToSteps ( temu_TimeSource TS,
uint64_t  Cycles 
)

Convert cycles to steps

Parameters
TSTime source object
CyclesCycle count to convert to steps
Returns
Cycles converted to steps given the time source IPC/CPI configuration.

◆ temu_cyclesToStepsRoundedUp()

TEMU_API uint64_t temu_cyclesToStepsRoundedUp ( temu_TimeSource TS,
uint64_t  Cycles 
)

Convert cycles to steps, rounding upwards

Parameters
TSTime source object
CyclesCycle count to convert to steps
Returns
Cycles converted to steps given the time source IPC/CPI configuration.

◆ temu_getCycles()

TEMU_API int64_t temu_getCycles ( temu_TimeSource_ TS)

Get current time in cycles.

Parameters
TSTime source object
Returns
Current cycles as it is understood by the object.

◆ temu_getNanos()

TEMU_API int64_t temu_getNanos ( temu_TimeSource_ TS)

Get current time in nanoseconds

Parameters
TSTime source object
Returns
Current nanoseconds as it is understood by the object.

◆ temu_getSecs()

TEMU_API double temu_getSecs ( temu_TimeSource_ TS)

Get current time in seconds

Parameters
TSTime source object
Returns
Current seconds as it is understood by the object.

◆ temu_getSteps()

TEMU_API int64_t temu_getSteps ( temu_TimeSource TS)

Get current step count

Parameters
TSTime source object
Returns
Current steps as it is understood by the object.

◆ temu_nanosToCycles()

TEMU_API int64_t temu_nanosToCycles ( int64_t  Nanos,
int64_t  Freq 
)

Convert nanoseconds to cycles

This function truncates the result in case of non-exact conversion.

Parameters
NanosNanoseconds to convert
FreqFrequency in Hz
Returns
Nanoseconds converted to cycles

◆ temu_nanosToCyclesRoundedUp()

TEMU_API int64_t temu_nanosToCyclesRoundedUp ( int64_t  Nanos,
int64_t  Freq 
)

Convert nanoseconds to cycles rounded upwards

This function rounds up the result in case of non-exact conversion.

Parameters
NanosNanoseconds to convert
FreqFrequency in Hz
Returns
Nanoseconds converted to cycles

◆ temu_nanosToSecs()

TEMU_API double temu_nanosToSecs ( int64_t  Nanos)

Convert nanoseconds to seconds

Parameters
NanosNanoseconds to convert
Returns
Nanoseconds converted to seconds

◆ temu_secsToCycles()

TEMU_API int64_t temu_secsToCycles ( double  Secs,
int64_t  Freq 
)

Convert seconds to cycles

Parameters
SecsSeconds to convert
FreqFrequency in Hz
Returns
Seconds converted to an integral number of cycles

◆ temu_secsToNanos()

TEMU_API int64_t temu_secsToNanos ( double  Secs)

Convert seconds to nanoseconds

Parameters
SecsSeconds to convert
Returns
Seconds converted to an integral number of nanoseconds

◆ temu_stepsToCycles()

TEMU_API uint64_t temu_stepsToCycles ( temu_TimeSource TS,
uint64_t  Steps 
)

Convert steps to cycles

Parameters
TSTime source object
StepsStep count to convert to cycles
Returns
Steps converted to cycles given the time source IPC/CPI configuration.

◆ temu_stepsToCyclesRoundedUp()

TEMU_API uint64_t temu_stepsToCyclesRoundedUp ( temu_TimeSource TS,
uint64_t  Steps 
)

Convert steps to cycles, rounding upwards

Parameters
TSTime source object
StepsStep count to convert to cycles
Returns
Steps converted to cycles given the time source IPC/CPI configuration.

◆ temu_timeGetCurrentSrtNanos()

TEMU_API uint64_t temu_timeGetCurrentSrtNanos ( temu_TimeSource_ TS)

Get the current simulated real-time in nanoseconds

Parameters
TSThe object in question
Returns
simulated time for the given object

◆ temu_timeGetMonotonicWct()

TEMU_API uint64_t temu_timeGetMonotonicWct ( void  )

Get monotonic time in nanoseconds.

The monotonic time is relative since some epoch of undefined start, but it is monotonic, unaffected by adjustments due to leap seconds, setting of the system clock, etc.

This function is primarily useful for doing performance measurements since the time returned is relative to an undefined point (although that undefined point will be consistent while the program is running).

In practice, on systems with clock_gettime() implemented, this function returns the timespec converted to nanoseconds, but on systems without clock_gettime(), e.g. Darwin and Windows, the function will only ensure that some notion of monotonic nanoseconds are returned. In Darwin for example, this results in a monotonic time returned which is relative to the first call to the function.

Returns
Wall clock nanoseconds since an unspecified epoch.

◆ temu_timeGetThreadWct()

TEMU_API uint64_t temu_timeGetThreadWct ( void  )

Returns wall clock nanoseconds of thread time

NOTE: This is how much time the thread this is called from has been scheduled.

Returns
wall clock nanoseconds of thread time