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 Content-Type: multipart/alternative; boundary="part1_12b.377ae9cb.2d0f43bc_boundary" 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 *************** *** 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 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 t= o modify
>the source files, some of them incorrectly, so that they now invoke the=20= 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?

<= BR>
The macros at issue from ../include/ieeefp.h are:

#define isnanf(x) (((*(long *)&(x) & 0x7f800000L)=3D=3D0x7f800000L)= && \
            &nbs= p;      ((*(long *)&(x) & 0x007fffffL)!=3D0= 000000000L))

#define isinff(x) (((*(long *)&(x) & 0x7f800000L)=3D=3D0x7f800000L)=20= && \
            &nbs= p;      ((*(long *)&(x) & 0x007fffffL)=3D= =3D0000000000L))

#define finitef(x) (((*(long *)&(x) & 0x7f800000L)!=3D0x7f800000L))<= BR>
<= BR>
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 fil= e
../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__ >=3D 199901L= ) \
-   || !defined(__STRICT_ANSI__)
-
- #endif /* (__STDC_VERSION__ >=3D 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.<= BR>
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 =3D x;
!       ufn.f =3D fn;
!
!       if (isnanf(ux.l)||isnanf(ufn.l)) retur= n 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=20= 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--