Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / time / clock.c
blob53ca208ee6dca9d677f1ea36e3ffa766a099f984
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. */
6 #ifdef CLOCK_PROVIDED
8 int _dummy_clock = 1;
10 #else
13 * clock.c
14 * Original Author: G. Haley
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.
22 FUNCTION
23 <<clock>>---cumulative processor time
25 INDEX
26 clock
28 SYNOPSIS
29 #include <time.h>
30 clock_t clock(void);
32 DESCRIPTION
33 Calculates the best available approximation of the cumulative amount
34 of time used by your program since it started. To convert the result
35 into seconds, divide by the macro <<CLOCKS_PER_SEC>>.
37 RETURNS
38 The amount of processor time used so far by your program, in units
39 defined by the machine-dependent macro <<CLOCKS_PER_SEC>>. If no
40 measurement is available, the result is (clock_t)<<-1>>.
42 PORTABILITY
43 ANSI C requires <<clock>> and <<CLOCKS_PER_SEC>>.
45 Supporting OS subroutine required: <<times>>.
48 #include <time.h>
49 #include <sys/times.h>
50 #include <reent.h>
52 clock_t
53 clock ()
55 struct tms tim_s;
56 clock_t res;
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);
62 return res;
65 #endif /* CLOCK_PROVIDED */