Last change
on this file since 444 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 | |
---|
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 | <<clock>>---cumulative processor time |
---|
24 | |
---|
25 | INDEX |
---|
26 | clock |
---|
27 | |
---|
28 | SYNOPSIS |
---|
29 | #include <time.h> |
---|
30 | clock_t clock(void); |
---|
31 | |
---|
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>>. |
---|
36 | |
---|
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>>. |
---|
41 | |
---|
42 | PORTABILITY |
---|
43 | ANSI C requires <<clock>> and <<CLOCKS_PER_SEC>>. |
---|
44 | |
---|
45 | Supporting OS subroutine required: <<times>>. |
---|
46 | */ |
---|
47 | |
---|
48 | #include <time.h> |
---|
49 | #include <sys/times.h> |
---|
50 | #include <reent.h> |
---|
51 | |
---|
52 | clock_t |
---|
53 | clock () |
---|
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.