delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/09/30/10:19:41

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
From: Kbwms AT aol DOT com
Message-ID: <1a5.19d80d7e.2caaeac4@aol.com>
Date: Tue, 30 Sep 2003 10:18:44 EDT
Subject: Re: Bug in modfl() in libc.a
To: djgpp-workers AT delorie DOT com
MIME-Version: 1.0
X-Mailer: 8.0 for Windows sub 6015
Reply-To: djgpp-workers AT delorie DOT com

--part1_1a5.19d80d7e.2caaeac4_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

In a message dated 9/29/2003 2:14:47 PM Eastern Standard Time, 
peuha AT cc DOT helsinki DOT fi writes:

> >modf(+-x, iptr) returns a result with the same sign as x.
> >modf(+-Inf , iptr) returns +-0 and stores +-Inf in the object pointed to by
> >iptr.
> >modf(NaN, iptr) stores a NaN in the object pointed to by iptr (and returns 
> a
> >NaN).
> [snip]
> >My interpretation is that the result returned for +-Inf should have the 
> same
> >sign, i.e.: +0 for +Inf, -0 for -Inf.
> 
> My previous patch would also return +0 for negative finite integers and
> NaNs.  This should do better (but it's completely untested):
> 
> Index: modfl.S
> ===================================================================
> RCS file: /cvs/djgpp/djgpp/src/libc/ansi/math/modfl.S,v
> retrieving revision 1.1
> diff -c -r1.1 modfl.S
> *** modfl.S   25 Nov 1994 19:59:40 -0000   1.1
> --- modfl.S   29 Sep 2003 10:08:25 -0000
> ***************
> *** 17,22 ****
> --- 17,40 ----
>    fldcw -2(%ebp)
>    fld %st(0)
>    fstpt (%eax)
> +   fucom %st(1)
> +   fnstsw -2(%ebp)
> +   movw -2(%ebp),%dx
> +   andb $0x44,%dh
> +   xorb $0x40,%dh
> +   jnz 0f
> +   fxam
> +   fnstsw -2(%ebp)
> +   fstp %st(0)
> +   fstp %st(0)
> +   fldz
> +   movw -2(%ebp),%dx
> +   andb $0x02,%dh
> +   jz 1f
> +   fchs
> +   jmp 1f
> + 0:
>    fsubrp %st,%st(1)
> + 1:
>    leave
>    ret
> 
> 

Here is the code as patched.  It causes a SIGSEGV signal and General 
Protection Fault when executed.


KB Williams

--part1_1a5.19d80d7e.2caaeac4_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<HTML><FONT FACE=3Darial,helvetica><FONT  SIZE=3D3 FAMILY=3D"SERIF" FACE=3D"=
Georgia" LANG=3D"0">In a message dated 9/29/2003 2:14:47 PM Eastern Standard=
 Time, peuha AT cc DOT helsinki DOT fi 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"=
 style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2 FAMILY=3D"SANSSERIF" FACE=3D"A=
rial" LANG=3D"0">&gt;modf(+-x, iptr) returns a result with the same sign as=20=
x.<BR>
&gt;modf(+-Inf , iptr) returns +-0 and stores +-Inf in the object pointed to=
 by<BR>
&gt;iptr.<BR>
&gt;modf(NaN, iptr) stores a NaN in the object pointed to by iptr (and retur=
ns a<BR>
&gt;NaN).<BR>
[snip]<BR>
&gt;My interpretation is that the result returned for +-Inf should have the=20=
same<BR>
&gt;sign, i.e.: +0 for +Inf, -0 for -Inf.<BR>
<BR>
My previous patch would also return +0 for negative finite integers and<BR>
NaNs.&nbsp; This should do better (but it's completely untested):<BR>
<BR>
Index: modfl.S<BR>
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<BR>
RCS file: /cvs/djgpp/djgpp/src/libc/ansi/math/modfl.S,v<BR>
retrieving revision 1.1<BR>
diff -c -r1.1 modfl.S<BR>
*** modfl.S&nbsp;&nbsp; 25 Nov 1994 19:59:40 -0000&nbsp;&nbsp; 1.1<BR>
--- modfl.S&nbsp;&nbsp; 29 Sep 2003 10:08:25 -0000<BR>
***************<BR>
*** 17,22 ****<BR>
--- 17,40 ----<BR>
&nbsp;&nbsp; fldcw -2(%ebp)<BR>
&nbsp;&nbsp; fld %st(0)<BR>
&nbsp;&nbsp; fstpt (%eax)<BR>
+&nbsp;&nbsp; fucom %st(1)<BR>
+&nbsp;&nbsp; fnstsw -2(%ebp)<BR>
+&nbsp;&nbsp; movw -2(%ebp),%dx<BR>
+&nbsp;&nbsp; andb $0x44,%dh<BR>
+&nbsp;&nbsp; xorb $0x40,%dh<BR>
+&nbsp;&nbsp; jnz 0f<BR>
+&nbsp;&nbsp; fxam<BR>
+&nbsp;&nbsp; fnstsw -2(%ebp)<BR>
+&nbsp;&nbsp; fstp %st(0)<BR>
+&nbsp;&nbsp; fstp %st(0)<BR>
+&nbsp;&nbsp; fldz<BR>
+&nbsp;&nbsp; movw -2(%ebp),%dx<BR>
+&nbsp;&nbsp; andb $0x02,%dh<BR>
+&nbsp;&nbsp; jz 1f<BR>
+&nbsp;&nbsp; fchs<BR>
+&nbsp;&nbsp; jmp 1f<BR>
+ 0:<BR>
&nbsp;&nbsp; fsubrp %st,%st(1)<BR>
+ 1:<BR>
&nbsp;&nbsp; leave<BR>
&nbsp;&nbsp; ret<BR>
<BR>
</BLOCKQUOTE><BR>
</FONT><FONT  COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D3=
 FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><BR>
Here is the code as patched.&nbsp; It causes a SIGSEGV signal and General Pr=
otection Fault when executed.<BR>
<BR>
<BR>
KB Williams</FONT></HTML>

--part1_1a5.19d80d7e.2caaeac4_boundary--

- Raw text -


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