/* -*-C-*-
-$Id: scheme16.c,v 1.6 1993/09/08 04:46:00 gjr Exp $
+$Id: scheme16.c,v 1.7 1993/09/13 18:39:57 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
struct ntw16lib_itimer_s FAR * next;
unsigned long index;
unsigned long FAR * base;
- unsigned long memtop_off;
- unsigned long int_code_off;
- unsigned long int_mask_off;
+ long memtop_off;
+ long int_code_off;
+ long int_mask_off;
unsigned long bit_mask;
- unsigned long ctr_off;
+ long ctr_off;
UINT message;
HWND window;
UINT selector;
void FAR _export
scheme_asynctimer (void)
{
- struct ntw16lib_itimer_s FAR * scm_timer = async_timers;
+ struct ntw16lib_itimer_s FAR * scm_timer;
- while (scm_timer != ((struct ntw16lib_itimer_s FAR *) NULL))
+ for (scm_timer = async_timers;
+ scm_timer != ((struct ntw16lib_itimer_s FAR *) NULL);
+ scm_timer = scm_timer->next)
{
scm_timer->base[scm_timer->int_code_off] |= scm_timer->bit_mask;
- if ((scm_timer->base[scm_timer->int_mask_off]
- & scm_timer->bit_mask)
- != 0)
+ if ((scm_timer->base[scm_timer->int_mask_off] & scm_timer->bit_mask)
+ != 0L)
scm_timer->base[scm_timer->memtop_off] = ((unsigned long) -1L);
scm_timer->base[scm_timer->ctr_off] += 1L;
if ((scm_timer->base[scm_timer->ctr_off]
> scm_timer->base[scm_timer->ctr_off + 1])
- && (scm_timer->base[scm_timer->ctr_off + 1] != 0))
+ && (scm_timer->base[scm_timer->ctr_off + 1] != 0L))
{
- if (scm_timer->base[scm_timer->ctr_off + 2] == 0)
+ if (scm_timer->base[scm_timer->ctr_off + 2] == 0L)
{
PostMessage (scm_timer->window,
scm_timer->message,
((WPARAM) 0),
((LPARAM) 0));
- scm_timer->base[scm_timer->ctr_off + 2] = 1;
+ scm_timer->base[scm_timer->ctr_off + 2] = 1L;
}
scm_timer->base[scm_timer->ctr_off] = 0L;
}
- scm_timer = scm_timer->next;
}
return;
}
/* -*-C-*-
-$Id: scheme32.c,v 1.6 1993/09/08 04:45:26 gjr Exp $
+$Id: scheme32.c,v 1.7 1993/09/13 18:40:22 gjr Exp $
Copyright (c) 1993 Massachusetts Institute of Technology
struct win32_timer_closure_s
{
UINT timer_id;
- unsigned long * block;
- unsigned long memtop_off;
- unsigned long int_code_off;
- unsigned long int_mask_off;
+ unsigned long * base;
+ long memtop_off;
+ long int_code_off;
+ long int_mask_off;
unsigned long bit_mask;
- unsigned long ctr_off;
+ long ctr_off;
unsigned long message;
HWND window;
};
static void _stdcall
win32_nt_timer_tick (UINT wID, UINT wMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
- struct win32_timer_closure_s * timer_closure =
+ struct win32_timer_closure_s * scm_timer =
((struct win32_timer_closure_s *) dwUser);
- timer_closure->block[timer_closure->int_code_off] |= timer_closure->bit_mask;
- if ((timer_closure->block[timer_closure->int_mask_off]
- & timer_closure->bit_mask)
- != 0)
- timer_closure->block[timer_closure->memtop_off] = ((unsigned long) -1);
- timer_closure->block[timer_closure->ctr_off] += 1;
- if ((timer_closure->block[timer_closure->ctr_off]
- > timer_closure->block[timer_closure->ctr_off + 1])
- && (timer_closure->block[timer_closure->ctr_off + 1] != 0))
{
- if (timer_closure->block[timer_closure->ctr_off + 2] == 0)
+ scm_timer->base[scm_timer->int_code_off] |= scm_timer->bit_mask;
+ if ((scm_timer->base[scm_timer->int_mask_off] & scm_timer->bit_mask)
+ != 0L)
+ scm_timer->base[scm_timer->memtop_off] = ((unsigned long) -1L);
+ scm_timer->base[scm_timer->ctr_off] += 1L;
+ if ((scm_timer->base[scm_timer->ctr_off]
+ > scm_timer->base[scm_timer->ctr_off + 1])
+ && (scm_timer->base[scm_timer->ctr_off + 1] != 0L))
{
- PostMessage (timer_closure->window,
- timer_closure->message,
- ((WPARAM) 0),
- ((LPARAM) 0));
- timer_closure->block[timer_closure->ctr_off + 2] = 1;
+ if (scm_timer->base[scm_timer->ctr_off + 2] == 0L)
+ {
+ PostMessage (scm_timer->window,
+ scm_timer->message,
+ ((WPARAM) 0),
+ ((LPARAM) 0));
+ scm_timer->base[scm_timer->ctr_off + 2] = 1L;
+ }
+ scm_timer->base[scm_timer->ctr_off] = 0L;
}
- timer_closure->block[timer_closure->ctr_off] = 0;
}
return;
}
void
win32_flush_async_timer (void * state)
{
- struct win32_timer_closure_s * timer_closure
+ struct win32_timer_closure_s * scm_timer
= ((struct win32_timer_closure_s *) state);
- if (timer_closure == ((struct win32_timer_closure_s *) NULL))
+ if (scm_timer == ((struct win32_timer_closure_s *) NULL))
return;
- if (timer_closure->timer_id != 0)
- (void) timeKillEvent (timer_closure->timer_id);
+ if (scm_timer->timer_id != 0)
+ (void) timeKillEvent (scm_timer->timer_id);
(void) VirtualUnlock (((void *) win32_nt_timer_tick),
(((char *) win32_flush_async_timer)
- ((char *) win32_nt_timer_tick)));
- (void) VirtualUnlock (timer_closure, (sizeof (struct win32_timer_closure_s)));
- (void) free ((char *) timer_closure);
+ (void) VirtualUnlock (scm_timer, (sizeof (struct win32_timer_closure_s)));
+ (void) free ((char *) scm_timer);
return;
}
\f
UINT
win32_install_async_timer (void ** state_ptr,
- unsigned long * block,
- unsigned long memtop_off,
- unsigned long int_code_off,
- unsigned long int_mask_off,
+ unsigned long * base,
+ long memtop_off,
+ long int_code_off,
+ long int_mask_off,
unsigned long bit_mask,
- unsigned long ctr_off,
+ long ctr_off,
unsigned long message,
HWND window)
{
UINT wTimerRes;
UINT msInterval = 50;
UINT msTargetResolution = 50;
- struct win32_timer_closure_s * timer_closure;
+ struct win32_timer_closure_s * scm_timer;
if ((timeGetDevCaps (&tc, sizeof (TIMECAPS))) != TIMERR_NOERROR)
return (WIN32_ASYNC_TIMER_NONE);
if ((timeBeginPeriod (wTimerRes)) == TIMERR_NOCANDO)
return (WIN32_ASYNC_TIMER_RESOLUTION);
- timer_closure = ((struct win32_timer_closure_s *)
- (malloc (sizeof (struct win32_timer_closure_s))));
+ scm_timer = ((struct win32_timer_closure_s *)
+ (malloc (sizeof (struct win32_timer_closure_s))));
- if (timer_closure == ((struct win32_timer_closure_s *) NULL))
+ if (scm_timer == ((struct win32_timer_closure_s *) NULL))
return (WIN32_ASYNC_TIMER_NOMEM);
- timer_closure->timer_id = 0;
- timer_closure->block = block;
- timer_closure->memtop_off = memtop_off;
- timer_closure->int_code_off = int_code_off;
- timer_closure->int_mask_off = int_mask_off;
- timer_closure->bit_mask = bit_mask;
- timer_closure->ctr_off = ctr_off;
- timer_closure->message = message;
- timer_closure->window = window;
-
- if ((! (VirtualLock (((void *) timer_closure),
+ scm_timer->timer_id = 0;
+ scm_timer->base = base;
+ scm_timer->memtop_off = memtop_off;
+ scm_timer->int_code_off = int_code_off;
+ scm_timer->int_mask_off = int_mask_off;
+ scm_timer->bit_mask = bit_mask;
+ scm_timer->ctr_off = ctr_off;
+ scm_timer->message = message;
+ scm_timer->window = window;
+
+ if ((! (VirtualLock (((void *) scm_timer),
(sizeof (struct win32_timer_closure_s)))))
|| (! (VirtualLock (((void *) win32_nt_timer_tick),
(((char *) win32_flush_async_timer)
- ((char *) win32_nt_timer_tick))))))
{
- win32_flush_async_timer ((void *) timer_closure);
+ win32_flush_async_timer ((void *) scm_timer);
return (WIN32_ASYNC_TIMER_NOLOCK);
}
- timer_closure->timer_id
+ scm_timer->timer_id
= (timeSetEvent (msInterval,
wTimerRes,
((LPTIMECALLBACK) win32_nt_timer_tick),
- ((DWORD) timer_closure),
+ ((DWORD) scm_timer),
TIME_PERIODIC));
- if (timer_closure->timer_id == 0)
+ if (scm_timer->timer_id == 0)
{
- win32_flush_async_timer ((void *) timer_closure);
+ win32_flush_async_timer ((void *) scm_timer);
return (WIN32_ASYNC_TIMER_EXHAUSTED);
}
- * state_ptr = ((void *) timer_closure);
+ * state_ptr = ((void *) scm_timer);
return (WIN32_ASYNC_TIMER_OK);
}
\f