Mail Archives: djgpp-workers/1998/10/01/14:07:36
Here's a patch that makes sure we don't leave the timer tick interrupt
pointing into the void.
*** src/libc/go32/dpmiexcp.c~0 Sun Aug 23 14:23:44 1998
--- src/libc/go32/dpmiexcp.c Tue Sep 29 11:39:14 1998
*************** extern void __djgpp_cbrk_hdlr(void);
*** 39,44 ****
--- 39,45 ----
extern int __djgpp_hw_lock_start, __djgpp_hw_lock_end;
extern __dpmi_paddr __djgpp_old_kbd;
extern unsigned djgpp_exception_stack __asm__("exception_stack");
+ extern __dpmi_paddr __djgpp_old_timer;
static void
itox(int v, int len)
*************** __djgpp_exception_processor(void)
*** 385,390 ****
--- 386,392 ----
static __dpmi_paddr except_ori[EXCEPTION_COUNT];
static __dpmi_paddr kbd_ori;
static __dpmi_paddr npx_ori;
+ static __dpmi_paddr timer_ori;
static __dpmi_raddr cbrk_ori,cbrk_rmcb;
static char cbrk_hooked = 0;
static __dpmi_regs cbrk_regs;
*************** __djgpp_exception_toggle(void)
*** 420,425 ****
--- 422,444 ----
__dpmi_set_real_mode_interrupt_vector(cbrk_vect, &cbrk_rmcb);
cbrk_hooked = 1;
}
+ /* If the timer interrupt is hooked, toggle it as well. This is so
+ programs which use SIGALRM or itimer, and don't unhook the timer before
+ they exit, won't leave the system with timer pointing into the void. */
+ if (__djgpp_old_timer.selector != 0 && __djgpp_old_timer.offset32 != 0)
+ {
+ if (timer_ori.selector == __djgpp_old_timer.selector
+ && timer_ori.offset32 == __djgpp_old_timer.offset32)
+ {
+ __dpmi_get_protected_mode_interrupt_vector(8, &timer_ori);
+ __dpmi_set_protected_mode_interrupt_vector(8, &__djgpp_old_timer);
+ }
+ else
+ {
+ __dpmi_set_protected_mode_interrupt_vector(8, &timer_ori);
+ timer_ori = __djgpp_old_timer;
+ }
+ }
}
#define RSHIFT 1
*************** __djgpp_exception_setup(void)
*** 532,537 ****
--- 551,557 ----
__dpmi_set_protected_mode_interrupt_vector(0x24, &except);
__dpmi_get_protected_mode_interrupt_vector(9, &__djgpp_old_kbd);
+ __dpmi_get_protected_mode_interrupt_vector(8, &timer_ori);
__djgpp_exception_toggle(); /* Set new values & save old values */
/* get original video mode and save */
*** src/docs/kb/wc202.t~0 Sun Jul 26 13:34:04 1998
--- src/docs/kb/wc202.txi Tue Sep 29 11:51:12 1998
***************
*** 447,449 ****
--- 447,461 ----
interrupted or crashed, and reports the run time with millisecond
resolution.
@cindex redir
+
+ The exit code now makes sure the timer interrupt is left pointing to its
+ original handler, even if the program is aborted, or exits without
+ disabling timers. @code{__djgpp_exception_toggle} now toggles the timer
+ interrupt handler as well, if it was hooked by SIGALRM/SIGPROF handler
+ or by @code{setitimer}. Thus, timers, periodic alarms, and profiling
+ will be disabled inside blocks that call @code{__djgpp_exception_toggle}.
+ @findex __djgpp_exception_toggle
+ @findex setitimer
+ @cindex SIGALRM
+ @cindex SIGPROF
+ @cindex profiling
- Raw text -