source: rtems/cpukit/posix/src/clockgetres.c @ e552d05

4.104.115
Last change on this file since e552d05 was 33046a5, checked in by Joel Sherrill <joel.sherrill@…>, on 09/13/09 at 20:42:10

2009-09-13 Joel Sherrill <joel.sherrill@…>

  • posix/Makefile.am, posix/src/clockgetres.c: Add clockgetres.c to set of clock and delayt methods built when POSIX threads are disabled. Ensure it builds when POSIX is disabled.
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 *  $Id$
3 */
4
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
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <time.h>
21#include <errno.h>
22
23#include <rtems/system.h>
24#include <rtems/config.h>
25#include <rtems/score/isr.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/tod.h>
28
29#include <rtems/seterr.h>
30
31/*PAGE
32 *
33 *  14.2.1 Clocks, P1003.1b-1993, p. 263
34 */
35
36int clock_getres(
37  clockid_t        clock_id,
38  struct timespec *res
39)
40{
41  if ( !res )
42    rtems_set_errno_and_return_minus_one( EINVAL );
43
44  switch ( clock_id ) {
45
46    /*
47     *  All time in rtems is based on the same clock tick.
48     */
49
50    case CLOCK_REALTIME:
51    case CLOCK_PROCESS_CPUTIME:
52    case CLOCK_THREAD_CPUTIME:
53      if ( res ) {
54        res->tv_sec = rtems_configuration_get_microseconds_per_tick() /
55            TOD_MICROSECONDS_PER_SECOND;
56        res->tv_nsec = rtems_configuration_get_nanoseconds_per_tick();
57      }
58      break;
59
60    default:
61      rtems_set_errno_and_return_minus_one( EINVAL );
62
63  }
64  return 0;
65}
Note: See TracBrowser for help on using the repository browser.