Floating point exceptions.

2000-03-21 Thread David Malone

Floating point exceptions seem to have been turned off by default:

gonzo 13% uname -r
5.0-CURRENT
gonzo 14% cat a.c
double div(double x,double y) { return x/y; }
int main() { double x; x = div(1.0,0.0); printf("%f\n",x); }
gonzo 15% gcc -o a a.c
gonzo 16% ./a
Inf

This seems to produce an SIGFPE on 3.0, which I would have thought
was the correct thing to do:

walton 12% uname -r
3.4-STABLE
walton 13% cat a.c
double div(double x,double y) { return x/y; }
int main() { double x; x = div(1.0,0.0); printf("%f\n",x); }
walton 14% gcc -o a a.c
walton 15% ./a
Floating exception (core dumped)

There was a discussion on one of the list about what to do for
floating point excpetions recently, and I thought people decided
that causing a signal by default was a right thing? I presume this
was caused by the commit below?

David.

cracauer2000/03/10 09:56:33 PST

  Modified files:
sys/i386/include npx.h 
  Log:
  Change the default FPU control word so that exceptions for new
  processes are now masked until set by fpsetmask(3).
  
  Submitted by: bde
  Approved by:  jkh, bde
  
  Revision  ChangesPath
  1.18  +5 -35 src/sys/i386/include/npx.h



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: Floating point exceptions.

2000-03-21 Thread Martin Cracauer

In [EMAIL PROTECTED], David Malone wrote: 
 Floating point exceptions seem to have been turned off by default:
[...]
 There was a discussion on one of the list about what to do for
 floating point excpetions recently, and I thought people decided
 that causing a signal by default was a right thing?

The outcome was that applications that care must set the control word
themself and that we go the way of least resistance for the rest.

Martin
-- 
%
Martin Cracauer [EMAIL PROTECTED] http://www.cons.org/cracauer/
  Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: Floating point exceptions.

2000-03-21 Thread David Malone

  There was a discussion on one of the list about what to do for
  floating point excpetions recently, and I thought people decided
  that causing a signal by default was a right thing?
 
 The outcome was that applications that care must set the control word
 themself and that we go the way of least resistance for the rest.

OK - I just did a quick scout around. Digital Unix gives a SIGFPE;
Solaris, AIX and Redhat print some captalisation of "Inf"; HP/UX
prints "++.00" ;-)

Is there a way of setting the control word which is in any sense
portable? Most machines I've looked at seem to have no documented
way of setting what exceptions should be masked, and each one that
does has a different set of calls.

David.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: Floating point exceptions.

2000-03-21 Thread Martin Cracauer

In [EMAIL PROTECTED], David Malone wrote: 
   There was a discussion on one of the list about what to do for
   floating point excpetions recently, and I thought people decided
   that causing a signal by default was a right thing?
  
  The outcome was that applications that care must set the control word
  themself and that we go the way of least resistance for the rest.
 
 OK - I just did a quick scout around. Digital Unix gives a SIGFPE;
 Solaris, AIX and Redhat print some captalisation of "Inf"; HP/UX
 prints "++.00" ;-)
 
 Is there a way of setting the control word which is in any sense
 portable? 

It is an i386 assembler instruction. Obviously, operating system
vendors thought it's not their business, but the compiler's.
Unfortunately, gcc doesn't care (although most other native compilers
like SRC m3, CMUCL, SML/NJ do).

FreeBSD's fpsetmask(3) stuff is simple inline assembler that I
personally used in Linux, it should be relativly easy to carry it
around with your application on i386 machines.

Martin
-- 
%
Martin Cracauer [EMAIL PROTECTED] http://www.cons.org/cracauer/
  Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: Floating point exceptions.

2000-03-21 Thread Brad Knowles

At 10:28 AM +0100 2000/3/21, Martin Cracauer wrote:

  It is an i386 assembler instruction. Obviously, operating system
  vendors thought it's not their business, but the compiler's.
  Unfortunately, gcc doesn't care (although most other native compilers
  like SRC m3, CMUCL, SML/NJ do).

Note that I have recently heard some complaints about Perl in 
this respect -- Perl considers it to be a hardware issue, and code 
that depends on a SIGFPE will not necessarily function the same under 
the same version of Perl, running on different OSes.

--
   These are my opinions -- not to be taken as official Skynet policy
==
Brad Knowles, [EMAIL PROTECTED]|| Belgacom Skynet SA/NV
Systems Architect, Mail/News/FTP/Proxy Admin || Rue Colonel Bourg, 124
Phone/Fax: +32-2-706.13.11/12.49 || B-1140 Brussels
http://www.skynet.be || Belgium


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: Floating point exceptions.

2000-03-21 Thread Bruce Evans

On Tue, 21 Mar 2000, David Malone wrote:

 Is there a way of setting the control word which is in any sense
 portable? Most machines I've looked at seem to have no documented
 way of setting what exceptions should be masked, and each one that
 does has a different set of calls.

No.  C99 provides an (optional) portable way of setting the rounding
mode (fesetround() corresponds to fpsetround()), but doesn't provide
a portable way to set the precision or exception masks.  It only
provides fesetenv(), and the only portable args for fesetenv() are
FE_DFL_ENV (which gives the default environment) and a pointer to
a result filled in by a previous call to fegetenv().

Bruce



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: Floating point exceptions.

2000-03-21 Thread Matthew Hunt

On Tue, Mar 21, 2000 at 10:28:43AM +0100, Martin Cracauer wrote:

 FreeBSD's fpsetmask(3) stuff is simple inline assembler that I
 personally used in Linux, it should be relativly easy to carry it
 around with your application on i386 machines.

fpsetmask(3) also exists on Solaris.

-- 
Matthew Hunt [EMAIL PROTECTED] * Stay close to the Vorlon.
http://www.pobox.com/~mph/   *


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: Floating point exceptions.

2000-03-21 Thread Garrett Wollman

On Tue, 21 Mar 2000 17:11:30 -0800, Matthew Hunt [EMAIL PROTECTED] said:

 fpsetmask(3) also exists on Solaris.

fpsetmask(3) was copied from System V.

-GAWollman

--
Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
[EMAIL PROTECTED]  | O Siem / The fires of freedom 
Opinions not those of| Dance in the burning flame
MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message