mirror of
git://git.musl-libc.org/musl
synced 2025-01-11 00:59:46 +00:00
math: add single precision error handling functions
These are supposed to be used in tail call positions when handling special cases in new code. (fp exceptions may be raised "naturally" by the common code path if special casing is more effort.) This implements the error handling apis used in https://github.com/ARM-software/optimized-routines without errno setting.
This commit is contained in:
parent
fe54544f05
commit
9ef6ca4235
@ -216,4 +216,11 @@ extern int __signgam;
|
||||
hidden double __lgamma_r(double, int *);
|
||||
hidden float __lgammaf_r(float, int *);
|
||||
|
||||
/* error handling functions */
|
||||
hidden float __math_xflowf(uint32_t, float);
|
||||
hidden float __math_uflowf(uint32_t);
|
||||
hidden float __math_oflowf(uint32_t);
|
||||
hidden float __math_divzerof(uint32_t);
|
||||
hidden float __math_invalidf(float);
|
||||
|
||||
#endif
|
||||
|
6
src/math/__math_divzerof.c
Normal file
6
src/math/__math_divzerof.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include "libm.h"
|
||||
|
||||
float __math_divzerof(uint32_t sign)
|
||||
{
|
||||
return fp_barrierf(sign ? -1.0f : 1.0f) / 0.0f;
|
||||
}
|
6
src/math/__math_invalidf.c
Normal file
6
src/math/__math_invalidf.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include "libm.h"
|
||||
|
||||
float __math_invalidf(float x)
|
||||
{
|
||||
return (x - x) / (x - x);
|
||||
}
|
6
src/math/__math_oflowf.c
Normal file
6
src/math/__math_oflowf.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include "libm.h"
|
||||
|
||||
float __math_oflowf(uint32_t sign)
|
||||
{
|
||||
return __math_xflowf(sign, 0x1p97f);
|
||||
}
|
6
src/math/__math_uflowf.c
Normal file
6
src/math/__math_uflowf.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include "libm.h"
|
||||
|
||||
float __math_uflowf(uint32_t sign)
|
||||
{
|
||||
return __math_xflowf(sign, 0x1p-95f);
|
||||
}
|
6
src/math/__math_xflowf.c
Normal file
6
src/math/__math_xflowf.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include "libm.h"
|
||||
|
||||
float __math_xflowf(uint32_t sign, float y)
|
||||
{
|
||||
return eval_as_float(fp_barrierf(sign ? -y : y) * y);
|
||||
}
|
Loading…
Reference in New Issue
Block a user