tools/nolibc: Implement msleep()
PATCH v3 1/1 tools/nolibc: Implement msleep()
Allow users to implement shorter delays than a full second by implementing msleep().
---
v3:
- Return the number of milliseconds remaining if the delay does not complete.
v2:
- Support delays of more than a second.
- Return the number of seconds remaining if the delay does not complete.
tools/include/nolibc/nolibc.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
tools/include/nolibc/nolibc.h +13 -0
@@ -2243,6 +2243,19 @@ unsigned int sleep(unsigned int seconds)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))int stat (const char *path,struct stat *buf) {
Signature · 1 line
2.20.1
Willy Tarreau
maintainerQuoted 4 lines · Mark Brown
Allow users to implement shorter delays than a full second by implementing
msleep().Signed-off-by Mark Brown <[email protected]>
Great, now queued, thank you Mark!
Willy
Quoted 7 lines · Willy Tarreau
Quoted 4 lines · Mark Brown
Allow users to implement shorter delays than a full second by implementing
msleep().Signed-off-by Mark Brown <[email protected]>Great, now queued, thank you Mark!
This doesn't seem to be showing up in -next, did it get missed or is the queue it's in not in -next?
Willy Tarreau
maintainerHi Mark,
Quoted 11 lines · Mark Brown
Quoted 7 lines · Willy Tarreau
Quoted 4 lines · Mark Brown
Allow users to implement shorter delays than a full second by implementing
msleep().Signed-off-by Mark Brown <[email protected]>Great, now queued, thank you Mark!
This doesn't seem to be showing up in -next, did it get missed or is the queue it's in not in -next?
I planned to send the two patches I have in this branch to Paul this week, will do so ASAP.
Thanks,
Willy