| // NACL MOD TRACK "third_party/nacl-glibc/sysdeps/nacl/nanosleep.c" |
| |
| #include <errno.h> |
| #include <time.h> |
| |
| #include <irt_syscalls.h> |
| #include <nacl_timespec.h> |
| |
| int __nanosleep (const struct timespec *req, struct timespec *rem) |
| { |
| struct nacl_abi_timespec nacl_req; |
| struct nacl_abi_timespec *nacl_req_ptr = NULL; |
| struct nacl_abi_timespec nacl_rem; |
| if (req) { |
| __timespec_to_nacl_abi_timespec(req, &nacl_req); |
| nacl_req_ptr = &nacl_req; |
| } |
| int result = __nacl_irt_nanosleep(nacl_req_ptr, &nacl_rem); |
| if (result != 0) { |
| errno = result; |
| return -1; |
| } |
| if (rem) |
| __nacl_abi_timespec_to_timespec(&nacl_rem, rem); |
| return 0; |
| } |
| |
| #ifdef _USE_NACL_SYS_ALIAS_ |
| libc_hidden_def (__nanosleep) |
| weak_alias (__nanosleep, nanosleep) |
| #endif |