From patchwork Wed Apr 3 12:11:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 785429 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp282219wro; Wed, 3 Apr 2024 05:12:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWLURcMRD1U+cLMA3+L8itu6vI8vdXkuDMX+GdE1rxDDdlegVHURMYkbdJP0dSf5fFlILTBtNA33yGHFayMooaq X-Google-Smtp-Source: AGHT+IHrFvzxZfWabdE1mZP2Nb5m5B5yCiBD197xa+FpyBd4rVsRKu6PNqNWZ5+rHLkeHS6DjA9b X-Received: by 2002:a05:620a:3184:b0:78a:2e68:7737 with SMTP id bi4-20020a05620a318400b0078a2e687737mr3798531qkb.18.1712146332077; Wed, 03 Apr 2024 05:12:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146332; cv=pass; d=google.com; s=arc-20160816; b=1CuNqqm6AsuRN3+de4/+7/JO8GBFYZnkx7lh7yhwawyDttwgPwR8dQSz4xVM/71zbf 5/28MSF4iKa/Nt8BmD4REmtZIlx91XQM3VQEOBgjLHzkHBWCikKiJ8Bsc0T5a6biIdI4 xzO0zduw8OiZZYyQedUqR5O0gJf7ag/JH5t9uakpLRWcXkm5rJy2jEH7smQUWcjfRxjZ 1PSPfxzSsjwbgRialKnEPrU1bCWs0Jb8K+yEyVSboI+FtASr/LIQHbT6XfkMQuks7zFL DiQB1tszGT/+BDGBNywFMNeDaeloAOQtIsoB8wjn3oYzdxSsslzUIhP8b+/8i+J2KfDY CEgw== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=yBnoKiREZAyF9WtfBKTXBXVceZfthbag9bfH0AMnsjE=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=mT/1WwSgldi8fEtHFCP1Js8LUe/eFarMD9eCFfdJZfRjX+aZ0UIc0ZzVryBm43XxqW NpQL7CAftowXfN8VP67yyVMJHh3Fy30XcZyghL7d2dLmn3lkaGe09Stb10TEgSlmHA/N bp8bV40F4XXmHjQ0MAkKwVXDjddcguAekl4kmpQ4/ey6QHonmXnOrdznvGIIn3TF7UwS 8eo6W0L+9PluCDxJtRKKVaoS1bXN8lH1OQ8dbww6pnA6v2nAZh2uoXEm7QqE0lOdk+2F 7VYnZImFGOutkKGmf3Ln7mivxR4k1lB/PiN1OAK/FJtqKHX0MSBdodE3SrTfcWHIRJ/6 z64Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i2EzMC5v; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id t4-20020a05620a0b0400b0078a15896c19si14112139qkg.213.2024.04.03.05.12.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:12 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i2EzMC5v; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 A7E163846410 for ; Wed, 3 Apr 2024 12:12:11 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id D7EC63847725 for ; Wed, 3 Apr 2024 12:11:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7EC63847725 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 D7EC63847725 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146320; cv=none; b=wXCF0C8iMEqZKo5zqNEgtIzmttqg7U1IhqpHifKMSFG9IoSjRBa56REJpqJrGodjf5qgfqTZHNdXyNzdjRsT06yAjGLsFoNrjQZ0/ordPhbOT/A4F1RlYi72tJQ2VmJuk7aWv/3Zsq68Mq3IGQBPLzgrpCWm0OPCFThIi+PCeDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146320; c=relaxed/simple; bh=eN0lZB1bJCCwhPaRpSK8cFENwqHODXINub32tPEfFuQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=p6/9+YR3bJE3tp10oBb6RQR6B8srfw5AP85YH/EOeAUYcdS9XphT/pkEJt7tb3lFwHB8gkAHKY93M0j/H+4trhdT9RNvtTfs9t51dAp7PR+DJybuxvGmUi0PK8v+OVOXEo8SYTn6DN3VIqyjetLwf0niiwQetsLf0oK3kuzzKCc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5f034b4dcecso654507a12.1 for ; Wed, 03 Apr 2024 05:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146316; x=1712751116; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yBnoKiREZAyF9WtfBKTXBXVceZfthbag9bfH0AMnsjE=; b=i2EzMC5v6DraL1S/tBebeGW1J1ky95JDJZpFYj0TgRDJxsekHr96CT+vijgECkER8+ nVpaTSWj2Q2mJoVSssvGIHsU+G9pWY5DHhuHDdzj+FoEPdxXD3OFNlYvVmo0lhPjIS76 9sXp1kMuw3ljGfJFyjutEGavqCTjQNywSrif+YTj/Q70aK2J2aVbBQzGoyXw86JEtEZi mFS8JrQ4Ezy9KVo86RzxgcbBWl3MWRdWJJUZZzu+1atT0f7K82eZ2BXHC3oUkwbkX3KB PvhS7UvJliVrwdpAvwYGIWPu1BcNSYUdXBdJnHZc+o0osPPDRvhvqAoa7Cwh8baN1IPB NDvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146316; x=1712751116; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yBnoKiREZAyF9WtfBKTXBXVceZfthbag9bfH0AMnsjE=; b=k0UcJ1wSCQb/6v+QBL4r6IROLgusvtSJJiYqGwrr6PpvYwj5oMNwgYdSGXiGmdw5jQ ixajjjoRoRUh8JW6uRAjOStEt7UWyLSvLdQa6frvEKeSbfSN9IXoVmiYzCFmhufbKGxl b91JJ/BTYsMTwsvLHUGjJHkbjla99MN5rkFrJKbUpHbxdhltROy1Aubp5+Uabi9xJ5Up l/d9kH1Fsl0EF8JyKUhPtx/EjH8M1yOyZ0pMeOmkPNpweUfsxcdL0qu0aYA7vHD+6ANh j4vhr/4VFkVetPN5azNjelus35ZSZRGlv3Ya0ff3LAtm1OW3j4uOq1A23sJWjdZX/zQq /6IA== X-Gm-Message-State: AOJu0Yy2oboDAcR2rdChjbshzqWezBQ2w+DsFJ0SkGDIJH3LhulQuNec jDyq3LylTWFKCh7mFtzZ6wdLCa4tyMjHWILzhG5vhvn+VTWdNf3M0pV1PnMQr0q9ED83GxI17Jf M X-Received: by 2002:a17:90a:b884:b0:29b:c31:1fe1 with SMTP id o4-20020a17090ab88400b0029b0c311fe1mr3313750pjr.10.1712146316183; Wed, 03 Apr 2024 05:11:56 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:12db:8f9c:da5:36ce]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b0029ffcf1df72sm13574141pjo.38.2024.04.03.05.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:11:55 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 01/10] math: Add test to check if ceil raise inexact floating-point exception Date: Wed, 3 Apr 2024 09:11:41 -0300 Message-Id: <20240403121150.1018799-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> References: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 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 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. Reviewed-by: H.J. Lu --- math/Makefile | 5 +++ math/test-ceil-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-ceil-except.c | 85 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 math/test-ceil-except-2.c create mode 100644 math/test-ceil-except.c diff --git a/math/Makefile b/math/Makefile index 121a709121..1017026d23 100644 --- a/math/Makefile +++ b/math/Makefile @@ -498,6 +498,8 @@ tests = \ bug-nextafter \ bug-nexttoward \ bug-tgmath1 \ + test-ceil-except \ + test-ceil-except-2 \ test-femode \ test-femode-traps \ test-fenv basic-test \ @@ -989,6 +991,9 @@ CFLAGS-test-fe-snans-always-signal.c += $(config-cflags-signaling-nans) CFLAGS-test-nan-const.c += -fno-builtin +CFLAGS-test-ceil-except.c += -fno-builtin +CFLAGS-test-ceil-except-2.c += -fno-builtin + include ../Rules gen-all-calls = $(gen-libm-calls) $(gen-calls) diff --git a/math/test-ceil-except-2.c b/math/test-ceil-except-2.c new file mode 100644 index 0000000000..394a272d89 --- /dev/null +++ b/math/test-ceil-except-2.c @@ -0,0 +1,67 @@ +/* Test ceil functions do not disable exception traps. + Copyright (C) 2024 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 + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* ceil must work when traps on "inexact" are enabled. */ \ + b = ceil ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-ceil-except.c b/math/test-ceil-except.c new file mode 100644 index 0000000000..f7627506f7 --- /dev/null +++ b/math/test-ceil-except.c @@ -0,0 +1,85 @@ +/* Test ceil functions do not clear exceptions. + Copyright (C) 2024 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 + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* ceil must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = ceil ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = ceil ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Wed Apr 3 12:11:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 785433 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp282810wro; Wed, 3 Apr 2024 05:13:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkRpkgeq5Wq8G5enuRmUKj7RuArUCKRO7zOThJwD5j/DJUaG+BcXJJhbn++xu4esJwBiyWhPmd3/LRAof+i69O X-Google-Smtp-Source: AGHT+IER78DhoZ8dkdahFcj4NuWtzNBW9Hqw7DQ323ey0lJm+WjDz87nQZZWdJp4ZE1InCzNMoPc X-Received: by 2002:a0c:a609:0:b0:699:29e0:10b4 with SMTP id s9-20020a0ca609000000b0069929e010b4mr1667492qva.13.1712146414225; Wed, 03 Apr 2024 05:13:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146414; cv=pass; d=google.com; s=arc-20160816; b=NbSECN649uTMh3kG5iJArKTWGo9GCN20Hgp7x8Y8916Kpy/A3QbO6E0ErpzNHhGWIm CGGKhAjnP8uRq96mF5l6fhmzWzITWi5HEgZox1JRoK+fhpzTSyHrvQLJHVTUVNs1+wCE dJgtla4N/yUaCS4TgMLMYauaH8p6vCTGtUtMRIEFTybfcIYok7y4fk1NtFpzEnjHQD8i HstnGtO/ZPXxgp3ObmNv4M2LczjCwPqohW0DJ1yHsMzaWLA6Cwnj4gbYs+odneWBNK9s 5e64K0XPoKS3aDNnIn4gIFZmKbCqMPsnHjST2Hv7QJJPLHQLGcGeI8NujNft7waiDVgO lweg== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=2Wmvo2Adv4jQNImqTSnIjebzrJ3rq6/wUO8Oni2XBzY=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=Yda+iY2GeU5CmI5Ox+vfrDQRRHAzeHAJ2tWiP4rfLjiZ25tzdcYgO1L9QAHncJrp7d SkHeyWtYfuqsRZIi1nvM+kwW7jIG/di4o39rV2TT2tri8vwktbobaofPLldBYJ65riVZ b6aij/yQtAoBUyVavhnK98FBloIulstO2bguNFVYblvvojmIdTMtvLBUX+raaDIvvTF0 TDrE/nDBQhkn5OHN0ChLFw3Oh4yJ2vhz/PW+ZRKASu/R9IoOl33jWi1+BgPLQTtYAPlO riJw3AnptvOjZwGjBElqKh/aHo806ukF+qJ2daXzNgPhlWf9sjzUPBs9ONJTrAfhrOfO sJTw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LkOvmSc3; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id cn7-20020ad44a67000000b0069921262cafsi2775823qvb.225.2024.04.03.05.13.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:13:34 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LkOvmSc3; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 C83673846424 for ; Wed, 3 Apr 2024 12:13:33 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id 5DC21384772F for ; Wed, 3 Apr 2024 12:11:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5DC21384772F 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 5DC21384772F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146321; cv=none; b=O3g0oXMM3w6CnHzQxKdk4kWUF+WRXFtWt/EbrWyUXW8fnfnpvUVx1BzEaaeb0ycbKmGtiMth45wFXvtE475PXU9wQkha8hiOs6gB0OQKNBllU6njOCANK67/BuDM4s+uXhostx5RfM/F5+vBNQ4p1iyo+TsS6tbfADdf7DjobIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146321; c=relaxed/simple; bh=vsQl7O/WiQ0wDy3oyjyrsGReBYl6UuGhJ4sbZFY0r7Y=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=YxFIzVV4StG5/LbxF3ff9FQoW2A/Pv1U9/zK+P946GxqSzpb1rIHK1YIfhrVuivxlRjXa/AMXSS5acxbfX4VzYSx2XEVZWfKYlcueF2TPVsp/LVmxbOlwxw94C98hin6c2FnPJzVHEzZPWfs+2mCAi87IxVplvw7hbwTCHW7Ykw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5c66b093b86so706142a12.0 for ; Wed, 03 Apr 2024 05:11:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146318; x=1712751118; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2Wmvo2Adv4jQNImqTSnIjebzrJ3rq6/wUO8Oni2XBzY=; b=LkOvmSc3aXHKdMnB0N56IjEVkVVa2DuSRPC/m6nB2YfqfuWzn79rcGY2KOLKiomD0H 0Pvq7ygYIFCAWgo/x+dfrGzN1cWBtQbf5jKzJSxvMZs9uhwXVN6t8WnKREbO562yBVsF 5kequGootNzaKOO2+cyT8zLvk9ii1urRso44yhhnhAhQKd2aXE0Ak77gtKvndZIWKl/n 38wOPyFL9rvYz76IaizIccJ8hHE90Tx+6s8W0vOu4hFDpBD7xx9H0WdyK+/Hv35O02zu cxX2xTLg71tnn24vSXfFdvgG9PNQlzS1BXGubfW6A7duIrGPg1YKD3Q02COpfEPZSgwK NdGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146318; x=1712751118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Wmvo2Adv4jQNImqTSnIjebzrJ3rq6/wUO8Oni2XBzY=; b=J4HXdZC8F79Hlw4y7fc/+Q8sosvRdYi6tPcfTLLX+xt9phVcJ5T9A8awGFrwe+OE4w zVfONfbHDufRuGtFkccdHY/K4QfoYSKGy3zPkKZTnD4+j0CziYBniR5BYyQ5TnI8/fJQ 1nvWLHaU7gf/9zxMkLm+huhpwNkvKhmV6m/pFnpKjVOzYGBhWRW0rzAJgM2FNsrho9DQ kQiXx+NbjbY3TWysDc4g5U2EFkJQua1ifCeMsyIHosDoc6H/atyDWKw+BlzayHF7wK+6 MAF6d2cKzaVPcGBTiqebMAZ/AUN+i65KkKz2q9uwqgoqQzQr5rd6j7V/GtgJr6fuYWOE /Kmw== X-Gm-Message-State: AOJu0YwBNd6xdaXS7c1tkS9psoiVPMboWhWvIwX+0aUdMUxlDtC5NuK0 sehe7m+u0ZWu+eCDUdFyBv+n2aoCplyg4nHi8UGLd7lqgps9qv/zYIUCkIStZdp+AbqZftfTWDf Z X-Received: by 2002:a17:90a:df85:b0:2a0:8d17:948d with SMTP id p5-20020a17090adf8500b002a08d17948dmr3140791pjv.1.1712146317820; Wed, 03 Apr 2024 05:11:57 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:12db:8f9c:da5:36ce]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b0029ffcf1df72sm13574141pjo.38.2024.04.03.05.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:11:57 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 02/10] math: Add test to check if floor raise inexact floating-point exception Date: Wed, 3 Apr 2024 09:11:42 -0300 Message-Id: <20240403121150.1018799-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> References: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 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 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. Reviewed-by: H.J. Lu --- math/Makefile | 4 ++ math/test-floor-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-floor-except.c | 85 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 math/test-floor-except-2.c create mode 100644 math/test-floor-except.c diff --git a/math/Makefile b/math/Makefile index 1017026d23..8ab2582d69 100644 --- a/math/Makefile +++ b/math/Makefile @@ -512,6 +512,8 @@ tests = \ test-fetestexceptflag \ test-fexcept \ test-fexcept-traps \ + test-floor-except \ + test-floor-except-2 \ test-flt-eval-method \ test-fp-ilogb-constants \ test-fp-llogb-constants \ @@ -993,6 +995,8 @@ CFLAGS-test-nan-const.c += -fno-builtin CFLAGS-test-ceil-except.c += -fno-builtin CFLAGS-test-ceil-except-2.c += -fno-builtin +CFLAGS-test-floor-except.c += -fno-builtin +CFLAGS-test-floor-except-2.c += -fno-builtin include ../Rules diff --git a/math/test-floor-except-2.c b/math/test-floor-except-2.c new file mode 100644 index 0000000000..d99e835909 --- /dev/null +++ b/math/test-floor-except-2.c @@ -0,0 +1,67 @@ +/* Test floor functions do not disable exception traps. + Copyright (C) 2024 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 + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* floor must work when traps on "inexact" are enabled. */ \ + b = floor ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-floor-except.c b/math/test-floor-except.c new file mode 100644 index 0000000000..a957c059e2 --- /dev/null +++ b/math/test-floor-except.c @@ -0,0 +1,85 @@ +/* Test floor functions do not clear exceptions. + Copyright (C) 2024 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 + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* floor must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = floor ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = floor ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Wed Apr 3 12:11:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 785430 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp282449wro; Wed, 3 Apr 2024 05:12:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3tHYiUK1fFZIld/vzTeiXYGvTa9aVtiwNcWPBAwb4AhmKN6/N0J/3ho03qsDZRLNJleobUAiibKKObHHCLC39 X-Google-Smtp-Source: AGHT+IFq+/osRj8lHJoJXzC1dx/dVI4QKlBcG3XLgpz86nzWfb3w4Set4PiJK7ifsJzcS6dMWjec X-Received: by 2002:a0c:9c0a:0:b0:690:c629:348d with SMTP id v10-20020a0c9c0a000000b00690c629348dmr11452761qve.36.1712146363934; Wed, 03 Apr 2024 05:12:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146363; cv=pass; d=google.com; s=arc-20160816; b=FyDBGErNpzKR+dAfS6huIaQoV0ZW+ACJrbyVXgeeq4yoF/yXC9Ewo+khoK3aS2wnom PmFJ1w/pB+H/clNz5urDXIrsSkNAxRVmqVLNuaXJx4vvqilgfJEpozsWwWjZZ3aw91mH BoIXkMGTIXvqXQxVdzfsaDXF6hWBRJ/4/wCLTTfcUP525rVkQkT+7STxbamJaQCX9dzU LCNM5wJNpIKzyTYqGxHbI9CjGGwrDU8xIgjBHvGuWTzxVtsd16EcUuLpcVEyrYmuXD0x r+F+E7jjpyTtChfA37GU+F/uEUzUJGWAqXzxYjlydeFm1X+ZX5zXuC3ims/QnMtp8YnV hOfQ== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=sJVUwPw+o65swr4NFl6cBc/HD+KLB28CZeANdJyKx8E=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=gRDfDDaG+7Nyv0AbN5KC3wYrDosvKdtWjuqv7QAzDZg2eacK8+RJJHKJQaM73ueweb ZpaMJNvpzCb81xe6oY3yxsp4NOPX5ce3DcQuQTRNwK7GV4XjZ7YrcXnERQbTYJaRTODD UAp8zbuStbTXGgemFrSBdIOTIwNb/m3wLSInCpAKMhwIYmdcv++eykmyrbfc7Zxg6+M4 XvJg1rB07cRN9ilQMHIY3Wfl7EHx9FXWxlCWpQUmjiih1gJSYVdcyILPjvfY97XyNk0s 3A3vrGY17dL6o83ig3nEnNQ1/FmuLS2TdgQRhfbvcupb5Er0uNO7+x6IlqrDNEVfJ8po hRNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PiGa3x6U; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c4-20020a056214004400b0069693c5d18esi14023612qvr.224.2024.04.03.05.12.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PiGa3x6U; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 22B193846070 for ; Wed, 3 Apr 2024 12:12:41 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id 45CD4384645B for ; Wed, 3 Apr 2024 12:12:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 45CD4384645B 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 45CD4384645B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1035 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146323; cv=none; b=h1CRmOSMbptCIa7+XDse8fmmuNcFzFuuHhGLdg1KzSE3tC03KDsyxtr3+cFw8o7FyNLpSTtxn8CiRwvVVmruVOelZwe+npDfD/gWdTg3fylD48fYx91kKkq5uEQM0skhRHIZVPJAbDO8Z+OsBlTnMLiKv+ZudUdCzc9VoE4/qfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146323; c=relaxed/simple; bh=sxputx73PIDlJw0P7KhCzWKPQQe3kMVUggcSiA1MGNM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=maZ5gJ7h76hhbLYed87mKZJSYFs75JF4VLEjNHEj9PiJeCagsTuuUfdv2Y5ANoyHEpOyeXp/spwNhXf6E+D+Z6R0G890gCRX4TaW0TQh4p0nmmq9OHAqpeu4OYhF9j2l35MLNPETZg6f/v3QAYPkbgVUD3dpu1KQABmyRyjNAYA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-2a266edbeb0so1157945a91.1 for ; Wed, 03 Apr 2024 05:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146319; x=1712751119; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sJVUwPw+o65swr4NFl6cBc/HD+KLB28CZeANdJyKx8E=; b=PiGa3x6Uu838gD4qjIrIWdLZ8xDR1cFtLg7LArFLQ7zuoHwUpoM8jM8s5/udqhHWFN Q8H2PvoBoYNQgUKnKerl/svc1IHpo7Bp1MgQw+unhoz/oDFbnCTtnedLu3J3gafit3A5 S7kprlYde4olGMzhfwjQGZkDdckSClnGS70M6A8wi6GMv06fv632el6SyC0gcdUS67uD PtWq4+ehaznpIr4Er8bDLFE2VXUjfLDH7YCuQOF3qgxsB7FHN5D7ANfjnMeZj2gUOl0a 8cyJqm3lbzZG+LiVtgzpCICl6Q9/yrtibnFfyQwaoRNUzIAX0RjWF4Nw5jSm8pSj6/0W JvvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146319; x=1712751119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sJVUwPw+o65swr4NFl6cBc/HD+KLB28CZeANdJyKx8E=; b=kuRrHRjWmO4QR+hIXXP8vX2SbwVb35AtmvBwLYSdphnoYN87Mxve4Te+GPtimDy5ts tOFt0LMiHDm3U4q3rVbLRIyTI7AeC5s+4WVt5ViZkV6VgDJ5odkdjlp3j9ZofZLrKOnJ lFo+mD6YB270jkUigz9vREpX8zverBLYFRXBB2qWvSmrCdtSxESvdHNf2JZXMX7FIL1u KFr3TKGjFP0iGopVX9Pz60JemAIX94pCpzUWFAYviA5o54O13ryh5nh/D93fE92M+v5f TQJDSZzyRM8gzTrjeY++tWerhDLf5UF9xPmH5N/zz9QUdQ14nSkMWF+tlL3wPPS9lFG4 OrDA== X-Gm-Message-State: AOJu0Ywb/4dCdb8ixUfkGLwIXvTnmDk16b5RvJ+wfXfwqwpjDHsp2wpk pgH+iqsPLGJ3m4nzfdyTtxMLUhz00k0Cq4eA1H9W+pWB/8UIZeUKcbXHaPAC+1HlDqCCgSukkZ9 r X-Received: by 2002:a17:90a:49cf:b0:2a2:7356:674a with SMTP id l15-20020a17090a49cf00b002a27356674amr3128986pjm.45.1712146319502; Wed, 03 Apr 2024 05:11:59 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:12db:8f9c:da5:36ce]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b0029ffcf1df72sm13574141pjo.38.2024.04.03.05.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:11:58 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 03/10] math: Add test to check if trunc raise inexact floating-point exception Date: Wed, 3 Apr 2024 09:11:43 -0300 Message-Id: <20240403121150.1018799-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> References: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 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 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. Reviewed-by: H.J. Lu --- math/Makefile | 4 ++ math/test-trunc-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-trunc-except.c | 85 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 math/test-trunc-except-2.c create mode 100644 math/test-trunc-except.c diff --git a/math/Makefile b/math/Makefile index 8ab2582d69..32e3001ec6 100644 --- a/math/Makefile +++ b/math/Makefile @@ -541,6 +541,8 @@ tests = \ test-tgmath-int \ test-tgmath-ret \ test-tgmath2 \ + test-trunc-except \ + test-trunc-except-2 \ tst-CMPLX \ tst-CMPLX2 \ tst-definitions \ @@ -997,6 +999,8 @@ CFLAGS-test-ceil-except.c += -fno-builtin CFLAGS-test-ceil-except-2.c += -fno-builtin CFLAGS-test-floor-except.c += -fno-builtin CFLAGS-test-floor-except-2.c += -fno-builtin +CFLAGS-test-trunc-except.c += -fno-builtin +CFLAGS-test-trunc-except-2.c += -fno-builtin include ../Rules diff --git a/math/test-trunc-except-2.c b/math/test-trunc-except-2.c new file mode 100644 index 0000000000..8933c6ab41 --- /dev/null +++ b/math/test-trunc-except-2.c @@ -0,0 +1,67 @@ +/* Test trunc functions do not disable exception traps. + Copyright (C) 2024 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 + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* trunc must work when traps on "inexact" are enabled. */ \ + b = trunc ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-trunc-except.c b/math/test-trunc-except.c new file mode 100644 index 0000000000..ff909d79ed --- /dev/null +++ b/math/test-trunc-except.c @@ -0,0 +1,85 @@ +/* Test trunc functions do not clear exceptions. + Copyright (C) 2024 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 + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* trunc must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = trunc ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = trunc ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Wed Apr 3 12:11:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 785431 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp282494wro; Wed, 3 Apr 2024 05:12:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVIyT/uB7AXtKIcInprzyBOHWx3JPcuh4ixZRMHbLvuwsgnpqbaUrmtoWkqxnqK9jhFzrCK7tWR+c4iV3M1JuqK X-Google-Smtp-Source: AGHT+IGhGmxlZYbyTmxhqoMh8ibnAjM/OisB+yejmV5S7TOYm5DW4j2XWP9wHYUBBlZSmlP+LrMV X-Received: by 2002:a05:6870:c6a4:b0:22e:7d53:3982 with SMTP id cv36-20020a056870c6a400b0022e7d533982mr3432618oab.57.1712146371513; Wed, 03 Apr 2024 05:12:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146371; cv=pass; d=google.com; s=arc-20160816; b=C0ByvHmdGcoX5x+gM0gbgKPDOi/8Q4migntxhvZyWrIZj9qgG0y17ENUzEePR96sSl /8bpQdjIPHhI6/8Io5UhLfQp1aUvDDY9T6Yj3kFxd2TRL+NPvFeC7MOjOkTOvGUPsjNf 1cFWu68epqgB0ZqAJTlH74g31Vz46R1Ms/R3jnABSfaRHvfovkq6NcmB/IZEeq226FTG KNt5hGNMqrEioC0HUOL5kyVB1kftU6KrpCTofXRmANO8RRN+2KblQBfBT5Jjbf5Rg9vs AeMqLxH0OO9o1Nu4KHi11NQnzAx++bl2zTmMDzQefXgdqjdFlFvYQUlvI/AUOu9guo+L JmpQ== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=YuaDTYelRPiHDzZYji8KBqMrTg4A0gZWeICeGTV8ZhY=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=uGqvuy9y83vjZ5/QY3siZ0JkH+ooNmXfvrMEoZAmbI3WtpqLQdib3O3sVIz3Ohc6Mx zpw2vL70ZZJMv/c7gGk8nme9KmP1wIhrYlkd9IlV8uyyZhLEzZ2uBw0mZVV48tCDQ5n2 7eVlRXviRH+dNnUxV9nYvZ4v2kb5+xHbxjVyy0wwbLCaQ+zExHvuFkBSEldYtsSYk46V Vyuv5yndzRiujZv2lJhlhvxQjt8m32XAP26ciFd0EdJHldy13o9Ot/y5behEzmNG/YL4 BTwGq/H5VSqcN5Bwz65dnCDadOCkDiQSug5F7jzuOhhDF7XuaAHV8VD0Ad+JNC+5BAy6 v/PA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KjiI7uO7; 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 z14-20020a05622a060e00b0043174f5f443si247327qta.270.2024.04.03.05.12.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:51 -0700 (PDT) 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=KjiI7uO7; 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 209C5384772F for ; Wed, 3 Apr 2024 12:12:51 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id B20FF3846420 for ; Wed, 3 Apr 2024 12:12:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B20FF3846420 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 B20FF3846420 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146325; cv=none; b=VWvD7Xd2/A+VPTZZf5Nh+I6i+ua4bodEsggYmfP8oRi2z434o5X1cKSKeCM3Hi5/7qH4pRgmTLuJIFJxyRruEWME28oRMeSGvn/lYnX7dBXiLbFcejocb1dme+TYP+JfWZxuz+vaMge4Cbg8SWrtBe5gNQq1rc+vSccsTQLmLlk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146325; c=relaxed/simple; bh=RbJ+I2e43wuJhH9S2TMtsBJuBVaz1sg7KhFF8nnzBU4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=DDh0AWiw4Nu2ZqAq039O6kUwa+GuquvyLaNSQVBaxMLVp+sWu+TROpB9onA/DBNb5kgAkFd1fYUeLTh7u7PWx+sjB553CfNTsetu0wAYOYbm2Xmz27NHkIR3akyF7QFPwC0HxTn91YZcl5i8PDNxtVYSWzX3Pq/HPxbl8WgTcqE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-5dbf7b74402so3494212a12.0 for ; Wed, 03 Apr 2024 05:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146321; x=1712751121; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YuaDTYelRPiHDzZYji8KBqMrTg4A0gZWeICeGTV8ZhY=; b=KjiI7uO7EMK8QoTrgmPmC7dfUoXO5JhgIAxnJcfXbspHZlFwGHKzTP9JO4hxtkFzSH 8T/AgG0ennsov6QBir3IH6ixZXz4w0MWrHJV1aj3zzsKb7wI/rfNaEXKD9hZ2+MWI/0n A1owl2tR3DUwG/nkWPsMP84fdFhUVbGNtmyG44B2dN/eZKNQznK2dzYJxYav6uE4stQ6 nwV+MG5sT01TMo114tkOxSE69/mnTIg1AtHE97OfJmF3jxtFPCb3ka+pdITYDzWa5Din HyMShEemlbZvlZqFuJGTCd6vcSHyJCJdydqWfCUCytEN2ZxKFB+jwWJ6BZcAOdwdaW5Q lCvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146321; x=1712751121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YuaDTYelRPiHDzZYji8KBqMrTg4A0gZWeICeGTV8ZhY=; b=ZBpd9vrPaeWQ0kWObj/KHK6WF9NzpS+4R7MQECqaAmHT5KZzK4VnR5PJFlKR7JVVSn k/WYTcqPxYmitldkIpLlZ9j8ll+WoNYbjNj0WLgMPJqLia21rMk9pIXQbIbcgSi78+5a uLe3pZH0RX2JMpkJo9MvB+5d9sqjA/J9p4hop9/51VMGI64nwa3ok1T7LJghaCF2/t/F hK7Hbfmwf1L4BRWZXkEgBL+qQp+HYqX8/PHUXzT6WHMplMnPqdi7TVvE4B1Eu3AmTszF LzIU+GryLyiOx4t8rwsHIlX58pp/jPwSP2Zotyi/6faAhB+fS0Q8obtucUJhl/7hCQG6 7Z7Q== X-Gm-Message-State: AOJu0YyjX/QM2kPKItadH+wrT1olyZPSmnGfVdNWtyunxmujrcweJM07 Yi1Vop+AuLeeF/8t6amkCjLVkYIjimfP3RuITGMWBN2vEC/RUyD40iihi1VjmoUZ95zOlvw+gKQ w X-Received: by 2002:a17:90b:1b45:b0:2a2:9f46:439 with SMTP id nv5-20020a17090b1b4500b002a29f460439mr1145070pjb.9.1712146321340; Wed, 03 Apr 2024 05:12:01 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:12db:8f9c:da5:36ce]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b0029ffcf1df72sm13574141pjo.38.2024.04.03.05.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:00 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 04/10] math: Add test to check if round raise inexact floating-point exception Date: Wed, 3 Apr 2024 09:11:44 -0300 Message-Id: <20240403121150.1018799-5-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> References: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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 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. Reviewed-by: H.J. Lu --- math/Makefile | 4 ++ math/test-round-except-2.c | 67 ++++++++++++++++++++++++++++++ math/test-round-except.c | 85 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 math/test-round-except-2.c create mode 100644 math/test-round-except.c diff --git a/math/Makefile b/math/Makefile index 32e3001ec6..35a148a66c 100644 --- a/math/Makefile +++ b/math/Makefile @@ -530,6 +530,8 @@ tests = \ test-nearbyint-except \ test-nearbyint-except-2 \ test-powl \ + test-round-except \ + test-round-except-2 \ test-signgam-uchar \ test-signgam-uchar-init \ test-signgam-uint \ @@ -1001,6 +1003,8 @@ CFLAGS-test-floor-except.c += -fno-builtin CFLAGS-test-floor-except-2.c += -fno-builtin CFLAGS-test-trunc-except.c += -fno-builtin CFLAGS-test-trunc-except-2.c += -fno-builtin +CFLAGS-test-round-except.c += -fno-builtin +CFLAGS-test-round-except-2.c += -fno-builtin include ../Rules diff --git a/math/test-round-except-2.c b/math/test-round-except-2.c new file mode 100644 index 0000000000..5281b919b0 --- /dev/null +++ b/math/test-round-except-2.c @@ -0,0 +1,67 @@ +/* Test round functions do not disable exception traps. + Copyright (C) 2024 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 + . */ + +#include +#include +#include + +#ifndef FE_INEXACT +# define FE_INEXACT 0 +#endif + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.5; \ + /* round must work when traps on "inexact" are enabled. */ \ + b = round ## SUFFIX (a); \ + /* And it must have left those traps enabled. */ \ + if (fegetexcept () == FE_INEXACT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + if (feenableexcept (FE_INEXACT) == -1) + { + puts ("enabling FE_INEXACT traps failed, cannot test"); + return 77; + } + int result = float_test (); + feenableexcept (FE_INEXACT); + result |= double_test (); + feenableexcept (FE_INEXACT); + result |= ldouble_test (); + return result; +} + +#include diff --git a/math/test-round-except.c b/math/test-round-except.c new file mode 100644 index 0000000000..c4515daf89 --- /dev/null +++ b/math/test-round-except.c @@ -0,0 +1,85 @@ +/* Test round functions do not clear exceptions. + Copyright (C) 2024 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 + . */ + +#include +#include +#include +#include + +#include + +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif + +static bool any_supported = false; + +#define TEST_FUNC(NAME, FLOAT, SUFFIX) \ +static int \ +NAME (void) \ +{ \ + int result = 0; \ + if (!EXCEPTION_TESTS (FLOAT)) \ + return 0; \ + any_supported = true; \ + volatile FLOAT a, b __attribute__ ((unused)); \ + a = 1.0; \ + /* round must not clear already-raised exceptions. */ \ + feraiseexcept (FE_ALL_EXCEPT); \ + b = round ## SUFFIX (a); \ + if (fetestexcept (FE_ALL_EXCEPT) == FE_ALL_EXCEPT) \ + puts ("PASS: " #FLOAT); \ + else \ + { \ + puts ("FAIL: " #FLOAT); \ + result = 1; \ + } \ + /* But it mustn't lose exceptions from sNaN arguments. */ \ + if (SNAN_TESTS (FLOAT)) \ + { \ + static volatile FLOAT snan = __builtin_nans ## SUFFIX (""); \ + volatile FLOAT c __attribute__ ((unused)); \ + feclearexcept (FE_ALL_EXCEPT); \ + c = round ## SUFFIX (snan); \ + if (fetestexcept (FE_INVALID) == FE_INVALID) \ + puts ("PASS: " #FLOAT " sNaN"); \ + else \ + { \ + puts ("FAIL: " #FLOAT " sNaN"); \ + result = 1; \ + } \ + } \ + return result; \ +} + +TEST_FUNC (float_test, float, f) +TEST_FUNC (double_test, double, ) +TEST_FUNC (ldouble_test, long double, l) + +static int +do_test (void) +{ + int result = float_test (); + result |= double_test (); + result |= ldouble_test (); + if (!any_supported) + return 77; + return result; +} + +#include From patchwork Wed Apr 3 12:11:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 785436 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp283033wro; Wed, 3 Apr 2024 05:14:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwuNqxYJxSHgNqzLuqUqJv5UU08FIgr5A/gtvKjozpjUHyoYkekxX/gsHlNbLIeC7GaCBas55+WTUsqEWtXyZj X-Google-Smtp-Source: AGHT+IG5Ebf3sIrP7z1iSSToQiZKoV8gTIMUjydSy37EWKZJsW65OYvnIBfiYSYSIBzOtZ76VNfq X-Received: by 2002:a05:620a:1a1d:b0:789:c689:6c37 with SMTP id bk29-20020a05620a1a1d00b00789c6896c37mr2827303qkb.54.1712146446299; Wed, 03 Apr 2024 05:14:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146446; cv=pass; d=google.com; s=arc-20160816; b=aB5iuoG5pRYWHFpmOn2x2Q7CRx+6iNnmqOVLsFQXaruUJwBWT2o/UNaE4TILNQ7SkX 4oQ4oT4uSW9wZsF7X5n0gf9qdfGqLve6Jt90BdtVN9/iO9bpb3Ih81reoKAutwcajc9v yki6eg/OMJ8kb14rdbuTxIIeCA5SOvR3VTzv9DekDi9GgegXLcx9e/UC/07aRBGCnQaf 6KufCLgN+iVjutN0v3h3xux2tjCQ0ehB3dzqPS9SSpY5CMxgzweVURjsWZAYHTpJ2F5z 1xyKJcTei5Ye8ZhBCHvR6/TO7Nd4JKgLpRT48soGKwfaWHbfL2KrcT72YbFwZIOjpYRw 2dhA== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=7TDdXvuo3sJbS/DX1+OISYI1rMNjhEeyXZ/PEXFfH4o=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=LE2C8RMU2lzyRBkCrDy+PeFRbZY9X8sokxI+Kr0lAempG0vQj5u2J4UopmEsUGOY6J qyAKAyoQJsIqQgM409Y/jCyyFlj0DfxISCDaGNMsU4gJwC/AyYxvVknPgHfn8gz261am yZSbHSVSqvhTnfkrzkPlFIgz5HLkTSJhPlyFO/AQ0gzMb9UAYAXNo3QWz5HeYAuG0pYa CYk+dAY3sLDmk/Vj28giRWo36bEmO2d/5//y7aUEIpdO8kQ3kQ/CRh/toTSKAvgXWXrm vBXClukFtRHNGnHTBH7CHE6e91KjnBrWCH0YEXAUsJy59+sfrnKWuE8TTvZ5uOHJu2VW GwLg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fX8U7jOC; 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 c8-20020a37e108000000b0078bea3b93cbsi4800973qkm.152.2024.04.03.05.14.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:14:06 -0700 (PDT) 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=fX8U7jOC; 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 E6D1D3846024 for ; Wed, 3 Apr 2024 12:14:05 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 816CB384640C for ; Wed, 3 Apr 2024 12:12:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 816CB384640C 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 816CB384640C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146326; cv=none; b=tlMKHhXCPs5SbNgUVqfhhmkBQzcqaBfFQjIqvcUetm2Ojxw1EysxOkANihDjd03PJ4BP+GLTAvUuJA/tPZP8NhVm5IOW/7DW383hcEHGz2BCx8MlnrU2nOx9dzy1uJJCPEaAt4NLzk4p6QXF5sK0tJsTu/1h9ROwB9Ac1osgVjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146326; c=relaxed/simple; bh=8g4fxH9M44OtNYweb9m1+FmXQvqgcDl99n8cxd2Yis0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=mU2gI5TpH1eviWDIzNYHgFjcqkn+xrG6VIjgpKwYxpxy087i3DiJnIxNkx1RN3tC60fl3Lv0Xqqw+v2QW0rPCZXzEXCev3VlPkUzB5JToOnSGvEsykiaITYALi8ciHtHPepj2bHiYGnAGI35xILmDKc/ogLWy0Qb+TV/WqJPxVA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6eafbcc5392so3258546b3a.1 for ; Wed, 03 Apr 2024 05:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146323; x=1712751123; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7TDdXvuo3sJbS/DX1+OISYI1rMNjhEeyXZ/PEXFfH4o=; b=fX8U7jOCKl74dkBS99GM4bgWCPeA+izzYqwdRTuft9I4ZPYMxyXnKooYWOEdiXmM1h upJk0Z23gXyhG5biD4RWqyobFvI19nltV0vmU7dzB1RUlQBsS4LCj714RqQJtpkIs+5U ERydJ5a1H3pp9f+A7BxoKCvSvu6VEBopsYlqsHYk72SLYGiiwtW/HXQATmJJSzWiMucL UyEA4lMwa7Df54u2wHFPeAxVaE2QUog9GrHIuLHSelBy9nAhfOH+Q27sSdbkp1SYTw2P iqxumjRM7lgwMz782fmMyQPidlYqSLTr2oZHI81NTBuaEOnGjG7aZ9j/sBLNEF5o/s/B 5uXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146323; x=1712751123; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7TDdXvuo3sJbS/DX1+OISYI1rMNjhEeyXZ/PEXFfH4o=; b=XRStajErKuHjGhL7grVkclr2Aoypg9CwJdQojTY4S5ZfG05a9OluZp28SGsJjU1ZGf xLzjwteq7n2mCV3weuI0grETbmnHixy7ivZp70dNk6gqRfzJB5VOui2SgZzjAxVfjjzB LjJu+frVvY9pvM184E9nxYZZ0CI8EUorNHqDrFbjlLlV4Twk6/59LejTuh/ysWdQi0h1 F22M4l6uSiWiRaMggh1PN5jLufzPP+n4KwQapVpJN9NIqYDiKYLbRw8PSvJPYslTm9q9 5aacXT4nzOK4b8Bg7cVCDSCveJGWS6DmzAd23WTOdZr/3WbpvZY3dFzWPMetXsipiYuV 4VaA== X-Gm-Message-State: AOJu0Yw0MeokQNEVXdd4Srt9uHJWjH853dpruJ1v8ASt/Zdrj0G0NK2E bykuPqxszjopTo2DpUiEJZo6FlravMK5BW8vgiUUX488nMoMdMNVJNopsGduRc/1lvV6Rq57nwp y X-Received: by 2002:a05:6a21:1a2:b0:1a5:6f0f:cbe0 with SMTP id le34-20020a056a2101a200b001a56f0fcbe0mr2801032pzb.48.1712146322960; Wed, 03 Apr 2024 05:12:02 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:12db:8f9c:da5:36ce]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b0029ffcf1df72sm13574141pjo.38.2024.04.03.05.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:02 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 05/10] x86: Do not raise inexact exception on ceill Date: Wed, 3 Apr 2024 09:11:45 -0300 Message-Id: <20240403121150.1018799-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> References: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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 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_ceill.S | 39 ------------------------------------ sysdeps/x86/fpu/s_ceill.c | 38 +++++++++++++++++++++++++++++++++++ sysdeps/x86_64/fpu/s_ceill.S | 34 ------------------------------- 3 files changed, 38 insertions(+), 73 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_ceill.S create mode 100644 sysdeps/x86/fpu/s_ceill.c delete mode 100644 sysdeps/x86_64/fpu/s_ceill.S diff --git a/sysdeps/i386/fpu/s_ceill.S b/sysdeps/i386/fpu/s_ceill.S deleted file mode 100644 index a551fce7f9..0000000000 --- a/sysdeps/i386/fpu/s_ceill.S +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: $") - -ENTRY(__ceill) - fldt 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 */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, 8(%esp) - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__ceill) -libm_alias_ldouble (__ceil, ceil) diff --git a/sysdeps/x86/fpu/s_ceill.c b/sysdeps/x86/fpu/s_ceill.c new file mode 100644 index 0000000000..6ccc9d84d4 --- /dev/null +++ b/sysdeps/x86/fpu/s_ceill.c @@ -0,0 +1,38 @@ +/* Return smallest integral value not less than argument. x86 version. + Copyright (C) 2024 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 + +long double +__ceill (long double x) +{ + fenv_t fenv; + long 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_ldouble (__ceil, ceil) diff --git a/sysdeps/x86_64/fpu/s_ceill.S b/sysdeps/x86_64/fpu/s_ceill.S deleted file mode 100644 index 16dbecd56d..0000000000 --- a/sysdeps/x86_64/fpu/s_ceill.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - - -ENTRY(__ceill) - fldt 8(%rsp) - - fnstenv -28(%rsp) /* 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 -28(%rsp),%edx - andl $0xfbff,%edx - movl %edx,-32(%rsp) - fldcw -32(%rsp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, -24(%rsp) - - fldenv -28(%rsp) /* restore original environment */ - - ret -END (__ceill) -libm_alias_ldouble (__ceil, ceil) From patchwork Wed Apr 3 12:11:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 785432 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp282664wro; Wed, 3 Apr 2024 05:13:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUYZvh0rNPoJiRS5Oxg29IK+SYe99cq1tRarjIqkiqVmQHOHjCrBDIcUjZh5FRgDUeK3T3wd9B9dLG6IQD/nhW X-Google-Smtp-Source: AGHT+IFwPw70bcigUz0osHoI0oc93kU6bzvW76/xwU+A9qG7Fa4O+Q8v/TolW3m1sX9f3kpff//f X-Received: by 2002:a05:6808:2e4b:b0:3c3:f737:99b with SMTP id gp11-20020a0568082e4b00b003c3f737099bmr17994618oib.19.1712146395653; Wed, 03 Apr 2024 05:13:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146395; cv=pass; d=google.com; s=arc-20160816; b=hyg7hO1v8Ih3UJIGv4CwXhkFkhewzRIa4EwXfyMxAQBLOYqDRgVsEp3EVoGbWfCTgD MMYBElHd54iaRHF+9i4XplSntFS6pJ1aII3K6gQSE21mUZIyV0oQ/rpSxcF9BgPldLJy Rntk4c+/XQh69bw31UV9vMlwpuvNpOwJht0rcK+6GOyTCbFbb4+dx4IXyycD+Xc3F4JB e8QiYqAnVNCTjXvR3Yd1mCaCH78h5X6b/5H8dcW/KhPsgg/x8zma04wflyPUfQPGcWy0 qWsDNBQ1WJX1XTdbzYMQVlKJbfflnZFPwiVD4+tSObV02bpQTQghnKz7tH4i64RiZ5fL P8sg== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=FQ5rLm032Y5QqQskna1qADGnTVJQSJ0WGlTt4XHwCYk=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=CSwcRK34aV60kIShnRD2uhGmT8mzLSBSL6fjQpNXyJfKrDaj9uwcv6gkuHi4s3ITui 7T7eufDZAg2UVhKGyFlEKPKbJ54XS+CSXcFGQYQM5BcNLXSuRPGHdDmSbhRzu9ZfsQ7P ZtZnRrDBuHVtJmi4J1zKHD13733qn780GKTdWAS5RksKcANd1lJWvf1xQ1Elz0Bjf1MM Dmw37auju3ZaAkGlV11Jb6DnKQfrFpTSwY5N09yDYQ59Sd+VVtaIu2SNits93oSw06ml +co9SWr1iyoFOhI6Pt8DjL7D8fpccdeaYdSg5KCegdYFj4uaV2QKLRTRSwsxnCRcGsF8 aI6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jy+CDZAt; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v2-20020a05620a122200b00789cfb8d3b4si14064904qkj.522.2024.04.03.05.13.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:13:15 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Jy+CDZAt; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 090E338460BD for ; Wed, 3 Apr 2024 12:13:15 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id 58BA2384640E for ; Wed, 3 Apr 2024 12:12:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 58BA2384640E 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 58BA2384640E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146331; cv=none; b=gT4Vx51rN34dB+JoFk6cT69g0HTafmFpqNR5AxzYcJUsraLs6kLcdLmS2PGyvUl5JUwNxEt4Z5lSB6l9gf1BZQqdeyHicKZMG2c1VnITMFt7b/pG5HtpxJpa9IOzLtNRNUVuRfsYfp380YmMIJ3d7FIpAqDq5ey2xgXum0c2HPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146331; c=relaxed/simple; bh=FOMDCenPAQlg5NMjQI5UJGbXM22kuiEHG338KjBy7TA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=TYT6YN3wQbDd1ueDK/3OaEpD+MXPVBvaOucgwEqIBgMXLrzDOGGsL8ZhJXnGz997rWexcUz/tPjyama8Bj/GtvvWpGaAA0gbHYv1H5WuWUZMcNV7rGIs8bNxjWW6YdP1ioUN27AJv5lkK0y8VwxNqZiAmhgUtiJyhDHXNw34K4U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2a27ba3b1f3so892081a91.3 for ; Wed, 03 Apr 2024 05:12:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146325; x=1712751125; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FQ5rLm032Y5QqQskna1qADGnTVJQSJ0WGlTt4XHwCYk=; b=Jy+CDZAtGCVliN0/CSdB3bWhtJxF02EgmDYLXPSpwWefvEu6h66K1Wnl2eHQiMUXi1 02Gg5NBbau/fG0WAyjLGv3a5aPfQsJLI+PZfgUb/8AaEGmuTFtVEpNZr/d/Rd8p8hTdi U/PKNBsBpztgS0pdaFJA+8KAvZmIKq34raRUNWOhJFKDbSlXxnM0Jdnw+068aeLsBB7G kpYPkskTivvIwNKXgwmoE1TlUngKm9U4WE83f6faAiRevXnRQqPancCUiWu60bAYPUY/ hN1D7Bp54ncGzcXBDGG8jTsQwQbvTRBfBAwdOxH+cMBIa5tcZdCOnic06CwRrJnYm+PN yB7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146325; x=1712751125; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FQ5rLm032Y5QqQskna1qADGnTVJQSJ0WGlTt4XHwCYk=; b=WfzvA64GpzzgqVgnLHZrpp9gvisKEj8kRgKVb+vOCag8azI7CusVIjGhMv6Qt4Zsdu Q6a7QCKcAZSUCJ8tpmZr1Aw+yyBv/OnexNLGPFP7NcvF8yJZ57FphZo8WwazeJSRrpT8 tLr+0UJxI8WvcZBXjpTBVZe2WRs4Y5Sg3QSuWdfG96OQx+6/ZFrC5qVhTU+8Q1fSU1Ad 2aFIZm2zLFolzi+6MZa/T+bTqU7Lch0hKZCHHvRMVGO+GNSN2gnj0RAv89j9JCzc1mTu 1PBxYT3KlyegJZMOVGK23M2edavJZJn3r5YQJpG1ze9vfvJu4Px43Ho1YVQR3GeY62js oRsA== X-Gm-Message-State: AOJu0YzLqditofPs+IDK6HiO0p7CDQwXVG8TuP/TY0tAbj3KYAc+0LwS wnBhWmqpXTHb4hnRFGGzzYFruhjR8WC7uyM44I62r2n0zrP7Gcab4MFUlUOFrA3yQwtDbDfjdRn k X-Received: by 2002:a17:90a:f008:b0:2a2:8c6d:17bf with SMTP id bt8-20020a17090af00800b002a28c6d17bfmr1966247pjb.4.1712146324747; Wed, 03 Apr 2024 05:12:04 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:12db:8f9c:da5:36ce]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b0029ffcf1df72sm13574141pjo.38.2024.04.03.05.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:04 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 06/10] x86: Do not raise inexact exception on floorl Date: Wed, 3 Apr 2024 09:11:46 -0300 Message-Id: <20240403121150.1018799-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> References: <20240403121150.1018799-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 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_floorl.S | 39 ----------------------------------- sysdeps/x86/fpu/s_floorl.c | 38 ++++++++++++++++++++++++++++++++++ sysdeps/x86_64/fpu/s_floorl.S | 33 ----------------------------- 3 files changed, 38 insertions(+), 72 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_floorl.S create mode 100644 sysdeps/x86/fpu/s_floorl.c delete mode 100644 sysdeps/x86_64/fpu/s_floorl.S diff --git a/sysdeps/i386/fpu/s_floorl.S b/sysdeps/i386/fpu/s_floorl.S deleted file mode 100644 index 3ec28b477b..0000000000 --- a/sysdeps/i386/fpu/s_floorl.S +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: $") - -ENTRY(__floorl) - fldt 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 $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%edx - movl %edx,(%esp) - fldcw (%esp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, 8(%esp) - - fldenv 4(%esp) /* restore original environment */ - - addl $32,%esp - cfi_adjust_cfa_offset (-32) - ret -END (__floorl) -libm_alias_ldouble (__floor, floor) diff --git a/sysdeps/x86/fpu/s_floorl.c b/sysdeps/x86/fpu/s_floorl.c new file mode 100644 index 0000000000..3eca033f46 --- /dev/null +++ b/sysdeps/x86/fpu/s_floorl.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. x86 version. + Copyright (C) 2024 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 + +long double +__floorl (long double x) +{ + fenv_t fenv; + long double r; + + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); + 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_ldouble (__floor, floor) diff --git a/sysdeps/x86_64/fpu/s_floorl.S b/sysdeps/x86_64/fpu/s_floorl.S deleted file mode 100644 index b74d1a4d6b..0000000000 --- a/sysdeps/x86_64/fpu/s_floorl.S +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -ENTRY(__floorl) - fldt 8(%rsp) - - fnstenv -28(%rsp) /* 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 $0x400,%edx /* round towards -oo */ - orl -28(%rsp),%edx - andl $0xf7ff,%edx - movl %edx,-32(%rsp) - fldcw -32(%rsp) /* load modified control word */ - - frndint /* round */ - - /* Preserve "invalid" exceptions from sNaN input. */ - fnstsw - andl $0x1, %eax - orl %eax, -24(%rsp) - - fldenv -28(%rsp) /* restore original environment */ - - ret -END (__floorl) -libm_alias_ldouble (__floor, floor) From patchwork Wed Apr 3 12:11:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 785437 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp283149wro; Wed, 3 Apr 2024 05:14:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXiGNcsJCYdd6JBhoNcaoqZTcNLbKshYnOcmlfOUycwnTPBCkBBvGruCwkZqYSWRJCULVbSXJf3sJWrYDrSMZOQ X-Google-Smtp-Source: AGHT+IGzZf16yFdkdg+44/Qy6tqOVvvsBoWUEJ43cawWHrXi9AIoi8IhxDyfUuhwCo2TYx6vnrjm X-Received: by 2002:a05:620a:22aa:b0:78a:45b7:2e46 with SMTP id p10-20020a05620a22aa00b0078a45b72e46mr14574959qkh.45.1712146458567; Wed, 03 Apr 2024 05:14:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146458; cv=pass; d=google.com; s=arc-20160816; b=G5rCFh+qM+fjCBR8AvoVkd/C6Fut7+LqwfrrsQIFu0PVb12Z8/rIs8F4kVqa/TaS1b qVAn72K2HIcVoFv65Wxc1qa8ZHEV+JlIH+T41IrDBfH+EpT8s7v2GE8AQq0zPYXJNROF pskN5IZX2qRSw03yBqqzNbgiSSeuDSh5rkVoyUPgHRz4CaYpmB0fBZPsM5tLFwQHK+bf DCxaeC2CsVSVopZL28wlIY77ioL59esgotmTlmXvOj6lHPBtHASNHoJ9BpBKIJUwhdj/ lUcyUjvQSSyZkRdQaF3jnjHQRppudC1TTX0EV7Zmzf2x2iuY8Ub3gykfjXCh9S49BMnN sBag== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=zlY9goMk06RobzKIAKJy3vjK/nrrQAIbI2heyFcTgXM=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=KxqDbF9ycTJt2Od5RwuY8iFltoWtGfAXW13pW2oAO/lwA/gcWfkmTToIPcOr9osK6j zQiWcAaWm8eqCV1DrKJkXM+qPi6yBSuSkXZpVwl+Oc6+HUQvsrXwDC7SGFAruYjvEKS2 cKQtThZLVNcmGqqN4kiEdN/KLwAdZBh4ql8kIwj8dFly0i2wtj6xj7D5BhVxGRhP6R6a WifOyuiVU1kPTu9vXgmBxm7laI7Y1Mjg7eBkbVT94AmTS4U1o0QUXfNIhbgcJWsSBS7m ku0VLeohbB6YUeu6f2xdrlV7GnRB5Vz6hYz2tjwHi9dMVViBXgmnEm5Aw73RONVaPaqQ If8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zs0Jw7YW; 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 k24-20020ae9f118000000b0078bdcce050bsi8378619qkg.147.2024.04.03.05.14.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:14:18 -0700 (PDT) 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=zs0Jw7YW; 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 5F044384476F for ; Wed, 3 Apr 2024 12:14:17 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id D1F7D38460B2 for ; Wed, 3 Apr 2024 12:12:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D1F7D38460B2 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 D1F7D38460B2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146331; cv=none; b=KKbvVREGFkmjf8vP6GP5p46aJMZ433XKZjZuSKCHtkdbCO1+zUaiOZA5Z+itJabD/F1L8PlLAXHrvEbwtUV7AW1Q6SbfRONwLFft5KftEvgIbVFIj9JFj2VZi5MbZ5NwXxARj1yK+9AZ5Ib/pleVWhN9yH8VQv5/L2vS/X4/IHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146331; c=relaxed/simple; bh=18KWDqJOCvFGiKrMSa8OpXnOZjyCtOADkaYgH7zX9vo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Mz2f2ZU6EIIDBo01OiwzgS02xIux7t9sh4H7haEjj2c7+KRrB6y6h04P7kwFy1e18gBvHmgSlNps/4grM7+U1gGJNPM6p+jI0nOeJbyFRkDDZLkilwap9dVSjR/I3RaVlm74lbfBSom8JQD3xrz48W65bHA070hvDsvfdQBBg1U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5cddc5455aeso3976930a12.1 for ; Wed, 03 Apr 2024 05:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146326; x=1712751126; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zlY9goMk06RobzKIAKJy3vjK/nrrQAIbI2heyFcTgXM=; b=zs0Jw7YWBa/RBCvgKVlhi0sOzbB0Egw9UKgRVBch4kZaiX1iFOR70RaXmKXTL1d3Ux lUXU5P+vg7GYTXL0eekq7BhuuSgQEwIjCwaN9B9Q4WSPPXuJ7bjkWoY7GsCGhzC+dtB6 KIPAsRU90/RGwPCE7P+wYqg17cZQOIu5M3IWerExQ2Rcu2FhAZir2zFKiVn+qTjcjaLR PQxfSwIPyX3UeXgg19SAHHOS1dK9LK7CtwD8P+7I6mqdJZbyfKf6mAj3DYmbEiOl/W1X /RLe2l4QK7H3j0r9Sv7HfmniNV+ClK55/7JS+VHvkIgfx6apLhvt35+AjYPJQJwWOMtz fSGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146326; x=1712751126; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zlY9goMk06RobzKIAKJy3vjK/nrrQAIbI2heyFcTgXM=; b=s2c9iHwShECbCXdCCyEs4vVmN4LfSCyN09g9ekCIPpUnv4/xOTR6Uo59LS+nhD4ho4 QbGGiJK4tCQNPNtNAFP7iv4p1n551eyCX36+9p4kX/ZeLOrlXdGb2jvg4knT3qWeGfID VGM0GL8O4LDa4VJNFFABumOtwKTf3KYjrQob3bFlYL0Jxh9DbzpTAQ1C5bqn2WX2M8Z2 JRji+cumg08gVVcl2JYoFsdvo5kT6jHn5GHKNx5C4A2kJyq7T6n9oY1zaUvXsBrqOfil chL7PkFh+cv9ox0SAZCfelaTCJaKGui7/Hwv3dGHNk7cw5K7m+mSGam6AI4zZol6szO0 MT7A== X-Gm-Message-State: AOJu0YzAVEiKBosBcFal8GMoD24uzkLIlnYY+nl20+gAg0dPkfn3WEui 851riuqvVr0IxPdAqe21Q0OKC7ON0l0llpQ6oHCe6j1hFs5ccHz6dIUbLcUhkpIf4isXut8Ggpi f X-Received: by 2002:a17:90b:3b88:b0:2a2:2eee:e86e with SMTP id pc8-20020a17090b3b8800b002a22eeee86emr7991046pjb.2.1712146326424; Wed, 03 Apr 2024 05:12:06 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:12db:8f9c:da5:36ce]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b0029ffcf1df72sm13574141pjo.38.2024.04.03.05.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:05 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 07/10] x86: Do not raise inexact exception on truncl Date: Wed, 3 Apr 2024 09:11:47 -0300 Message-Id: <20240403121150.1018799-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> References: <20240403121150.1018799-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 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. --- .../fpu/s_truncl.S => x86/fpu/s_truncl.c} | 40 +++++++++---------- sysdeps/x86_64/fpu/s_truncl.S | 36 ----------------- 2 files changed, 19 insertions(+), 57 deletions(-) rename sysdeps/{i386/fpu/s_truncl.S => x86/fpu/s_truncl.c} (61%) delete mode 100644 sysdeps/x86_64/fpu/s_truncl.S diff --git a/sysdeps/i386/fpu/s_truncl.S b/sysdeps/x86/fpu/s_truncl.c similarity index 61% rename from sysdeps/i386/fpu/s_truncl.S rename to sysdeps/x86/fpu/s_truncl.c index dfd0ca4a57..59614cd006 100644 --- a/sysdeps/i386/fpu/s_truncl.S +++ b/sysdeps/x86/fpu/s_truncl.c @@ -1,5 +1,5 @@ -/* Truncate long double value. - Copyright (C) 1997-2024 Free Software Foundation, Inc. +/* Round to integer, toward zero. x86 version. + Copyright (C) 2024 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 @@ -16,25 +16,23 @@ License along with the GNU C Library; if not, see . */ +#define NO_MATH_REDIRECT +#include +#include #include -#include -ENTRY(__truncl) - fldt 4(%esp) - subl $32, %esp - cfi_adjust_cfa_offset (32) - fnstenv 4(%esp) - movl $0xc00, %edx - orl 4(%esp), %edx - movl %edx, (%esp) - fldcw (%esp) - frndint - fnstsw - andl $0x1, %eax - orl %eax, 8(%esp) - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__truncl) +long double +__truncl (long double x) +{ + fenv_t fenv; + long double r; + + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO); + 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_ldouble (__trunc, trunc) diff --git a/sysdeps/x86_64/fpu/s_truncl.S b/sysdeps/x86_64/fpu/s_truncl.S deleted file mode 100644 index e3d64a84e8..0000000000 --- a/sysdeps/x86_64/fpu/s_truncl.S +++ /dev/null @@ -1,36 +0,0 @@ -/* Truncate long double value. - Copyright (C) 1997-2024 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 - . */ - -#include -#include - -ENTRY(__truncl) - fldt 8(%rsp) - fnstenv -28(%rsp) - movl $0xc00, %edx - orl -28(%rsp), %edx - movl %edx, -32(%rsp) - fldcw -32(%rsp) - frndint - fnstsw - andl $0x1, %eax - orl %eax, -24(%rsp) - fldenv -28(%rsp) - ret -END(__truncl) -libm_alias_ldouble (__trunc, trunc) From patchwork Wed Apr 3 12:11:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 785438 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp283434wro; Wed, 3 Apr 2024 05:14:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV93SJCdS/T7FaURMcPmMu9u0FjS32CPAnr5wfnnhfSmHfdM6SCi/PkztfU0j/CjkPJkpORLmKnRoOMam0J9061 X-Google-Smtp-Source: AGHT+IE5yHN1um772kxjVmalBNJWjvqZLDvkXtfR4dp/zOfqrq+HAy7uI1ncnX7x0zrmSylb/EOk X-Received: by 2002:a05:6214:170e:b0:696:990b:dfeb with SMTP id db14-20020a056214170e00b00696990bdfebmr15257376qvb.16.1712146498001; Wed, 03 Apr 2024 05:14:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146497; cv=pass; d=google.com; s=arc-20160816; b=keSzPDXC7UQeELLGNlPNAVjnUakHE8EjKG8KZ2WrI53+uy8fyb4aCCyorg7Tgp4L+6 nhlntzKNj4M7hMj+LZWniU8Ucl7XIvOhkmswSh8sElNbRMBbdomNDVZlvQTzC9MOoFy2 As5rAEvh2CSgZ5YB90Ivs9gJZYM++/eGoHdck+UF73pho5ygS2axpzcUYxq6/PVevxaL cXinidRh+YdgXr+vt6vpG+iKw2NCVcVkGn5RQy/8Y5Ea3NcQWD/B/Sybnr/bci05Q7cV mEqhSjMyP4u3itnJZMihEWAIgxtuPFF6xlhTrsnwC/+Rqm+Lq4ekCPnHN0aN0Dvt0YXH rXOQ== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=J/Hd4wfoUBN6nzKlseuAtLyrP9hg4ATd5bOGXdKfpHA=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=P4pj87wo8jPF6/5zvLofy8ZGm0GwxxrkULF85RNjdhKjNrZDx+4RmqECfmBNqYEpam YEAhtPMeldg0bXQTCe/qv6JOLKb7IOFRyIkLtSeyO6r9OYBZauJhbz7hHkHx1gKziPOP rZah3yn7zEpVrLVkVr29iICw1I0kfp57a+CfczTDkYmUdxyd7FYhExdC1zp+SrlOLrKe OSE1fI7IcBRssSiDIvRUPNSooNrG3tV6LEoT+ZI3f4HUmtBKLNciXFc6jznSzhKeM3k1 NoNcSzNK+J9ev/H5CCR3P4iEQLiA/C+NkVmroLQ/SWESGfb6ry1T0UE6e9eEeam6INuf +93g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CPmePX/c"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id pr21-20020a056214141500b006990ee36c8dsi5163964qvb.488.2024.04.03.05.14.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:14:57 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CPmePX/c"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 90BA53847718 for ; Wed, 3 Apr 2024 12:14:57 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id C8F643846402 for ; Wed, 3 Apr 2024 12:12:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C8F643846402 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 C8F643846402 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::533 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146333; cv=none; b=KW3qPWft4jnwKWLR4vt6GQPwxPEE0EnYR6M7kcSaGKaimO3/y0iuGhvD11uz1ar/kQuwUC/PwgQhlEONaAlaOocjxXr5ECGcsI7HFoUzOj+EqS7WNz1gXS0uXCPG33/uJ2tuvgo/5zWlCwmuNIWme3WFKRSsyWvv7hLGdVtyBa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146333; c=relaxed/simple; bh=HOTicEWALthATkxUWlUAwWIoeL1jPKakutAyvc6a1x0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=QmZWUGTYQfy+8K90eXcFmj1DdFsb7kgn6A2FGPuuan0wZ2bqUBWQ22BGaS+3ZF5ierNup/J95WVpZ9onRDpLDlQvcsUJ/Mf2RYJepXfNPb1ugszWfZ1tM2QXzh8bc9/HRPVBNWND24+xjr73sGyNH4RhZaawS2nDkjR+53QLWkU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5d42e7ab8a9so3554457a12.3 for ; Wed, 03 Apr 2024 05:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146328; x=1712751128; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J/Hd4wfoUBN6nzKlseuAtLyrP9hg4ATd5bOGXdKfpHA=; b=CPmePX/cIgyo51eYuj3fd5deLqYnLwyQxcGMP7rKQe+GgCpuYteYLGUkMSbaombGJM LI3Yx4a5dJXogrDTlBKdV9A/wOvrpq4OehZVMkskgn+FK/mcSN4Sps7lgPYGgj4l9Lw/ Ys0Ph5a337Zm4HErsCLIn/apOWUtgBIZj4wfSqb8mFm7V4biUZ3Du2BxVhzoZopDNeRM 2gaiu534ey0npGgx6worx/gVGLeMBVH2n4tlykmOJ0w+Np56w0RWojTfEx01wcPd9h9R atZrRPpHIedVpkf+0JvAI/y76s5Yw8G6BuOjrEFAz9UJXzdEjzCaFsDCAoum+IA7AYf6 6JgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146328; x=1712751128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J/Hd4wfoUBN6nzKlseuAtLyrP9hg4ATd5bOGXdKfpHA=; b=SVxPnylcxyO3LDFZKZ/seIn8f3ArphD6MGRh8Cj0OFNUkMa3DUv4+15hOOsHGvbpXV F5rq+1VB2hKk0iOjQma291Ynwq3THbW6z4Bk9AU0OAuW11rqUF+CaNrIVjHSyzB1QIcV U+xdkVyc6B3X7LiiNGit7YMX+/VQghA5HwXV0zc9PFKfE62O7VhxYnJl8MRhpNSiUpId XjmhL4YrvhWMpnMaH9YKeLZNhNb5VDcAFxHYBoPfY/h98IGXAMU57pu2i1od+Ky6i3xg YQb7LQjOP/vGvUDSzEb1bGw+UOXYDu8acbszkviCxn087mlRc5GajrdYkoEaigQP21tu SWKw== X-Gm-Message-State: AOJu0Yz24ITgaOR7diQDABzb/6ipcAM19rewAvnoo4t48Mf323cHvDG0 jBI/QjBvj5Z5MKEROJ6Vyor7Po1Pg9DW8sbLVzCxKW8x2ewykVv26b3cV2Ekysq4j6HyL2sXxvN l X-Received: by 2002:a17:90a:c28f:b0:2a2:648a:74fa with SMTP id f15-20020a17090ac28f00b002a2648a74famr3875034pjt.42.1712146328040; Wed, 03 Apr 2024 05:12:08 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:12db:8f9c:da5:36ce]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b0029ffcf1df72sm13574141pjo.38.2024.04.03.05.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:07 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 08/10] x86: Do not raise inexact exception on floor/floorf Date: Wed, 3 Apr 2024 09:11:48 -0300 Message-Id: <20240403121150.1018799-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> References: <20240403121150.1018799-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 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_floor.S | 34 --------------------------------- sysdeps/i386/fpu/s_floor.c | 38 +++++++++++++++++++++++++++++++++++++ sysdeps/i386/fpu/s_floorf.S | 34 --------------------------------- sysdeps/i386/fpu/s_floorf.c | 38 +++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 68 deletions(-) delete mode 100644 sysdeps/i386/fpu/s_floor.S create mode 100644 sysdeps/i386/fpu/s_floor.c delete mode 100644 sysdeps/i386/fpu/s_floorf.S create mode 100644 sysdeps/i386/fpu/s_floorf.c diff --git a/sysdeps/i386/fpu/s_floor.S b/sysdeps/i386/fpu/s_floor.S deleted file mode 100644 index 7143fdcc9a..0000000000 --- a/sysdeps/i386/fpu/s_floor.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_floor.S,v 1.4 1995/05/09 00:01:59 jtc Exp $") - -ENTRY(__floor) - 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 $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%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 (__floor) -libm_alias_double (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floor.c b/sysdeps/i386/fpu/s_floor.c new file mode 100644 index 0000000000..8e763327ad --- /dev/null +++ b/sysdeps/i386/fpu/s_floor.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 version. + Copyright (C) 2024 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 +__floor (double x) +{ + fenv_t fenv; + double r; + + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); + 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 (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floorf.S b/sysdeps/i386/fpu/s_floorf.S deleted file mode 100644 index 8fad9c0698..0000000000 --- a/sysdeps/i386/fpu/s_floorf.S +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Public domain. - */ - -#include -#include - -RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $") - -ENTRY(__floorf) - 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 $0x400,%edx /* round towards -oo */ - orl 4(%esp),%edx - andl $0xf7ff,%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 (__floorf) -libm_alias_float (__floor, floor) diff --git a/sysdeps/i386/fpu/s_floorf.c b/sysdeps/i386/fpu/s_floorf.c new file mode 100644 index 0000000000..e5ff58c8c6 --- /dev/null +++ b/sysdeps/i386/fpu/s_floorf.c @@ -0,0 +1,38 @@ +/* Return largest integral value not less than argument. i386 version. + Copyright (C) 2024 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 +__floorf (float x) +{ + fenv_t fenv; + float r; + + libc_feholdexcept_setround_387 (&fenv, FE_DOWNWARD); + 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 (__floor, floor) From patchwork Wed Apr 3 12:11:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 785435 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp282989wro; Wed, 3 Apr 2024 05:13:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXYXqoWzCGlKH1HES32mzw7vzDfFaxDxgmkBk+QlbKfP63n42znMl5KGsKgZuJa7Rpasv+q8QVpbGans8pdUbu X-Google-Smtp-Source: AGHT+IHgmCKLme4OVqInF7tNrIlRf8wERFpdIV+VOnUcQFKB4p6vs1JQH6az78zS5x0wiyluNF2A X-Received: by 2002:a05:6830:18eb:b0:6e5:ebf:ed65 with SMTP id d11-20020a05683018eb00b006e50ebfed65mr2536455otf.31.1712146439063; Wed, 03 Apr 2024 05:13:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146439; cv=pass; d=google.com; s=arc-20160816; b=AzShVhBQChiU8IpzIrBVkJpg3spDKZDQqKiZqCWkoT5L/ov0xHmt4taw7uOzr9KySK 0uVHAd9EfHl1zmstztQOpXPmLwdLsJXtVoHmzP2mYNPxxuOkkOZIaMmUAccbK64qJTnS SjaGNTolJu0LGpZMSGNz+P2cFI9NJ+4MbEt22x6Lt0GZHgEfk6r+iJEl1Q7pUMA5gHsX fnaGr1umUNu1UKk1lO4Xgq7zbNkBDFsGABA73XfhzIPRwyf87IqjOuiAjXUJy1ElZ5Z+ fuUGFvLkFx1J4p95HeAOtR/VHECDd31yPG6SxLGc091jQBKHya/lBlmmQIizMnycnuB6 RMxQ== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=116LvhQoZoYG5EqlPfIh2lOHRaUeY+a+L9AtMyuji3g=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=wRQbzwVwU5ufyZ06Ak88riFExOnxrgSz5OidrKGLpeUzFsYnvdJok077kVFB1isb+T 1QmKQRBsRmdacw8wwdNCuZsjt0BrwQE5fRm1i1lBn89XRDN7CLwyJj53QWufHrimnRvp zzmlcw/mtI9UahTnkI4gDo6r/MrSz38yVgyXz7//X05Zjp3L8H4nHJXH9upq5EONyv0r +zPRnJVvbK8Qo7EsH98BbmTJe069QT6AT625mae465+EV7MvAyjdVYgRaY7G80H1D/Qm WcqJ9X5vflPfCxgCLj4FvYM5a0OCHusfSRgpuzJMi6Pby5LjhN3/k9plhFA5HnjWjCm9 Wi5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=edHk3bwX; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ei14-20020ad45a0e000000b006991f0f14d5si3034252qvb.538.2024.04.03.05.13.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:13:59 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=edHk3bwX; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 A8C003845BE1 for ; Wed, 3 Apr 2024 12:13:58 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 3D2313847718 for ; Wed, 3 Apr 2024 12:12:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3D2313847718 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 3D2313847718 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146333; cv=none; b=fjRoIWLt15/HgBgCQrSjnmdOj8l/Hj19iEi4l3xLDQ7JJScDnquDGhciYqQDVlqgZWn00dHH8oXGlsnwK2uxcuVidfZVxyQn6BQR9kv2iSFZJkFfW8yV0UlfB6YnOpDZ24Kgn/5FZ0IAI1cgijxR4ahBBwNEscxgf82V0n7tTqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146333; c=relaxed/simple; bh=1semKmK8KQYDjaxbDquUACFTy/pOOqvAsAHk9ChhDDY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=yD4WhL3zNZO1ZS1QbeLablVx9gBQWMuESoeomV+jaLYudDDxKg5uZO+e9R6nnamV/Iql69Lqrvpojpe2BgAIXb5NcOhCl/cWVBTBTrQ8f0sFpMd2KhiDBPZpmmuEJSTiN1RZIHArAynTNwUIWFQHsjP4KNrhN1L9rxMN7450L1c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5d8b519e438so4585764a12.1 for ; Wed, 03 Apr 2024 05:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146330; x=1712751130; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=116LvhQoZoYG5EqlPfIh2lOHRaUeY+a+L9AtMyuji3g=; b=edHk3bwXciUb7Oh6Ia4zDryH4F55wIdToBcUL42Ysk0yv59/Z08vbYs96vecPQUr2n O8v7/lDkOmdR+XPqIy7ZiHXKWw8Tg9rC6UwRkfb5GUW3aSfCEYBpxbGZHeHee+7glcvW S3CuHiBuNQfpD2cycXXjkErJew2BA52HafHcglWxwH24HY4ZN0bDNwzjq2jSwm322Kao bIplGu7C7JQEJ7ta8YJppTMnczAxrE/5BDXFSmWi08gxgkFZhfsyVz6SX0e+nOS2Vd9T /R+JA/VEs76HxcDwcSkvxPVpTEXQP6EahBTFrCxU/oQ0d1BwTzE6k4N4hmHA0uPNYw+h VyJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146330; x=1712751130; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=116LvhQoZoYG5EqlPfIh2lOHRaUeY+a+L9AtMyuji3g=; b=LF9XyoRohXqkE1hzPixRp6fAi0uRsi1f7QvpFgCFSP4lvTmqthgJxsJEmJIRz7L1xB Wtq2Va+C3gXRV6b3aF8kwemMj81PHPq+71Ycm8BUFXafXkrF2jQZ9wNqDY/uMrapXsNw zv9FSLpjl4oz3nUrcXmCSc8zgDWVj4kTOPdP2y/BMso0B/4XFUlDAta2Ofb84tVtD6vy uyGA223+Z03IijzzfL4wdmB0dbijkuN3I8iKQ4QtUUFKYKBAkBujkpaVZHK2HJ8rvwHC nWN6Oh8FT8VShojdn987yso9ipygojx+AcMiwK18Fv06nprSAYlwjZMBA5SNM7CxPWQu lvfQ== X-Gm-Message-State: AOJu0YzVf7Kcz9uEVfnC8vrKU5YIhyLbpnT6zu1IwzCwGzT5JtM+kVOp k8loeTHaj5VFKE7emvH1sFWxrph+BSEWxNXeavfrNbIozr1aD2AM47qxhIcVtC/JispTeiuSQ/G H X-Received: by 2002:a17:90a:fe90:b0:2a2:9001:94bf with SMTP id co16-20020a17090afe9000b002a2900194bfmr1835928pjb.14.1712146329679; Wed, 03 Apr 2024 05:12:09 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:12db:8f9c:da5:36ce]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b0029ffcf1df72sm13574141pjo.38.2024.04.03.05.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:09 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 09/10] i386: Do not raise inexact exception on ceil/ceilf Date: Wed, 3 Apr 2024 09:11:49 -0300 Message-Id: <20240403121150.1018799-10-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> References: <20240403121150.1018799-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 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..1ab3d357ba --- /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) 2024 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..3de0a962f3 --- /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) 2024 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) From patchwork Wed Apr 3 12:11:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 785434 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp282889wro; Wed, 3 Apr 2024 05:13:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXYG88enj0f+IGeLZLLWBRSBvUeMZI/e5JjTrV8hUAgTrBfdrskQ9U47/e1FHHTQFpXU5nMzEILQgfixTh/PEoR X-Google-Smtp-Source: AGHT+IE7BkMl7mUlXcA7UD9//sMkapI/k9uT3QXtoz8bGGtS3jPW2PowgwQh6JjsR0uYsoLSFPAK X-Received: by 2002:a05:6808:1709:b0:3c5:d2fb:ed8a with SMTP id bc9-20020a056808170900b003c5d2fbed8amr1355108oib.35.1712146424019; Wed, 03 Apr 2024 05:13:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712146423; cv=pass; d=google.com; s=arc-20160816; b=twRK+yormT2W9M2Iy+hHq7CSBAPRSrhke7OKgCdtOEw3NzHvTgCjb/Da1JbAK+08zQ c0/1pXXcD/XA09RloSuQnpMP22j5w/QHCwqiKNSOxuKPuTBaeu7z6demEVN8KGt4WCpj UxA6MjtCu+sp627iyqczrknKEFs2UxuEkbOONnkmNVUQl2HGVJ6NEoiJABgZIugiqbYs 8VmRI8+fNEQmKzHd9kkGet1iAbbNWZjqco53KRelvux+DejxzCV9pCeBNTUfMi0B13AQ G5llR+S7g7Hn0M2+Sf4btV3Mcon5XM51AlqQvAODOIx2xucYV/ZdmSkgVHUY55I8ks87 de1w== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=mcC9BT77771N8Eii2ZWnHojpfSkULVnusjkmQelNl8o=; fh=+6orIzRLXQY2FWXAtGF+abYflc8V+YPKzsYFuX0DJM4=; b=ett6B60nu0tAixQf0acwXW5Ug5MfYZVccqKPOKrFOy/UPHaGwgfeghfpHtjADsqT3v 05NkQIvlUZ8lIu2S4vx4qNFGfBaya28ebVtmL0XAYHraZPhfn/4kbBvo3xswKkat0c55 crVi3P5/ChEOsYW1soszMzfi6ti/S3rAdtxaatietH6L0CEziXnEChuwd/kntoenPV/5 5CvsG1W3T5x9Q5/WekURl1mQJjq+o00H1rloi8mDd2aidUFzf9CfpZYHmGc+Tb1IDU7h cAVpJHusWveK25mMTayRkkzYP2ckeLTy3HmOWUpIsZaIKadqvLcbiwbJ0zUc1sqpdaIW psmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YmQAYLOd; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id pc4-20020a05620a840400b00789f61e3e39si13510207qkn.74.2024.04.03.05.13.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:13:43 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YmQAYLOd; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 9C8B3384475D for ; Wed, 3 Apr 2024 12:13:43 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 1BB69384640D for ; Wed, 3 Apr 2024 12:12:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1BB69384640D 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 1BB69384640D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1029 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146338; cv=none; b=gYnbCOPvkNElUGgfRq0HV5csDEZAdSHO1ND8wMWmasiRT3TCYTFhe+vBIWQfCiGnT+vJCu5hGMe1hb0AsUo7Qu6AN91OzCEJDQfQWEYrJtjji7zHhJI9XwDZqrtdyZvjNC0X4Rnfy+baLLreil8FEfBv0D2Iy4qdx4nvS0ct8Ps= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712146338; c=relaxed/simple; bh=pTBS8UJ8xIbuv48fM//Cqy517Qa01Ep8u6I9kE9tSFA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=hqvaDWXnVyLRsTG2Au7MaHP3PE25gtenlTCxfXECppbOn7B8jlNj0G+672Bw3/XTuTNQH2H99au2+RiJv1wb3qRe9CYp7qH1guUF4wktPRElPy2Lv8E8/TLJeoz4kvzj6RmVu84g1zbtjEN+emPHDAwaxyfCh32QJN7Nn183kx8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-2a2474f2595so2069548a91.1 for ; Wed, 03 Apr 2024 05:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712146331; x=1712751131; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mcC9BT77771N8Eii2ZWnHojpfSkULVnusjkmQelNl8o=; b=YmQAYLOd3RijGtnSgBKsJgK2vhuOieuBV2fdXbg2uJDj/3WP+7QJRKrQfv55lbOGPm jS7+eYsDz74C7YXVHfGB4avyI7SxOi/+/l/Or/gLa3pU3ZAe3iXjAzpDwLTv0ikWCLsU X3LlyzuVzQpAE3MRTaeSoxqMRpOvdLYqnACTKvglGf7VtvtbTyDcbTXOTyMFHcGJ9Suu F5kq5tFEUTZxN+GGdlS2h1wNWHqAhkXTpWxdKUXQfjqXoKFeFZoRiQTnoiHUzVXterS7 SNdGlnyD6zwJkO4n1wt/BY4CQqHkVwjJZ0//xJg/YwCeDvUTsWgygLABvYK4nzVZcR/+ D6Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712146331; x=1712751131; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mcC9BT77771N8Eii2ZWnHojpfSkULVnusjkmQelNl8o=; b=Qu3GvsI/qYiP9PBqKnTHyYo0E3xIdY2HcvziLyEegmbgGOLNT4PFJ++Pok44iYhhpn e6tB1wjs39QapL+Oaj9ClpueqFKsZ/ehS+LKq2RiWZCm8bCtoUd8Jdr0XLiSbM1c5QS2 J6BozZ9riMfvMFSrnFxaNVJTHKYO1Kee0rHEhLzsD3y3oe2tTlNn69v2fZ1mHwM/WToh WTKQ/cFuj3ga32Pal7yove32dJ/eTQJAmcNk1KHKKL3L52jFPRRh33X1qXG1+7BKmzAC s+Ejn78XGz+5Rz1+iSDYT0ZDnAWf8G2NZ1hf8TFQ5pp+UD1qhFk0BAcjq0tYY7Y59GSr hFZQ== X-Gm-Message-State: AOJu0YxKw8b4T0ynKMUO9nvDVZuAv0aYlA2hCk7+0nHLIjecClM4Ojdz aRXrWJYHIb9MGUmTCw9zWJgiij3HYrIpqKfodBYeipFwecQrSJKufi4qrrzJ+EFYXnVfCYw6TDN n X-Received: by 2002:a17:90a:bb89:b0:29b:307a:d5ed with SMTP id v9-20020a17090abb8900b0029b307ad5edmr2463967pjr.10.1712146331305; Wed, 03 Apr 2024 05:12:11 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:12db:8f9c:da5:36ce]) by smtp.gmail.com with ESMTPSA id q6-20020a17090a938600b0029ffcf1df72sm13574141pjo.38.2024.04.03.05.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 05:12:10 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: "H . J . Lu" Subject: [PATCH v2 10/10] i386: Do not raise inexact exception on trunc/truncf Date: Wed, 3 Apr 2024 09:11:50 -0300 Message-Id: <20240403121150.1018799-11-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> References: <20240403121150.1018799-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 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 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_trunc.S => s_trunc.c} | 37 +++++++++++---------- sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} | 37 +++++++++++---------- 2 files changed, 38 insertions(+), 36 deletions(-) rename sysdeps/i386/fpu/{s_trunc.S => s_trunc.c} (61%) rename sysdeps/i386/fpu/{s_truncf.S => s_truncf.c} (61%) diff --git a/sysdeps/i386/fpu/s_trunc.S b/sysdeps/i386/fpu/s_trunc.c similarity index 61% rename from sysdeps/i386/fpu/s_trunc.S rename to sysdeps/i386/fpu/s_trunc.c index 40e45c9f9c..5880964499 100644 --- a/sysdeps/i386/fpu/s_trunc.S +++ b/sysdeps/i386/fpu/s_trunc.c @@ -1,5 +1,5 @@ -/* Truncate double value. - Copyright (C) 1997-2024 Free Software Foundation, Inc. +/* Round to integer, toward zero. i386 version. + Copyright (C) 2024 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 @@ -16,22 +16,23 @@ License along with the GNU C Library; if not, see . */ -#include +#define NO_MATH_REDIRECT +#include +#include #include -ENTRY(__trunc) - fldl 4(%esp) - subl $32, %esp - cfi_adjust_cfa_offset (32) - fnstenv 4(%esp) - movl $0xc00, %edx - orl 4(%esp), %edx - movl %edx, (%esp) - fldcw (%esp) - frndint - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__trunc) +double +__trunc (double x) +{ + fenv_t fenv; + double r; + + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO); + 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 (__trunc, trunc) diff --git a/sysdeps/i386/fpu/s_truncf.S b/sysdeps/i386/fpu/s_truncf.c similarity index 61% rename from sysdeps/i386/fpu/s_truncf.S rename to sysdeps/i386/fpu/s_truncf.c index 0b26e09d61..037099024f 100644 --- a/sysdeps/i386/fpu/s_truncf.S +++ b/sysdeps/i386/fpu/s_truncf.c @@ -1,5 +1,5 @@ -/* Truncate float value. - Copyright (C) 1997-2024 Free Software Foundation, Inc. +/* Round to integer, toward zero. i386 version. + Copyright (C) 2024 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 @@ -16,22 +16,23 @@ License along with the GNU C Library; if not, see . */ -#include +#define NO_MATH_REDIRECT +#include +#include #include -ENTRY(__truncf) - flds 4(%esp) - subl $32, %esp - cfi_adjust_cfa_offset (32) - fnstenv 4(%esp) - movl $0xc00, %edx - orl 4(%esp), %edx - movl %edx, (%esp) - fldcw (%esp) - frndint - fldenv 4(%esp) - addl $32, %esp - cfi_adjust_cfa_offset (-32) - ret -END(__truncf) +float +__truncf (float x) +{ + fenv_t fenv; + float r; + + libc_feholdexcept_setround_387 (&fenv, FE_TOWARDZERO); + 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 (__trunc, trunc)