2 * Single-precision math error handling.
4 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 * See https://llvm.org/LICENSE.txt for license information.
6 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 #include "math_config.h"
13 /* NOINLINE reduces code size and avoids making math functions non-leaf
14 when the error handling is inlined. */
16 with_errnof (float y
, int e
)
22 #define with_errnof(x, e) (x)
25 /* NOINLINE reduces code size. */
27 xflowf (uint32_t sign
, float y
)
29 y
= eval_as_float (opt_barrier_float (sign
? -y
: y
) * y
);
30 return with_errnof (y
, ERANGE
);
34 __math_uflowf (uint32_t sign
)
36 return xflowf (sign
, 0x1p
-95f
);
40 /* Underflows to zero in some non-nearest rounding mode, setting errno
41 is valid even if the result is non-zero, but in the subnormal range. */
43 __math_may_uflowf (uint32_t sign
)
45 return xflowf (sign
, 0x1.4p
-75f
);
50 __math_oflowf (uint32_t sign
)
52 return xflowf (sign
, 0x1p
97f
);
56 __math_divzerof (uint32_t sign
)
58 float y
= opt_barrier_float (sign
? -1.0f
: 1.0f
) / 0.0f
;
59 return with_errnof (y
, ERANGE
);
63 __math_invalidf (float x
)
65 float y
= (x
- x
) / (x
- x
);
66 return isnan (x
) ? y
: with_errnof (y
, EDOM
);