On 08/24/2014 05:02 AM, Chris Johns wrote:
On 23/08/2014 1:12 am, Sebastian Huber wrote:
Add rtems_clock_ticks_later(), rtems_clock_ticks_later_us() and
rtems_clock_ticks_later_us().

FIXME: Patch is incomplete.  Documentation and tests are missing.  Just
for API review.
---
cpukit/rtems/include/rtems/rtems/clock.h | 66 ++++++++++++++++++++++++++++++++
  1 file changed, 66 insertions(+)

diff --git a/cpukit/rtems/include/rtems/rtems/clock.h b/cpukit/rtems/include/rtems/rtems/clock.h
index ff71665..cee930e 100644
--- a/cpukit/rtems/include/rtems/rtems/clock.h
+++ b/cpukit/rtems/include/rtems/rtems/clock.h
@@ -34,6 +34,7 @@
  #include <rtems/score/tod.h>
  #include <rtems/rtems/status.h>
  #include <rtems/rtems/types.h>
+#include <rtems/config.h>

  #include <sys/time.h> /* struct timeval */

@@ -160,6 +161,71 @@ RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_get_ticks_since_boot(void)
  }

  /**
+ * @brief Returns the ticks counter value delta ticks in the future.
+ *
+ * @param[in] delta The ticks delta value.
+ *
+ * @return The tick counter value delta ticks in the future.
+ */
+RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_ticks_later(
+  rtems_interval delta
+)
+{
+  return _Watchdog_Ticks_since_boot + delta;
+}
+
+/**
+ * @brief Returns the ticks counter value at least delta microseconds in the
+ * future.
+ *
+ * @param[in] delta The delta value in microseconds.
+ *
+ * @return The tick counter value at least delta microseconds in the future.
+ */
+RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_ticks_later_us(

This should be rtems_clock_ticks_later_usec. When I first saw this I though it meant 'us' as in 'you and me'.

Ok.


The calls names make sense from a programming point of view but from a user point of view they are sort of forwards and backwards. For example rtems_clock_ticks_later_us is the "the clock tick so many micro-seconds later where later implies now" or 'rtems_clock_tick_usecs_later' and following this I suppose 'rtems_clock_ticks_later' becomes 'rtems_clock_tick_ticks_later' ?

What about rtems_clock_tick_later() and rtems_clock_tick_before()? In the context it should be clear what they do, e.g.

+ * @code
+ * status busy( void )
+ * {
+ *   rtems_interval timeout = rtems_clock_tick_later_usec( 10000 );
+ *
+ *   do {
+ *     if ( ok() ) {
+ *       return success;
+ *     }
+ *   } while ( rtems_clock_tick_before( timeout ) );
+ *
+ *   return timeout;
+ * }
+ * @endcode

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to