From patchwork Wed Mar 27 16:45:25 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: 1916936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=uMzcZlPc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V4XdW6jtsz1yYW for ; Thu, 28 Mar 2024 03:47:11 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1FC76385F027 for ; Wed, 27 Mar 2024 16:47:10 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id B178F385843B for ; Wed, 27 Mar 2024 16:46:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B178F385843B 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 B178F385843B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::635 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711557963; cv=none; b=L7fRkZh1Bl4aQf/yu+uswZYVb1tojenvgFRqyGNLEkTjz+Sf1I5IMLYnZEG9PE4bLGLfOQRUJPj+N1HOiOtJjZSOptRR1tWbHyPrubEe81K4deoyyV5szseCRUzwLaGblQQWOMNFQmmsSP+2dUS5iuEi4zq3ngw3i6fSeQZ/9EM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711557963; c=relaxed/simple; bh=x+kArivzxvN8hcZBiHq9bKAjCxH//BHD7Hfi3o2dTmk=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=iEk81uoPG4ts3VUDD/Ytnb7WyWsQFy+MjBS0d9kIwJtoil2ODhxfznTwBCS2dVQyVkA2UVH1ozCWI2yKv0GUw4CVIP4Yr1t9bPdqbSXuea/eHMnaba5ZH7mRxH19uTIZfz46vhNGqXvSKIRGHlzcHU27kzOvLAIY4RQZpFzoVRI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1def89f0cfdso9091615ad.0 for ; Wed, 27 Mar 2024 09:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711557960; x=1712162760; 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=C8SvVzRbyUaeCjml/gbQthQjBarqYX4J2exTyVV+POs=; b=uMzcZlPcrOVCTF38iXm5xmMiCjYnfnvc7al9B1VdhNFzlYtLfLP+Xa21lMPjF9X+c3 0WwmzduSCd1pOziNY+YSLD2PCExRvztZBbl1LgwxllcZtQJ6qPrmcXS2geDCG1EgZ/S3 3EnrDCi81ftIPyxhA97/wAPwrric1jwF+SXgmt8MOACFZe9X5kikOlSvlM5J++Wx79Fx OocBhUUgCFxL5MPvIl12N91PvtdImuzpptR55JYwRpwhxlwNJNGJkrjvViAiUMoCiiY4 pLvweNEldHyhiB4jRqqW+djy0OVE3dTEftIPonQ3WcO/vcS76ckH7j3DuFWxIGlwKAu1 QPZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711557960; x=1712162760; 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=C8SvVzRbyUaeCjml/gbQthQjBarqYX4J2exTyVV+POs=; b=kadU3XWwRODSyVuq1hFwbUjIJWsYw0GbMjG9gcXrhu4tOFIpCCZb8xCMZK2YlbWEfe ddjdyfAUdQ5yn5LyiGOw02Ag7/d29t8dT/hOvueviqtwCtW7XbzZIBg6RunNnIGXhXms Yrh6MmY8nSBR7R5narPWB45nFpyYxM7P5DewMvO1vs9Jr3uC8eslEPFnyxUbllc000M0 MR/SG6KYTHglLq6bupSscHPFWmsxocKXmcS3I3J3xdFf2ZY1oOYYWRWQU5jH55/OL/D7 kvQ34qPpIC3f92OqtOjt7OFdUWZCDGoFy7AmFwcqzUtJfU/TM88awMlsnZuK0389LXp2 heMA== X-Gm-Message-State: AOJu0YzOTrJQFIXFpeyqvMxPS7sfngsH39+X3GJ93KZvPXOpBSpMXLp/ dOqpUCkVnpHy2kWjBGgKX2b3TXdQseY1BG3HZGp8dGJpmyZVcgJOo87gUY3XWJNh/m1dxTyRGkK i X-Google-Smtp-Source: AGHT+IFAMeAvwdBUxkjZMxoah6+I0MTpOFg5OTtrgKYdRqgsKdWIWU753Ty5+qwWyVGWqZXWCk498Q== X-Received: by 2002:a17:902:e54e:b0:1e0:188a:5ade with SMTP id n14-20020a170902e54e00b001e0188a5ademr207385plf.11.1711557960234; Wed, 27 Mar 2024 09:46:00 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:b18e:67c4:6248:3d8a:f386]) by smtp.gmail.com with ESMTPSA id c4-20020a170903234400b001e20578b524sm858593plh.252.2024.03.27.09.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 09:45:59 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Joseph Myers , Florian Weimer , "H . J . Lu" Subject: [PATCH 13/15] math: Fix log2 template for inputs less than 0 Date: Wed, 27 Mar 2024 13:45:25 -0300 Message-Id: <20240327164527.3717523-14-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240327164527.3717523-1-adhemerval.zanella@linaro.org> References: <20240327164527.3717523-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_NUMSUBJECT, 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+incoming=patchwork.ozlabs.org@sourceware.org The template is used by some ABIs for the static build, and it fails to correctly set the floating exceptions if the argument is less than 0. Checked on x86_64-linux-gnu. --- math/Makefile | 1 + math/w_log2_template.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/math/Makefile b/math/Makefile index aa57171f77..7391f2bd41 100644 --- a/math/Makefile +++ b/math/Makefile @@ -370,6 +370,7 @@ $(libm-test-c-narrow-obj): $(objpfx)libm-test%.c: libm-test%.inc \ libm-test-funcs-auto-static = \ acos \ exp10 \ + log2 \ log10 \ # libm-test-funcs-auto-static libm-test-funcs-noauto-static = \ diff --git a/math/w_log2_template.c b/math/w_log2_template.c index f3ac0aab49..8933f2cd62 100644 --- a/math/w_log2_template.c +++ b/math/w_log2_template.c @@ -32,11 +32,19 @@ M_DECL_FUNC (__log2) (FLOAT x) if (__glibc_unlikely (islessequal (x, M_LIT (0.0)))) { if (x == 0) - /* Pole error: log2(0). */ - __set_errno (ERANGE); + { + /* Pole error: log2(0). */ + __feraiseexcept (FE_DIVBYZERO); + __set_errno (ERANGE); + return -INFINITY; + } else - /* Domain error: log2(<0). */ - __set_errno (EDOM); + { + /* Domain error: log2(<0). */ + __feraiseexcept (FE_INVALID); + __set_errno (EDOM); + return NAN; + } } return M_SUF (__ieee754_log2) (x); }