diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-10 16:34:03 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-10 16:34:03 +0200 |
commit | 11f2e99c13b42675bb65cf2cfd3e3a98f95f2cee (patch) | |
tree | 3fc17fbedb484e69a6079da9550c2803bc1c31eb /shell/ash.c | |
parent | c52dc0e83699cd8378740ef8f32a063a9c24fa51 (diff) | |
download | busybox-w32-11f2e99c13b42675bb65cf2cfd3e3a98f95f2cee.tar.gz busybox-w32-11f2e99c13b42675bb65cf2cfd3e3a98f95f2cee.tar.bz2 busybox-w32-11f2e99c13b42675bb65cf2cfd3e3a98f95f2cee.zip |
hush: optional times builtin
function old new delta
builtin_times - 108 +108
bltins1 360 372 +12
static.times_tbl - 9 +9
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/0 up/down: 129/0) Total: 129 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/shell/ash.c b/shell/ash.c index fd1772351..5c03f1fdc 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -13351,21 +13351,23 @@ static const unsigned char timescmd_str[] ALIGN1 = { | |||
13351 | static int FAST_FUNC | 13351 | static int FAST_FUNC |
13352 | timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | 13352 | timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
13353 | { | 13353 | { |
13354 | unsigned long clk_tck, s, t; | 13354 | unsigned clk_tck; |
13355 | const unsigned char *p; | 13355 | const unsigned char *p; |
13356 | struct tms buf; | 13356 | struct tms buf; |
13357 | 13357 | ||
13358 | clk_tck = bb_clk_tck(); | 13358 | clk_tck = bb_clk_tck(); |
13359 | times(&buf); | ||
13360 | 13359 | ||
13360 | times(&buf); | ||
13361 | p = timescmd_str; | 13361 | p = timescmd_str; |
13362 | do { | 13362 | do { |
13363 | unsigned sec, frac; | ||
13364 | unsigned long t; | ||
13363 | t = *(clock_t *)(((char *) &buf) + p[1]); | 13365 | t = *(clock_t *)(((char *) &buf) + p[1]); |
13364 | s = t / clk_tck; | 13366 | sec = t / clk_tck; |
13365 | t = t % clk_tck; | 13367 | frac = t % clk_tck; |
13366 | out1fmt("%lum%lu.%03lus%c", | 13368 | out1fmt("%um%u.%03us%c", |
13367 | s / 60, s % 60, | 13369 | sec / 60, sec % 60, |
13368 | (t * 1000) / clk_tck, | 13370 | (frac * 1000) / clk_tck, |
13369 | p[0]); | 13371 | p[0]); |
13370 | p += 2; | 13372 | p += 2; |
13371 | } while (*p); | 13373 | } while (*p); |