From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id E3ED63858C74; Fri, 27 Jan 2023 13:25:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3ED63858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674825955; bh=uFpuvPLNEwhKUGkSIX+TgFBReULY5onOI3KC0V738xs=; h=From:To:Subject:Date:From; b=OL1yz110w4h+lKN9QD2YDq71jar7Blzoam/CeidbHxETPyTogWGuQ8tX+eh9C8tiL KgwBwGaRe5MrxSsR6lbMXkfIuuaDJba9NghiEB8kdZhg9vlYfpN8kmRoA5NnpANNkT HhulC7PO0Kp6F60eyXFKpuNYS7NVEnliK2/I0l/g= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin/main] RISC-V: Fix floating-point environment support for soft float X-Act-Checkin: newlib-cygwin X-Git-Author: Maciej W. Rozycki X-Git-Refname: refs/heads/main X-Git-Oldrev: 28594480df73bbed642b4471445fa106ee387730 X-Git-Newrev: 963d6c79ead3941b399e3549bc753c2cb90ab79b Message-Id: <20230127132555.E3ED63858C74@sourceware.org> Date: Fri, 27 Jan 2023 13:25:55 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D963d6c79ead= 3941b399e3549bc753c2cb90ab79b commit 963d6c79ead3941b399e3549bc753c2cb90ab79b Author: Maciej W. Rozycki AuthorDate: Fri Jan 27 08:53:35 2023 +0000 Commit: Corinna Vinschen CommitDate: Fri Jan 27 14:25:44 2023 +0100 RISC-V: Fix floating-point environment support for soft float =20 We don't have floating-point exception or non-default rounding mode support for the RISC-V soft-float environment, `feraiseexcept' and `fesetround' do nothing unless the `__riscv_flen' macro has been set. Therefore following ISO C language requirements[1] only define macros for soft float that correspond to actually supported floating-point environment features, removing failures from GCC testing such as: =20 FAIL: gcc.dg/torture/fp-int-convert-timode-3.c -O0 execution test FAIL: gcc.dg/torture/fp-int-convert-timode-4.c -O0 execution test =20 References: =20 [1] "Programming languages -- C", ISO/IEC 9899:2023, working draft -- September 3, 2022, Section 7.6 "Floating-point environment " =20 Fixes: 7040b2de0883 ("Add RISC-V port for libm") Signed-off-by: Maciej W. Rozycki Diff: --- newlib/libc/machine/riscv/sys/fenv.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/newlib/libc/machine/riscv/sys/fenv.h b/newlib/libc/machine/ris= cv/sys/fenv.h index 6cbd321f3499..772f3833f4a4 100644 --- a/newlib/libc/machine/riscv/sys/fenv.h +++ b/newlib/libc/machine/riscv/sys/fenv.h @@ -14,6 +14,8 @@ =20 #include =20 +#if __riscv_flen + /* Per "The RISC-V Instruction Set Manual: Volume I: User-Level ISA: * Version 2.1", Section 8.2, "Floating-Point Control and Status * Register": @@ -69,6 +71,13 @@ * floating-point unit." */ =20 +#else /* !__riscv_flen */ + +#define FE_ALL_EXCEPT 0x00000000 +#define FE_TONEAREST 0x00000000 + +#endif /* !__riscv_flen */ + typedef size_t fenv_t; typedef size_t fexcept_t; extern const fenv_t fe_dfl_env;