aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-11-02 11:15:55 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-12-19 15:12:38 -0300
commit802aef27b2d9f04b06344706f88d37bbe89629e9 (patch)
tree2616f5cafd6a27b72a0d6ed3c0a2725d1620dee7 /sysdeps
parente55599e0286655dd5f1f5b48005a17be37cc7f2c (diff)
downloadglibc-802aef27b2d9f04b06344706f88d37bbe89629e9.tar
glibc-802aef27b2d9f04b06344706f88d37bbe89629e9.tar.gz
glibc-802aef27b2d9f04b06344706f88d37bbe89629e9.tar.bz2
glibc-802aef27b2d9f04b06344706f88d37bbe89629e9.zip
riscv: Fix feenvupdate with FE_DFL_ENV (BZ 31022)
libc_feupdateenv_riscv should check for FE_DFL_ENV, similar to libc_fesetenv_riscv. Also extend the test-fenv.c to test fenvupdate. Checked on riscv under qemu-system. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/riscv/rvf/fenv_private.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/sysdeps/riscv/rvf/fenv_private.h b/sysdeps/riscv/rvf/fenv_private.h
index 40e23661b7..d8d65458b2 100644
--- a/sysdeps/riscv/rvf/fenv_private.h
+++ b/sysdeps/riscv/rvf/fenv_private.h
@@ -93,10 +93,7 @@ libc_fetestexcept_riscv (int ex)
static __always_inline void
libc_fesetenv_riscv (const fenv_t *envp)
{
- long int env = (long int) envp - (long int) FE_DFL_ENV;
- if (env != 0)
- env = *envp;
-
+ long int env = (envp != FE_DFL_ENV ? *envp : 0);
_FPU_SETCW (env);
}
@@ -123,7 +120,8 @@ libc_feupdateenv_test_riscv (const fenv_t *envp, int ex)
static __always_inline void
libc_feupdateenv_riscv (const fenv_t *envp)
{
- _FPU_SETCW (*envp | riscv_getflags ());
+ long int env = (envp != FE_DFL_ENV ? *envp : 0);
+ _FPU_SETCW (env | riscv_getflags ());
}
#define libc_feupdateenv libc_feupdateenv_riscv