delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/12/23/16:13:08

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
From: Kbwms AT aol DOT com
Message-ID: <25.426e728a.2d1a09d4@aol.com>
Date: Tue, 23 Dec 2003 16:12:52 EST
Subject: Fwd: isnanf et al
To: rich AT phekda DOT gotadsl DOT co DOT uk, djgpp-workers AT delorie DOT com
MIME-Version: 1.0
X-Mailer: 8.0 for Windows sub 6021
Reply-To: djgpp-workers AT delorie DOT com

--part1_25.426e728a.2d1a09d4_boundary
Content-Type: multipart/alternative;
	boundary="part1_25.426e728a.2d1a09d4_alt_boundary"


--part1_25.426e728a.2d1a09d4_alt_boundary
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

In a message dated 12/23/2003 2:17:28 PM Eastern Standard Time,=20
rich AT phekda DOT gotadsl DOT co DOT uk writes:

>=20
> I completely confused by this thread. I think I'm confusing you guys=20
> too. I'll get back to you with an answer sometime in the new year.
>=20
>=20
=20
Some misguided, hapless individual cluttered 24 functions in libm of type=20
float with code that was not needed.  Some of it was incorrect as pointed ou=
t in=20
the forwarded email.

Here is the magic patch that fixes the problem:

--- c:/djgpp.204/src/libm/math/fdlibm.h 1998-10-04 06:48:42.000000000 -0400
+++ c:/djgpp/src/libm/math/fdlibm.h 2003-12-15 11:44:02.000000000 -0500
@@ -22,6 +22,10 @@
 #include <machine/ieeefp.h>
 #endif
=20
+#undef isnanf
+#undef isinff
+#undef finitef
+
 /* CYGNUS LOCAL: Default to XOPEN_MODE.  */
 #define _XOPEN_MODE


If the changes persist into DJGPP v2.04, I will submit correcting patches=20
that restore the code.  The functions to be "reverted" are listed in the=20
forwarded email and below:

ef_hypot.c=A0=A0=A0=A0=A0 wf_hypot.c
ef_scalb.c=A0=A0=A0=A0=A0 wf_j0.c
sf_ldexp.c=A0=A0=A0=A0=A0 wf_j1.c
wf_acos.c=A0=A0=A0=A0=A0=A0 wf_jn.c
wf_acosh.c=A0=A0=A0=A0=A0 wf_lgamma.c
wf_asin.c=A0=A0=A0=A0=A0=A0 wf_log.c
wf_atan2.c=A0=A0=A0=A0=A0 wf_log10.c
wf_atanh.c=A0=A0=A0=A0=A0 wf_pow.c
wf_cosh.c=A0=A0=A0=A0=A0=A0 wf_remainder.c
wf_exp.c=A0=A0=A0=A0=A0=A0=A0 wf_scalb.c
wf_fmod.c=A0=A0=A0=A0=A0=A0 wf_sinh.c
wf_gamma.c=A0=A0=A0=A0=A0 wf_sqrt.c


--part1_25.426e728a.2d1a09d4_alt_boundary
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

<HTML><FONT FACE=3Darial,helvetica><HTML><FONT  SIZE=3D3 PTSIZE=3D12 FAMILY=
=3D"SERIF" FACE=3D"Georgia" LANG=3D"0">In a message dated 12/23/2003 2:17:28=
 PM Eastern Standard Time, rich AT phekda DOT gotadsl DOT co DOT uk writes:<BR>
<BR>
<BLOCKQUOTE TYPE=3DCITE style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT=
: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"></FONT><FONT  COLOR=3D"#000000"=
 BACK=3D"#ffffff" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2 PTSIZE=3D10 F=
AMILY=3D"SANSSERIF" FACE=3D"Arial" LANG=3D"0"><BR>
I completely confused by this thread. I think I'm confusing you guys <BR>
too. I'll get back to you with an answer sometime in the new year.<BR>
<BR>
</BLOCKQUOTE><BR>
</FONT><FONT  COLOR=3D"#000000" BACK=3D"#ffffff" style=3D"BACKGROUND-COLOR:=20=
#ffffff" SIZE=3D3 PTSIZE=3D12 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0">=20=
<BR>
Some misguided, hapless individual cluttered 24 functions in libm of type fl=
oat with code that was not needed.&nbsp; Some of it was incorrect as pointed=
 out in the forwarded email.<BR>
<BR>
Here is the magic patch that fixes the problem:<BR>
</FONT><FONT  COLOR=3D"#000000" BACK=3D"#ffffff" style=3D"BACKGROUND-COLOR:=20=
#ffffff" SIZE=3D2 PTSIZE=3D10 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><=
BR>
--- c:/djgpp.204/src/libm/math/fdlibm.h 1998-10-04 06:48:42.000000000 -0400<=
BR>
+++ c:/djgpp/src/libm/math/fdlibm.h 2003-12-15 11:44:02.000000000 -0500<BR>
@@ -22,6 +22,10 @@<BR>
 #include &lt;machine/ieeefp.h&gt;<BR>
 #endif<BR>
 <BR>
+#undef isnanf<BR>
+#undef isinff<BR>
+#undef finitef<BR>
+<BR>
 /* CYGNUS LOCAL: Default to XOPEN_MODE.&nbsp; */<BR>
 #define _XOPEN_MODE<BR>
</FONT><FONT  COLOR=3D"#000000" BACK=3D"#ffffff" style=3D"BACKGROUND-COLOR:=20=
#ffffff" SIZE=3D3 PTSIZE=3D12 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><=
BR>
<BR>
If the changes persist into DJGPP v2.04, I will submit correcting patches th=
at restore the code.&nbsp; The functions to be "reverted" are listed in the=20=
forwarded email and below:<BR>
<BR>
ef_hypot.c=A0=A0=A0=A0=A0 wf_hypot.c<BR>
ef_scalb.c=A0=A0=A0=A0=A0 wf_j0.c<BR>
sf_ldexp.c=A0=A0=A0=A0=A0 wf_j1.c<BR>
wf_acos.c=A0=A0=A0=A0=A0=A0 wf_jn.c<BR>
wf_acosh.c=A0=A0=A0=A0=A0 wf_lgamma.c<BR>
wf_asin.c=A0=A0=A0=A0=A0=A0 wf_log.c<BR>
wf_atan2.c=A0=A0=A0=A0=A0 wf_log10.c<BR>
wf_atanh.c=A0=A0=A0=A0=A0 wf_pow.c<BR>
wf_cosh.c=A0=A0=A0=A0=A0=A0 wf_remainder.c<BR>
wf_exp.c=A0=A0=A0=A0=A0=A0=A0 wf_scalb.c<BR>
wf_fmod.c=A0=A0=A0=A0=A0=A0 wf_sinh.c<BR>
wf_gamma.c=A0=A0=A0=A0=A0 wf_sqrt.c<BR>
</FONT><FONT  COLOR=3D"#000000" BACK=3D"#ffffff" style=3D"BACKGROUND-COLOR:=20=
#ffffff" SIZE=3D2 PTSIZE=3D10 FAMILY=3D"SANSSERIF" FACE=3D"Arial" LANG=3D"0"=
><BR>
</FONT></HTML>
--part1_25.426e728a.2d1a09d4_alt_boundary--

--part1_25.426e728a.2d1a09d4_boundary
Content-Type: message/rfc822
Content-Disposition: inline

Return-path: <Kbwms AT aol DOT com>
From: Kbwms AT aol DOT com
Full-name: Kbwms
Message-ID: <12b DOT 377ae9cb DOT 2d0f43bc AT aol DOT com>
Date: Mon, 15 Dec 2003 12:05:00 EST
Subject: Re: isnanf et al
To: djgpp-workers AT delorie DOT com
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="part2_25.426e728a.2d0f43bc_boundary"
X-Mailer: 8.0 for Windows sub 6021


--part2_25.426e728a.2d0f43bc_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

In a message dated 12/15/2003 1:17:15 AM Eastern Standard Time, 
eliz AT elta DOT co DOT il writes:

> >From: Kbwms AT aol DOT com
> >Date: Sun, 14 Dec 2003 17:09:37 EST
> >
> >The library at issue at the moment is libm.  Someone has seen fit to modify 
> 
> >the source files, some of them incorrectly, so that they now invoke the is* 
> 
> >macros in ieeefp.h.
> 
> Can you please show an example of a source from libm that was changed
> like that, including the diffs between the previous and the current
> versions?
> 

 
The macros at issue from ../include/ieeefp.h are:

#define isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
                   ((*(long *)&(x) & 0x007fffffL)!=0000000000L))

#define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
                   ((*(long *)&(x) & 0x007fffffL)==0000000000L))

#define finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L))


These macros enable an improper form of aliasing when parameter x is not a
type compatible with one of type long.

In v204 of the source for libm, 24 files were modified to include header file
../include/libc/ieee.h which had been modified.  The files are:

ef_hypot.c      wf_hypot.c
ef_scalb.c      wf_j0.c
sf_ldexp.c      wf_j1.c
wf_acos.c       wf_jn.c
wf_acosh.c      wf_lgamma.c
wf_asin.c       wf_log.c
wf_atan2.c      wf_log10.c
wf_atanh.c      wf_pow.c
wf_cosh.c       wf_remainder.c
wf_exp.c        wf_scalb.c
wf_fmod.c       wf_sinh.c
wf_gamma.c      wf_sqrt.c


The diffs in ieee.h are:

*** ieee.h      Mon Jun 30 16:38:16 2003
--- ieee_old.h  Fri Apr 28 21:01:28 1995
***************
*** 1 ****
- /* Copyright (C) 2003 DJ Delorie, see COPYING.DJ for details */
--- 0 ----
***************
*** 12,16 ****
- #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
-   || !defined(__STRICT_ANSI__)
-
- #endif /* (__STDC_VERSION__ >= 199901L) || !__STRICT_ANSI__ */
-
--- 10 ----
***************
*** 41,59 ****
-
- typedef union
- {
-   double d;
-   double_t dt;
- } _double_union_t;
-
- typedef union
- {
-   long double ld;
-   long_double_t ldt;
- } _longdouble_union_t;
-
- typedef union
- {
-   float f;
-   long  l;
- } _float_long_union;
-
--- 34 ----

The 24 files listed previously were modified to use type _float_long_union.

Here are the diffs for the code in ef_scalb.c:

*** ef_scalb.c  Tue Apr 15 04:39:46 1997
--- c:/djgpp/src/libm/libm204/ef_scalb.c        Sun Jun 29 10:24:18 2003
***************
*** 17 ****
--- 18 ----
+ #include <libc/ieee.h>
***************
*** 38,39 ****
!       if (isnanf(x)||isnanf(fn)) return x*fn;
!       if (!finitef(fn)) {
--- 39,46 ----
!       _float_long_union ux;
!       _float_long_union ufn;
!
!       ux.f = x;
!       ufn.f = fn;
!
!       if (isnanf(ux.l)||isnanf(ufn.l)) return x*fn;
!       if (!finitef(ufn.f)) {

Note that macro isnanf() is invoked with a parameter of type long while
macro finitef() is invoked with a parameter of type float.

The point here is that the source files listed need never have been modified. 
 Since the functions are already defined in math.h, the simple act of 
undefining the macros by placing #undefs in ../src/libm/math/fdlibm.h will do the job 
quite nicely:

*** c:/djgpp.204/src/libm/math/fdlibm.h Sun Oct  4 06:48:42 1998
--- c:/djgpp/src/libm/math/fdlibm.h Mon Dec 15 11:44:02 2003
***************
*** 24 ****
--- 25,28 ----
+ #undef isnanf
+ #undef isinff
+ #undef finitef
+ 

This change has already been checked out.

--part2_25.426e728a.2d0f43bc_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<HTML><FONT FACE=3Darial,helvetica><HTML><FONT  SIZE=3D3 PTSIZE=3D12 FAMILY=
=3D"SERIF" FACE=3D"Georgia" LANG=3D"0">In a message dated 12/15/2003 1:17:15=
 AM Eastern Standard Time, eliz AT elta DOT co DOT il writes:<BR>
<BR>
<BLOCKQUOTE TYPE=3DCITE style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT=
: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"></FONT><FONT  COLOR=3D"#000000"=
 BACK=3D"#ffffff" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2 PTSIZE=3D10 F=
AMILY=3D"SANSSERIF" FACE=3D"Arial" LANG=3D"0">&gt;From: Kbwms AT aol DOT com<BR>
&gt;Date: Sun, 14 Dec 2003 17:09:37 EST<BR>
&gt;<BR>
&gt;The library at issue at the moment is libm.&nbsp; Someone has seen fit t=
o modify <BR>
&gt;the source files, some of them incorrectly, so that they now invoke the=20=
is* <BR>
&gt;macros in ieeefp.h.<BR>
<BR>
Can you please show an example of a source from libm that was changed<BR>
like that, including the diffs between the previous and the current<BR>
versions?<BR>
</BLOCKQUOTE><BR>
</FONT><FONT  COLOR=3D"#000000" BACK=3D"#ffffff" style=3D"BACKGROUND-COLOR:=20=
#ffffff" SIZE=3D3 PTSIZE=3D12 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><=
BR>
 <BR>
The macros at issue from ../include/ieeefp.h are:<BR>
<BR>
</FONT><FONT  COLOR=3D"#000000" BACK=3D"#ffffff" style=3D"BACKGROUND-COLOR:=20=
#ffffff" SIZE=3D2 PTSIZE=3D10 FAMILY=3D"SANSSERIF" FACE=3D"Arial" LANG=3D"0"=
>#define isnanf(x) (((*(long *)&amp;(x) &amp; 0x7f800000L)=3D=3D0x7f800000L)=
 &amp;&amp; \<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((*(long *)&amp;(x) &amp; 0x007fffffL)!=3D0=
000000000L))<BR>
<BR>
#define isinff(x) (((*(long *)&amp;(x) &amp; 0x7f800000L)=3D=3D0x7f800000L)=20=
&amp;&amp; \<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((*(long *)&amp;(x) &amp; 0x007fffffL)=3D=
=3D0000000000L))<BR>
<BR>
#define finitef(x) (((*(long *)&amp;(x) &amp; 0x7f800000L)!=3D0x7f800000L))<=
BR>
</FONT><FONT  COLOR=3D"#000000" BACK=3D"#ffffff" style=3D"BACKGROUND-COLOR:=20=
#ffffff" SIZE=3D3 PTSIZE=3D12 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><=
BR>
<BR>
These macros enable an improper form of aliasing when parameter x is not a<B=
R>
type compatible with one of type long.<BR>
<BR>
In v204 of the source for libm, 24 files were modified to include header fil=
e<BR>
../include/libc/ieee.h which had been modified.&nbsp; The files are:<BR>
<BR>
ef_hypot.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_hypot.c<BR>
ef_scalb.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_j0.c<BR>
sf_ldexp.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_j1.c<BR>
wf_acos.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_jn.c<BR>
wf_acosh.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_lgamma.c<BR>
wf_asin.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_log.c<BR>
wf_atan2.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_log10.c<BR>
wf_atanh.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_pow.c<BR>
wf_cosh.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_remainder.c<BR>
wf_exp.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_scalb.c<BR>
wf_fmod.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_sinh.c<BR>
wf_gamma.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wf_sqrt.c<BR>
<BR>
<BR>
The diffs in ieee.h are:<BR>
<BR>
*** ieee.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Mon Jun 30 16:38:16 2003<BR>
--- ieee_old.h&nbsp; Fri Apr 28 21:01:28 1995<BR>
***************<BR>
*** 1 ****<BR>
- /* Copyright (C) 2003 DJ Delorie, see COPYING.DJ for details */<BR>
--- 0 ----<BR>
***************<BR>
*** 12,16 ****<BR>
- #if (defined(__STDC_VERSION__) &amp;&amp; __STDC_VERSION__ &gt;=3D 199901L=
) \<BR>
-&nbsp;&nbsp; || !defined(__STRICT_ANSI__)<BR>
-<BR>
- #endif /* (__STDC_VERSION__ &gt;=3D 199901L) || !__STRICT_ANSI__ */<BR>
-<BR>
--- 10 ----<BR>
***************<BR>
*** 41,59 ****<BR>
-<BR>
- typedef union<BR>
- {<BR>
-&nbsp;&nbsp; double d;<BR>
-&nbsp;&nbsp; double_t dt;<BR>
- } _double_union_t;<BR>
-<BR>
- typedef union<BR>
- {<BR>
-&nbsp;&nbsp; long double ld;<BR>
-&nbsp;&nbsp; long_double_t ldt;<BR>
- } _longdouble_union_t;<BR>
-<BR>
- typedef union<BR>
- {<BR>
-&nbsp;&nbsp; float f;<BR>
-&nbsp;&nbsp; long&nbsp; l;<BR>
- } _float_long_union;<BR>
-<BR>
--- 34 ----<BR>
<BR>
The 24 files listed previously were modified to use type _float_long_union.<=
BR>
<BR>
Here are the diffs for the code in ef_scalb.c:<BR>
<BR>
*** ef_scalb.c&nbsp; Tue Apr 15 04:39:46 1997<BR>
--- c:/djgpp/src/libm/libm204/ef_scalb.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp; Sun Jun 29 10:24:18 2003<BR>
***************<BR>
*** 17 ****<BR>
--- 18 ----<BR>
+ #include &lt;libc/ieee.h&gt;<BR>
***************<BR>
*** 38,39 ****<BR>
!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (isnanf(x)||isnanf(fn)) return x*fn=
;<BR>
!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!finitef(fn)) {<BR>
--- 39,46 ----<BR>
!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _float_long_union ux;<BR>
!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _float_long_union ufn;<BR>
!<BR>
!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ux.f =3D x;<BR>
!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ufn.f =3D fn;<BR>
!<BR>
!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (isnanf(ux.l)||isnanf(ufn.l)) retur=
n x*fn;<BR>
!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!finitef(ufn.f)) {<BR>
<BR>
Note that macro isnanf() is invoked with a parameter of type long while<BR>
macro finitef() is invoked with a parameter of type float.<BR>
<BR>
The point here is that the source files listed need never have been modified=
.&nbsp; Since the functions are already defined in math.h, the simple act of=
 undefining the macros by placing #undefs in ../src/libm/math/fdlibm.h will=20=
do the job quite nicely:<BR>
<BR>
*** c:/djgpp.204/src/libm/math/fdlibm.h Sun Oct&nbsp; 4 06:48:42 1998<BR>
--- c:/djgpp/src/libm/math/fdlibm.h Mon Dec 15 11:44:02 2003<BR>
***************<BR>
*** 24 ****<BR>
--- 25,28 ----<BR>
+ #undef isnanf<BR>
+ #undef isinff<BR>
+ #undef finitef<BR>
+ <BR>
<BR>
This change has already been checked out.</FONT></HTML>

--part2_25.426e728a.2d0f43bc_boundary--

--part1_25.426e728a.2d1a09d4_boundary--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019