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>
This commit is contained in:
Mark Brown 2021-06-24 08:53:14 +02:00 committed by Paul E. McKenney
parent 9a83f9aea7
commit f916d77eed
1 changed files with 13 additions and 0 deletions

View File

@ -2243,6 +2243,19 @@ unsigned int sleep(unsigned int seconds)
return 0; return 0;
} }
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)) static __attribute__((unused))
int stat(const char *path, struct stat *buf) int stat(const char *path, struct stat *buf)
{ {