From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Fix strtold
Date: Wed, 24 Mar 2004 18:14:00 -0000 [thread overview]
Message-ID: <20040324131531.GK15946@sunsite.ms.mff.cuni.cz> (raw)
Hi!
There were 2 bugs in strtold{,_l} if RETURN_LIMB_SIZE > 2 (e.g. IEEE quad
long double on 32-bit architecture).
1) when clearing the rest of retval, it assumed there are at most 2 limbs
2) when shifting up by BITS_PER_MP_LIMB * empty bits, there was an
off-by-one and no clearing of the bottom-most limbs
2004-03-24 Jakub Jelinek <jakub@redhat.com>
* stdlib/strtod_l.c (INTERNAL (__STRTOF)): Clear the rest of retval,
not just one limb if RETURN_LIMB_SIZE > 2. Fix shifting up if
RETURN_LIMB_SIZE > 2.
--- libc/stdlib/strtod_l.c.jj 2004-03-24 13:45:24.000000000 -0500
+++ libc/stdlib/strtod_l.c 2004-03-24 14:14:18.000000000 -0500
@@ -1159,7 +1159,11 @@ INTERNAL (__STRTOF) (nptr, endptr, group
memcpy (retval, num, numsize * sizeof (mp_limb_t));
#if RETURN_LIMB_SIZE > 1
if (numsize < RETURN_LIMB_SIZE)
+# if RETURN_LIMB_SIZE == 2
retval[numsize] = 0;
+# else
+ MPN_ZERO (retval + numsize, RETURN_LIMB_SIZE - numsize);
+# endif
#endif
}
@@ -1465,8 +1469,10 @@ INTERNAL (__STRTOF) (nptr, endptr, group
__mpn_lshift_1 (retval, RETURN_LIMB_SIZE,
BITS_PER_MP_LIMB, 0);
#else
- for (i = RETURN_LIMB_SIZE; i > empty; --i)
+ for (i = RETURN_LIMB_SIZE - 1; i >= empty; --i)
retval[i] = retval[i - empty];
+ while (i >= 0)
+ retval[i--] = 0;
#endif
for (i = numsize; i > 0; --i)
num[i + empty] = num[i - 1];
Jakub
next reply other threads:[~2004-03-24 15:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-24 18:14 Jakub Jelinek [this message]
2004-03-26 9:49 ` Ulrich Drepper
2004-11-29 12:00 Jakub Jelinek
2004-12-10 4:41 ` Ulrich Drepper
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=20040324131531.GK15946@sunsite.ms.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).