source: rtems/cpukit/posix/src/clockgettime.c @ 0061ef98

4.104.114.84.9
Last change on this file since 0061ef98 was 0061ef98, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 26, 2007 at 10:56:12 PM

2007-03-26 Joel Sherrill <joel@…>

PR 1231/cpukit

  • posix/src/adasupp.c, posix/src/clockgetcpuclockid.c, posix/src/clockgetenableattr.c, posix/src/clockgetres.c, posix/src/clockgettime.c, posix/src/clocksetenableattr.c, posix/src/mutex.c, posix/src/mutexattrdestroy.c, posix/src/mutexattrgetprioceiling.c, posix/src/mutexattrgetprotocol.c, posix/src/mutexattrgetpshared.c, posix/src/mutexattrinit.c, posix/src/mutexattrsetprioceiling.c, posix/src/mutexattrsetprotocol.c, posix/src/mutexattrsetpshared.c, posix/src/mutexdefaultattributes.c, posix/src/mutexdestroy.c, posix/src/mutexgetprioceiling.c, posix/src/mutexlock.c, posix/src/mutexlocksupp.c, posix/src/mutexmp.c, posix/src/mutexsetprioceiling.c, posix/src/mutextimedlock.c, posix/src/mutextrylock.c, posix/src/mutexunlock.c, posix/src/nanosleep.c, posix/src/posixintervaltotimespec.c, posix/src/posixtimespecsubtract.c, posix/src/posixtimespectointerval.c, posix/src/psignalclearprocesssignals.c, posix/src/psignalclearsignals.c, posix/src/psignalsetprocesssignals.c, posix/src/psignalunblockthread.c, posix/src/ptimer.c, posix/src/ptimer1.c, posix/src/sched.c, posix/src/time.c: Remove unneeded includes of assert.h
  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  $Id$
3 */
4
5#if HAVE_CONFIG_H
6#include "config.h"
7#endif
8
9#include <time.h>
10#include <errno.h>
11
12#include <rtems/system.h>
13#include <rtems/score/isr.h>
14#include <rtems/score/thread.h>
15#include <rtems/score/tod.h>
16
17#include <rtems/seterr.h>
18#include <rtems/posix/time.h>
19
20/*PAGE
21 *
22 *  14.2.1 Clocks, P1003.1b-1993, p. 263
23 */
24
25int clock_gettime(
26  clockid_t        clock_id,
27  struct timespec *tp
28)
29{
30  ISR_Level      level;
31  time_t         seconds;
32  long           ticks;
33
34  if ( !tp )
35    rtems_set_errno_and_return_minus_one( EINVAL );
36
37  switch ( clock_id ) {
38
39    case CLOCK_REALTIME:
40
41      _ISR_Disable( level );
42        seconds = _TOD_Seconds_since_epoch;
43        ticks   = _TOD_Current.ticks;
44      _ISR_Enable( level );
45
46      tp->tv_sec  = seconds + POSIX_TIME_SECONDS_1970_THROUGH_1988;
47      tp->tv_nsec = ticks * _TOD_Microseconds_per_tick *
48                      TOD_NANOSECONDS_PER_MICROSECOND;
49      break;
50
51#ifdef _POSIX_CPUTIME
52    case CLOCK_PROCESS_CPUTIME:
53      /* don't base this on _Watchdog_Ticks_since_boot--duration is too short*/
54      return POSIX_NOT_IMPLEMENTED();
55      break;
56#endif
57
58#ifdef _POSIX_THREAD_CPUTIME
59    case CLOCK_THREAD_CPUTIME:
60      return POSIX_NOT_IMPLEMENTED();
61      break;
62#endif
63    default:
64      rtems_set_errno_and_return_minus_one( EINVAL );
65
66  }
67  return 0;
68}
Note: See TracBrowser for help on using the repository browser.