Fix timer test
[bertos.git] / bertos / emul / timer_posix.c
index e6149cead7f43d5e2a3058b381e86716ea2109d0..c372bae1c8b6db7b51a70dfeac34e40cb9bc2bfc 100644 (file)
  * invalidate any other reasons why the executable file might be covered by
  * the GNU General Public License.
  *
- * Copyright 2005,2008 Develer S.r.l. (http://www.develer.com/)
- *
+ * Copyright 2005, 2008 Develer S.r.l. (http://www.develer.com/)
  * -->
  *
  * \version $Id$
  *
- * \author Bernardo Innocenti <bernie@develer.com>
- *
+ * \author Bernie Innocenti <bernie@codewiz.org>
  * \brief Low-level timer module for Qt emulator (implementation).
  */
 #include <cfg/compiler.h> // hptime.t
@@ -61,7 +59,7 @@ static void timer_hw_init(void)
        sigaction(SIGALRM, &sa, NULL);
 
        // Setup POSIX realtime timer to interrupt every 1/TIMER_TICKS_PER_SEC.
-       static struct itimerval itv =
+       static const struct itimerval itv =
        {
                { 0, 1000000 / TIMER_TICKS_PER_SEC }, /* it_interval */
                { 0, 1000000 / TIMER_TICKS_PER_SEC }  /* it_value */
@@ -69,7 +67,19 @@ static void timer_hw_init(void)
        setitimer(ITIMER_REAL, &itv, NULL);
 }
 
+static void timer_hw_cleanup(void)
+{
+       static const struct itimerval itv =
+       {
+               { 0, 0 }, /* it_interval */
+               { 0, 0 }  /* it_value */
+       };
+       setitimer(ITIMER_REAL, &itv, NULL);
+}
+
 INLINE hptime_t timer_hw_hpread(void)
 {
        return hptime_get();
 }
+
+#define timer_hw_triggered() (true)