TEMU  3.0
The Terma Emulator
Time.h
Go to the documentation of this file.
1 //===-- temu-c/Support/Time.h - Portable Timers -----------------*- C++ -*-===//
2 //
3 // TEMU: The Terma Emulator
4 // (c) Terma 2015
5 // Authors: Mattias Holm <maho (at) terma.com>
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef TEMU_SUPPORT_TIME
10 #define TEMU_SUPPORT_TIME
11 
12 #include <stdint.h>
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
39 TEMU_API uint64_t temu_timeGetMonotonicWct(void);
40 
48 TEMU_API uint64_t temu_timeGetThreadWct(void);
49 
55 TEMU_API uint64_t temu_timeGetCurrentSrtNanos(void *Obj);
56 
62 TEMU_API int64_t temu_getCycles(const void *Q);
63 
69 TEMU_API int64_t temu_getNanos(const void *Q);
70 
76 TEMU_API double temu_getSecs(const void *Q);
77 
78 /*
79  * Time conversion, note that this isn't super-trivial due to
80  * overflows. So use these functions, they are well tested and
81  * hardened against overflow. Note that due to rounding, there is no
82  * strict guarantee that the inverse functions are strictly inverse
83  * e.g. WE DO NOT GUARANTEE that:
84  * (cyclesToNanos(nanosToCycles(N, F), F)) == N
85  */
86 
93 TEMU_API int64_t temu_cyclesToNanos(int64_t Cycles, int64_t Freq);
94 
101 TEMU_API double temu_cyclesToSecs(int64_t Cycles, int64_t Freq);
102 
111 TEMU_API int64_t temu_nanosToCycles(int64_t Nanos, int64_t Freq);
112 
121 TEMU_API int64_t temu_nanosToCyclesRoundedUp(int64_t Nanos, int64_t Freq);
122 
123 
129 TEMU_API double temu_nanosToSecs(int64_t Nanos);
130 
136 TEMU_API int64_t temu_secsToNanos(double Secs);
137 
144 TEMU_API int64_t temu_secsToCycles(double Secs, int64_t Freq);
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif /* ! TEMU_SUPPORT_TIME */
TEMU_API int64_t temu_secsToNanos(double Secs)
TEMU_API uint64_t temu_timeGetCurrentSrtNanos(void *Obj)
TEMU_API int64_t temu_nanosToCycles(int64_t Nanos, int64_t Freq)
TEMU_API int64_t temu_getCycles(const void *Q)
TEMU_API double temu_nanosToSecs(int64_t Nanos)
TEMU_API double temu_cyclesToSecs(int64_t Cycles, int64_t Freq)
#define TEMU_API
Definition: Attributes.h:53
TEMU_API int64_t temu_secsToCycles(double Secs, int64_t Freq)
TEMU_API int64_t temu_nanosToCyclesRoundedUp(int64_t Nanos, int64_t Freq)
TEMU_API int64_t temu_cyclesToNanos(int64_t Cycles, int64_t Freq)
TEMU_API int64_t temu_getNanos(const void *Q)
TEMU_API uint64_t temu_timeGetThreadWct(void)
TEMU_API uint64_t temu_timeGetMonotonicWct(void)
TEMU_API double temu_getSecs(const void *Q)