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:
1.1 KB
|
Rev | Line | |
---|
[28352fae] | 1 | /** |
---|
[5a58b1e] | 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @brief Divide Timestamp |
---|
| 5 | * @ingroup SuperCore |
---|
[e57cb3c] | 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 |
---|
[c499856] | 14 | * http://www.rtems.org/license/LICENSE. |
---|
[e57cb3c] | 15 | */ |
---|
| 16 | |
---|
| 17 | #if HAVE_CONFIG_H |
---|
| 18 | #include "config.h" |
---|
| 19 | #endif |
---|
| 20 | |
---|
| 21 | #include <rtems/score/timestamp.h> |
---|
| 22 | |
---|
| 23 | /* This method is never inlined. */ |
---|
[3a42e6fd] | 24 | #if CPU_TIMESTAMP_USE_INT64 == TRUE || CPU_TIMESTAMP_USE_INT64_INLINE == TRUE |
---|
[e57cb3c] | 25 | void _Timestamp64_Divide( |
---|
| 26 | const Timestamp64_Control *_lhs, |
---|
| 27 | const Timestamp64_Control *_rhs, |
---|
| 28 | uint32_t *_ival_percentage, |
---|
| 29 | uint32_t *_fval_percentage |
---|
| 30 | ) |
---|
| 31 | { |
---|
| 32 | Timestamp64_Control answer; |
---|
| 33 | |
---|
| 34 | if ( *_rhs == 0 ) { |
---|
| 35 | *_ival_percentage = 0; |
---|
| 36 | *_fval_percentage = 0; |
---|
| 37 | return; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | /* |
---|
| 41 | * This looks odd but gives the results the proper precision. |
---|
| 42 | * |
---|
| 43 | * TODO: Rounding on the last digit of the fval. |
---|
| 44 | */ |
---|
| 45 | |
---|
| 46 | answer = (*_lhs * 100000) / *_rhs; |
---|
| 47 | |
---|
| 48 | *_ival_percentage = answer / 1000; |
---|
| 49 | *_fval_percentage = answer % 1000; |
---|
| 50 | } |
---|
| 51 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.