The existing hppa code does this:
s.sw[0] |= (*flagp & excepts & FE_ALL_EXCEPT) << 27;
When it should do something like this:
excepts &= FE_ALL_EXCEPT;
s.sw[0] = s.sw[0] & ~(excepts << 27);
s.sw[0] |= (*flagp & excepts) << 27;
Which actually clears the flags if excepts specifies more flag bits than *flagp sets.
While fixing this I decided to rewrite it using fpu_control.h to test the new code, and in doing so fixed a bug in fpu_control.h with _FPU_SETCW not initializing the other word is loads/stores.

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via e4363cfb5760d88a9f353c69383b15d5c2705070 (commit)
via fae1aa8d226ce860124efd67ede03004b19b89e2 (commit)
from 068a6274556f9f362443648f4fd47525c8cf2dba (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e4363cfb5760d88a9f353c69383b15d5c2705070
commit e4363cfb5760d88a9f353c69383b15d5c2705070
Author: Carlos O'Donell <carlos@systemhalted.org>
Date: Wed Mar 11 02:42:27 2015 -0400
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.
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fae1aa8d226ce860124efd67ede03004b19b89e2
commit fae1aa8d226ce860124efd67ede03004b19b89e2
Author: John David Anglin <danglin@gcc.gnu.org>
Date: Tue Mar 10 23:43:50 2015 -0400
hppa: Fix feholdexcpt and fesetenv (Bug 18110).
The constraints in the inline assembly in feholdexcept and fesetenv
are incorrect. The assembly modifies the buffer pointer, but doesn't
express that in the constraints. The simple fix is to remove the
modification of the buffer pointer which is no longer required by
the existing code, and adjust the one constraint that did express
the modification of bufptr.
The change fixes test-fenv when glibc is compiled with recent gcc.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 16 ++++++++++++++++
NEWS | 3 ++-
sysdeps/hppa/fpu/feholdexcpt.c | 10 ++++------
sysdeps/hppa/fpu/fesetenv.c | 4 ++--
sysdeps/hppa/fpu/feupdateenv.c | 19 ++++++++++++++++---
sysdeps/hppa/fpu/fpu_control.h | 7 ++++++-
sysdeps/hppa/fpu/fsetexcptflg.c | 18 ++++++++++++------
7 files changed, 58 insertions(+), 19 deletions(-)