OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [time/] [clock.c] - Diff between revs 207 and 345

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
/* NetWare can not use this implementation of clock, since it does not
/* NetWare can not use this implementation of clock, since it does not
   have times or any similar function.  It provides its own version of
   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 clib.nlm.  If we can not use clib.nlm, then we must write
   clock in sys/netware.  */
   clock in sys/netware.  */
 
 
#ifdef CLOCK_PROVIDED
#ifdef CLOCK_PROVIDED
 
 
int _dummy_clock = 1;
int _dummy_clock = 1;
 
 
#else
#else
 
 
/*
/*
 * clock.c
 * clock.c
 * Original Author:     G. Haley
 * Original Author:     G. Haley
 *
 *
 * Determines the processor time used by the program since invocation. The time
 * 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.
 * 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.
 * If the processor time used is not available, (clock_t) -1 is returned.
 */
 */
 
 
/*
/*
FUNCTION
FUNCTION
<<clock>>---cumulative processor time
<<clock>>---cumulative processor time
 
 
INDEX
INDEX
        clock
        clock
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <time.h>
        #include <time.h>
        clock_t clock(void);
        clock_t clock(void);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <time.h>
        #include <time.h>
        clock_t clock();
        clock_t clock();
 
 
DESCRIPTION
DESCRIPTION
Calculates the best available approximation of the cumulative amount
Calculates the best available approximation of the cumulative amount
of time used by your program since it started.  To convert the result
of time used by your program since it started.  To convert the result
into seconds, divide by the macro <<CLOCKS_PER_SEC>>.
into seconds, divide by the macro <<CLOCKS_PER_SEC>>.
 
 
RETURNS
RETURNS
The amount of processor time used so far by your program, in units
The amount of processor time used so far by your program, in units
defined by the machine-dependent macro <<CLOCKS_PER_SEC>>.  If no
defined by the machine-dependent macro <<CLOCKS_PER_SEC>>.  If no
measurement is available, the result is (clock_t)<<-1>>.
measurement is available, the result is (clock_t)<<-1>>.
 
 
PORTABILITY
PORTABILITY
ANSI C requires <<clock>> and <<CLOCKS_PER_SEC>>.
ANSI C requires <<clock>> and <<CLOCKS_PER_SEC>>.
 
 
Supporting OS subroutine required: <<times>>.
Supporting OS subroutine required: <<times>>.
*/
*/
 
 
#include <time.h>
#include <time.h>
#include <sys/times.h>
#include <sys/times.h>
#include <reent.h>
#include <reent.h>
 
 
clock_t
clock_t
clock ()
clock ()
{
{
  struct tms tim_s;
  struct tms tim_s;
  clock_t res;
  clock_t res;
 
 
  if ((res = (clock_t) _times_r (_REENT, &tim_s)) != -1)
  if ((res = (clock_t) _times_r (_REENT, &tim_s)) != -1)
    res = (clock_t) (tim_s.tms_utime + tim_s.tms_stime +
    res = (clock_t) (tim_s.tms_utime + tim_s.tms_stime +
                     tim_s.tms_cutime + tim_s.tms_cstime);
                     tim_s.tms_cutime + tim_s.tms_cstime);
 
 
  return res;
  return res;
}
}
 
 
#endif /* CLOCK_PROVIDED */
#endif /* CLOCK_PROVIDED */
 
 

powered by: WebSVN 2.1.0

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