X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=rts%2Fposix%2FItimer.c;h=51e08f82803a2f84e9b0a610174571557bd9f8b3;hp=df95f21b924433b9f902f529955148d28ca7c135;hb=8d71be7cbd079f5eab23484a53a43b59dd0399e5;hpb=37e27d92a0fc14105e4533514c3995fccd6da9fe diff --git a/rts/posix/Itimer.c b/rts/posix/Itimer.c index df95f21..51e08f8 100644 --- a/rts/posix/Itimer.c +++ b/rts/posix/Itimer.c @@ -127,7 +127,7 @@ install_vtalrm_handler(TickProc handle_tick) } void -startTicker(nat ms, TickProc handle_tick) +initTicker (TickProc handle_tick) { install_vtalrm_handler(handle_tick); @@ -137,21 +137,30 @@ startTicker(nat ms, TickProc handle_tick) #if defined(USE_TIMER_CREATE) { - struct itimerspec it; struct sigevent ev; ev.sigev_notify = SIGEV_SIGNAL; ev.sigev_signo = ITIMER_SIGNAL; - - it.it_value.tv_sec = ms / 1000; - it.it_value.tv_nsec = (ms % 1000) * 1000000; - it.it_interval = it.it_value; - + if (timer_create(TIMER_FLAVOUR, &ev, &timer) != 0) { sysErrorBelch("timer_create"); stg_exit(EXIT_FAILURE); } + } +#endif +} +void +startTicker(nat ms) +{ +#if defined(USE_TIMER_CREATE) + { + struct itimerspec it; + + it.it_value.tv_sec = ms / 1000; + it.it_value.tv_nsec = (ms % 1000) * 1000000; + it.it_interval = it.it_value; + if (timer_settime(timer, 0, &it, NULL) != 0) { sysErrorBelch("timer_settime"); stg_exit(EXIT_FAILURE); @@ -201,6 +210,13 @@ stopTicker(void) #endif } +void +exitTicker(void) +{ + timer_delete(timer); + // ignore errors - we don't really care if it fails. +} + #if 0 /* Currently unused */ void