From patchwork Thu Dec 28 17:20:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 758609 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp4116352wrw; Thu, 28 Dec 2023 09:25:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdWL7zpmmeU9O1NvvL0rxkljz4NrQIVs5Ygp+ftYSH/l25cWENyG8IidsyFSqnB2tUqQEF X-Received: by 2002:ae9:c210:0:b0:77f:32ab:4989 with SMTP id j16-20020ae9c210000000b0077f32ab4989mr10503658qkg.133.1703784313152; Thu, 28 Dec 2023 09:25:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703784313; cv=pass; d=google.com; s=arc-20160816; b=ucrFTL2HFI0HvlIAiU5joISxM0AYqTEvmOvzjkMxp2XrZkIvivN8wVER2QnwsvLjLy PNpwlRlF/N41khDzIa2GkcMNg7HOB/W8nV26DS3peKgvKQwWYqKu9sFytMibWtxC4Oaa gJIFMgG6ssouKB9vx4aWJ69QJuCMquq+GK4eLlwPhIDncp+IdUYHxiuGLdkr0x4L6Fjo E10Tj/ZY33UzPI6MZ8ak6ML7lr1TRu0RFuJM5KMDT/cP4Py41fa9Qngn8uqOGPrNXWtp AIt2TP45ae54clFezmoLxKXSLHHKxoS41EeoOtvNElqBkARR9YCWgG7lb5hw6OFpmnxw GlJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=76aBXE3UrOPVF+O7d9VzYNthTJeLJTw6ogbUAjN8z+0=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=YoeBz9xuvLSC1q8tkqbLjGyNgMAftVK0EDaIhMUG3SKJVK6+Gi+maIv5QK5SsPCFyR 7zdR8Fv/d+s+O+TnmbMckTJQPYoVEgJ+aQ7TgAHDr2v/o40rABT9OitrVquc9OYCDKBB t34C8GiijHRyooVgAVxufxhKU94Gd6vvL8o8d/Lquae6ilwXP8TzIgJHeWWvQAgq8qaC lXnte+8pi0zYL1tFmBgud5Y/39kGTgmr7bDPE/OkOuZkNVFFyKJC4kIH4XrqbcnjUGxz 0e50wBT5mrp6mBf7HK6geMx+ii7PwdkE/iTUpTzzhbSkPFh11jrDZjzEjQTGm7hEqCIh IMZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SaWtldn/"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p26-20020a05620a113a00b0078155486896si5688365qkk.644.2023.12.28.09.25.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:25:13 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SaWtldn/"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3411385842C for ; Thu, 28 Dec 2023 17:25:12 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by sourceware.org (Postfix) with ESMTPS id C39E038582B3 for ; Thu, 28 Dec 2023 17:20:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C39E038582B3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C39E038582B3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784052; cv=none; b=tkl7m4dQZg2WCspwGkBRlYqpyiIRbt6pxHiliOuSr97LeKJ7Tv+LR4tIk5Y8KHLwMRV54WYTwm+r+9+WPdJfHRDVXoDGnivZBODrJl3Tb76HXELzrMLQc0Gb4P1CfE1x305W2qMS+e9mhe+NSm3m7j+vl/kIcA1rWWumJ3VG744= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703784052; c=relaxed/simple; bh=NO5XYk+qncsfEiGHVdntk+f4jc1W/NdZGwux3E14TC4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=v+C4SddEYw2EYLqt7ehzVLVmOIj0pv+QLIem63QhNw7KQqHdu1Q2NgYI8S21yFZGisGAunMUZ1iIhFOQxteKS63++hXHGs4ii120s4aMnUL2ND6ydC2caPzgcPRg5rOWoslI1lF7HVfx2oxdGLJhtUi1YzyUbPAN+7H/YFIouK0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-204520717b3so3526554fac.0 for ; Thu, 28 Dec 2023 09:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703784048; x=1704388848; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=76aBXE3UrOPVF+O7d9VzYNthTJeLJTw6ogbUAjN8z+0=; b=SaWtldn/FvbagikVsIIFDuanFVapTPuKPstGiRwy6T4ima2UhZk1PSEmZP8d0aMmOI I5M5Y6R9v4PNPJ6w7GnpwZfEhxh4QyTwWsmRllW/Bd8WoeGFWSexzgfnGW1+hlyl/Ots TIaN24KaCh8+nP1gM3ksoCdQZ9HWmDJmdsEWkqkzSZHLykI4XAWK+7MhodC0AmMXFxNH of6V8x9OiL9VZUkGUlgv0VEfu8A/UTxA79rDMsskPvqxjhfw9Fpjfh4pCg35nSHZDfqs SarZNPmKPhz1xDxvb3A9fAALTZq96Qb14t5UayYbwn+Wj68RMa7TO32oAirtQFZt0b3u hGOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703784048; x=1704388848; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=76aBXE3UrOPVF+O7d9VzYNthTJeLJTw6ogbUAjN8z+0=; b=q7KjCQli2LqrGVhnskE6tuvtXk292lU4uwe8oR3ilSq4iiWNq4eJVyj5V6AWl9FclT emApqvgjgFMFJLT8SG33c/3L0fKXBv0aasaXSCcMDdzkpkrTYHCJ4ZSpWxPOT5dECdev hU8G/BuZnXg0snp3f5jpbAvRGc7xLW9W5gO9yNwdn788oS/w8R/IcH9vBfYEDczio7p1 O0ffS4PcsXV/EFKJ1iL1nRxvLT5LSK03QQZOv+PHbIntpwpUTAjbJjpjHfTkG1YqLVUa baS6mXBmHSPMDfHHM5fD5iAjRDRRbbhYguE5Vc4TWtKZMPsAemycnvonMlcz9gW3+L2/ gVdw== X-Gm-Message-State: AOJu0YztAlzcEblQR/gTMlBuUCvaDcl97kv2n2sDx7yTDzOX6kJmUnP5 P/B2OxX8HLfsY8quEK07o0Q6khM4U62+NiixumuIcq5KI44= X-Received: by 2002:a05:6870:2194:b0:204:4093:b89b with SMTP id l20-20020a056870219400b002044093b89bmr12228921oae.31.1703784048180; Thu, 28 Dec 2023 09:20:48 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:bd9:84dc:8a87:ea0:57d7]) by smtp.gmail.com with ESMTPSA id q7-20020aa79827000000b006d9a94a03a8sm9593839pfl.77.2023.12.28.09.20.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 09:20:47 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 11/12] i386: Do not raise inexact exception on ceil/ceilf Date: Thu, 28 Dec 2023 14:20:25 -0300 Message-Id: <20231228172026.2013007-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> References: <20231228172026.2013007-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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+patch=linaro.org@sourceware.org It is not allowed anymore on ISO C23. Checked on x86_64-linux-gnu and i686-linux-gnu. --- sysdeps/i386/fpu/s_ceil.S | 34 ---------------------------------- sysdeps/i386/fpu/s_ceil.c | 38 ++++++++++++++++++++++++++++++++++++++ sysdeps/i386/fpu/s_ceilf.S | 34 ---------------------------------- sysdeps/i386/fpu/s_ceilf.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 68 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_ceil.S create mode 100644 sysdeps/i386/fpu/s_ceil.c delete mode 100644 sysdeps/i386/fpu/s_ceilf.S create mode 100644 sysdeps/i386/fpu/s_ceilf.c diff --git a/sysdeps/i386/fpu/s_ceil.S b/sysdeps/i386/fpu/s_ceil.S deleted file mode 100644 index 99984f9b8d..0000000000 --- a/sysdeps/i386/fpu/s_ceil.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_ceil.S,v 1.4 1995/05/08 23:52:13 jtc Exp $") - -ENTRY(__ceil) - fldl 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl 4(%esp),%edx - andl $0xfbff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__ceil) -libm_alias_double (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceil.c b/sysdeps/i386/fpu/s_ceil.c new file mode 100644 index 0000000000..ec948ef83f --- /dev/null +++ b/sysdeps/i386/fpu/s_ceil.c @@ -0,0 +1,38 @@ +/* Return smallest integral value not less than argument. i386 version. + Copyright (C) 2023 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 + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +double +__ceil (double x) +{ + fenv_t fenv; + double r; + + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_double (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceilf.S b/sysdeps/i386/fpu/s_ceilf.S deleted file mode 100644 index 03e8e22609..0000000000 --- a/sysdeps/i386/fpu/s_ceilf.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $") - -ENTRY(__ceilf) - flds 4(%esp) - subl $32,%esp - cfi_adjust_cfa_offset (32) - - fnstenv 4(%esp) /* store fpu environment */ - - /* We use here %edx although only the low 1 bits are defined. - But none of the operations should care and they are faster - than the 16 bit operations. */ - movl $0x0800,%edx /* round towards +oo */ - orl 4(%esp),%edx - andl $0xfbff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__ceilf) -libm_alias_float (__ceil, ceil) diff --git a/sysdeps/i386/fpu/s_ceilf.c b/sysdeps/i386/fpu/s_ceilf.c new file mode 100644 index 0000000000..36159610b2 --- /dev/null +++ b/sysdeps/i386/fpu/s_ceilf.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 version. + Copyright (C) 2023 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 + . */ + +#define NO_MATH_REDIRECT +#include +#include +#include + +float +__ceilf (float x) +{ + fenv_t fenv; + float r; + + libc_feholdexcept_setround_387 (&fenv, FE_UPWARD); + asm volatile ("frndint" : "=t" (r) : "0" (x)); + /* Preserve "invalid" exceptions from sNaN input. */ + fenv.__status_word |= libc_fetestexcept_387 (FE_INVALID); + libc_fesetenv_387 (&fenv); + + return r; +} +libm_alias_float (__ceil, ceil)