From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Change module interface to no longer use GMP objects directly. Date: Mon, 9 Dec 2019 16:22:13 -0800 Organization: UCLA Computer Science Department Message-ID: References: <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> <83wob6ch6n.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1CD52F36DC5ADA6F14794474" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="72604"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 Cc: Philipp Stephani , Andreas Schwab , Stefan Monnier , Emacs developers To: Philipp Stephani , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 10 01:22:50 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 1ieTIg-000IjY-Lv for ged-emacs-devel@m.gmane.org; Tue, 10 Dec 2019 01:22:50 +0100 Original-Received: from localhost ([::1]:48636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieTIf-0003Xl-45 for ged-emacs-devel@m.gmane.org; Mon, 09 Dec 2019 19:22:49 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52385) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieTIC-0003XP-QC for emacs-devel@gnu.org; Mon, 09 Dec 2019 19:22:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieTIB-0006ZM-Bq for emacs-devel@gnu.org; Mon, 09 Dec 2019 19:22:20 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:51734) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ieTI8-0006Ya-S9; Mon, 09 Dec 2019 19:22:17 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0EEDF1600CA; Mon, 9 Dec 2019 16:22:15 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id gUUgTVHTMeHf; Mon, 9 Dec 2019 16:22:14 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id F2E2F1601B6; Mon, 9 Dec 2019 16:22:13 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id eaCe5A38VRd3; Mon, 9 Dec 2019 16:22:13 -0800 (PST) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id D1CA41600CA; Mon, 9 Dec 2019 16:22:13 -0800 (PST) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 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:243269 Archived-At: This is a multi-part message in MIME format. --------------1CD52F36DC5ADA6F14794474 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 12/9/19 3:15 PM, Philipp Stephani wrote: > In other words, you'd like it to be an alias for uintptr_t? I'd be > totally fine with that as well. size_t would be a bit better, as it would serve the same function and it's more commonly used and better supported. Something like the attached patch, say. --------------1CD52F36DC5ADA6F14794474 Content-Type: text/x-patch; charset=UTF-8; name="0001-Just-use-size_t-for-emacs_limb_t.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Just-use-size_t-for-emacs_limb_t.patch" >From fa7a36d9f2577fe843fd32beb8df771d7e485c99 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 9 Dec 2019 16:16:56 -0800 Subject: [PATCH] Just use size_t for emacs_limb_t * src/emacs-module.h.in: Do not include limits.h; no longer needed. (emacs_limb_t, EMACS_LIMB_MAX): Now size_t and SIZE_MAX. --- src/emacs-module.h.in | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in index 800c0188ff..0891b1aa28 100644 --- a/src/emacs-module.h.in +++ b/src/emacs-module.h.in @@ -20,7 +20,6 @@ along with GNU Emacs. If not, see . */ #ifndef EMACS_MODULE_H #define EMACS_MODULE_H -#include #include #include #include @@ -97,22 +96,13 @@ enum emacs_process_input_result emacs_process_input_quit = 1 }; -/* -Implementation note: We define emacs_limb_t so that it is likely to -match the GMP mp_limb_t type. If the types match, GMP can use an -optimization for mpz_import and mpz_export that boils down to a -memcpy. According to https://gmplib.org/manual/ABI-and-ISA.html GMP -will prefer a 64-bit limb and will default to unsigned long if that is -wide enough. Note that this is an internal micro-optimization. Users -shouldn't rely on the exact size of emacs_limb_t. -*/ -#if ULONG_MAX == 0xFFFFFFFF -typedef unsigned long long emacs_limb_t; -# define EMACS_LIMB_MAX ULLONG_MAX -#else -typedef unsigned long emacs_limb_t; -# define EMACS_LIMB_MAX ULONG_MAX -#endif +/* Define emacs_limb_t so that it is likely to match GMP's mp_limb_t. + This micro-optimization can help modules that use mpz_export and + mpz_import, which operate more efficiently on mp_limb_t. It's OK + (if perhaps a bit slower) if the two types do not match, and + modules shouldn't rely on the two types matching. */ +typedef size_t emacs_limb_t; +#define EMACS_LIMB_MAX SIZE_MAX struct emacs_env_25 { -- 2.23.0 --------------1CD52F36DC5ADA6F14794474--