Skip to content

Commit efb0217

Browse files
WinterMuteDacoTaco
authored andcommitted
implement time syscalls. Closes #199
1 parent dfa1750 commit efb0217

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

libogc/timesupp.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <_ansi.h>
22
#include <_syslist.h>
33

4+
#include <errno.h>
5+
46
#include "asm.h"
57
#include "processor.h"
68
#include "lwp.h"
@@ -189,3 +191,32 @@ int __libogc_gettod_r(struct _reent *ptr, struct timeval *tp, struct timezone *t
189191
return 0;
190192
}
191193

194+
int __syscall_clock_gettime(clockid_t clock_id, struct timespec *tp)
195+
{
196+
if (clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_REALTIME) return EINVAL;
197+
198+
u64 now = gettime();
199+
tp->tv_sec = ticks_to_secs(now);
200+
tp->tv_nsec = tick_nanosecs(now);
201+
202+
if (clock_id == CLOCK_REALTIME) tp->tv_sec += 946684800;
203+
204+
return 0;
205+
}
206+
207+
int __syscall_clock_settime(clockid_t clock_id, const struct timespec *tp)
208+
{
209+
return EPERM;
210+
}
211+
212+
int __syscall_clock_getres(clockid_t clock_id, struct timespec *res)
213+
{
214+
if (clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_REALTIME) return EINVAL;
215+
if (res)
216+
{
217+
res->tv_sec = 0;
218+
res->tv_nsec = ticks_to_nanosecs(1);
219+
}
220+
return 0;
221+
}
222+

0 commit comments

Comments
 (0)