tools/nolibc/unistd: add usleep()
authorWilly Tarreau <w@1wt.eu>
Mon, 7 Feb 2022 16:23:50 +0000 (17:23 +0100)
committerPaul E. McKenney <paulmck@kernel.org>
Thu, 21 Apr 2022 00:05:45 +0000 (17:05 -0700)
This call is trivial to implement based on select() to complete sleep()
and msleep(), let's add it.

Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/include/nolibc/unistd.h

index 87b448ff2191e5679c4e3361ca49ee8d589bac95..1c25e20ee360667540ab80fad43ed2d31935d789 100644 (file)
@@ -37,6 +37,14 @@ unsigned int sleep(unsigned int seconds)
                return 0;
 }
 
+static __attribute__((unused))
+int usleep(unsigned int usecs)
+{
+       struct timeval my_timeval = { usecs / 1000000, usecs % 1000000 };
+
+       return sys_select(0, 0, 0, 0, &my_timeval);
+}
+
 static __attribute__((unused))
 int tcsetpgrp(int fd, pid_t pid)
 {