4.115
Last change
on this file since aff220d was
7cd2484,
checked in by Alexander Krutwig <alexander.krutwig@…>, on 05/12/15 at 12:32:47
|
timecounter: Use in RTEMS
Replace timestamp implementation with FreeBSD bintime and timecounters.
New test sptests/sptimecounter02.
Update #2271.
|
-
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.org/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/todimpl.h> |
---|
25 | #include <rtems/seterr.h> |
---|
26 | |
---|
27 | /* |
---|
28 | * 14.2.1 Clocks, P1003.1b-1993, p. 263 |
---|
29 | */ |
---|
30 | |
---|
31 | int 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_as_timespec(tp); |
---|
41 | return 0; |
---|
42 | } |
---|
43 | #ifdef CLOCK_MONOTONIC |
---|
44 | if ( clock_id == CLOCK_MONOTONIC ) { |
---|
45 | _TOD_Get_zero_based_uptime_as_timespec( tp ); |
---|
46 | --tp->tv_sec; |
---|
47 | return 0; |
---|
48 | } |
---|
49 | #endif |
---|
50 | |
---|
51 | #ifdef _POSIX_CPUTIME |
---|
52 | if ( clock_id == CLOCK_PROCESS_CPUTIME_ID ) { |
---|
53 | _TOD_Get_zero_based_uptime_as_timespec( tp ); |
---|
54 | --tp->tv_sec; |
---|
55 | return 0; |
---|
56 | } |
---|
57 | #endif |
---|
58 | |
---|
59 | #ifdef _POSIX_THREAD_CPUTIME |
---|
60 | if ( clock_id == CLOCK_THREAD_CPUTIME_ID ) |
---|
61 | rtems_set_errno_and_return_minus_one( ENOSYS ); |
---|
62 | #endif |
---|
63 | |
---|
64 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
65 | |
---|
66 | return 0; |
---|
67 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.