[13/15] math: Fix log2 template for inputs less than 0
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Testing passed
|
Commit Message
The template is used by some ABIs for the static build, and it
fails to correctly set the floating exceptions if the argument
is less than 0.
Checked on x86_64-linux-gnu.
---
math/Makefile | 1 +
math/w_log2_template.c | 16 ++++++++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
@@ -370,6 +370,7 @@ $(libm-test-c-narrow-obj): $(objpfx)libm-test%.c: libm-test%.inc \
libm-test-funcs-auto-static = \
acos \
exp10 \
+ log2 \
log10 \
# libm-test-funcs-auto-static
libm-test-funcs-noauto-static = \
@@ -32,11 +32,19 @@ M_DECL_FUNC (__log2) (FLOAT x)
if (__glibc_unlikely (islessequal (x, M_LIT (0.0))))
{
if (x == 0)
- /* Pole error: log2(0). */
- __set_errno (ERANGE);
+ {
+ /* Pole error: log2(0). */
+ __feraiseexcept (FE_DIVBYZERO);
+ __set_errno (ERANGE);
+ return -INFINITY;
+ }
else
- /* Domain error: log2(<0). */
- __set_errno (EDOM);
+ {
+ /* Domain error: log2(<0). */
+ __feraiseexcept (FE_INVALID);
+ __set_errno (EDOM);
+ return NAN;
+ }
}
return M_SUF (__ieee754_log2) (x);
}