Re: [PATCH v3] LoongArch: fix missing trap for enabled exceptions on narrowing operation

Yury Khrustalev <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <[email protected]>
On Tue, Mar 24, 2026 at 03:22:59PM +0800, Xi Ruoyao wrote:
> The libc_feupdateenv_test macro is supposed to trap when the trap for a
> previously held exception is enabled.  But
> libc_feupdateenv_test_loongarch wasn't doing it properly: the comment
> claims "setting of the cause bits" would cause "the hardware to generate
> the exception" but that's simply not true for the LoongArch movgr2fcsr
> instruction.
> 
> To fix the issue, we need to call __feraiseexcept in case a held exception
> is enabled to trap.
> 
> Reviewed-by: caiyinyu <[email protected]>
> Signed-off-by: Xi Ruoyao <[email protected]>
> ---
>
> ...
>
> diff --git a/math/test-narrowing-trap.c b/math/test-narrowing-trap.c
> new file mode 100644
> index 0000000000..a483c4bf1a
> --- /dev/null
> +++ b/math/test-narrowing-trap.c
>
> ...
>
> +static int
> +do_test (void)
> +{
> +  pid_t pid;
> +
> +  if (!EXCEPTION_ENABLE_SUPPORTED (FE_INVALID))
> +    FAIL_UNSUPPORTED ("feenableexcept (FE_INVALID) not supported");

On AArch64 we have

  #define EXCEPTION_ENABLE_SUPPORTED(EXCEPT)	((EXCEPT) == 0)

Which means that this test will always be unsupported even if

  feenableexcept (FE_INVALID)

would return 0 (compare with math/test-fenv-preserve.c for example).

I think this check is not correct.

Thanks,
Yury
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.