From 8a0efa53e44919bcf5ccb1d3353618a82afdf8bc Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 17 Feb 2000 19:39:52 +0000 Subject: import newlib-2000-02-17 snapshot --- newlib/libc/time/clock.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 newlib/libc/time/clock.c (limited to 'newlib/libc/time/clock.c') diff --git a/newlib/libc/time/clock.c b/newlib/libc/time/clock.c new file mode 100644 index 000000000..b15915d6a --- /dev/null +++ b/newlib/libc/time/clock.c @@ -0,0 +1,69 @@ +/* NetWare can not use this implementation of clock, since it does not + have times or any similar function. It provides its own version of + clock in clib.nlm. If we can not use clib.nlm, then we must write + clock in sys/netware. */ + +#ifdef CLOCK_PROVIDED + +int _dummy_clock = 1; + +#else + +/* + * clock.c + * Original Author: G. Haley + * + * Determines the processor time used by the program since invocation. The time + * in seconds is the value returned divided by the value of the macro CLK_TCK. + * If the processor time used is not available, (clock_t) -1 is returned. + */ + +/* +FUNCTION +<>---cumulative processor time + +INDEX + clock + +ANSI_SYNOPSIS + #include + clock_t clock(void); + +TRAD_SYNOPSIS + #include + clock_t clock(); + +DESCRIPTION +Calculates the best available approximation of the cumulative amount +of time used by your program since it started. To convert the result +into seconds, divide by the macro <>. + +RETURNS +The amount of processor time used so far by your program, in units +defined by the machine-dependent macro <>. If no +measurement is available, the result is <<-1>>. + +PORTABILITY +ANSI C requires <> and <>. + +Supporting OS subroutine required: <>. +*/ + +#include +#include +#include + +clock_t +clock () +{ + struct tms tim_s; + clock_t res; + + if ((res = (clock_t) _times_r (_REENT, &tim_s)) != -1) + res = (clock_t) (tim_s.tms_utime + tim_s.tms_stime + + tim_s.tms_cutime + tim_s.tms_cstime); + + return res; +} + +#endif /* CLOCK_PROVIDED */ -- cgit v1.2.3