1 /* clock.c - operations on struct tms and clock_t's */
3 /* Copyright (C) 1999 Free Software Foundation, Inc.
5 This file is part of GNU Bash, the Bourne Again SHell.
7 Bash is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License along
18 with Bash; see the file COPYING. If not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */
23 #if defined (HAVE_TIMES)
25 #include <sys/types.h>
26 #include <posixtime.h>
28 #if defined (HAVE_SYS_TIMES_H)
29 # include <sys/times.h>
35 extern long get_clk_tck __P((void));
38 clock_t_to_secs (t, sp, sfp)
43 static long clk_tck = -1;
46 clk_tck = get_clk_tck ();
49 *sfp = (*sfp * 1000) / clk_tck;
61 /* Print the time defined by a clock_t (returned by the `times' and `time'
62 system calls) in a standard way to stdio stream FP. This is scaled in
63 terms of the value of CLK_TCK, which is what is returned by the
72 int seconds, seconds_fraction;
74 clock_t_to_secs (t, ×tamp, &seconds_fraction);
76 minutes = timestamp / 60;
77 seconds = timestamp % 60;
79 fprintf (fp, "%ldm%d.%03ds", minutes, seconds, seconds_fraction);
81 #endif /* HAVE_TIMES */