source: rtems/cpukit/posix/src/clockgettime.c @ f26145b

4.104.114.84.95
Last change on this file since f26145b was 874297f3, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/16/04 at 10:01:03

Remove stray white spaces.

  • 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 <assert.h>
10#include <time.h>
11#include <errno.h>
12
13#include <rtems/system.h>
14#include <rtems/score/isr.h>
15#include <rtems/score/thread.h>
16#include <rtems/score/tod.h>
17
18#include <rtems/seterr.h>
19#include <rtems/posix/time.h>
20
21/*PAGE
22 *
23 *  14.2.1 Clocks, P1003.1b-1993, p. 263
24 */
25
26int clock_gettime(
27  clockid_t        clock_id,
28  struct timespec *tp
29)
30{
31  ISR_Level      level;
32  time_t         seconds;
33  long           ticks;
34
35  if ( !tp )
36    rtems_set_errno_and_return_minus_one( EINVAL );
37
38  switch ( clock_id ) {
39
40    case CLOCK_REALTIME:
41
42      _ISR_Disable( level );
43        seconds = _TOD_Seconds_since_epoch;
44        ticks   = _TOD_Current.ticks;
45      _ISR_Enable( level );
46
47      tp->tv_sec  = seconds + POSIX_TIME_SECONDS_1970_THROUGH_1988;
48      tp->tv_nsec = ticks * _TOD_Microseconds_per_tick *
49                      TOD_NANOSECONDS_PER_MICROSECOND;
50      break;
51
52#ifdef _POSIX_CPUTIME
53    case CLOCK_PROCESS_CPUTIME:
54      /* don't base this on _Watchdog_Ticks_since_boot--duration is too short*/
55      return POSIX_NOT_IMPLEMENTED();
56      break;
57#endif
58
59#ifdef _POSIX_THREAD_CPUTIME
60    case CLOCK_THREAD_CPUTIME:
61      return POSIX_NOT_IMPLEMENTED();
62      break;
63#endif
64    default:
65      rtems_set_errno_and_return_minus_one( EINVAL );
66
67  }
68  return 0;
69}
Note: See TracBrowser for help on using the repository browser.