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

5
Last change on this file since 2256946 was 2256946, checked in by Sebastian Huber <sebastian.huber@…>, on 10/06/17 at 13:30:47

score: Use struct timespec for TOD

Use the timestamps only for uptime based values. Use struct timespec
for the absolute time values (TOD).

Update #2740.

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[d527562e]1/**
2 * @file
3 *
4 * @brief Retrieves the Specified Clock Time
[5cb175bb]5 * @ingroup POSIXAPI
[d527562e]6 */
7
[9f95a19]8/*
[fbfb5926]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
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[9f95a19]15 */
16
[f42b726]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[9f95a19]21#include <time.h>
22#include <errno.h>
23
[f031df0e]24#include <rtems/score/todimpl.h>
[188c82b]25#include <rtems/seterr.h>
[9f95a19]26
[64adc13]27/*
[9f95a19]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 )
[e180a77e]37    rtems_set_errno_and_return_minus_one( EINVAL );
[9f95a19]38
[c16bcc0]39  if ( clock_id == CLOCK_REALTIME ) {
[2256946]40    _TOD_Get(tp);
[c16bcc0]41    return 0;
42  }
[1ee474ea]43#ifdef CLOCK_MONOTONIC
[c16bcc0]44  if ( clock_id == CLOCK_MONOTONIC ) {
[7cd2484]45    _TOD_Get_zero_based_uptime_as_timespec( tp );
[c16bcc0]46    return 0;
47  }
[812da54]48#endif
[c16bcc0]49
[9f95a19]50#ifdef _POSIX_CPUTIME
[5153d87]51  if ( clock_id == CLOCK_PROCESS_CPUTIME_ID ) {
[7cd2484]52    _TOD_Get_zero_based_uptime_as_timespec( tp );
[c16bcc0]53    return 0;
54  }
[9f95a19]55#endif
[c16bcc0]56
[9f95a19]57#ifdef _POSIX_THREAD_CPUTIME
[5153d87]58  if ( clock_id == CLOCK_THREAD_CPUTIME_ID )
[e889a857]59    rtems_set_errno_and_return_minus_one( ENOSYS );
[9f95a19]60#endif
[1de949a8]61
[c16bcc0]62  rtems_set_errno_and_return_minus_one( EINVAL );
[9f95a19]63
64  return 0;
65}
Note: See TracBrowser for help on using the repository browser.