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: Mon, 06 Aug 2018 18:36:45 -0600 Message-ID: <87k1p3ko6a.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> <83a7q4ufxp.fsf@gnu.org> <86in4resc8.fsf@gmail.com> <831sbfvl11.fsf@gnu.org> <8636vv7ohh.fsf@gmail.com> <83y3dntwsw.fsf@gnu.org> <83wot7tkdh.fsf@gnu.org> <87y3dnyzkl.fsf@tromey.com> <861sbegz37.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1533602137 4538 195.159.176.226 (7 Aug 2018 00:35:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 7 Aug 2018 00:35:37 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Andy Moreton Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 07 02:35:33 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 1fmpyG-00015R-DP for ged-emacs-devel@m.gmane.org; Tue, 07 Aug 2018 02:35:32 +0200 Original-Received: from localhost ([::1]:36769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmq0N-000511-4f for ged-emacs-devel@m.gmane.org; Mon, 06 Aug 2018 20:37:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmpzk-0004wL-El for emacs-devel@gnu.org; Mon, 06 Aug 2018 20:37:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmpzf-0003Wk-FG for emacs-devel@gnu.org; Mon, 06 Aug 2018 20:37:04 -0400 Original-Received: from gateway22.websitewelcome.com ([192.185.47.79]:47001) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fmpzf-0003Vl-2d for emacs-devel@gnu.org; Mon, 06 Aug 2018 20:36:59 -0400 Original-Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 3759B16B5B for ; Mon, 6 Aug 2018 19:36:47 -0500 (CDT) Original-Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id mpzTfH3JIaSeympzTfpIfO; Mon, 06 Aug 2018 19:36:47 -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=/Xit+5xplULV04fwG57C8wrqtTyT6pTLcynN6qzpCn8=; b=gw+JkXc8v9viXw5R1a7CNldt4O cew0OxiLj7YKj8ovd2fBVwSAn2Epc6KyqoKqi7kih9Qjaf012qoV1tLWFyh9KVmzCkchMFD9QZvy2 wzcCo6l+YthzAAZb3AfNJhj16; Original-Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:52936 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fmpzS-0038JZ-SB; Mon, 06 Aug 2018 19:36:47 -0500 X-Attribution: Tom In-Reply-To: <861sbegz37.fsf@gmail.com> (Andy Moreton's message of "Sat, 04 Aug 2018 12:17:48 +0100") 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: 1fmpzS-0038JZ-SB X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-85-72.hlrn.qwest.net (bapiya) [75.166.85.72]:52936 X-Source-Auth: tom+tromey.com X-Email-Count: 2 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.47.79 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:228253 Archived-At: >>>>> "Andy" == Andy Moreton writes: Andy> purecopy also needs updating tosupport bignums Did you have a use for this? It seems like there must not be any bignums being dumped currently, since if there were, surely something would fail. Anyway, if you do have a use, could you try the appended? Andy> and also the macros in .gdbinit. This doesn't seem like a must-have to me; but if it is, I think it would be best to start by writing pretty-printers to submit to GMP. Tom diff --git a/src/alloc.c b/src/alloc.c index 367bb73fc1..dba90e7eb2 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -5535,6 +5535,28 @@ make_pure_float (double num) return new; } +/* Value is a bignum object with value VALUE allocated from pure + space. */ + +static Lisp_Object +make_pure_bignum (struct Lisp_Bignum *value) +{ + Lisp_Object new; + size_t nbytes = value->value[0]._mp_alloc * sizeof (mp_limb_t); + + struct Lisp_Bignum *b = pure_alloc (sizeof (struct Lisp_Bignum), Lisp_Misc); + b->type = Lisp_Misc_Bignum; + + /* An mpz_t is an array of one element, so this is the correct way + to copy the contents. */ + b->value[0] = value->value[0]; + + b->value[0]._mp_d = pure_alloc (nbytes, -1); + memcpy (b->value[0]._mp_d, value->value[0]._mp_d, nbytes); + + XSETMISC (new, b); + return new; +} /* Return a vector with room for LEN Lisp_Objects allocated from pure space. */ @@ -5676,6 +5698,8 @@ purecopy (Lisp_Object obj) /* Don't hash-cons it. */ return obj; } + else if (BIGNUMP (obj)) + obj = make_pure_bignum (XBIGNUM (obj)); else { AUTO_STRING (fmt, "Don't know how to purify: %S");