From 4c20d9f2b0223874e2b5ac1235d5f33fdd02589b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 3 Aug 2018 18:17:12 +0200 Subject: extend fractional duration support to "top -d N.N" and "timeout" function old new delta parse_duration_str - 168 +168 sleep_for_duration - 157 +157 top_main 885 928 +43 timeout_main 269 312 +43 handle_input 571 614 +43 duration_suffixes - 40 +40 sfx 40 - -40 sleep_main 364 79 -285 ------------------------------------------------------------------------------ (add/remove: 4/1 grow/shrink: 3/1 up/down: 494/-325) Total: 169 bytes Signed-off-by: Denys Vlasenko --- include/libbb.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/libbb.h b/include/libbb.h index 94caba2bb..7cad12c44 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1018,6 +1018,14 @@ int xatoi_positive(const char *numstr) FAST_FUNC; /* Useful for reading port numbers */ uint16_t xatou16(const char *numstr) FAST_FUNC; +#if ENABLE_FLOAT_DURATION +typedef double duration_t; +void sleep_for_duration(duration_t duration) FAST_FUNC; +#else +typedef unsigned duration_t; +#define sleep_for_duration(duration) sleep(duration) +#endif +duration_t parse_duration_str(char *str) FAST_FUNC; /* These parse entries in /etc/passwd and /etc/group. This is desirable * for BusyBox since we want to avoid using the glibc NSS stuff, which -- cgit v1.2.3