-/*
- vtalrm_handler is assigned and set up in Signals.c
-
- vtalrm_id (defined in Signals.c) holds
- the system id for the current timer (used to
- later block/kill it.)
-*/
-extern nat vtalrm_id;
-TIMECALLBACK *vtalrm_cback;
-
-nat
-initialize_virtual_timer(nat ms)
-{
-# ifdef PROFILING
- /* On Win32 setups that don't have support for
- setitimer(), we use the MultiMedia API's timer
- support.
-
- As the delivery of ticks isn't free, we only
- enable it if we really needed, i.e., when profiling.
- (the RTS now also needs timer ticks to implement
- threadDelay in non-profiling mode, but the pure
- Win32 port doesn't support that.....yet.)
- */
- unsigned int delay,vtalrm_id;
-
- delay = timeBeginPeriod(1);
- if (delay == TIMERR_NOCANDO) { /* error of some sort. */
- return delay;
- }
- vtalrm_id =
- timeSetEvent(ms, /* event every `delay' milliseconds. */
- 1, /* precision is within 5 millisecs. */
- (LPTIMECALLBACK)vtalrm_cback,
- 0,
- TIME_PERIODIC);
-# endif