msun: swap words order instead of bits order on BIG ENDIAN

The "for" loop on big endian was inverting all the bits instead of
just the words

Issue reported by TestSuite (msun lib nan_test case)

Submitted by:	Renato Riolino <renato.riolino@eldorado.org.br>
Submitted by:	Fernando Valle <fernando.valle@eldorado.org.br>
Reviewed by:	pfg, alfredo
Approved by:	jhibbits (mentor)
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D23926
This commit is contained in:
Alfredo Dal'Ava Junior 2020-03-26 18:50:54 +00:00
parent 68fbe6f0b3
commit f1343c7f67

View File

@ -66,14 +66,15 @@ _scan_nan(uint32_t *words, int num_words, const char *s)
;
/* Scan backwards, filling in the bits in words[] as we go. */
#if _BYTE_ORDER == _LITTLE_ENDIAN
for (bitpos = 0; bitpos < 32 * num_words; bitpos += 4) {
#else
for (bitpos = 32 * num_words - 4; bitpos >= 0; bitpos -= 4) {
#endif
if (--si < 0)
break;
#if _BYTE_ORDER == _LITTLE_ENDIAN
words[bitpos / 32] |= digittoint(s[si]) << (bitpos % 32);
#else
words[num_words - 1 - bitpos / 32] |=
digittoint(s[si]) << (bitpos % 32);
#endif
}
}