source: trunk/libs/newlib/src/libgloss/riscv/nanosleep.c @ 646

Last change on this file since 646 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 367 bytes
Line 
1#include <machine/syscall.h>
2#include <sys/time.h>
3
4int
5nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
6{
7  unsigned long current_time, end_time;
8  asm ("rdtime %0" : "+r" (current_time));
9  end_time = current_time + rqtp->tv_sec * 1000000000ULL + rqtp->tv_nsec;
10  while (current_time <= end_time) asm ("rdtime %0" : "+r" (current_time));
11  return 0;
12}
Note: See TracBrowser for help on using the repository browser.