delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/12/15/12:07:05

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
From: Kbwms AT aol DOT com
Message-ID: <12b.377ae9cb.2d0f43bc@aol.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
X-Mailer: 8.0 for Windows sub 6021
Reply-To: djgpp-workers AT delorie DOT com

--part1_12b.377ae9cb.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.

--part1_12b.377ae9cb.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>

--part1_12b.377ae9cb.2d0f43bc_boundary--

- Raw text -


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