www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/05/06/05:37:20

Date: Thu, 6 May 1999 12:34:58 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp-workers AT delorie DOT com
cc: Charles Sandmann <sandmann AT clio DOT rice DOT edu>
Subject: _clear87 at exit
Message-ID: <Pine.SUN.3.91.990506123007.11958C-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

You might remember the problem with a program that crashes due to SIGFPE 
on Windows: the next program you run crashes immediately at startup.  

I have found that adding a call to `_clear87' before exiting prevents 
this from happening, at least in Windows 95 and in those cases I tested.

Are there any downsides to calling `_clear87' during the exit code in 
general and after an FP exception in particular?  If not, I think we 
should check in this change.  The modified version of `_exit' (from 
dpmiexcp.c) is attached below, for your reference, with the addition of 
the call to `_clear87' as the first thing it does.

Thanks in advance for any feedback.


void __attribute__((noreturn))
_exit(int status)
{
  _clear87 ();
  /* We need to restore hardware interrupt handlers even if somebody calls
     `_exit' directly, or else we crash the machine in nested programs.
     We only toggle the handlers if the original keyboard handler is intact
     (otherwise, they might have already toggled them).  */
  if (__djgpp_old_kbd.offset32 == kbd_ori.offset32
      && __djgpp_old_kbd.selector == kbd_ori.selector)
    __djgpp_exception_toggle ();
  __exit (status);
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019