diff options
author | Mark Brown <broonie@kernel.org> | 2021-06-24 08:53:14 +0200 |
---|---|---|
committer | Paul E. McKenney <paulmck@kernel.org> | 2021-07-20 22:42:26 +0200 |
commit | f916d77eedfeb3efbbcd4b209601671ec1b417f2 (patch) | |
tree | 8b9e4cfdf4e62b32549d8bc5c58f070bb8e3e441 /tools/include/nolibc | |
parent | tools: include: nolibc: Fix a typo occured to occurred in the file nolibc.h (diff) | |
download | linux-f916d77eedfeb3efbbcd4b209601671ec1b417f2.tar.xz linux-f916d77eedfeb3efbbcd4b209601671ec1b417f2.zip |
tools/nolibc: Implement msleep()
Allow users to implement shorter delays than a full second by implementing
msleep().
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'tools/include/nolibc')
-rw-r--r-- | tools/include/nolibc/nolibc.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 13c194aeaf3f..3430667b0d24 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -2244,6 +2244,19 @@ unsigned int sleep(unsigned int seconds) } static __attribute__((unused)) +int msleep(unsigned int msecs) +{ + struct timeval my_timeval = { msecs / 1000, (msecs % 1000) * 1000 }; + + if (sys_select(0, 0, 0, 0, &my_timeval) < 0) + return (my_timeval.tv_sec * 1000) + + (my_timeval.tv_usec / 1000) + + !!(my_timeval.tv_usec % 1000); + else + return 0; +} + +static __attribute__((unused)) int stat(const char *path, struct stat *buf) { int ret = sys_stat(path, buf); |