wut  1.0.0-beta9
Wii U Toolchain
time.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include "systeminfo.h"
4 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
16 
17 typedef int32_t OSTick;
18 typedef int64_t OSTime;
19 
22 {
23  int32_t tm_sec;
24  int32_t tm_min;
25  int32_t tm_hour;
26  int32_t tm_mday;
27  int32_t tm_mon;
28  int32_t tm_year;
29  int32_t tm_wday;
30  int32_t tm_yday;
31  int32_t tm_msec;
32  int32_t tm_usec;
33 };
34 WUT_CHECK_OFFSET(OSCalendarTime, 0x00, tm_sec);
35 WUT_CHECK_OFFSET(OSCalendarTime, 0x04, tm_min);
36 WUT_CHECK_OFFSET(OSCalendarTime, 0x08, tm_hour);
37 WUT_CHECK_OFFSET(OSCalendarTime, 0x0C, tm_mday);
38 WUT_CHECK_OFFSET(OSCalendarTime, 0x10, tm_mon);
39 WUT_CHECK_OFFSET(OSCalendarTime, 0x14, tm_year);
40 WUT_CHECK_OFFSET(OSCalendarTime, 0x18, tm_wday);
41 WUT_CHECK_OFFSET(OSCalendarTime, 0x1C, tm_yday);
42 WUT_CHECK_OFFSET(OSCalendarTime, 0x20, tm_msec);
43 WUT_CHECK_OFFSET(OSCalendarTime, 0x24, tm_usec);
44 WUT_CHECK_SIZE(OSCalendarTime, 0x28);
45 
46 #define OSTimerClockSpeed ((OSGetSystemInfo()->busClockSpeed) / 4)
47 
48 #define OSSecondsToTicks(val) ((uint64_t)(val) * (uint64_t)OSTimerClockSpeed)
49 #define OSMillisecondsToTicks(val) (((uint64_t)(val) * (uint64_t)OSTimerClockSpeed) / 1000ull)
50 #define OSMicrosecondsToTicks(val) (((uint64_t)(val) * (uint64_t)OSTimerClockSpeed) / 1000000ull)
51 #define OSNanosecondsToTicks(val) (((uint64_t)(val) * ((uint64_t)OSTimerClockSpeed) / 31250ull) / 32000ull)
52 
53 #define OSTicksToSeconds(val) ((uint64_t)(val) / (uint64_t)OSTimerClockSpeed)
54 #define OSTicksToMilliseconds(val) (((uint64_t)(val) * 1000ull) / (uint64_t)OSTimerClockSpeed)
55 #define OSTicksToMicroseconds(val) (((uint64_t)(val) * 1000000ull) / (uint64_t)OSTimerClockSpeed)
56 #define OSTicksToNanoseconds(val) (((uint64_t)(val) * 32000ull) / ((uint64_t)OSTimerClockSpeed / 31250ull))
57 
58 OSTime
59 OSGetTime();
60 
61 OSTime
63 
64 OSTick
65 OSGetTick();
66 
67 OSTick
69 
70 OSTime
72 
73 void
75  OSCalendarTime *calendarTime);
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
OSTime
int64_t OSTime
Definition: time.h:18
OSCalendarTime::tm_year
int32_t tm_year
Definition: time.h:28
OSGetTick
OSTick OSGetTick()
OSCalendarTime::tm_wday
int32_t tm_wday
Definition: time.h:29
OSCalendarTime
Same as std c struct tm but with msec and usec added.
Definition: time.h:21
OSCalendarTime::tm_mday
int32_t tm_mday
Definition: time.h:26
OSCalendarTime::tm_yday
int32_t tm_yday
Definition: time.h:30
OSCalendarTime::tm_min
int32_t tm_min
Definition: time.h:24
OSCalendarTime::tm_mon
int32_t tm_mon
Definition: time.h:27
wut.h
OSGetTime
OSTime OSGetTime()
OSCalendarTimeToTicks
OSTime OSCalendarTimeToTicks(OSCalendarTime *calendarTime)
OSGetSystemTime
OSTime OSGetSystemTime()
OSTicksToCalendarTime
void OSTicksToCalendarTime(OSTime time, OSCalendarTime *calendarTime)
OSGetSystemTick
OSTick OSGetSystemTick()
OSCalendarTime::tm_usec
int32_t tm_usec
Definition: time.h:32
OSCalendarTime::tm_hour
int32_t tm_hour
Definition: time.h:25
OSTick
int32_t OSTick
Definition: time.h:17
systeminfo.h
OSCalendarTime::tm_msec
int32_t tm_msec
Definition: time.h:31
OSCalendarTime::tm_sec
int32_t tm_sec
Definition: time.h:23