Tao Xu <tao3...@intel.com> writes:

> Support full 64bit precision, modify related test cases.

That's not true in general: long double need not be any wider than
double.

It might be true on the host machines we support, but I don't know.  If
we decide to rely on it, we better make the build fail when the host
machine doesn't meet our expectations, preferably in configure.

>
> Signed-off-by: Tao Xu <tao3...@intel.com>
> ---
[...]
> diff --git a/util/cutils.c b/util/cutils.c
> index 5db3b2add5..d94a468954 100644
> --- a/util/cutils.c
> +++ b/util/cutils.c
> @@ -216,13 +216,13 @@ static int do_strtosz(const char *nptr, const char 
> **end,
>      const char *endptr;
>      unsigned char c;
>      int mul_required = 0;
> -    double val, mul, integral, fraction;
> +    long double val, mul, integral, fraction;
>  
> -    retval = qemu_strtod_finite(nptr, &endptr, &val);
> +    retval = qemu_strtold_finite(nptr, &endptr, &val);
>      if (retval) {
>          goto out;
>      }
> -    fraction = modf(val, &integral);
> +    fraction = modfl(val, &integral);
>      if (fraction != 0) {
>          mul_required = 1;
>      }
> @@ -238,11 +238,8 @@ static int do_strtosz(const char *nptr, const char **end,
>          retval = -EINVAL;
>          goto out;
>      }
> -    /*
> -     * Values >= 0xfffffffffffffc00 overflow uint64_t after their trip
> -     * through double (53 bits of precision).
> -     */
> -    if ((val * mul >= 0xfffffffffffffc00) || val < 0) {
> +    /* Values > UINT64_MAX overflow uint64_t */
> +    if ((val * mul > UINT64_MAX) || val < 0) {
>          retval = -ERANGE;
>          goto out;
>      }

Not portable.  If it was, we'd have made this changd long ago :)


Reply via email to