Re: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)

2006-03-16 Thread Jonas Maebe


On 16 mrt 2006, at 03:22, Jose Manuel wrote:


Math.SetExceptionMask([exDenormalized,exInvalidOp,exOverflow,e
xPrecision,exUnderflow,exZeroDivide]);


I do agree it's much polite and cross platform, but doesn't seem to  
work in Windows XP Pro (only tested in WinXP Pro SP2) with GL 3.2  
and FPC 2.0.2 (I've looked everywhere down my PC for a version  
number, but not found :-), I guess it oughtta be 4.1 but I can't  
stand for it). Anyway using Set8087CW (which is indeed CPU  
dependant) does work under my equipment, SetExceptionMask doesn't.


SetExceptionMask calls Set8087CW on x86, so if it doesn't work it's  
because you either use it wrongly, or because it translates its  
parameters wrongly to the input Set8087CW expects.



Jonas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


RE: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)

2006-03-16 Thread Jose Manuel


  Math.SetExceptionMask([exDenormalized,exInvalidOp,exOverflow,e
  xPrecision,exUnderflow,exZeroDivide]);

[...]

  stand for it). Anyway using Set8087CW (which is indeed CPU  
  dependant) does work under my equipment, SetExceptionMask doesn't.
 
 SetExceptionMask calls Set8087CW on x86, so if it doesn't work it's  
 because you either use it wrongly, or because it translates its  
 parameters wrongly to the input Set8087CW expects.

Maybe both :-)
I just was calling SetExceptionMask([exZeroDivide]), without qualifying.
OK, thanks. I'll check it, and if I find anything odd in parameter translating 
I will tell.
Anyway, don't pay me too much attention, I gotta review it all this weekend, 
but AFAICR I think I was using the DOS version under Windows XP (not a proper 
way of doing things ;-(). Sorry for the incoveniences and the loss of time. 
Anyhow I'll check it up.

Thanx,
JMR

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)

2006-03-15 Thread Den Jean
On Wednesday 15 March 2006 01:55 am, Peter Vreman wrote:
  Hello,
 
  Is there a better way to disable fpu exception other then linking to
  libc and calling fedisableexcept ???

 Set8087CW() in system unit
 SetExceptionMask() in unit math

It was for MacOsX we needed to get rid of libc,
I guess Set8087CW($133F) is not CPU independant (PowerPC,x86_64),
so I will use
Math.SetExceptionMask([exDenormalized,exInvalidOp,exOverflow,exPrecision,exUnderflow,exZeroDivide]);

I hope MacOsX is happier now (don't have one, so don't know)

kind regards,

Den Jean





___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


RE: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)

2006-03-15 Thread Jose Manuel

  Set8087CW() in system unit
  SetExceptionMask() in unit math
 
 It was for MacOsX we needed to get rid of libc,
 I guess Set8087CW($133F) is not CPU independant (PowerPC,x86_64),

AFAIK, x86_32 will do too!!

 so I will use
 Math.SetExceptionMask([exDenormalized,exInvalidOp,exOverflow,e
 xPrecision,exUnderflow,exZeroDivide]);

I do agree it's much polite and cross platform, but doesn't seem to work in 
Windows XP Pro (only tested in WinXP Pro SP2) with GL 3.2 and FPC 2.0.2 (I've 
looked everywhere down my PC for a version number, but not found :-), I guess 
it oughtta be 4.1 but I can't stand for it). Anyway using Set8087CW (which is 
indeed CPU dependant) does work under my equipment, SetExceptionMask doesn't.

 
 I hope MacOsX is happier now (don't have one, so don't know)

Just to make it know (as a primarily Win NT user). I really don't know whether 
it is as it should be or it should be fixed :-?. A plain Win user as me 
normally use syscalls to the API, but I'm afraid it's comprimising 
compatability issues. Masters will tell, I hope :-)
 
 kind regards,
 
Regards,
JMR

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)

2006-03-14 Thread Felipe Monteiro de Carvalho
Hello,

Is there a better way to disable fpu exception other then linking to
libc and calling fedisableexcept ???

thanks a lot,
--
Felipe Monteiro de Carvalho
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)

2006-03-11 Thread Michalis Kamburelis

Den Jean wrote:

Hi,

I have a strange problem. My Qt4 demo program worked 
fine with FPC 2.0.0, but crashes (div by zero) with FPC 2.0.2.

Debugging shows that indeed a div by zero is done within
the Qt4 lib. However with FPC 2.0.0 or using C++ code the library
isn't bothered with the div by zero. When I use FPC 2.0.2 however
it is.



Maybe it was FPC 2.0.0 bug (that was fixed in the meantime) that caused 
this SIGFPE inside qt to be ignored ? AFAIK it was always the intention 
of FPC that if used library causes a signal like SIGFPE, this signal 
*will not be ignored* and will cause our program to fail with some 
exception.


Maybe you can workaround this with Set8087CW, just like it has to be 
workarounded for OpenGL under Windows (see 
[http://www.freepascal.org/bugs/showrec.php3?ID=3955]). Just add 
Set8087CW($133F); at the beginning of your program (or even right 
inside qt unit initialization) and see if it helps.


(Note that I'm writing this without any knowledge of qt or your testcase 
--- I just thought that it may be helpful, sorry if it's not relevant :) ).


Michalis
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)

2006-03-09 Thread Den Jean
On Wednesday 08 March 2006 10:12 pm, Michalis Kamburelis wrote:
 Maybe you can workaround this with Set8087CW, just like it has to be

see my previous mail
 So I now use fedisableexcept(FE_ALL_EXCEPT);
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)

2006-03-08 Thread Michalis Kamburelis
(Second send, it seems that mails from my old email address do not reach 
fpc lists)


Den Jean wrote:

Hi,

I have a strange problem. My Qt4 demo program worked 
fine with FPC 2.0.0, but crashes (div by zero) with FPC 2.0.2.

Debugging shows that indeed a div by zero is done within
the Qt4 lib. However with FPC 2.0.0 or using C++ code the library
isn't bothered with the div by zero. When I use FPC 2.0.2 however
it is.



Maybe it was FPC 2.0.0 bug (that was fixed in the meantime) that caused
this SIGFPE inside qt to be ignored ? AFAIK it was always the intention
of FPC that if used library causes a signal like SIGFPE, this signal
*will not be ignored* and will cause our program to fail with some
exception.

Maybe you can workaround this with Set8087CW, just like it has to be
workarounded for OpenGL under Windows (see
[http://www.freepascal.org/bugs/showrec.php3?ID=3955]). Just add
Set8087CW($133F); at the beginning of your program (or even right
inside qt unit initialization) and see if it helps.

(Note that I'm writing this without any knowledge of qt or your testcase
--- I just thought that it may be helpful, sorry if it's not relevant :) ).

Michalis
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)

2006-03-07 Thread Den Jean
On Tuesday 07 March 2006 02:45 am, Peter Vreman wrote:
  Anyone any idea?

 In 2.0.0 the fpu exceptions are disabled if linking to C. In 2.0.2 this is
 fixed.

for man G++  it is not the default, I could not find Qt makefile
to disable them, so I was a bit perplex. 
(also had integer divisions in mind, quite a difference)

I notice now that even the smallest C++ program has FPE disabled
$ cat test.cpp
#include stdio.h
int main() { printf(FPE test:%f\n,142.0/0.0); }
$ ./a.out
FPE test:inf

So I now use fedisableexcept(FE_ALL_EXCEPT); 
in the initialization section of qt4.pas

thx

Den Jean





___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] FPC 2.0.0 vs FPC 2.0.2 (div by zero)

2006-03-06 Thread Peter Vreman
 Hi,

 I have a strange problem. My Qt4 demo program worked
 fine with FPC 2.0.0, but crashes (div by zero) with FPC 2.0.2.
 Debugging shows that indeed a div by zero is done within
 the Qt4 lib. However with FPC 2.0.0 or using C++ code the library
 isn't bothered with the div by zero. When I use FPC 2.0.2 however
 it is.

 I added some writelns euh printfs in the Qt lib:
  if (p1.x() == p2.x()) printf(Before DIV by Zero: p1.x:%f p2.x:
 %f\n,p1.x(),p2.x());
 edge.m = (p1.y() - p2.y()) / (p1.x() - p2.x()); // this causes the div by
 zero
 if (p1.x() == p2.x()) printf(After DIV by Zero: p1.x:%f p2.x:
 %f\n,p1.x(),p2.x());

 with FPC 2.0.2 I get

 Before DIV by Zero: p1.x:196.50 p2.x:196.50
 An unhandled exception occurred at $405CB772 :
 EDivByZero : Division by zero
   $405CB772
 etc

 with FPC 2.0.0 or the original C++ demo program I get:
 Before DIV by Zero: p1.x:196.50 p2.x:196.50
 After DIV by Zero: p1.x:196.50 p2.x:196.50
 Before DIV by Zero: p1.x:187.50 p2.x:187.50
 After DIV by Zero: p1.x:187.50 p2.x:187.50
 Before DIV by Zero: p1.x:100.00 p2.x:100.00
 After DIV by Zero: p1.x:100.00 p2.x:100.00
 and so on, never a crash (but why :-)

 Anyone any idea?

In 2.0.0 the fpu exceptions are disabled if linking to C. In 2.0.2 this is
fixed.



___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel