4.115
Line | |
---|
1 | /** |
---|
2 | * @file score/src/timespectoticks.c |
---|
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 <sys/types.h> |
---|
21 | |
---|
22 | #include <rtems/system.h> |
---|
23 | #include <rtems/config.h> |
---|
24 | #include <rtems/score/timespec.h> |
---|
25 | #include <rtems/score/tod.h> |
---|
26 | #include <rtems/score/watchdog.h> |
---|
27 | |
---|
28 | /** |
---|
29 | * |
---|
30 | * This routines converts a timespec to the corresponding number of ticks. |
---|
31 | */ |
---|
32 | |
---|
33 | uint32_t _Timespec_To_ticks( |
---|
34 | const struct timespec *time |
---|
35 | ) |
---|
36 | { |
---|
37 | uint32_t ticks; |
---|
38 | |
---|
39 | if ( (time->tv_sec == 0) && (time->tv_nsec == 0) ) |
---|
40 | return 0; |
---|
41 | |
---|
42 | ticks = time->tv_sec * TOD_TICKS_PER_SECOND; |
---|
43 | |
---|
44 | ticks += time->tv_nsec / rtems_configuration_get_nanoseconds_per_tick(); |
---|
45 | |
---|
46 | if (ticks) |
---|
47 | return ticks; |
---|
48 | |
---|
49 | return 1; |
---|
50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.