svn commit: r359342 - head/lib/msun/src

Alfredo Dal'Ava Junior alfredo at FreeBSD.org
Thu Mar 26 18:51:04 UTC 2020


Author: alfredo
Date: Thu Mar 26 18:50:54 2020
New Revision: 359342
URL: https://svnweb.freebsd.org/changeset/base/359342

Log:
  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 at eldorado.org.br>
  Submitted by:	Fernando Valle <fernando.valle at 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

Modified:
  head/lib/msun/src/s_nan.c

Modified: head/lib/msun/src/s_nan.c
==============================================================================
--- head/lib/msun/src/s_nan.c	Thu Mar 26 17:59:48 2020	(r359341)
+++ head/lib/msun/src/s_nan.c	Thu Mar 26 18:50:54 2020	(r359342)
@@ -66,14 +66,15 @@ _scan_nan(uint32_t *words, int num_words, const char *
 		;
 
 	/* 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
 	}
 }
 


More information about the svn-src-all mailing list