VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
author: Joseph Myers <joseph@codesourcery.com> 2013-11-04 16:54:15 +0000 committer: Scott Wood <scottwood@freescale.com> 2014-01-07 18:36:24 -0600 commit: d06b3326dfd02f3f036b670d622fe56eb68a5f30 parent: 4f6db5efff8256c7f608285877e892e7e649137a
Commit Summary:
math-emu: fix floating-point to integer overflow detection
Diffstat:
1 file changed, 5 insertions, 0 deletions
diff --git a/include/math-emu/op-common.h b/include/math-emu/op-common.h
index 70fe5e989ace..6bdf8c61d221 100644
--- a/include/math-emu/op-common.h
+++ b/include/math-emu/op-common.h
@@ -743,12 +743,17 @@ do {									\
 	  }									\
 	else									\
 	  {									\
+	    int _lz0, _lz1;							\
 	    if (X##_e <= -_FP_WORKBITS - 1)					\
 	      _FP_FRAC_SET_##wc(X, _FP_MINFRAC_##wc);				\
 	    else								\
 	      _FP_FRAC_SRS_##wc(X, _FP_FRACBITS_##fs - 1 - X##_e,		\
 				_FP_WFRACBITS_##fs);				\
+	    _FP_FRAC_CLZ_##wc(_lz0, X);						\
 	    _FP_ROUND(wc, X);							\
+	    _FP_FRAC_CLZ_##wc(_lz1, X);						\
+	    if (_lz1 < _lz0)							\
+	      X##_e++; /* For overflow detection.  */				\
 	    _FP_FRAC_SRL_##wc(X, _FP_WORKBITS);					\
 	    _FP_FRAC_ASSEMBLE_##wc(r, X, rsize);				\
 	  }									\