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 Function Returns the Resolution of any Clock |
---|
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/config.h> |
---|
26 | #include <rtems/seterr.h> |
---|
27 | |
---|
28 | /* |
---|
29 | * 14.2.1 Clocks, P1003.1b-1993, p. 263 |
---|
30 | */ |
---|
31 | |
---|
32 | int clock_getres( |
---|
33 | clockid_t clock_id, |
---|
34 | struct timespec *res |
---|
35 | ) |
---|
36 | { |
---|
37 | if ( !res ) |
---|
38 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
39 | |
---|
40 | switch ( clock_id ) { |
---|
41 | |
---|
42 | /* |
---|
43 | * All time in rtems is based on the same clock tick. |
---|
44 | */ |
---|
45 | |
---|
46 | case CLOCK_REALTIME: |
---|
47 | case CLOCK_PROCESS_CPUTIME_ID: |
---|
48 | case CLOCK_THREAD_CPUTIME_ID: |
---|
49 | if ( res ) { |
---|
50 | res->tv_sec = rtems_configuration_get_microseconds_per_tick() / |
---|
51 | TOD_MICROSECONDS_PER_SECOND; |
---|
52 | res->tv_nsec = rtems_configuration_get_nanoseconds_per_tick(); |
---|
53 | } |
---|
54 | break; |
---|
55 | |
---|
56 | default: |
---|
57 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
58 | |
---|
59 | } |
---|
60 | return 0; |
---|
61 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.