aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2022-02-07 17:23:50 +0100
committerPaul E. McKenney <paulmck@kernel.org>2022-04-20 17:05:45 -0700
commit180a9797b03472e6881066d9752f2f0d81e1880f (patch)
tree9af02bdf324e48c6b789cea1b896f9b0f0e2346e
parenttools/nolibc/unistd: extract msleep(), sleep(), tcsetpgrp() to unistd.h (diff)
downloadlinux-dev-180a9797b03472e6881066d9752f2f0d81e1880f.tar.xz
linux-dev-180a9797b03472e6881066d9752f2f0d81e1880f.zip
tools/nolibc/unistd: add usleep()
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>
-rw-r--r--tools/include/nolibc/unistd.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h
index 87b448ff2191..1c25e20ee360 100644
--- a/tools/include/nolibc/unistd.h
+++ b/tools/include/nolibc/unistd.h
@@ -38,6 +38,14 @@ unsigned int sleep(unsigned int seconds)
}
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)
{
return ioctl(fd, TIOCSPGRP, &pid);