]> xenbits.xensource.com Git - unikraft/libs/newlib.git/commitdiff
Implement usleep
authorVlad-Andrei BĂDOIU (78692) <vlad_andrei.badoiu@stud.acs.upb.ro>
Thu, 30 May 2019 11:38:50 +0000 (11:38 +0000)
committerFelipe Huici <felipe.huici@neclab.eu>
Fri, 31 May 2019 20:02:02 +0000 (22:02 +0200)
Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
time.c

diff --git a/time.c b/time.c
index dccf8a15e879cc66b8b2a2db75556dc41f85d7b2..94e8097bd6484ec5e8bd4c4fe0ff138afefd0fac 100644 (file)
--- a/time.c
+++ b/time.c
@@ -113,6 +113,18 @@ int nanosleep(const struct timespec *req, struct timespec *rem)
        return 0;
 }
 
+int usleep(useconds_t usec)
+{
+       struct timespec ts;
+
+       ts.tv_sec = (long int) (usec / 1000000);
+       ts.tv_nsec = (long int) ukarch_time_usec_to_nsec(usec % 1000000);
+       if (nanosleep(&ts, &ts))
+               return -1;
+
+       return 0;
+}
+
 unsigned int sleep(unsigned int seconds)
 {
        struct timespec ts;