From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: bignum branch Date: Sat, 04 Aug 2018 11:24:56 -0600 Message-ID: <8736vum4d3.fsf@tromey.com> References: <87o9fbbw1t.fsf@tromey.com> <86in5jdj49.fsf@gmail.com> <83wotxaiwi.fsf@gnu.org> <86k1pxmvmx.fsf@gmail.com> <87efg4a9xc.fsf@tromey.com> <87a7qr8cz7.fsf@tromey.com> <86tvoy3je9.fsf@gmail.com> <86bmb0vbxf.fsf@gmail.com> <87k1pnfcg1.fsf@tromey.com> <86sh4b1833.fsf@gmail.com> <861sbgz3dm.fsf@gmail.com> <87ftzum6ge.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1533403427 2328 195.159.176.226 (4 Aug 2018 17:23:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 4 Aug 2018 17:23:47 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux) Cc: Andy Moreton , emacs-devel@gnu.org To: Tom Tromey Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 04 19:23:42 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fm0HG-0000UZ-BO for ged-emacs-devel@m.gmane.org; Sat, 04 Aug 2018 19:23:42 +0200 Original-Received: from localhost ([::1]:55755 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fm0JL-00027d-5W for ged-emacs-devel@m.gmane.org; Sat, 04 Aug 2018 13:25:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fm0Ia-00027Q-2b for emacs-devel@gnu.org; Sat, 04 Aug 2018 13:25:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fm0IV-0003YL-5T for emacs-devel@gnu.org; Sat, 04 Aug 2018 13:25:04 -0400 Original-Received: from gateway24.websitewelcome.com ([192.185.51.35]:45203) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fm0IU-0003Y9-Vj for emacs-devel@gnu.org; Sat, 04 Aug 2018 13:24:59 -0400 Original-Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway24.websitewelcome.com (Postfix) with ESMTP id E3B1653D0 for ; Sat, 4 Aug 2018 12:24:57 -0500 (CDT) Original-Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id m0ITfZd9LkBj6m0ITfs8C4; Sat, 04 Aug 2018 12:24:57 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=/pvnizrGw6T5PA6WrnreCuGpeh9g1SgHLpsBvg6Ouh0=; b=QZzv37i4gb/KhyhfDncOgOSgee JC7xoqSzusSBx00vlcoE8s1bh9HqMH2K1TJexyFxZw+jgFUhRWvKpnRv1P6oDg3oopWIHb465loNB bhFddLRyyuFzPezYvbHlkYJA1; Original-Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:43650 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fm0IT-001iFo-IS; Sat, 04 Aug 2018 12:24:57 -0500 X-Attribution: Tom In-Reply-To: <87ftzum6ge.fsf@tromey.com> (Tom Tromey's message of "Sat, 04 Aug 2018 10:39:45 -0600") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.85.72 X-Source-L: No X-Exim-ID: 1fm0IT-001iFo-IS X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-85-72.hlrn.qwest.net (bapiya) [75.166.85.72]:43650 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 192.185.51.35 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:228174 Archived-At: Andy> Please check this works for you, and feel free to commit it to the Andy> bignum branch. Hi. Today I found out about the mpz_import function, which would make the slow case of uintmax_t conversion more robust. I was wondering if you could try the appended? I can't readily try it since I don't think this code path is ever used on my machine. thanks, Tom diff --git a/src/alloc.c b/src/alloc.c index 367bb73fc1..c9c3cfb496 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3874,12 +3874,12 @@ mpz_set_uintmax_slow (mpz_t result, uintmax_t v) { /* If long is larger then a faster path is taken. */ eassert (sizeof (uintmax_t) > sizeof (unsigned long)); - /* This restriction could be lifted if needed. */ - eassert (sizeof (uintmax_t) <= 2 * sizeof (unsigned long)); - mpz_set_ui (result, v >> (CHAR_BIT * sizeof (unsigned long))); - mpz_mul_2exp (result, result, CHAR_BIT * sizeof (unsigned long)); - mpz_add_ui (result, result, v & -1ul); + /* COUNT = 1 means just a single word of the given size. ORDER = -1 + is arbitrary since there's only a single word. ENDIAN = 0 means + use the native endian-ness. NAILS = 0 means use the whole + word. */ + mpz_import (result, 1, -1, sizeof (uintmax_t), 0, 0, &v); }