delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/04/27/09:01:09

Message-Id: <200004271332.PAA01783@cerbere.u-strasbg.fr>
X-Sender: muller AT ics DOT u-strasbg DOT fr
X-Mailer: QUALCOMM Windows Eudora Pro Version 4.0.2
Date: Thu, 27 Apr 2000 15:18:21 +0200
To: djgpp-workers AT delorie DOT com
From: Pierre Muller <muller AT cerbere DOT u-strasbg DOT fr>
Subject: interrupt 0x75 limitation in Win95 ?
References: <3907023C DOT 30855 DOT 3E86E3 AT localhost>
Mime-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

   When I run a simple code that creates a FPU exception by a 

   j:=j/e;

  where j and e are double and e has 0.0 value;

  I get a nice FPU exception,
but if I redirect the output of this code using DJGPP redir executable 
it does not work anymore :(

  The exception seems to be sent to the redir executable rather than to the
correct executable !

  Is this a know bug of Win95 (it works under raw Dos !) ??
  Is this bug common to all Windows OS ?
  Is it specific to certain CPU ?
(I am using a Pentium 200MHz without MMX )
  I think some  later processor directly generate an exception rather
that an interrupt, am I right here ?

 Trying to debug this a little I found several 
strange things ! The value of int 0x75 is apparently reset
to the original value before dpmi_exception_toggle is called at exit !

Note to Eli : this is the FPU for which I also get those spurious
int 0x75 inside the signal handler in Free Pascal code
even inside the signal handler :(
(but not in C code if it is inside the signal handler,
I still did not understand why the DJGPP code and the FP code
behave differenetly :( )

  Here is a sample code that shows the bug

compile it 
  gcc -o  divexcp  divexcp.c

run it directly 
then
  redir -x divexcp 


>>> file divexcp.c
#include <signal.h>
#include <setjmp.h>
#include <float.h>
#include <sys/exceptn.h>

static jmp_buf t;
static int fpustate;
static int excep;

void
  fpesig (i)
  {
    fpustate=_clear87();
    if (__djgpp_exception_state)
      excep= __djgpp_exception_state->__signum;
    else
      excep = 0;
    longjmp(t,1);
  }

int
  main (int argc)
  {
   int res = 1;
   _control87 (0x1332, 0xffff);
   signal(SIGFPE,fpesig);

   if (setjmp(t)==0)
     {
       double j,e;
       int k;
       k=100;
       j=0.0;
       e=k/j;
       printf("No exception \r\n");
       res = 2;
     }
   else
     {
      printf("FPU exception 0x%x caught\r\n",excep);
      printf("FPU state is 0x%x\r\n",fpustate);
      res = 0;
     }
   return res;
 }


Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller AT ics DOT u-strasbg DOT fr
Phone : (33)-3-88-41-40-07  Fax : (33)-3-88-41-40-99

- Raw text -


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