* [9front] ape modf infinite recursion
@ 2021-01-22 3:00 Xiao-Yong Jin
2021-01-22 4:20 ` [9front] " Anthony Martin
2021-01-22 4:27 ` Alex Musolino
0 siblings, 2 replies; 6+ messages in thread
From: Xiao-Yong Jin @ 2021-01-22 3:00 UTC (permalink / raw)
To: 9front
modf(ip=0x7fffffffe9e8,d=0xffffffffffffffff)+0x43 /sys/src/ape/lib/ap/plan9/frexp.c:78
modf(ip=0x7fffffffe9e8,d=0xffffffffffffffff)+0x43 /sys/src/ape/lib/ap/plan9/frexp.c:78
modf(ip=0x7fffffffe9e8,d=0xffffffffffffffff)+0x43 /sys/src/ape/lib/ap/plan9/frexp.c:78
^ permalink raw reply [flat|nested] 6+ messages in thread
* [9front] Re: ape modf infinite recursion
2021-01-22 3:00 [9front] ape modf infinite recursion Xiao-Yong Jin
@ 2021-01-22 4:20 ` Anthony Martin
2021-01-22 17:06 ` [9front] " Xiao-Yong Jin
2021-01-22 4:27 ` Alex Musolino
1 sibling, 1 reply; 6+ messages in thread
From: Anthony Martin @ 2021-01-22 4:20 UTC (permalink / raw)
To: 9front
Xiao-Yong Jin <meta.jxy@gmail.com> once said:
> modf(ip=0x7fffffffe9e8,d=0xffffffffffffffff)+0x43 /sys/src/ape/lib/ap/plan9/frexp.c:78
> modf(ip=0x7fffffffe9e8,d=0xffffffffffffffff)+0x43 /sys/src/ape/lib/ap/plan9/frexp.c:78
> modf(ip=0x7fffffffe9e8,d=0xffffffffffffffff)+0x43 /sys/src/ape/lib/ap/plan9/frexp.c:78
There was a fix to this on sources that was
apparently never picked up by 9front.
I've included it below but you can also find
it in David du Colombier's mirror:
https://github.com/0intro/plan9/commit/119c1d0c712512776162de1eca755006f07fe91c
Cheers,
Anthony
diff --git a/sys/src/ape/lib/ap/plan9/frexp.c b/sys/src/ape/lib/ap/plan9/frexp.c
--- a/sys/src/ape/lib/ap/plan9/frexp.c
+++ b/sys/src/ape/lib/ap/plan9/frexp.c
@@ -73,6 +73,16 @@
Cheat x;
int e;
+ x.d = d;
+ e = (x.ms >> SHIFT) & MASK;
+ if(e == MASK){
+ *ip = d;
+ if(x.ls != 0 || (x.ms & 0xfffffL) != 0) /* NaN */
+ return d;
+ /* ±Inf */
+ x.ms &= 0x80000000L;
+ return x.d;
+ }
if(d < 1) {
if(d < 0) {
f = modf(-d, ip);
@@ -82,8 +92,7 @@
*ip = 0;
return d;
}
- x.d = d;
- e = ((x.ms >> SHIFT) & MASK) - BIAS;
+ e -= BIAS;
if(e <= SHIFT+1) {
x.ms &= ~(0x1fffffL >> e);
x.ls = 0;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9front] ape modf infinite recursion
2021-01-22 3:00 [9front] ape modf infinite recursion Xiao-Yong Jin
2021-01-22 4:20 ` [9front] " Anthony Martin
@ 2021-01-22 4:27 ` Alex Musolino
1 sibling, 0 replies; 6+ messages in thread
From: Alex Musolino @ 2021-01-22 4:27 UTC (permalink / raw)
To: 9front
We might need an isNaN check in there but it looks like we're also
generating the wrong code for the <0 comparison. 6c emits UCOMISD
followed by JCC. The UCOMISD will set all three ZF, PF, CF flags to 1
when either operand is NaN to indicate there is no ordering, but the
JCC only looks at CF and incorrectly determines that NaN < 0.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9front] ape modf infinite recursion
2021-01-22 4:20 ` [9front] " Anthony Martin
@ 2021-01-22 17:06 ` Xiao-Yong Jin
2021-01-22 17:21 ` Xiao-Yong Jin
2021-01-23 14:54 ` cinap_lenrek
0 siblings, 2 replies; 6+ messages in thread
From: Xiao-Yong Jin @ 2021-01-22 17:06 UTC (permalink / raw)
To: 9front
> On Jan 21, 2021, at 10:20 PM, Anthony Martin <ality@pbrane.org> wrote:
>
> Xiao-Yong Jin <meta.jxy@gmail.com> once said:
>> modf(ip=0x7fffffffe9e8,d=0xffffffffffffffff)+0x43 /sys/src/ape/lib/ap/plan9/frexp.c:78
>> modf(ip=0x7fffffffe9e8,d=0xffffffffffffffff)+0x43 /sys/src/ape/lib/ap/plan9/frexp.c:78
>> modf(ip=0x7fffffffe9e8,d=0xffffffffffffffff)+0x43 /sys/src/ape/lib/ap/plan9/frexp.c:78
>
> There was a fix to this on sources that was
> apparently never picked up by 9front.
>
> I've included it below but you can also find
> it in David du Colombier's mirror:
>
> https://github.com/0intro/plan9/commit/119c1d0c712512776162de1eca755006f07fe91c
The one at
/sys/src/libc/port/frexp.c
seems up-to-date with that, but not the ape one.
I borrowed the one from musl
https://git.musl-libc.org/cgit/musl/tree/src/math/modf.c
to ape, which seems to behave better.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9front] ape modf infinite recursion
2021-01-22 17:06 ` [9front] " Xiao-Yong Jin
@ 2021-01-22 17:21 ` Xiao-Yong Jin
2021-01-23 14:54 ` cinap_lenrek
1 sibling, 0 replies; 6+ messages in thread
From: Xiao-Yong Jin @ 2021-01-22 17:21 UTC (permalink / raw)
To: 9front
There is another ancient stray copy of modf
/sys/src/ape/lib/ap/math/modf.c
which is not in the mkfile.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9front] ape modf infinite recursion
2021-01-22 17:06 ` [9front] " Xiao-Yong Jin
2021-01-22 17:21 ` Xiao-Yong Jin
@ 2021-01-23 14:54 ` cinap_lenrek
1 sibling, 0 replies; 6+ messages in thread
From: cinap_lenrek @ 2021-01-23 14:54 UTC (permalink / raw)
To: 9front
you are correct. this fix has been applied previously
to plan9 libc, but was missed the ape version.
applied! thank you!
--
cinap
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-23 15:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22 3:00 [9front] ape modf infinite recursion Xiao-Yong Jin
2021-01-22 4:20 ` [9front] " Anthony Martin
2021-01-22 17:06 ` [9front] " Xiao-Yong Jin
2021-01-22 17:21 ` Xiao-Yong Jin
2021-01-23 14:54 ` cinap_lenrek
2021-01-22 4:27 ` Alex Musolino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).