source: rtems/cpukit/score/src/ts64divide.c @ 25f5730f

4.11
Last change on this file since 25f5730f was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Divide Timestamp
5 *  @ingroup SuperCore
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.org/license/LICENSE.
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. */
24#if CPU_TIMESTAMP_USE_INT64 == TRUE || CPU_TIMESTAMP_USE_INT64_INLINE == TRUE
25void _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.