From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
libc-alpha@sourceware.org, Bruno Haible <bruno@clisp.org>
Subject: Re: [PATCH 5/7] riscv: Fix feenvupdate with FE_DFL_ENV (BZ 31022)
Date: Tue, 9 Jan 2024 13:44:06 +0000 [thread overview]
Message-ID: <ZZ1NpmWCqQ+HZSoV@arm.com> (raw)
In-Reply-To: <20231103122416.2724355-6-adhemerval.zanella@linaro.org>
The 11/03/2023 09:24, Adhemerval Zanella wrote:
> 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.
the test fails on aarch64 when trapping is supported.
> +++ b/math/test-fenv.c
> @@ -196,6 +196,30 @@ set_single_exc (const char *test_name, int fe_exc, fexcept_t exception)
> feclearexcept (exception);
> test_exceptions (str, ALL_EXC ^ fe_exc, 0);
> }
> +
> +static void
> +update_single_exc (const char *test_name, const fenv_t *envp, int fe_exc,
> + int fe_exc_clear, fexcept_t exception)
> +{
> + char str[200];
> + /* The standard allows the inexact exception to be set together with the
> + underflow and overflow exceptions. So ignore the inexact flag if the
> + others are raised. */
> + int ignore_inexact = (fe_exc & (UNDERFLOW_EXC | OVERFLOW_EXC)) != 0;
> +
> + strcpy (str, test_name);
> + strcat (str, ": set flag, with rest not set");
> + feclearexcept (FE_ALL_EXCEPT);
> + feraiseexcept (exception);
this relies on disabled trapping.
> + feupdateenv (envp);
> + test_exceptions (str, fe_exc, ignore_inexact);
> +
> + strcpy (str, test_name);
> + strcat (str, ": clear flag, rest also unset");
> + feclearexcept (exception);
> + feupdateenv (envp);
> + test_exceptions (str, fe_exc_clear, ignore_inexact);
> +}
...
> /* Test that program aborts with no masked interrupts */
> static void
> -feenv_nomask_test (const char *flag_name, int fe_exc)
> +feenv_nomask_test (const char *flag_name, int fe_exc, int (*func)(const fenv_t *))
> {
> # if defined FE_NOMASK_ENV
> int status;
> pid_t pid;
>
> if (!EXCEPTION_ENABLE_SUPPORTED (FE_ALL_EXCEPT)
> - && fesetenv (FE_NOMASK_ENV) != 0)
> + && func (FE_NOMASK_ENV) != 0)
trapping is enabled here on targets where trapping is optional.
> +static void
> +feupdate_single_test (const char *flag_name, int fe_exc)
> +{
> + feenv_nomask_test (flag_name, fe_exc, feupdateenv);
> + feenv_mask_test (flag_name, fe_exc, feupdateenv);
> +}
trapping is still on after this function.
> +static void
> +feupdateenv_single_test (const char *test_name, int fe_exc,
> + fexcept_t exception)
> +{
> + char str[100];
> + fenv_t env;
> + int res;
> +
> + snprintf (str, sizeof str, "feupdateenv %s and FL_DFL_ENV", test_name);
> + update_single_exc (str, FE_DFL_ENV, fe_exc, NO_EXC, exception);
this relies on disabled trapping.
> +static void
> +feupdateenv_tests (void)
> +{
...
> +#ifdef FE_OVERFLOW
> + feupdate_single_test ("FE_OVERFLOW", FE_OVERFLOW);
> +#endif
> +
> +#ifdef FE_DIVBYZERO
> + feupdateenv_single_test ("DIVBYZERO", DIVBYZERO_EXC, FE_DIVBYZERO);
> +#endif
this test fails because previous enables trapping mode.
fwiw a feupdateenv (FE_DFL_ENV); in between the tests
makes math/test-fenv pass.
next prev parent reply other threads:[~2024-01-09 13:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 12:24 [PATCH 0/7] Multiple floating-point environment fixes Adhemerval Zanella
2023-11-03 12:24 ` [PATCH 1/7] powerpc: Do not raise exception traps for fesetexcept/fesetexceptflag (BZ 30988) Adhemerval Zanella
2023-11-03 12:24 ` [PATCH 2/7] i686: Do not raise exception traps on fesetexcept (BZ 30989) Adhemerval Zanella
2023-11-06 0:15 ` Bruno Haible
2023-11-06 11:24 ` Adhemerval Zanella Netto
2023-11-03 12:24 ` [PATCH 3/7] x86: Do not raises floating-point exception traps on fesetexceptflag (BZ 30990) Adhemerval Zanella
2023-11-06 0:17 ` Bruno Haible
2023-11-06 11:24 ` Adhemerval Zanella Netto
2023-11-03 12:24 ` [PATCH 4/7] manual: Clarify undefined behavior of feenableexcept (BZ 31019) Adhemerval Zanella
2023-11-03 16:20 ` Joseph Myers
2023-11-06 0:17 ` Bruno Haible
2023-11-06 11:25 ` Adhemerval Zanella Netto
2023-11-03 12:24 ` [PATCH 5/7] riscv: Fix feenvupdate with FE_DFL_ENV (BZ 31022) Adhemerval Zanella
2023-11-06 0:21 ` Bruno Haible
2023-11-06 11:28 ` Adhemerval Zanella Netto
2023-11-06 0:24 ` Bruno Haible
2023-11-06 11:32 ` Adhemerval Zanella Netto
2024-01-09 13:44 ` Szabolcs Nagy [this message]
2024-01-09 18:16 ` Adhemerval Zanella Netto
2023-11-03 12:24 ` [PATCH 6/7] alpha: Fix fesetexceptflag (BZ 30998) Adhemerval Zanella
2023-11-03 12:24 ` [PATCH 7/7] hppa: Fix undefined behaviour in feclearexcept (BZ 30983) Adhemerval Zanella
2023-11-06 0:25 ` [PATCH 0/7] Multiple floating-point environment fixes Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZZ1NpmWCqQ+HZSoV@arm.com \
--to=szabolcs.nagy@arm.com \
--cc=adhemerval.zanella@linaro.org \
--cc=bruno@clisp.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).