Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Nov 1995 18:24:20 -0800
From:      Mark Diekhans <markd@grizzly.com>
To:        bde@zeta.org.au
Cc:        julian@ref.tfs.com, freebsd-hackers@freebsd.org, markd@grizzly.com, jkh@time.cdrom.com
Subject:   Re: NPX still broken in 2.1.0-951104-SNAP...
Message-ID:  <199511060224.SAA06030@Grizzly.COM>
In-Reply-To: <199511052310.KAA18574@godzilla.zeta.org.au> (message from Bruce Evans on Mon, 6 Nov 1995 10:10:54 %2B1100)

next in thread | previous in thread | raw e-mail | index | archive | help

Hey Bruce,

<responses to various piece of mail from bde included>

>>but is it MORE broken than it is now to do this?
>>surely such a simple change that might help some people
>>is worth puting in now?
>
>I think the current behaviour (trapping) is more useful for
>most programs.  Programs that can handle IEEE arithmetic
>should do something special to check and get it at confiuration
>time since it is not guaranteed.

Its incompatible with every Unix system I have access to.  See enclosed table.
No system core dumps!  I don't have any standards handy, but SCO, which
is X/Open, ANSI, and POSIX compatible sets errno and returns NaN.

Most portable software checks errno, although the best approach is to check
both errno and NaN.

>The change similar to mapping page 0 and putting 0's there so
>that strcmp("foo", NULL) works right.  
>Surely such a simple change that might help some people
>is worth puting in now? ;-)

I don't see this as being analogous. strcmp to NULL is an undefined, invalid
operation.  IMHO calling acos with an out of range operand is an error case
akin to calling open with an invalid file name.  The big difference between
this and strcmp is that you can read a man page and find out the expected
error respones.
Sure, it would help some people to core dump if you couldn't open a file.  It
sure would be pain in the rear for us portable software writers that have to
deal with this kind of incompatibility.  Call some non-standard, FreeBSD only
function (fpsetmask) to make the libraries behave as they do on other systems.


>>that wants to get a status back from the floating point math functions instead
>>of a core dump.  Tcl is most notable, but it breaks several other packages as
>>well.
>
>The tcl port has a patch to set the exception mask to ~0.

The ports are very handy, but they are no substitute for compatibility.
For instance, the ports don't have the lastest Tcl alpha.  Elk is in
there, but it doesn't have a patch to add the fpsetmask call.  It just
happens to not have as extensive a test suite as Tcl, but this breaks it.


>This still fails for more-portable software that sets errno to 0 before
>calling every math function and checks for errno being ERANGE or EDOM
>after the call (this is the only error reporting mechanism guaranteed
>in ANSI C).  You can fix this by changing CFLAGS in libc/msun/Makefile
>to the POSIX/ANSI setting recommended there (-D_POSIX_MODE), but then
>acos(2.0) will return a stupid value (0 instead of NaN).

Yes, I can change my system to work like others (I already have), its
the problem of writing portable code for others that I am worried about.

It seems pretty straight forward to modify k_standard.c to return NaN
in POSIX_MODE.  Making the modified POSIX mode the default, and changing the
default FPU exception mask, would make the vast majority of the software out
there happy.

Just another PD software writer trying to help make FreeBSD a good target
to port to (unlike Linux).

Mark

----------------------------------------------
SCO 3.2v5:
acos (2.0) = nan, errno = 33
----------------------------------------------
BSDI 1.1:
acos (2.0) = NaN, errno = 0
----------------------------------------------
HP-UX A.09.01:
acos: DOMAIN error
acos (2.0) = 0, errno = 33
----------------------------------------------
IRIX 5.3
acos (2.0) = nan0x7fffffff, errno = 33
----------------------------------------------
OSF/1 V3.0
acos (2.0) = 0, errno = 33
----------------------------------------------
ULTRIX 4.3 
acos (2.0) = NaN, errno = 33
----------------------------------------------
SunOS olden 4.1.3_U1 1 sun4c
acos: DOMAIN error
acos (2.0) = NaN, errno = 33
----------------------------------------------




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511060224.SAA06030>