libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
Time.h
1/****************************************************************************
2 * Platform Abstraction Layer
3 * Daryl Borth 2026
4 * Time.h
5 *
6 * Platform-agnostic monotonic timing.
7 ***************************************************************************/
8#pragma once
9
10#include <cstdint>
11
12#if defined(__WIIU__)
13#include <coreinit/time.h>
14#else
15#include <ogc/lwp_watchdog.h>
16#endif
17
20typedef uint64_t Ticks;
21
25{
26 public:
28 static inline Ticks now()
29 {
30 #if defined(__WIIU__)
31 return (Ticks)OSGetSystemTime();
32 #else
33 return (Ticks)gettime();
34 #endif
35 }
36
40 static inline uint32_t diffSecs(Ticks start, Ticks end)
41 {
42 #if defined(__WIIU__)
43 return (uint32_t)OSTicksToSeconds((int64_t)(end - start));
44 #else
45 return diff_sec(start, end);
46 #endif
47 }
48
52 static inline uint32_t diffMillisecs(Ticks start, Ticks end)
53 {
54 #if defined(__WIIU__)
55 return (uint32_t)OSTicksToMilliseconds((int64_t)(end - start));
56 #else
57 return diff_msec(start, end);
58 #endif
59 }
60
66 static inline uint32_t diffMicrosecs(Ticks start, Ticks end)
67 {
68 #if defined(__WIIU__)
69 return (uint32_t)OSTicksToMicroseconds((int64_t)(end - start));
70 #else
71 return diff_usec(start, end);
72 #endif
73 }
74
83 static inline uint64_t ticksToMicrosecs(Ticks ticks)
84 {
85 #if defined(__WIIU__)
86 return (uint64_t)OSTicksToMicroseconds((int64_t)ticks);
87 #else
88 return (uint64_t)ticks_to_microsecs(ticks);
89 #endif
90 }
91};
Platform-agnostic monotonic clock.
Definition Time.h:25
static uint32_t diffMicrosecs(Ticks start, Ticks end)
Definition Time.h:66
static Ticks now()
Definition Time.h:28
static uint32_t diffMillisecs(Ticks start, Ticks end)
Definition Time.h:52
static uint32_t diffSecs(Ticks start, Ticks end)
Definition Time.h:40
static uint64_t ticksToMicrosecs(Ticks ticks)
Definition Time.h:83