diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-09-01 18:24:57 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-09-01 18:24:57 +0000 |
commit | a1bfb335c0cc274513e144da46e203bff29e000b (patch) | |
tree | e994694851e8f30b4dd7c93262124d0571605db7 /cpukit/score/src/coretodmsecstoticks.c | |
parent | Remove. (diff) | |
download | rtems-a1bfb335c0cc274513e144da46e203bff29e000b.tar.bz2 |
2011-09-01 Joel Sherrill <joel.sherrilL@OARcorp.com>
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.
Diffstat (limited to 'cpukit/score/src/coretodmsecstoticks.c')
-rw-r--r-- | cpukit/score/src/coretodmsecstoticks.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/cpukit/score/src/coretodmsecstoticks.c b/cpukit/score/src/coretodmsecstoticks.c index cddd3d646d..0b6fa6dede 100644 --- a/cpukit/score/src/coretodmsecstoticks.c +++ b/cpukit/score/src/coretodmsecstoticks.c @@ -1,4 +1,4 @@ -/* COPYRIGHT (c) 1989-2008. +/* COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -21,5 +21,18 @@ uint32_t TOD_MILLISECONDS_TO_TICKS( uint32_t milliseconds ) { - return (milliseconds / rtems_configuration_get_milliseconds_per_tick()); + uint32_t ticks; + uint32_t milliseconds_per_tick; + + /** + * We should ensure the ticks not be truncated by integer division. We + * need to have it be greater than or equal to the requested time. It + * should not be shorter. + */ + milliseconds_per_tick = rtems_configuration_get_milliseconds_per_tick(); + ticks = milliseconds / milliseconds_per_tick; + if ( (milliseconds % milliseconds_per_tick) != 0 ) + ticks += 1; + + return ticks; } |