Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Nov 1995 08:44:48 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-hackers@freebsd.org, markd@grizzly.com
Subject:   Re: NPX still broken in 2.1.0-951104-SNAP...
Message-ID:  <199511052144.IAA15439@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>It appears (from looking at the code) that the floating point exception
>register is still broken in the latest SNAP.  I bug reported this eons ago
>against 2.0, it generated a bit of discussion and I believe I got a response
>to the bug report saying it was fixed.  This breaks pretty much any program

Scheduled to be fixed.  In 2.2 :-(.

>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.

>This program should not core dump:

>#include <math.h>
>#include <stdio.h>
>main ()
>{
>    printf ("acos (2.0) = %g\n", acos (2.0));
>}

>Please fix this before releasing, its a big pain for us portable
>software maintainers.  This patch fixed it for me:

>*** sys/i386/include/npx.h.ORG	Tue Jan 17 21:51:47 1995
>--- sys/i386/include/npx.h	Sat Jan 21 12:56:44 1995
>***************
>*** 133,139 ****
>  #define	__INITIAL_NPXCW__	__iBCS_NPXCW__
>  #endif
>  #else
>! #define	__INITIAL_NPXCW__	__BDE_NPXCW__
>  #endif
>  
>  #ifdef KERNEL
>--- 133,139 ----
>  #define	__INITIAL_NPXCW__	__iBCS_NPXCW__
>  #endif
>  #else
>! #define	__INITIAL_NPXCW__	__BETTER_BDE_NPXCW__
>  #endif
>  
>  #ifdef KERNEL

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).

Bruce



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