From patchwork Fri Oct 25 15:34:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel F. T. Gomes" X-Patchwork-Id: 1184257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106328-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="nU/xlw3I"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4707Yw5LzDz9sPf for ; Sat, 26 Oct 2019 02:38:44 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding:content-type; q=dns; s=default; b=Gb+puKrGcBBepw4gmJPP7uT98n91fiiW8Jtip0M6OvG uVIFwH9xdnTK9rahlfEej3PiRZDrw84rwm6Ug9oQGKS592v9JcSMMJso+S+HYqex F/H+PeGX2JqhrWYYl4q+Lf6Am5EE5o8nIFmbmrgKbPP68q4zvKbn/4kydz4FtwW4 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding:content-type; s=default; bh=v7LmdsiS2mGLbg8eaQg41uSST0c=; b=nU/xlw3Id/T3HFkvn BAdQgXgFU0mFMIzQ8GTjVmjGADsYFexgWxDXaH53CAErOGbnEGCIDZB3r2g3ZAuo v0TX3SHGTI0S/lb1GkZtzsuPjBcJ/vuAE2X4tqvRCFj/YwrYhUQgHavxGdBBLkf7 QuxSt1iWGg4zZtIKrsjsYBLDcc= Received: (qmail 113887 invoked by alias); 25 Oct 2019 15:36:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 113825 invoked by uid 89); 25 Oct 2019 15:36:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 20/30] Refactor *cvt functions implementation (2/5) Date: Fri, 25 Oct 2019 12:34:00 -0300 Message-ID: <20191025153410.15405-21-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1617073745272622787 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- This patch is to be squashed with the other n/5 refactoring patches. This patch only moves and merges the contents of misc/efgcvt-template.c and misc/efgcvt_r-template.c into misc/efgcvt-dbl-macros.h. --- misc/efgcvt-dbl-macros.h | 52 ++++++++++++++++++++++++++++++++++++++++ misc/efgcvt-template.c | 25 ------------------- misc/efgcvt_r-template.c | 33 ------------------------- 3 files changed, 52 insertions(+), 58 deletions(-) create mode 100644 misc/efgcvt-dbl-macros.h diff --git a/misc/efgcvt-dbl-macros.h b/misc/efgcvt-dbl-macros.h new file mode 100644 index 0000000000..08640e9639 --- /dev/null +++ b/misc/efgcvt-dbl-macros.h @@ -0,0 +1,52 @@ +/* Macros for the implementation of *cvt functions, double version. + Copyright (C) 2018 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 + +#define FLOAT_TYPE double +#define FUNC_PREFIX +#define FLOAT_FMT_FLAG +#define FLOAT_NAME_EXT +#define FLOAT_MIN_10_EXP DBL_MIN_10_EXP +/* Actually we have to write (DBL_DIG + log10 (DBL_MAX_10_EXP)) but we + don't have log10 available in the preprocessor. */ +#define MAXDIG (NDIGIT_MAX + 3) +#define FCVT_MAXDIG (DBL_MAX_10_EXP + MAXDIG) +#if DBL_MANT_DIG == 53 +# define NDIGIT_MAX 17 +#elif DBL_MANT_DIG == 24 +# define NDIGIT_MAX 9 +#elif DBL_MANT_DIG == 56 +# define NDIGIT_MAX 18 +#else +/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a + compile time constant here, so we cannot use it. */ +# error "NDIGIT_MAX must be precomputed" +# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0))) +#endif +#if DBL_MIN_10_EXP == -37 +# define FLOAT_MIN_10_NORM 1.0e-37 +#elif DBL_MIN_10_EXP == -307 +# define FLOAT_MIN_10_NORM 1.0e-307 +#elif DBL_MIN_10_EXP == -4931 +# define FLOAT_MIN_10_NORM 1.0e-4931 +#else +/* libc can't depend on libm. */ +# error "FLOAT_MIN_10_NORM must be precomputed" +# define FLOAT_MIN_10_NORM exp10 (DBL_MIN_10_EXP) +#endif diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c index 492e4e8086..f8650a934f 100644 --- a/misc/efgcvt-template.c +++ b/misc/efgcvt-template.c @@ -20,34 +20,9 @@ #include #include #include -#include #include #include -#ifndef FLOAT_TYPE -# define FLOAT_TYPE double -# define FUNC_PREFIX -# define FLOAT_FMT_FLAG -/* Actually we have to write (DBL_DIG + log10 (DBL_MAX_10_EXP)) but we - don't have log10 available in the preprocessor. */ -# define MAXDIG (NDIGIT_MAX + 3) -# define FCVT_MAXDIG (DBL_MAX_10_EXP + MAXDIG) -# if DBL_MANT_DIG == 53 -# define NDIGIT_MAX 17 -# elif DBL_MANT_DIG == 24 -# define NDIGIT_MAX 9 -# elif DBL_MANT_DIG == 56 -# define NDIGIT_MAX 18 -# else -/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a - compile time constant here, so we cannot use it. */ -# error "NDIGIT_MAX must be precomputed" -# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0))) -# endif -#else -# define LONG_DOUBLE_CVT -#endif - #define APPEND(a, b) APPEND2 (a, b) #define APPEND2(a, b) a##b #define __APPEND(a, b) __APPEND2 (a, b) diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c index 981249850c..74baad78a0 100644 --- a/misc/efgcvt_r-template.c +++ b/misc/efgcvt_r-template.c @@ -17,7 +17,6 @@ . */ #include -#include #include #include #include @@ -26,38 +25,6 @@ #include #include -#ifndef FLOAT_TYPE -# define FLOAT_TYPE double -# define FUNC_PREFIX -# define FLOAT_FMT_FLAG -# define FLOAT_NAME_EXT -# define FLOAT_MIN_10_EXP DBL_MIN_10_EXP -# if DBL_MANT_DIG == 53 -# define NDIGIT_MAX 17 -# elif DBL_MANT_DIG == 24 -# define NDIGIT_MAX 9 -# elif DBL_MANT_DIG == 56 -# define NDIGIT_MAX 18 -# else -/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a - compile time constant here, so we cannot use it. */ -# error "NDIGIT_MAX must be precomputed" -# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0))) -# endif -# if DBL_MIN_10_EXP == -37 -# define FLOAT_MIN_10_NORM 1.0e-37 -# elif DBL_MIN_10_EXP == -307 -# define FLOAT_MIN_10_NORM 1.0e-307 -# elif DBL_MIN_10_EXP == -4931 -# define FLOAT_MIN_10_NORM 1.0e-4931 -# else -/* libc can't depend on libm. */ -# error "FLOAT_MIN_10_NORM must be precomputed" -# define FLOAT_MIN_10_NORM exp10 (DBL_MIN_10_EXP) -# endif -#else -# define LONG_DOUBLE_CVT -#endif #define APPEND(a, b) APPEND2 (a, b) #define APPEND2(a, b) a##b