Rev 4921 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4921 | Serge | 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 | |||
8 | int _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 | /* |
||
22 | FUNCTION |
||
23 | < |
||
24 | |||
25 | INDEX |
||
26 | clock |
||
27 | |||
28 | ANSI_SYNOPSIS |
||
29 | #include |
||
30 | clock_t clock(void); |
||
31 | |||
32 | TRAD_SYNOPSIS |
||
33 | #include |
||
34 | clock_t clock(); |
||
35 | |||
36 | DESCRIPTION |
||
37 | Calculates the best available approximation of the cumulative amount |
||
38 | of time used by your program since it started. To convert the result |
||
39 | into seconds, divide by the macro < |
||
40 | |||
41 | RETURNS |
||
42 | The amount of processor time used so far by your program, in units |
||
43 | defined by the machine-dependent macro < |
||
44 | measurement is available, the result is (clock_t)<<-1>>. |
||
45 | |||
46 | PORTABILITY |
||
47 | ANSI C requires < |
||
48 | |||
49 | Supporting OS subroutine required: < |
||
50 | */ |
||
51 | |||
52 | #include |
||
53 | #include |
||
54 | #include |
||
55 | |||
56 | clock_t |
||
57 | clock () |
||
58 | { |
||
59 | struct tms tim_s; |
||
60 | clock_t res; |
||
61 | |||
6099 | serge | 62 | if ((res = (clock_t) _times_r (_REENT, &tim_s)) != (clock_t) -1) |
4921 | Serge | 63 | res = (clock_t) (tim_s.tms_utime + tim_s.tms_stime + |
64 | tim_s.tms_cutime + tim_s.tms_cstime); |
||
65 | |||
66 | return res; |
||
67 | } |
||
68 | |||
69 | #endif /* CLOCK_PROVIDED */ |