RCS file: /usr1/CVS/rtems/cpukit/score/src/coretodmsecstoticks.c,v
retrieving revision 1.1
diff -u -r1.1 coretodmsecstoticks.c
|
|
|
1 | | /* COPYRIGHT (c) 1989-2008. |
| 1 | /* COPYRIGHT (c) 1989-2011. |
2 | 2 | * On-Line Applications Research Corporation (OAR). |
3 | 3 | * |
4 | 4 | * The license and distribution terms for this file may be |
… |
… |
|
21 | 21 | uint32_t milliseconds |
22 | 22 | ) |
23 | 23 | { |
24 | | return (milliseconds / rtems_configuration_get_milliseconds_per_tick()); |
| 24 | uint32_t ticks; |
| 25 | uint32_t milliseconds_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 | milliseconds_per_tick = rtems_configuration_get_milliseconds_per_tick(); |
| 33 | ticks = milliseconds / milliseconds_per_tick; |
| 34 | if ( (milliseconds % milliseconds_per_tick) != 0 ) |
| 35 | ticks += 1; |
| 36 | |
| 37 | return ticks; |
25 | 38 | } |
RCS file: /usr1/CVS/rtems/cpukit/score/src/coretodusectoticks.c,v
retrieving revision 1.1
diff -u -r1.1 coretodusectoticks.c
|
|
|
1 | | /* COPYRIGHT (c) 1989-2008. |
| 1 | /* COPYRIGHT (c) 1989-2011. |
2 | 2 | * On-Line Applications Research Corporation (OAR). |
3 | 3 | * |
4 | 4 | * The license and distribution terms for this file may be |
… |
… |
|
21 | 21 | uint32_t microseconds |
22 | 22 | ) |
23 | 23 | { |
24 | | return (microseconds / rtems_configuration_get_microseconds_per_tick()); |
| 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; |
25 | 38 | } |
RCS file: /usr1/CVS/rtems/cpukit/score/src/timespectoticks.c,v
retrieving revision 1.3
diff -u -r1.3 timespectoticks.c
|
|
|
35 | 35 | ) |
36 | 36 | { |
37 | 37 | uint32_t ticks; |
| 38 | uint32_t nanoseconds_per_tick; |
38 | 39 | |
39 | 40 | if ( (time->tv_sec == 0) && (time->tv_nsec == 0) ) |
40 | 41 | return 0; |
41 | 42 | |
42 | | ticks = time->tv_sec * TOD_TICKS_PER_SECOND; |
| 43 | /** |
| 44 | * We should ensure the ticks not be truncated by integer division. We |
| 45 | * need to have it be greater than or equal to the requested time. It |
| 46 | * should not be shorter. |
| 47 | */ |
| 48 | ticks = time->tv_sec * TOD_TICKS_PER_SECOND; |
| 49 | nanoseconds_per_tick = rtems_configuration_get_nanoseconds_per_tick(); |
| 50 | ticks += time->tv_nsec / nanoseconds_per_tick; |
43 | 51 | |
44 | | ticks += time->tv_nsec / rtems_configuration_get_nanoseconds_per_tick(); |
| 52 | if ( (time->tv_nsec % nanoseconds_per_tick) != 0 ) |
| 53 | ticks += 1; |
45 | 54 | |
46 | | if (ticks) |
47 | | return ticks; |
48 | | |
49 | | return 1; |
| 55 | return ticks; |
50 | 56 | } |