source: rtems/cpukit/posix/src/clockgettime.c @ 88c74ab

4.115
Last change on this file since 88c74ab was 88c74ab, checked in by Sebastian Huber <sebastian.huber@…>, on 07/25/13 at 13:10:11

score: Merge tod implementation into one file

Delete TOD_MICROSECONDS_PER_SECOND, TOD_MICROSECONDS_TO_TICKS() and
TOD_MILLISECONDS_TO_TICKS().

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Retrieves the Specified Clock Time
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <time.h>
22#include <errno.h>
23
24#include <rtems/score/tod.h>
25#include <rtems/seterr.h>
26
27/*
28 *  14.2.1 Clocks, P1003.1b-1993, p. 263
29 */
30
31int clock_gettime(
32  clockid_t        clock_id,
33  struct timespec *tp
34)
35{
36  if ( !tp )
37    rtems_set_errno_and_return_minus_one( EINVAL );
38
39  if ( clock_id == CLOCK_REALTIME ) {
40    _TOD_Get(tp);
41    return 0;
42  }
43#ifdef CLOCK_MONOTONIC
44  if ( clock_id == CLOCK_MONOTONIC ) {
45    _TOD_Get_uptime_as_timespec( tp );
46    return 0;
47  }
48#endif
49
50#ifdef _POSIX_CPUTIME
51  if ( clock_id == CLOCK_PROCESS_CPUTIME_ID ) {
52    _TOD_Get_uptime_as_timespec( tp );
53    return 0;
54  }
55#endif
56
57#ifdef _POSIX_THREAD_CPUTIME
58  if ( clock_id == CLOCK_THREAD_CPUTIME_ID )
59    rtems_set_errno_and_return_minus_one( ENOSYS );
60#endif
61
62  rtems_set_errno_and_return_minus_one( EINVAL );
63
64  return 0;
65}
Note: See TracBrowser for help on using the repository browser.