]> git.ipfire.org Git - thirdparty/glibc.git/commit
powerpc: Do not raise exception traps for fesetexcept/fesetexceptflag (BZ 30988)
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 24 Oct 2023 11:37:14 +0000 (08:37 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 19 Dec 2023 18:12:34 +0000 (15:12 -0300)
commitecb1e7220ddc7a4845bbd1b6fd7fcf17aba566bd
tree5e38bda17e720b93e0a50273c75c3acb27efd8f8
parentf94446c38fb3f4ad26183984c490a9590cd05282
powerpc: Do not raise exception traps for fesetexcept/fesetexceptflag (BZ 30988)

According to ISO C23 (7.6.4.4), fesetexcept is supposed to set
floating-point exception flags without raising a trap (unlike
feraiseexcept, which is supposed to raise a trap if feenableexcept was
called with the appropriate argument).

This is a side-effect of how we implement the GNU extension
feenableexcept, where feenableexcept/fesetenv/fesetmode/feupdateenv
might issue prctl (PR_SET_FPEXC, PR_FP_EXC_PRECISE) depending of the
argument.  And on PR_FP_EXC_PRECISE, setting a floating-point exception
flag triggers a trap.

To make the both functions follow the C23, fesetexcept and
fesetexceptflag now fail if the argument may trigger a trap.

The math tests now check for an value different than 0, instead
of bail out as unsupported for EXCEPTION_SET_FORCES_TRAP.

Checked on powerpc64le-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
math/test-fesetexcept-traps.c
math/test-fexcept-traps.c
sysdeps/powerpc/fpu/fesetexcept.c
sysdeps/powerpc/fpu/fsetexcptflg.c