source: rtems/c/src/lib/libbsp/unix/posix/timer/timer.c @ 9700578

4.104.114.84.95
Last change on this file since 9700578 was 1ceface, checked in by Joel Sherrill <joel.sherrill@…>, on 10/06/95 at 16:33:30

moved to new development machine and went to gcc 2.7.0

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*  timer.c
2 *
3 *  This file manages the interval timer on the PA-RISC.
4 *
5 *  NOTE: It is important that the timer start/stop overhead be
6 *        determined when porting or modifying this code.
7 *
8 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
9 *  On-Line Applications Research Corporation (OAR).
10 *  All rights assigned to U.S. Government, 1994.
11 *
12 *  This material may be reproduced by or for the U.S. Government pursuant
13 *  to the copyright license under the clause at DFARS 252.227-7013.  This
14 *  notice must appear in all copies of this file and its derivatives.
15 *
16 *  $Id$
17 */
18
19/* For solaris 2.4 */
20#define __EXTENSIONS__
21
22#include <bsp.h>
23#include <time.h>
24#include <sys/time.h>
25
26struct timeval  Timer_start;
27struct timeval  Timer_stop;
28struct timezone Time_zone;
29
30rtems_boolean   Timer_driver_Find_average_overhead;
31
32void Timer_initialize()
33{
34   gettimeofday( &Timer_start, &Time_zone );
35}
36
37#define AVG_OVERHEAD      0  /* It typically takes xxx microseconds */
38                             /* (XX countdowns) to start/stop the timer. */
39#define LEAST_VALID       10 /* Don't trust a value lower than this */
40
41int Read_timer()
42{
43  int total;
44
45  gettimeofday( &Timer_stop, &Time_zone );
46
47  if ( Timer_stop.tv_sec == Timer_start.tv_sec )
48    total = Timer_stop.tv_usec - Timer_start.tv_usec;
49  else {
50    total  = 1000000 - Timer_start.tv_usec;
51    total += (Timer_stop.tv_sec - Timer_start.tv_sec - 1) * 1000000;
52    total += Timer_stop.tv_usec;
53  }
54
55  if ( Timer_driver_Find_average_overhead == 1 )
56      return total;          /* in countdown units */
57  else {
58    if ( total < LEAST_VALID )
59        return 0;            /* below timer resolution */
60    return total - AVG_OVERHEAD;
61  }
62}
63
64rtems_status_code Empty_function( void )
65{
66  return RTEMS_SUCCESSFUL;
67}
68
69void Set_find_average_overhead(
70  rtems_boolean find_flag
71)
72{
73  Timer_driver_Find_average_overhead = find_flag;
74}
Note: See TracBrowser for help on using the repository browser.