~ubuntu-branches/ubuntu/hardy/klibc/hardy-updates

« back to all changes in this revision

Viewing changes to dash/bltin/times.c

  • Committer: Bazaar Package Importer
  • Author(s): Jeff Bailey
  • Date: 2006-01-04 20:24:52 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060104202452-ec4v3n829rymukuv
Tags: 1.1.15-0ubuntu1
* New upstream version.

* Patch to fix compilation on parisc64 kernels.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 1999 Herbert Xu <herbert@gondor.apana.org.au>
 
3
 * This file contains code for the times builtin.
 
4
 */
 
5
 
 
6
#include <sys/times.h>
 
7
#include <unistd.h>
 
8
#ifdef USE_GLIBC_STDIO
 
9
#include <stdio.h>
 
10
#else
 
11
#include "bltin.h"
 
12
#endif
 
13
#include "system.h"
 
14
 
 
15
int timescmd() {
 
16
        struct tms buf;
 
17
        long int clk_tck = sysconf(_SC_CLK_TCK);
 
18
 
 
19
        times(&buf);
 
20
        printf("%dm%fs %dm%fs\n%dm%fs %dm%fs\n",
 
21
               (int) (buf.tms_utime / clk_tck / 60),
 
22
               ((double) buf.tms_utime) / clk_tck,
 
23
               (int) (buf.tms_stime / clk_tck / 60),
 
24
               ((double) buf.tms_stime) / clk_tck,
 
25
               (int) (buf.tms_cutime / clk_tck / 60),
 
26
               ((double) buf.tms_cutime) / clk_tck,
 
27
               (int) (buf.tms_cstime / clk_tck / 60),
 
28
               ((double) buf.tms_cstime) / clk_tck);
 
29
        return 0;
 
30
}