source: rtems/cpukit/score/src/coretodusectoticks.c @ e3f6d35

4.10
Last change on this file since e3f6d35 was a1bfb33, checked in by Joel Sherrill <joel.sherrill@…>, on 09/01/11 at 18:24:57

2011-09-01 Joel Sherrill <joel.sherrilL@…>

PR 1895/cpukit

  • posix/src/mqueuerecvsupp.c, posix/src/pthreadjoin.c, score/src/coretodmsecstoticks.c, score/src/coretodusectoticks.c, score/src/timespectoticks.c: Ensure time conversions to ticks do not ignore partial tick and return 1 less than desired.
  • Property mode set to 100644
File size: 924 bytes
Line 
1/*  COPYRIGHT (c) 1989-2011.
2 *  On-Line Applications Research Corporation (OAR).
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 *
8 *  $Id$
9 */
10
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/system.h>
17#include <rtems/config.h>
18#include <rtems/score/tod.h>
19
20uint32_t TOD_MICROSECONDS_TO_TICKS(
21  uint32_t microseconds
22)
23{
24  uint32_t ticks;
25  uint32_t microseconds_per_tick;
26
27  /**
28   *  We should ensure the ticks not be truncated by integer division.  We
29   *  need to have it be greater than or equal to the requested time.  It
30   *  should not be shorter.
31   */
32  microseconds_per_tick = rtems_configuration_get_microseconds_per_tick();
33  ticks                 = microseconds / microseconds_per_tick;
34  if ( (microseconds % microseconds_per_tick) != 0 )
35    ticks += 1;
36
37  return ticks;
38}
Note: See TracBrowser for help on using the repository browser.