From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from conssluserg-04.nifty.com (conssluserg-04.nifty.com [210.131.2.83]) by sourceware.org (Postfix) with ESMTPS id 087D1385841A for ; Sun, 28 Nov 2021 12:38:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 087D1385841A Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp Received: from Express5800-S70 (z221123.dynamic.ppp.asahi-net.or.jp [110.4.221.123]) (authenticated) by conssluserg-04.nifty.com with ESMTP id 1ASCcbkD015848 for ; Sun, 28 Nov 2021 21:38:37 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com 1ASCcbkD015848 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=dec2015msa; t=1638103117; bh=NpFUHOYBnvsP2qHYoM9JtkzVxtkUf5ponZUxE5JNYcA=; h=Date:From:To:Subject:In-Reply-To:References:From; b=voWZn7h1f5nM84v518zxtE2l6bIHSc5MsrO30I6f9K+rIDcuLKbE4HerCuUexQnOT 1ks92ECxpcdr70LI7XQ+iWghbTbVfFKmKLkOUi2OCcAOzLNSTOxHsCLKJU6kOefpGt qeKoWX3ASlAIrqRdR4P1B9jvrD25awZehDHzIZD3RE24GL1bKV4GcAZC8DnT0JoJzV blUZu5auXB90Xs9XxTS1pEKE9rjsp7Pno8SpH6rYuwlhVkdqQa5wdNq63cD/HayCz6 5iypgui5LzetJd9aLi970zcEJl7816iHYfXPen/XE74K7SaacUawUzuAu72lwglKaz Qd/guPYUyB2gw== X-Nifty-SrcIP: [110.4.221.123] Date: Sun, 28 Nov 2021 21:38:39 +0900 From: Takashi Yano To: newlib@sourceware.org Subject: Re: gcc 11.1.0: printf("%.43f\n", 0x1.52f8a8e32e982p-140): printed value is incorrectly rounded Message-Id: <20211128213839.90567fce0606267eb0362cc3@nifty.ne.jp> In-Reply-To: <20211128164311.c405014bdf153aec8de46c6e@nifty.ne.jp> References: <20211128164311.c405014bdf153aec8de46c6e@nifty.ne.jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Nov 2021 12:38:57 -0000 On Sun, 28 Nov 2021 16:43:11 +0900 Takashi Yano wrote: > On Thu, 4 Nov 2021 13:24:42 +0100 > Corinna Vinschen wrote: > > However, a much better fix would be to switch to gdtoa, as the BSDs and > > Mingw64 do. > > I have tried to import gdtoa into newlib from OpenBSD. > > gdtoa seems to use malloc much, so it may not work in some of > platforms due to insufficient heap. Therefore, new ldtoa.c tries > gdtoa first and fallbacks to legacy ldtoa if gdtoa fails. > > To import gdtoa to newlib, I did: > 1) Create "machine/ieee.h" which conditionally defines ieee_ext > structure and EXT_TO_ARRAY32() macro depend on architecture. > 2) Create arith.h which reflects endian of architecture. > 3) Merge gdtoa.h with OpenBSD's gdtoa.h. __BEGIN_HIDDEN_DECLS, > __END_HIDDEN_DECLS, PROTO_NORMAL() and DEF_STRONG() are > defined as dummy in this header. > 4) Replace malloc()/free() with _malloc_r()/_free_r(). > 5) Implement ACQUIRE_DTOA_LOCK() and FREE_DTOA_LOCK() macros > using "sys/lock.h" for multi-threading environment. > 6) Remove inclusion of "gd_qnan.h" which is not used. > > Please see attached patch for more details. > > I confirmed this works nicely with cygwin. Moreover, it is much > faster than legacy ldtoa (more than 4 times faster). > > However, this may break some other supported platforms. > > Could anyone please check this? Ah, in "machine/ieee.h", struct ieee_ext definition for LDBL_MANT_DIG==64 and __IEEE_BIG_ENDIAN case, is obviously wrong. -- Takashi Yano