9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Anthony Martin <ality@pbrane.org>
To: 9front@9front.org
Subject: [9front] Re: ape modf infinite recursion
Date: Thu, 21 Jan 2021 20:20:43 -0800	[thread overview]
Message-ID: <YApSm3KPXx3M1qqF@alice> (raw)
In-Reply-To: <ABFD8ED6-5269-49D5-85A6-8693BF646CC9@gmail.com>

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;

  reply	other threads:[~2021-01-22  4:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22  3:00 [9front] " Xiao-Yong Jin
2021-01-22  4:20 ` Anthony Martin [this message]
2021-01-22 17:06   ` 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YApSm3KPXx3M1qqF@alice \
    --to=ality@pbrane.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).