OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [time/] [clock.c] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
/* 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
ANSI_SYNOPSIS
29
        #include <time.h>
30
        clock_t clock(void);
31
 
32
TRAD_SYNOPSIS
33
        #include <time.h>
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 <<CLOCKS_PER_SEC>>.
40
 
41
RETURNS
42
The amount of processor time used so far by your program, in units
43
defined by the machine-dependent macro <<CLOCKS_PER_SEC>>.  If no
44
measurement is available, the result is <<-1>>.
45
 
46
PORTABILITY
47
ANSI C requires <<clock>> and <<CLOCKS_PER_SEC>>.
48
 
49
Supporting OS subroutine required: <<times>>.
50
*/
51
 
52
#include <time.h>
53
#include <sys/times.h>
54
#include <reent.h>
55
 
56
clock_t
57
clock ()
58
{
59
  struct tms tim_s;
60
  clock_t res;
61
 
62
  if ((res = (clock_t) _times_r (_REENT, &tim_s)) != -1)
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 */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.