forked from OSchip/llvm-project
improve portability to systems that don't have round, patch by
Evzen Muller! llvm-svn: 103877
This commit is contained in:
parent
93cd0f1c89
commit
9e01b615a4
|
@ -312,6 +312,9 @@
|
||||||
/* Define to 1 if you have the `roundf' function. */
|
/* Define to 1 if you have the `roundf' function. */
|
||||||
#undef HAVE_ROUNDF
|
#undef HAVE_ROUNDF
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `round' function. */
|
||||||
|
#cmakedefine HAVE_ROUND ${HAVE_ROUND}
|
||||||
|
|
||||||
/* Define to 1 if you have the `sbrk' function. */
|
/* Define to 1 if you have the `sbrk' function. */
|
||||||
#cmakedefine HAVE_SBRK ${HAVE_SBRK}
|
#cmakedefine HAVE_SBRK ${HAVE_SBRK}
|
||||||
|
|
||||||
|
|
|
@ -1382,13 +1382,12 @@ APInt APInt::sqrt() const {
|
||||||
// libc sqrt function which will probably use a hardware sqrt computation.
|
// libc sqrt function which will probably use a hardware sqrt computation.
|
||||||
// This should be faster than the algorithm below.
|
// This should be faster than the algorithm below.
|
||||||
if (magnitude < 52) {
|
if (magnitude < 52) {
|
||||||
#if defined( _MSC_VER ) || defined(_MINIX)
|
#if HAVE_ROUND
|
||||||
// Amazingly, VC++ and Minix don't have round().
|
|
||||||
return APInt(BitWidth,
|
|
||||||
uint64_t(::sqrt(double(isSingleWord()?VAL:pVal[0]))) + 0.5);
|
|
||||||
#else
|
|
||||||
return APInt(BitWidth,
|
return APInt(BitWidth,
|
||||||
uint64_t(::round(::sqrt(double(isSingleWord()?VAL:pVal[0])))));
|
uint64_t(::round(::sqrt(double(isSingleWord()?VAL:pVal[0])))));
|
||||||
|
#else
|
||||||
|
return APInt(BitWidth,
|
||||||
|
uint64_t(::sqrt(double(isSingleWord()?VAL:pVal[0]))) + 0.5);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue