summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b79fdec)
initialize_virtual_timer: Robustified win32 version; don't
assume that the minimal resolution is one millisec, consult
the underlying impl via timeGetDevCaps().
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: Itimer.c,v 1.24 2001/11/13 13:38:02 simonmar Exp $
+ * $Id: Itimer.c,v 1.25 2001/11/21 20:55:10 sof Exp $
*
* (c) The GHC Team, 1995-1999
*
*
* (c) The GHC Team, 1995-1999
*
LPTIMECALLBACK vtalrm_cback;
LPTIMECALLBACK vtalrm_cback;
initialize_virtual_timer(nat ms)
{
/* On Win32 setups that don't have support for
initialize_virtual_timer(nat ms)
{
/* On Win32 setups that don't have support for
The delivery of ticks isn't free; the performance hit should be checked.
*/
unsigned int delay;
The delivery of ticks isn't free; the performance hit should be checked.
*/
unsigned int delay;
- static unsigned int vtalrm_id;
+ static unsigned int vtalrm_id = 0;
+ static unsigned int period = -1;
- if (ms) {
- delay = timeBeginPeriod(1);
- if (delay == TIMERR_NOCANDO) { /* error of some sort. */
- return delay;
+ /* A zero argument value means shutdown. */
+ if (ms != 0) {
+ TIMECAPS tc;
+
+ if ( timeGetDevCaps(&tc, sizeof(TIMECAPS)) == TIMERR_NOERROR) {
+ period = tc.wPeriodMin;
+ delay = timeBeginPeriod(period);
+ if (delay == TIMERR_NOCANDO) { /* error of some sort. */
+ return -1;
+ }
+ } else {
+ return -1;
vtalrm_id =
timeSetEvent(ms, /* event every `delay' milliseconds. */
1, /* precision is within 1 ms */
vtalrm_id =
timeSetEvent(ms, /* event every `delay' milliseconds. */
1, /* precision is within 1 ms */
TIME_CALLBACK_FUNCTION, /* ordinary callback */
TIME_PERIODIC);
} else {
TIME_CALLBACK_FUNCTION, /* ordinary callback */
TIME_PERIODIC);
} else {
- timeKillEvent(vtalrm_id);
- timeEndPeriod(1);
+ /* Shutdown the MM timer */
+ if ( vtalrm_id != 0 ) {
+ timeKillEvent(vtalrm_id);
+ }
+ if (period > 0) {
+ timeEndPeriod(period);
+ }
initialize_virtual_timer(nat ms)
{
# ifndef HAVE_SETITIMER
initialize_virtual_timer(nat ms)
{
# ifndef HAVE_SETITIMER
-#endif /* !cygwin32_TARGET_OS */
+#endif /* !{mingw,cygwin32}_TARGET_OS */
# if 0
/* This is a potential POSIX version */
# if 0
/* This is a potential POSIX version */
initialize_virtual_timer(nat ms)
{
struct sigevent se;
initialize_virtual_timer(nat ms)
{
struct sigevent se;
it.it_value.tv_sec = ms / 1000;
it.it_value.tv_nsec = 1000000 * (ms - 1000 * it.it_value.tv_sec);
it.it_interval = it.it_value;
it.it_value.tv_sec = ms / 1000;
it.it_value.tv_nsec = 1000000 * (ms - 1000 * it.it_value.tv_sec);
it.it_interval = it.it_value;
- timer_settime(tid, TIMER_RELTIME, &it, NULL);
+ return timer_settime(tid, TIMER_RELTIME, &it, NULL);
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
- * $Id: Itimer.h,v 1.7 2000/08/25 13:12:07 simonmar Exp $
+ * $Id: Itimer.h,v 1.8 2001/11/21 20:55:10 sof Exp $
*
* (c) The GHC Team 1998-1999
*
*
* (c) The GHC Team 1998-1999
*
/* Total number of ticks since startup */
extern lnat total_ticks;
/* Total number of ticks since startup */
extern lnat total_ticks;
-nat initialize_virtual_timer ( nat ms );
+int initialize_virtual_timer ( nat ms );
int install_vtalrm_handler ( void );
void block_vtalrm_signal ( void );
void unblock_vtalrm_signal ( void );
int install_vtalrm_handler ( void );
void block_vtalrm_signal ( void );
void unblock_vtalrm_signal ( void );