[PATCH v3] LoongArch: fix missing trap for enabled exceptions on narrowing operation
Yury Khrustalev
yury.khrustalev@arm.com
Tue Jul 7 12:46:09 GMT 2026
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 <caiyinyu@loongson.cn>
> Signed-off-by: Xi Ruoyao <xry111@xry111.site>
> ---
>
> ...
>
> 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
More information about the Libc-alpha
mailing list