summaryrefslogtreecommitdiffstats
path: root/contrib/compiler-rt/lib/builtins/fixunsxfsi.c
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-03-14 12:40:19 +0000
committerdim <dim@FreeBSD.org>2015-03-14 12:40:19 +0000
commit73a5b102bba947d10e5dd482c1f14bc444d4fcb3 (patch)
tree22c96169e9ec91b9a5b31830347710371a91096d /contrib/compiler-rt/lib/builtins/fixunsxfsi.c
parentd202cb2c64432c785dfaf1544f77b27349d33d56 (diff)
downloadFreeBSD-src-73a5b102bba947d10e5dd482c1f14bc444d4fcb3.zip
FreeBSD-src-73a5b102bba947d10e5dd482c1f14bc444d4fcb3.tar.gz
Pull in r231965 from upstream compiler-rt trunk (by Jörg Sonnenberger):
Refactor float to integer conversion to share the same code. 80bit Intel/PPC long double is excluded due to lacking support for the abstraction. Consistently provide saturation logic. Extend to long double on 128bit IEEE extended platforms. Initial patch with test cases from GuanHong Liu. Reviewed by Steve Canon. Differential Revision: http://reviews.llvm.org/D2804 Pull in r232107 from upstream compiler-rt trunk (by Ed Maste): Use signed int implementation for __fixint Requested by: emaste
Diffstat (limited to 'contrib/compiler-rt/lib/builtins/fixunsxfsi.c')
-rw-r--r--contrib/compiler-rt/lib/builtins/fixunsxfsi.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/compiler-rt/lib/builtins/fixunsxfsi.c b/contrib/compiler-rt/lib/builtins/fixunsxfsi.c
index df0a18e..c3c70f7 100644
--- a/contrib/compiler-rt/lib/builtins/fixunsxfsi.c
+++ b/contrib/compiler-rt/lib/builtins/fixunsxfsi.c
@@ -23,7 +23,6 @@
/* Assumption: long double is an intel 80 bit floating point type padded with 6 bytes
* su_int is a 32 bit integral type
* value in long double is representable in su_int or is negative
- * (no range checking performed)
*/
/* gggg gggg gggg gggg gggg gggg gggg gggg | gggg gggg gggg gggg seee eeee eeee eeee |
@@ -38,6 +37,8 @@ __fixunsxfsi(long double a)
int e = (fb.u.high.s.low & 0x00007FFF) - 16383;
if (e < 0 || (fb.u.high.s.low & 0x00008000))
return 0;
+ if ((unsigned)e > sizeof(su_int) * CHAR_BIT)
+ return ~(su_int)0;
return fb.u.low.s.high >> (31 - e);
}
OpenPOWER on IntegriCloud