RISC-V: Add nanosleep functionality
This commit is contained in:
parent
e807c51d78
commit
a6633677b9
|
@ -7,6 +7,7 @@ gloss_hdrs = \
|
|||
|
||||
gloss_srcs = \
|
||||
syscalls.c \
|
||||
nanosleep.c
|
||||
|
||||
# Extra files
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#include <machine/syscall.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int
|
||||
nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
||||
{
|
||||
unsigned long current_time, end_time;
|
||||
asm ("rdtime %0" : "+r" (current_time));
|
||||
end_time = current_time + rqtp->tv_sec * 1000000000ULL + rqtp->tv_nsec;
|
||||
while (current_time <= end_time) asm ("rdtime %0" : "+r" (current_time));
|
||||
return 0;
|
||||
}
|
|
@ -258,7 +258,7 @@ case "${host_cpu}" in
|
|||
riscv*)
|
||||
libm_machine_dir=riscv
|
||||
machine_dir=riscv
|
||||
newlib_cflags="${newlib_cflags}"
|
||||
newlib_cflags="${newlib_cflags} -DHAVE_NANOSLEEP"
|
||||
default_newlib_atexit_dynamic_alloc="no"
|
||||
;;
|
||||
rl78)
|
||||
|
|
Loading…
Reference in New Issue