Mail Archives: djgpp-workers/2000/04/27/09:01:09
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 -