4.104.115
Line | |
---|
1 | /** |
---|
2 | * @file score/src/timespecaddto.c |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * COPYRIGHT (c) 1989-2008. |
---|
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 <rtems/system.h> |
---|
21 | #include <sys/types.h> |
---|
22 | #include <rtems/score/timespec.h> |
---|
23 | #include <rtems/score/tod.h> |
---|
24 | #include <rtems/score/watchdog.h> |
---|
25 | |
---|
26 | /** |
---|
27 | * |
---|
28 | * This routines adds two timespecs. The second argument is added |
---|
29 | * to the first. |
---|
30 | */ |
---|
31 | |
---|
32 | uint32_t _Timespec_Add_to( |
---|
33 | struct timespec *time, |
---|
34 | const struct timespec *add |
---|
35 | ) |
---|
36 | { |
---|
37 | uint32_t seconds = add->tv_sec; |
---|
38 | |
---|
39 | /* Add the basics */ |
---|
40 | time->tv_sec += add->tv_sec; |
---|
41 | time->tv_nsec += add->tv_nsec; |
---|
42 | |
---|
43 | /* Now adjust it so nanoseconds is in range */ |
---|
44 | while ( time->tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) { |
---|
45 | time->tv_nsec -= TOD_NANOSECONDS_PER_SECOND; |
---|
46 | time->tv_sec++; |
---|
47 | seconds++; |
---|
48 | } |
---|
49 | |
---|
50 | return seconds; |
---|
51 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.