about summary refs log tree commit diff
path: root/sysdeps/hppa/fpu/feupdateenv.c
diff options
context:
space:
mode:
authorCarlos O'Donell <carlos@systemhalted.org>2015-03-11 02:42:27 -0400
committerCarlos O'Donell <carlos@systemhalted.org>2015-03-11 02:48:59 -0400
commite4363cfb5760d88a9f353c69383b15d5c2705070 (patch)
treed45136a41ea523d4ee293b62fcbe98b2095a16d6 /sysdeps/hppa/fpu/feupdateenv.c
parentfae1aa8d226ce860124efd67ede03004b19b89e2 (diff)
downloadglibc-e4363cfb5760d88a9f353c69383b15d5c2705070.tar.gz
glibc-e4363cfb5760d88a9f353c69383b15d5c2705070.tar.xz
glibc-e4363cfb5760d88a9f353c69383b15d5c2705070.zip
hppa: Fix feupdateenv and fesetexceptflag (Bug 18111).
The function feupdateenv has been fixed to correctly handle FE_DFL_ENV
and FE_NOMASK_ENV.

The fesetexceptflag function has been fixed to correctly handle setting
the new flags instead of just OR-ing the existing flags.

This fixes the test-fenv-return and test-fenvinline failures on hppa.
Diffstat (limited to 'sysdeps/hppa/fpu/feupdateenv.c')
-rw-r--r--sysdeps/hppa/fpu/feupdateenv.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/sysdeps/hppa/fpu/feupdateenv.c b/sysdeps/hppa/fpu/feupdateenv.c
index 931f7e6292..345559edab 100644
--- a/sysdeps/hppa/fpu/feupdateenv.c
+++ b/sysdeps/hppa/fpu/feupdateenv.c
@@ -29,9 +29,22 @@ __feupdateenv (const fenv_t *envp)
   __asm__ ("fstd %%fr0,0(%1)	\n\t"
            "fldd 0(%1),%%fr0	\n\t"
 	   : "=m" (s.l) : "r" (&s.l));
-  memcpy(&temp, envp, sizeof(fenv_t));
-  /* Currently raised exceptions not cleared */
-  temp.__status_word |= s.sw[0] & (FE_ALL_EXCEPT << 27);
+
+  /* Given environment with exception flags not cleared.  */
+  if ((envp != FE_DFL_ENV) && (envp != FE_NOMASK_ENV))
+    {
+      memcpy(&temp, envp, sizeof(fenv_t));
+      temp.__status_word |= s.sw[0] & (FE_ALL_EXCEPT << 27);
+    }
+
+  /* Default environment with exception flags not cleared.  */
+  if (envp == FE_DFL_ENV)
+    temp.__status_word = s.sw[0] & (FE_ALL_EXCEPT << 27);
+
+  /* All traps enabled and current exception flags not cleared.  */
+  if (envp == FE_NOMASK_ENV)
+    temp.__status_word = (s.sw[0] & (FE_ALL_EXCEPT << 27)) | FE_ALL_EXCEPT;
+
   /* Install new environment.  */
   __fesetenv (&temp);
   /* Success.  */