aboutsummaryrefslogtreecommitdiff
path: root/math
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2018-05-10 17:53:31 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2018-05-16 13:52:13 +0100
commitc65db17340782d647c49e17cbba244862dc38402 (patch)
tree781a38089ac7431fba502e213a328bca0f3a0b14 /math
parent2f2d687988c6614e3d2f8636dce5b2d1a10683e5 (diff)
downloadarm-optimized-routines-c65db17340782d647c49e17cbba244862dc38402.tar.gz
Use fixed 32bit sign argument to error functions
Ideally sign should be bool, but we don't want to depend on stdbool.h and sometimes (e.g. in powf) it's more efficient to pass a non-zero value than 1 to indicate that the sign should be set. While working on double precision versions i realized that the unsigned long argument is fragile (may fail on 32bit targets only).
Diffstat (limited to 'math')
-rw-r--r--math/math_config.h8
-rw-r--r--math/math_errf.c10
-rw-r--r--math/powf.c4
3 files changed, 11 insertions, 11 deletions
diff --git a/math/math_config.h b/math/math_config.h
index 70bd6c0..c8e7d78 100644
--- a/math/math_config.h
+++ b/math/math_config.h
@@ -138,10 +138,10 @@ issignalingf_inline (float x)
# define NOINLINE
#endif
-HIDDEN float __math_oflowf (unsigned long);
-HIDDEN float __math_uflowf (unsigned long);
-HIDDEN float __math_may_uflowf (unsigned long);
-HIDDEN float __math_divzerof (unsigned long);
+HIDDEN float __math_oflowf (uint32_t);
+HIDDEN float __math_uflowf (uint32_t);
+HIDDEN float __math_may_uflowf (uint32_t);
+HIDDEN float __math_divzerof (uint32_t);
HIDDEN float __math_invalidf (float);
/* Shared between expf, exp2f and powf. */
diff --git a/math/math_errf.c b/math/math_errf.c
index cd6df2c..c96c5df 100644
--- a/math/math_errf.c
+++ b/math/math_errf.c
@@ -35,14 +35,14 @@ with_errnof (float y, int e)
/* NOINLINE prevents fenv semantics breaking optimizations. */
NOINLINE static float
-xflowf (unsigned long sign, float y)
+xflowf (uint32_t sign, float y)
{
y = (sign ? -y : y) * y;
return with_errnof (y, ERANGE);
}
HIDDEN float
-__math_uflowf (unsigned long sign)
+__math_uflowf (uint32_t sign)
{
return xflowf (sign, 0x1p-95f);
}
@@ -51,20 +51,20 @@ __math_uflowf (unsigned long sign)
/* Underflows to zero in some non-nearest rounding mode, setting errno
is valid even if the result is non-zero, but in the subnormal range. */
HIDDEN float
-__math_may_uflowf (unsigned long sign)
+__math_may_uflowf (uint32_t sign)
{
return xflowf (sign, 0x1.4p-75f);
}
#endif
HIDDEN float
-__math_oflowf (unsigned long sign)
+__math_oflowf (uint32_t sign)
{
return xflowf (sign, 0x1p97f);
}
HIDDEN float
-__math_divzerof (unsigned long sign)
+__math_divzerof (uint32_t sign)
{
float y = 0;
return with_errnof ((sign ? -1 : 1) / y, ERANGE);
diff --git a/math/powf.c b/math/powf.c
index de9195f..70c535e 100644
--- a/math/powf.c
+++ b/math/powf.c
@@ -87,7 +87,7 @@ log2_inline (uint32_t ix)
(in case of fast toint intrinsics) or not. The unscaled xd must be
in [-1021,1023], sign_bias sets the sign of the result. */
static inline double_t
-exp2_inline (double_t xd, unsigned long sign_bias)
+exp2_inline (double_t xd, uint32_t sign_bias)
{
uint64_t ki, ski, t;
/* double_t for better performance on targets with FLT_EVAL_METHOD==2. */
@@ -146,7 +146,7 @@ zeroinfnan (uint32_t ix)
float
powf (float x, float y)
{
- unsigned long sign_bias = 0;
+ uint32_t sign_bias = 0;
uint32_t ix, iy;
ix = asuint (x);