mirror of
https://github.com/devkitPro/wut.git
synced 2026-05-25 05:41:59 -05:00
Some checks failed
C/C++ CI / ubuntu-latest (push) Has been cancelled
`find . -regex '.*\.\(cpp\|hpp\|cu\|cuh\|c\|h\)' -exec clang-format -style=file -i {} \;`
52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
#include "wut_clock.h"
|
|
#include "wut_newlib.h"
|
|
|
|
#include <coreinit/systeminfo.h>
|
|
#include <coreinit/time.h>
|
|
|
|
int
|
|
__wut_clock_gettime(clockid_t clock_id,
|
|
struct timespec *tp)
|
|
{
|
|
if (clock_id == CLOCK_MONOTONIC) {
|
|
OSTime time = OSGetSystemTime();
|
|
tp->tv_sec = (time_t)OSTicksToSeconds(time);
|
|
|
|
time -= OSSecondsToTicks(tp->tv_sec);
|
|
tp->tv_nsec = (long)OSTicksToNanoseconds(time);
|
|
} else if (clock_id == CLOCK_REALTIME) {
|
|
OSTime time = OSGetTime();
|
|
tp->tv_sec = (time_t)OSTicksToSeconds(time);
|
|
|
|
time -= OSSecondsToTicks(tp->tv_sec);
|
|
tp->tv_nsec = (long)OSTicksToNanoseconds(time);
|
|
|
|
tp->tv_sec += EPOCH_DIFF_SECS(WIIU_OSTIME_EPOCH_YEAR);
|
|
} else {
|
|
return EINVAL;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
__wut_clock_settime(clockid_t clock_id,
|
|
const struct timespec *tp)
|
|
{
|
|
return EPERM;
|
|
}
|
|
|
|
int
|
|
__wut_clock_getres(clockid_t clock_id,
|
|
struct timespec *res)
|
|
{
|
|
if (clock_id != CLOCK_MONOTONIC &&
|
|
clock_id != CLOCK_REALTIME) {
|
|
return EINVAL;
|
|
}
|
|
|
|
res->tv_sec = 0;
|
|
res->tv_nsec = (long)((1000000000ull + (uint64_t)OSTimerClockSpeed) / (uint64_t)OSTimerClockSpeed);
|
|
return 0;
|
|
}
|