[PATCH] Fix underflow reporting and tie up loose ends in sparc soft-fp.

Richard Henderson rth@twiddle.net
Tue May 29 20:14:00 GMT 2012


On 05/27/2012 09:16 PM, David Miller wrote:
> -  if (exceptions&  FP_EX_INVALID)
> -    d = p[0]/p[0];
> -  if (exceptions&  FP_EX_OVERFLOW)
> -    {
> -      d = p[3] + p[3];
> -      exceptions&= ~FP_EX_INEXACT;
> -    }
> -  if (exceptions&  FP_EX_UNDERFLOW)
> -    {
> -      if (exceptions&  FP_EX_INEXACT)
> -        {
> -	  d = p[2] * p[2];
> -	  exceptions&= ~FP_EX_INEXACT;
> -	}
> -      else
> -	d = p[1] - p[2];
> -    }
> -  if (exceptions&  FP_EX_DIVZERO)
> -    d = 1.0/p[0];
> -  if (exceptions&  FP_EX_INEXACT)
> -    d = p[3] - p[2];
> -  return d;
> +  fpu_control_t fcw;
> +  int tem, ou;
> +
> +  _FPU_GETCW(fcw);
> +
> +  tem = (fcw>>  23)&  0x1f;
> +
> +  ou = exceptions&  (FP_EX_OVERFLOW | FP_EX_UNDERFLOW);
> +  if (ou&  tem)
> +    exceptions&= ~FP_EX_INVALID;
> +
> +  fcw&= ~0x1f;
> +  fcw |= (exceptions | (exceptions<<  5));
> +
> +  _FPU_SETCW(fcw);

The thing that the former code does that the later does not is
raise SIGFPE in the event that the exception is not masked.


r~



More information about the Libc-alpha mailing list