From patchwork Tue Jan 16 08:31:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Cederman X-Patchwork-Id: 84165 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 905973858439 for ; Tue, 16 Jan 2024 08:32:37 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) by sourceware.org (Postfix) with ESMTPS id EF3D03858C29 for ; Tue, 16 Jan 2024 08:31:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF3D03858C29 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=gaisler.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gaisler.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EF3D03858C29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705393914; cv=none; b=c0NNwJ+VO54iPwLbcSUb9yimBC642PgQ1DfbBwOStTW835jtFFBnq7GSpY7bqYoLZ+IdkMMKyBlW1KeMGWMe8gWla1arDNAyKuIQcpqSmlwDMmgejbBni0R3lREYk7tc5zeXsj2U7QOuApZTBTDyy/wlJIW/g9TtVwwoFqEBx6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705393914; c=relaxed/simple; bh=w4aP6toJ61JO3Ipr/B+PTp5lE2SzkhDf7Y5rMKc4OJQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=XF6/3Aluf1bAoUYKPLqIVhKx2uI9Gfp68fsYEfsn5wRoBKB81BqcqzgXT9NUxeA9FhEBjjnbX/DoQwJC1IVk06iYIM+xYwutVOwJIl5oPW/v6jH32U6PmdJVI2S0XMak9BD1CGX7FRv7Jeom23oxQF2kijB1s/csU0e+b1YU/hA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4TDj0g58xnz67wS; Tue, 16 Jan 2024 09:31:47 +0100 (CET) Received: from cederman.got.gaisler.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4TDj0g3lLkz67ss; Tue, 16 Jan 2024 09:31:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=unoeuro; t=1705393907; bh=/QvvkLaVYEiwse1CEVSUu1HThlzHzeQsccp8g9lCAok=; h=From:To:Cc:Subject:Date; b=YldV2cBGdQ6DuyEIkSBvaD11exC8c/o0LqeizS+HEDcHDmqb/RHvc4OlxAgrQP25O 5KNmlnmA/wmhF47vHuF/cKLGBoMdevAOiYLVG4M19pbY39uRbOX1+4b8UbTbMy24A4 8fzqK40VhltJ/W0dP2e6atZxsB/PlsoMBGsS6TRI= From: Daniel Cederman To: libc-alpha@sourceware.org Cc: daniel@gaisler.com, andreas@gaisler.com Subject: [PATCH v2] sparc: Fix llrint and llround missing exceptions on SPARC V8 Date: Tue, 16 Jan 2024 09:31:40 +0100 Message-Id: <20240116083141.3395401-1-cederman@gaisler.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Conversions from a float to a long long on SPARC v8 uses a libgcc function that may not raise the correct exceptions on overflow. It also may raise spurious "inexact" exceptions on non overflow cases. This patch fixes the problem in the same way as for RV32. Signed-off-by: Daniel Cederman Reviewed-by: Adhemerval Zanella --- .../sparc32/fpu/fix-fp-int-convert-overflow.h | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 sysdeps/sparc/sparc32/fpu/fix-fp-int-convert-overflow.h diff --git a/sysdeps/sparc/sparc32/fpu/fix-fp-int-convert-overflow.h b/sysdeps/sparc/sparc32/fpu/fix-fp-int-convert-overflow.h new file mode 100644 index 0000000000..4ed2f16a5f --- /dev/null +++ b/sysdeps/sparc/sparc32/fpu/fix-fp-int-convert-overflow.h @@ -0,0 +1,43 @@ +/* Fix for conversion of floating point to integer overflow. SPARC32 version. + Copyright (C) 2015-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef FIX_FP_INT_CONVERT_OVERFLOW_H +#define FIX_FP_INT_CONVERT_OVERFLOW_H 1 + +/* Define these macros to 1 to workaround conversions of out-of-range + floating-point numbers to integer types failing to raise the + "invalid" exception, or raising spurious "inexact" or other + exceptions. */ + +#define FIX_FLT_LONG_CONVERT_OVERFLOW 0 +#define FIX_DBL_LONG_CONVERT_OVERFLOW 0 +#define FIX_LDBL_LONG_CONVERT_OVERFLOW 0 +#define FIX_LDBL_LLONG_CONVERT_OVERFLOW 0 +#define FIX_FLT128_LONG_CONVERT_OVERFLOW 0 +#define FIX_FLT128_LLONG_CONVERT_OVERFLOW 0 +/* For sparcv9 compiler generates fdtox/fstox for floating point to + integer generation. */ +#ifdef __sparcv9 +# define FIX_FLT_LLONG_CONVERT_OVERFLOW 0 +# define FIX_DBL_LLONG_CONVERT_OVERFLOW 0 +#else +# define FIX_FLT_LLONG_CONVERT_OVERFLOW 1 +# define FIX_DBL_LLONG_CONVERT_OVERFLOW 1 +#endif + +#endif /* fix-fp-int-convert-overflow.h */