source: rtems/cpukit/posix/src/clockgetres.c @ 3d66dfc1

4.104.115
Last change on this file since 3d66dfc1 was 3d66dfc1, checked in by Joel Sherrill <joel.sherrill@…>, on 12/16/08 at 17:36:01

2008-12-16 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/times.c, posix/src/adjtime.c, posix/src/clockgetres.c, posix/src/sysconf.c, rtems/src/clockgettickspersecond.c, rtems/src/clockgettod.c, rtems/src/clockset.c, rtems/src/clocktodvalidate.c, score/src/timespecfromticks.c, score/src/timespectoticks.c, score/src/ts64toticks.c: More case converted to use configuration table entry not _TOD_Microseconds_per_tick.
  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[9f95a19]1/*
2 *  $Id$
3 */
4
[412dbff6]5/*
6 *  COPYRIGHT (c) 1989-2007.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
[f42b726]16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
[9f95a19]20#include <time.h>
21#include <errno.h>
22
23#include <rtems/system.h>
[3d66dfc1]24#include <rtems/config.h>
[9f95a19]25#include <rtems/score/isr.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/tod.h>
28
[188c82b]29#include <rtems/seterr.h>
[9f95a19]30#include <rtems/posix/time.h>
31
32/*PAGE
33 *
34 *  14.2.1 Clocks, P1003.1b-1993, p. 263
35 */
36
37int clock_getres(
38  clockid_t        clock_id,
39  struct timespec *res
40)
41{
42  if ( !res )
[e180a77e]43    rtems_set_errno_and_return_minus_one( EINVAL );
[874297f3]44
[9f95a19]45  switch ( clock_id ) {
[874297f3]46
[9f95a19]47    /*
48     *  All time in rtems is based on the same clock tick.
49     */
50
51    case CLOCK_REALTIME:
52    case CLOCK_PROCESS_CPUTIME:
53    case CLOCK_THREAD_CPUTIME:
[a93baa43]54      if ( res ) {
[3d66dfc1]55        res->tv_sec = rtems_configuration_get_microseconds_per_tick() /
56            TOD_MICROSECONDS_PER_SECOND;
57        res->tv_nsec = rtems_configuration_get_nanoseconds_per_tick();
[a93baa43]58      }
[9f95a19]59      break;
[874297f3]60
[9f95a19]61    default:
[e180a77e]62      rtems_set_errno_and_return_minus_one( EINVAL );
[874297f3]63
[9f95a19]64  }
65  return 0;
66}
Note: See TracBrowser for help on using the repository browser.