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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [clockgettime.c] - Blame information for rev 609

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

Line No. Rev Author Line
1 30 unneback
/*
2
 *  $Id: clockgettime.c,v 1.2 2001-09-27 11:59:17 chris Exp $
3
 */
4
 
5
#include <assert.h>
6
#include <time.h>
7
#include <errno.h>
8
 
9
#include <rtems/system.h>
10
#include <rtems/score/isr.h>
11
#include <rtems/score/thread.h>
12
#include <rtems/score/tod.h>
13
 
14
#include <rtems/posix/seterr.h>
15
#include <rtems/posix/time.h>
16
 
17
/*PAGE
18
 *
19
 *  14.2.1 Clocks, P1003.1b-1993, p. 263
20
 */
21
 
22
int clock_gettime(
23
  clockid_t        clock_id,
24
  struct timespec *tp
25
)
26
{
27
  ISR_Level      level;
28
  time_t         seconds;
29
  long           ticks;
30
 
31
  if ( !tp )
32
    set_errno_and_return_minus_one( EINVAL );
33
 
34
  switch ( clock_id ) {
35
 
36
    case CLOCK_REALTIME:
37
 
38
      _ISR_Disable( level );
39
        seconds = _TOD_Seconds_since_epoch;
40
        ticks   = _TOD_Current.ticks;
41
      _ISR_Enable( level );
42
 
43
      tp->tv_sec  = seconds + POSIX_TIME_SECONDS_1970_THROUGH_1988;
44
      tp->tv_nsec = ticks * _TOD_Microseconds_per_tick *
45
                      TOD_NANOSECONDS_PER_MICROSECOND;
46
      break;
47
 
48
#ifdef _POSIX_CPUTIME
49
    case CLOCK_PROCESS_CPUTIME:
50
      /* don't base this on _Watchdog_Ticks_since_boot--duration is too short*/
51
      return POSIX_NOT_IMPLEMENTED();
52
      break;
53
#endif
54
 
55
#ifdef _POSIX_THREAD_CPUTIME
56
    case CLOCK_THREAD_CPUTIME:
57
      return POSIX_NOT_IMPLEMENTED();
58
      break;
59
#endif
60
    default:
61
      set_errno_and_return_minus_one( EINVAL );
62
 
63
  }
64
  return 0;
65
}

powered by: WebSVN 2.1.0

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