aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-10 16:34:03 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-10 16:34:03 +0200
commit11f2e99c13b42675bb65cf2cfd3e3a98f95f2cee (patch)
tree3fc17fbedb484e69a6079da9550c2803bc1c31eb /shell/ash.c
parentc52dc0e83699cd8378740ef8f32a063a9c24fa51 (diff)
downloadbusybox-11f2e99c13b42675bb65cf2cfd3e3a98f95f2cee.tar.gz
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.c16
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 = {
static int FAST_FUNC
timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
- unsigned long clk_tck, s, t;
+ unsigned clk_tck;
const unsigned char *p;
struct tms buf;
clk_tck = bb_clk_tck();
- times(&buf);
+ times(&buf);
p = timescmd_str;
do {
+ unsigned sec, frac;
+ unsigned long t;
t = *(clock_t *)(((char *) &buf) + p[1]);
- s = t / clk_tck;
- t = t % clk_tck;
- out1fmt("%lum%lu.%03lus%c",
- s / 60, s % 60,
- (t * 1000) / clk_tck,
+ sec = t / clk_tck;
+ frac = t % clk_tck;
+ out1fmt("%um%u.%03us%c",
+ sec / 60, sec % 60,
+ (frac * 1000) / clk_tck,
p[0]);
p += 2;
} while (*p);