21#include <timer_alarm.h>
24static u64 nanosleep_wakeup_callback(s32 alarm_id, u64 scheduled_time, u64 actual_time,
void *arg,
void *pc_value)
31 iSignalSema((s32)arg);
36int nanosleep(
const struct timespec *req,
struct timespec *rem)
43 __asm__ __volatile__ (
"mfc0\t%0, $12" :
"=r" (eie));
44 if ((eie & 0x10000) == 0)
49 sema.option = (u32)
"nanosleep";
51 sema_id = CreateSema(&sema);
56 timer_alarm_id = SetTimerAlarm(Sec2TimerBusClock(req->tv_sec) + NSec2TimerBusClock(req->tv_nsec), nanosleep_wakeup_callback, (
void *)sema_id);
57 if (timer_alarm_id < 0)