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: Using the GNU GMP Library for Bignums in Emacs Date: Sat, 07 Jul 2018 00:20:47 -0600 Message-ID: <87lgano9c0.fsf@tromey.com> References: <29f933ac-a6bf-8742-66a7-0a9d6d3e5a88@disroot.org> <83bmecy6fx.fsf@gnu.org> <0d3175d8-d996-651e-b221-71978bde3a65@cs.ucla.edu> <87tvpdnzgy.fsf@tromey.com> <4c2a814f-c254-29e5-39cf-11b5f2e5c9c8@cs.ucla.edu> <87pnzzoeky.fsf@tromey.com> <1150776f-a8fe-86a1-680b-3d1a5d582c6a@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1530944380 31715 195.159.176.226 (7 Jul 2018 06:19:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 7 Jul 2018 06:19:40 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux) Cc: Tom Tromey , Stefan Monnier , emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 07 08:19:36 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 1fbgZD-00087J-Ch for ged-emacs-devel@m.gmane.org; Sat, 07 Jul 2018 08:19:35 +0200 Original-Received: from localhost ([::1]:60722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbgbI-0000vW-RR for ged-emacs-devel@m.gmane.org; Sat, 07 Jul 2018 02:21:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbgaW-0000vE-WC for emacs-devel@gnu.org; Sat, 07 Jul 2018 02:20:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbgaS-0002rM-16 for emacs-devel@gnu.org; Sat, 07 Jul 2018 02:20:56 -0400 Original-Received: from gateway23.websitewelcome.com ([192.185.50.129]:19527) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fbgaR-0002qf-Lm for emacs-devel@gnu.org; Sat, 07 Jul 2018 02:20:51 -0400 Original-Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 845C349ED for ; Sat, 7 Jul 2018 01:20:50 -0500 (CDT) Original-Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id bgaQf0vdWRPojbgaQfb08d; Sat, 07 Jul 2018 01:20:50 -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=ySGNqyfBE4pKDlA7uZ2l8b67+RlA5XjfNV5poEI2bBk=; b=bAKDoliI5rlaPva6H7R+RBOd5x ad99vnnwgIpVv32grwNy0W1/8M4BQGPomNyflyjQQ+ebBxsvQGTNmEvDLTnNWrLHIfo1opKql3eh9 DF7R0uhJHT+gQVBEya+uLTgSA; Original-Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:39720 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fbgaP-004OdP-Vq; Sat, 07 Jul 2018 01:20:50 -0500 X-Attribution: Tom In-Reply-To: <1150776f-a8fe-86a1-680b-3d1a5d582c6a@cs.ucla.edu> (Paul Eggert's message of "Fri, 6 Jul 2018 21:53:15 -0700") 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: 1fbgaP-004OdP-Vq X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-85-72.hlrn.qwest.net (bapiya) [75.166.85.72]:39720 X-Source-Auth: tom+tromey.com X-Email-Count: 3 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.50.129 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:227030 Archived-At: >> #define lisp_h_CHECK_FIXNUM(x) CHECK_TYPE (FIXNUMP (x), Qintegerp, x) Paul> That last line should use Qfixnump, surely. The reason I hesitated is that it seems possible for some Lisp code to notice this change. This is also why I wasn't sure that intbig_to_lisp et al should be converted. (This one seems even a little worse since it'll be possible to build without GMP.) >> sed -i 's/INTEGERP/FIXNUMP/g' *.[ch] Paul> I doubt whether this is the best option. Often, the code should Paul> actually be checking for integers, not for fixnums. So the existing Paul> code needs to be examined more carefully, with only some INTEGERP Paul> instances changed to FIXNUMP. (Code should prefer INTEGERP to FIXNUMP, Paul> for generality, but in some cases FIXNUMP will have to do.) I probably should have explained a little more. The basic idea behind the patch series is to do the conversion incrementally. So, the first patch is just these sed-based renamings -- the resulting Emacs works the same. Next comes the configury; then the bignum type and type predicate. After this come some patches to change various operations: eql, comparisons, arithmetic, printing, the reader, Ffloat, ... Some of these subsequent patches introduce things like the new INTEGERP: INLINE bool INTEGERP (Lisp_Object x) { return FIXNUMP (x) || BIGNUMP (x); } ... or the new make_number, etc. So, the examination you want is done, just not all in a single patch. I think this will make review simpler for whoever does that. Also this avoids having to convert absolutely everything, which I am sure I can't do alone. It's not all so clean right now, so if you do happen to look the patches, don't be worried, I plan to rework the whole series to be cleaner before submitting it. I made a few more things work tonight. My "minimal viable feature" to-do list is down to: * documentation * natnump * since we can't have small bignums we can simplify eql a bit * logcount * check how rounding should be done for division and fix the code * lsh / ash * logb * % and mod Any ideas on things that might be missing from this list? I wonder if Emacs should (provide 'bignum) when bignums are compiled in. I still haven't looked at using the mpn_ API. Tom