From d1ca5c4ea6f08a4a2b06659a4633c9acaeaaccdb Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Wed, 13 Jun 2018 09:14:57 +0100 Subject: [PATCH] implement nanosleep for devkitARM r49 (cherry picked from commit fba44c189e568df13573a9e119e63dbd718424c6) --- libctru/source/os.c | 9 --------- libctru/source/system/syscalls.c | 8 ++++++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libctru/source/os.c b/libctru/source/os.c index 29ad36a..402ea99 100644 --- a/libctru/source/os.c +++ b/libctru/source/os.c @@ -163,12 +163,3 @@ void osSetSpeedupEnable(bool enable) __ctru_speedup = enable; __ctru_speedup_config(); } - -int usleep(useconds_t useconds) -{ - - svcSleepThread(useconds * 1000ull); - - return 0; - -} diff --git a/libctru/source/system/syscalls.c b/libctru/source/system/syscalls.c index a0c2903..4d06f66 100644 --- a/libctru/source/system/syscalls.c +++ b/libctru/source/system/syscalls.c @@ -28,12 +28,20 @@ static struct _reent* __ctru_get_reent() return tv->reent; } +static int __libctru_nanosleep(const struct timespec *req, struct timespec *rem) +{ + svcSleepThread(req->tv_sec * 1000000000ull + req->tv_nsec); + return 0; +} + + void __system_initSyscalls(void) { // Register newlib syscalls __syscalls.exit = __ctru_exit; __syscalls.gettod_r = __libctru_gtod; __syscalls.getreent = __ctru_get_reent; + __syscalls.nanosleep = __libctru_nanosleep; // Register locking syscalls __syscalls.lock_init = LightLock_Init;