source: trunk/libs/newlib/src/newlib/libc/time/clock.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.5 KB
Line 
1/* NetWare can not use this implementation of clock, since it does not
2   have times or any similar function.  It provides its own version of
3   clock in clib.nlm.  If we can not use clib.nlm, then we must write
4   clock in sys/netware.  */
5
6#ifdef CLOCK_PROVIDED
7
8int _dummy_clock = 1;
9
10#else
11
12/*
13 * clock.c
14 * Original Author:     G. Haley
15 *
16 * Determines the processor time used by the program since invocation. The time
17 * in seconds is the value returned divided by the value of the macro CLK_TCK.
18 * If the processor time used is not available, (clock_t) -1 is returned.
19 */
20
21/*
22FUNCTION
23<<clock>>---cumulative processor time
24
25INDEX
26        clock
27
28SYNOPSIS
29        #include <time.h>
30        clock_t clock(void);
31
32DESCRIPTION
33Calculates the best available approximation of the cumulative amount
34of time used by your program since it started.  To convert the result
35into seconds, divide by the macro <<CLOCKS_PER_SEC>>.
36
37RETURNS
38The amount of processor time used so far by your program, in units
39defined by the machine-dependent macro <<CLOCKS_PER_SEC>>.  If no
40measurement is available, the result is (clock_t)<<-1>>.
41
42PORTABILITY
43ANSI C requires <<clock>> and <<CLOCKS_PER_SEC>>.
44
45Supporting OS subroutine required: <<times>>.
46*/
47
48#include <time.h>
49#include <sys/times.h>
50#include <reent.h>
51
52clock_t 
53clock ()
54{
55  struct tms tim_s;
56  clock_t res;
57
58  if ((res = (clock_t) _times_r (_REENT, &tim_s)) != (clock_t) -1)
59    res = (clock_t) (tim_s.tms_utime + tim_s.tms_stime +
60                     tim_s.tms_cutime + tim_s.tms_cstime);
61
62  return res;
63}
64
65#endif /* CLOCK_PROVIDED */
Note: See TracBrowser for help on using the repository browser.