From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id A3D473858C74 for ; Fri, 27 Jan 2023 08:53:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A3D473858C74 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-lf1-x12b.google.com with SMTP id y25so7061886lfa.9 for ; Fri, 27 Jan 2023 00:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=mime-version:user-agent:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=msGpIbvnoP48sL9UKK1ppZYycWwbIlEBvNH25GSIvpM=; b=hOwHrTEmbVQIlQKv0lTd71P/fsWCU2zFF/PLaitLWVKWoKlTZdtROxNGeTbaCyQCQQ aUSKiHoa5VBP3fMjSYRFJU49squ3tZLHCugBUykCvkRDJoLZZqrnhXpMlPSoy63s1Zfh qR7CHeAMaaXNasDxhGknOxPHj45TAwlOqVxPQXNEjuIQQdnOV5xExyPrHRS1AGlhjl9q EOMPyxus1suaRzpqxgo7ZNFo/A33SL6Xk7HJ8Qe/uO7tcaRWWsAPAQ4ywDxd+a97FTlR bMdTa7k6fwh9DUervR4orWf3FtIx+cI8v+22+rEuOa6bhTw+ZSlIEG7E+5+TA58R3gEE Y4DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=msGpIbvnoP48sL9UKK1ppZYycWwbIlEBvNH25GSIvpM=; b=AFqlr8qCAy/bZu7x6KAJBjp9IsPKldUiHNCP2Waa01y02yZ8kLkl+m2lt+lzULzbEQ vEp3sLAZkqQHGdtTKVH13KrlwoLjJXCvT8CpfArv+UompdyI/fc7U3/bow6lMEHwk3BC BtpZXEoHIXAwUibPfKA0wzzuSHsJ5mcpFjP5JD/MtqKLnJnXJJugD0UUDmYWr5rj4yuk tznOob5SxqPg0EDXthwSyny9vRJ3OBWrm7QVUoQqGnG2TDaPrmIM6Gd9vW8ruMOe9Fvl LS8ZH6UZ8iRWGITceALF8NZnuWfLqcktR/93Ygb7kxXpFuhEi5AFs2WFr1evrpQug15m 4gsg== X-Gm-Message-State: AFqh2kroOTwu6/MJJGA8oKPhMouiCg+4ZcNGPMenic1/WpJDQ2pQ9NxQ yu8FVk4Aqh1uJyVFt9/SkMmXAxh7SXklAclX X-Google-Smtp-Source: AMrXdXsnNho+0I6bZ/8n6ndl5dL6W6xrf3amuYWAYCrIr9ilVYd9CwIVRM7VOuxQroo0SHN/Jwaz/w== X-Received: by 2002:ac2:5a0a:0:b0:4a4:68b9:60ae with SMTP id q10-20020ac25a0a000000b004a468b960aemr9744496lfn.57.1674809618183; Fri, 27 Jan 2023 00:53:38 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id t3-20020a056512068300b004b550c26949sm222872lfe.290.2023.01.27.00.53.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Jan 2023 00:53:37 -0800 (PST) Date: Fri, 27 Jan 2023 08:53:35 +0000 (GMT) From: "Maciej W. Rozycki" To: newlib@sourceware.org cc: Kito Cheng Subject: [PATCH] RISC-V: Fix floating-point environment support for soft float Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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: 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 References: [1] "Programming languages -- C", ISO/IEC 9899:2023, working draft -- September 3, 2022, Section 7.6 "Floating-point environment " Fixes: 7040b2de0883 ("Add RISC-V port for libm") Signed-off-by: Maciej W. Rozycki --- newlib/libc/machine/riscv/sys/fenv.h | 9 +++++++++ 1 file changed, 9 insertions(+) newlib-riscv-fenv-soft-float.diff Index: newlib/newlib/libc/machine/riscv/sys/fenv.h =================================================================== --- newlib.orig/newlib/libc/machine/riscv/sys/fenv.h +++ newlib/newlib/libc/machine/riscv/sys/fenv.h @@ -14,6 +14,8 @@ #include +#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." */ +#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;