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: 783138 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp2300128wrt; Wed, 27 Mar 2024 09:47:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTv4rCDIeZ6Re6iygh1TOWrYayvZlB6e2O/GQOe3VTLcXihhI/tWRWKN4OjP4rB2OflSxzTtrUhVBdyGGuKKD+ X-Google-Smtp-Source: AGHT+IFkVF2S8F2WZJs+lAY9rzYMozstQoMvFcJAgNR46YGUd/dHvHvTfmsmFgI6WZm530f/vHqu X-Received: by 2002:a05:622a:1801:b0:431:627e:d390 with SMTP id t1-20020a05622a180100b00431627ed390mr214423qtc.29.1711558024853; Wed, 27 Mar 2024 09:47:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711558024; cv=pass; d=google.com; s=arc-20160816; b=dejFUb9I3SoQNz4FhjhZ8j6C/p1XFue7zUg1CaSbJOLOdiUYtU1lrky79CvAKICWOv KgNMcWiwgpNBbayZQAqaygip0b1qEHQoV/M/vtknY7K6IdScuqiXd5TbdXl2Lr32IIj7 kMPORkxCNzb8wmFO2l5BhdvlHeWdTXXM9yPoPdaaw/Vogjv03DePjKJjFdElfICIxtc/ CMB18Z/Hv8dd7HhgiK7IbM0xQzFdtWCiu2lyjWfhU2un/HGOy3Ox8EPkMuDSD+V2lPYn 9CtHE1JCmS4G9MXORc2fNuWt+9Wf5nYZk3mzqSy4CSMiNXt5iR626h7WTG7PpfHkr+Cl MO5g== 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=C8SvVzRbyUaeCjml/gbQthQjBarqYX4J2exTyVV+POs=; fh=WtLnUd2EuDKv+EP3BSdEI8hdivapDDAq3MY9+WgWrlk=; b=u/OTGXG72VMxyxbSPVoQJJxpkFDoocmZsUZDRPEZjBlx4QjeMVNL5iaAFyNnLOgWwG WEfhOj0RejYHq4go2sY/9FkEjUafwXr6AgrS2RGdK9xeIzFopwioAmYe9XM7bNTfw/Zx lbB85Oq5aIae3Kw17D6wKOOI3K8cS72yHZ44CF4hXvSKje/wFOo+FRFxJHeIkCd4gB/I 6R5Awc64rfyE2nLC183dJ/+S2KfhUrQvCJSRAWGKPC1doNy87jZjtekGl09/axr8eeP9 hdJNJGRrj1YclO1T382x7vgBtophe7BQ1YOsy9vOtwK2kbXnVxfHSnkbIcLJI2fzD5Xq 05xA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uMzcZlPc; 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 a12-20020a05622a064c00b0042f2127fa75si10183850qtb.683.2024.03.27.09.47.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 09:47:04 -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=uMzcZlPc; 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 78743385E448 for ; Wed, 27 Mar 2024 16:47:04 +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-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+patch=linaro.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); }