From e79a10229670461d3d0b2282de13e4679fb09db3 Mon Sep 17 00:00:00 2001 From: "Guillermo J. Rozas" Date: Mon, 13 Sep 1993 18:41:24 +0000 Subject: [PATCH] offsets are not unsigned. Make ntwntlib.c and ntw16lib.c timer interrupt handlers virtually identical. --- v7/src/microcode/ntutl/scheme16.c | 28 ++++---- v7/src/microcode/ntutl/scheme31.c | 18 ++--- v7/src/microcode/ntutl/scheme32.c | 111 +++++++++++++++--------------- 3 files changed, 79 insertions(+), 78 deletions(-) diff --git a/v7/src/microcode/ntutl/scheme16.c b/v7/src/microcode/ntutl/scheme16.c index b37d422aa..16b229203 100644 --- a/v7/src/microcode/ntutl/scheme16.c +++ b/v7/src/microcode/ntutl/scheme16.c @@ -1,6 +1,6 @@ /* -*-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 @@ -312,11 +312,11 @@ static struct ntw16lib_itimer_s 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; @@ -326,31 +326,31 @@ static struct ntw16lib_itimer_s 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; } diff --git a/v7/src/microcode/ntutl/scheme31.c b/v7/src/microcode/ntutl/scheme31.c index 2ef62daec..4417a4b44 100644 --- a/v7/src/microcode/ntutl/scheme31.c +++ b/v7/src/microcode/ntutl/scheme31.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: scheme31.c,v 1.4 1993/09/04 07:00:37 gjr Exp $ +$Id: scheme31.c,v 1.5 1993/09/13 18:41:24 gjr Exp $ Copyright (c) 1993 Massachusetts Institute of Technology @@ -169,11 +169,11 @@ win32_unlock_memory_area (LPVOID area, unsigned long size) UINT win32_install_async_timer (void ** state_ptr, unsigned long * 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, unsigned long message, HWND window) { @@ -182,11 +182,11 @@ win32_install_async_timer (void ** state_ptr, UINT result; param.base = ((SCM_ULPTR) base); - param.memtop_off = ((SCM_ULONG) memtop_off); - param.int_code_off = ((SCM_ULONG) int_code_off); - param.int_mask_off = ((SCM_ULONG) int_mask_off); + param.memtop_off = ((SCM_LONG) memtop_off); + param.int_code_off = ((SCM_LONG) int_code_off); + param.int_mask_off = ((SCM_LONG) int_mask_off); param.bit_mask = ((SCM_ULONG) bit_mask); - param.ctr_off = ((SCM_ULONG) ctr_off); + param.ctr_off = ((SCM_LONG) ctr_off); param.message = ((SCM_ULONG) message); param.window = ((SCM_ULONG) window); diff --git a/v7/src/microcode/ntutl/scheme32.c b/v7/src/microcode/ntutl/scheme32.c index 3cb33c1ab..3111e1e75 100644 --- a/v7/src/microcode/ntutl/scheme32.c +++ b/v7/src/microcode/ntutl/scheme32.c @@ -1,6 +1,6 @@ /* -*-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 @@ -85,12 +85,12 @@ win32_unlock_memory_area (void * area, unsigned long size) 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; }; @@ -98,28 +98,29 @@ struct win32_timer_closure_s 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; } @@ -127,30 +128,30 @@ win32_nt_timer_tick (UINT wID, UINT wMsg, DWORD dwUser, DWORD dw1, DWORD dw2) 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; } 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) { @@ -158,7 +159,7 @@ win32_install_async_timer (void ** state_ptr, 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); @@ -167,46 +168,46 @@ win32_install_async_timer (void ** state_ptr, 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); } -- 2.25.1