From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Change module interface to no longer use GMP objects directly. Date: Mon, 09 Dec 2019 15:19:50 +0200 Message-ID: <83pngxd4ax.fsf@gnu.org> References: <20191117183828.82379-1-phst@google.com> <089f3d06-e227-27da-c8fe-afcbbbbc934a@cs.ucla.edu> <10cefdff-38ce-438b-881d-15d2fe816a8b@cs.ucla.edu> <3d727645-911e-fc71-1f86-364aa82d06ba@cs.ucla.edu> <287b5f71-75eb-bae2-4f6e-01cce6f07b02@cs.ucla.edu> <87sgmdmxn9.fsf@hase.home> <3479c610-17b7-579c-8109-f7f5d237dcc2@cs.ucla.edu> <83k17aj0je.fsf@gnu.org> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="224929"; mail-complaints-to="usenet@blaine.gmane.org" Cc: phst@google.com, p.stephani2@gmail.com, schwab@linux-m68k.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 09 14:22:22 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ieIzT-000wLw-UD for ged-emacs-devel@m.gmane.org; Mon, 09 Dec 2019 14:22:20 +0100 Original-Received: from localhost ([::1]:40072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieIzS-0002KN-FE for ged-emacs-devel@m.gmane.org; Mon, 09 Dec 2019 08:22:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48441) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieIxO-0000gz-V3 for emacs-devel@gnu.org; Mon, 09 Dec 2019 08:20:13 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:32831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ieIxN-00065t-5z; Mon, 09 Dec 2019 08:20:09 -0500 Original-Received: from [176.228.60.248] (port=1642 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ieIxL-000051-73; Mon, 09 Dec 2019 08:20:08 -0500 In-reply-to: (message from Paul Eggert on Sun, 8 Dec 2019 16:35:13 -0800) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:243259 Archived-At: > Cc: phst@google.com, schwab@linux-m68k.org, monnier@iro.umontreal.ca, > emacs-devel@gnu.org > From: Paul Eggert > Date: Sun, 8 Dec 2019 16:35:13 -0800 > > With that in mind, perhaps we should replace the above 7 lines with > these 2 lines: > > typedef unsigned long long emacs_limb_t; > #define EMACS_LIMB_MAX ULLONG_MAX I don't mind doing this, but then we should remove this comment from emacs-module.c, or reword it so that it says nothing about optimality of matching emacs_limb_t and mp_limb_t: For the magnitude we pick an array of an unsigned integer type similar to mp_limb_t instead of e.g. unsigned char. This matches in most cases the representation of a GMP limb. In such cases GMP picks an optimized algorithm for mpz_import and mpz_export that boils down to a single memcpy to convert the magnitude. This way we largely avoid the import/export overhead on most platforms. because the suggestion means we don't really care about how optimal this is.