4.115
Last change
on this file since 25f5730f was
c499856,
checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47
|
Change all references of rtems.com to rtems.org.
|
-
Property mode set to
100644
|
File size:
1022 bytes
|
Rev | Line | |
---|
[28352fae] | 1 | /** |
---|
[d4d7899] | 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @brief Divide Timespec By Integer |
---|
| 5 | * |
---|
| 6 | * @ingroup Timespec |
---|
[c3330a8] | 7 | */ |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | * COPYRIGHT (c) 1989-2007. |
---|
| 11 | * On-Line Applications Research Corporation (OAR). |
---|
| 12 | * |
---|
| 13 | * The license and distribution terms for this file may be |
---|
| 14 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 15 | * http://www.rtems.org/license/LICENSE. |
---|
[c3330a8] | 16 | */ |
---|
| 17 | |
---|
| 18 | #if HAVE_CONFIG_H |
---|
| 19 | #include "config.h" |
---|
| 20 | #endif |
---|
| 21 | |
---|
| 22 | #include <rtems/score/timespec.h> |
---|
[f031df0e] | 23 | #include <rtems/score/todimpl.h> |
---|
[c3330a8] | 24 | |
---|
| 25 | void _Timespec_Divide_by_integer( |
---|
| 26 | const struct timespec *time, |
---|
| 27 | uint32_t iterations, |
---|
| 28 | struct timespec *result |
---|
| 29 | ) |
---|
| 30 | { |
---|
| 31 | uint64_t t; |
---|
| 32 | |
---|
| 33 | /* |
---|
| 34 | * For math simplicity just convert the timespec to nanoseconds |
---|
| 35 | * in a 64-bit integer. |
---|
| 36 | */ |
---|
[48f3027] | 37 | t = time->tv_sec; |
---|
| 38 | t *= TOD_NANOSECONDS_PER_SECOND; |
---|
[c3330a8] | 39 | t += time->tv_nsec; |
---|
| 40 | |
---|
| 41 | /* |
---|
| 42 | * Divide to get nanoseconds per iteration |
---|
| 43 | */ |
---|
| 44 | |
---|
| 45 | t /= iterations; |
---|
| 46 | |
---|
| 47 | /* |
---|
| 48 | * Put it back in the timespec result |
---|
| 49 | */ |
---|
| 50 | |
---|
| 51 | result->tv_sec = t / TOD_NANOSECONDS_PER_SECOND; |
---|
| 52 | result->tv_nsec = t % TOD_NANOSECONDS_PER_SECOND; |
---|
| 53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.