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 <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2018-08-03 18:17:12 +02:00
parent 9b1c8bf89b
commit 4c20d9f2b0
5 changed files with 101 additions and 81 deletions

View File

@@ -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