[PATCH 03/12] score: Simplify _Timespec_To_ticks()
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Apr 8 06:49:18 UTC 2016
---
cpukit/score/src/timespectoticks.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/cpukit/score/src/timespectoticks.c b/cpukit/score/src/timespectoticks.c
index d02a350..61ee06d 100644
--- a/cpukit/score/src/timespectoticks.c
+++ b/cpukit/score/src/timespectoticks.c
@@ -30,8 +30,7 @@ uint32_t _Timespec_To_ticks(
uint32_t ticks;
uint32_t nanoseconds_per_tick;
- if ( (time->tv_sec == 0) && (time->tv_nsec == 0) )
- return 0;
+ nanoseconds_per_tick = rtems_configuration_get_nanoseconds_per_tick();
/**
* We should ensure the ticks not be truncated by integer division. We
@@ -39,11 +38,7 @@ uint32_t _Timespec_To_ticks(
* should not be shorter.
*/
ticks = time->tv_sec * rtems_configuration_get_ticks_per_second();
- nanoseconds_per_tick = rtems_configuration_get_nanoseconds_per_tick();
- ticks += time->tv_nsec / nanoseconds_per_tick;
-
- if ( (time->tv_nsec % nanoseconds_per_tick) != 0 )
- ticks += 1;
+ ticks += ( time->tv_nsec + nanoseconds_per_tick - 1 ) / nanoseconds_per_tick;
return ticks;
}
--
1.8.4.5
More information about the devel
mailing list