From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.devel Subject: Re: bignum branch Date: Sat, 14 Jul 2018 21:04:38 +0100 Message-ID: <86k1pxmvmx.fsf@gmail.com> References: <87o9fbbw1t.fsf@tromey.com> <86in5jdj49.fsf@gmail.com> <83wotxaiwi.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1531598575 8691 195.159.176.226 (14 Jul 2018 20:02:55 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 14 Jul 2018 20:02:55 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 14 22:02:51 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 1feQkk-00029x-Py for ged-emacs-devel@m.gmane.org; Sat, 14 Jul 2018 22:02:50 +0200 Original-Received: from localhost ([::1]:42590 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feQmr-0000mO-Tm for ged-emacs-devel@m.gmane.org; Sat, 14 Jul 2018 16:05:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1feQmm-0000mJ-3N for emacs-devel@gnu.org; Sat, 14 Jul 2018 16:04:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1feQmh-0001lu-6T for emacs-devel@gnu.org; Sat, 14 Jul 2018 16:04:56 -0400 Original-Received: from [195.159.176.226] (port=45433 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1feQmg-0001jo-VB for emacs-devel@gnu.org; Sat, 14 Jul 2018 16:04:51 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1feQkW-0001wR-IE for emacs-devel@gnu.org; Sat, 14 Jul 2018 22:02:36 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 42 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:2Odg6jp6W4wo1xgPMRqLbCLNm0w= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:227414 Archived-At: On Sat 14 Jul 2018, Eli Zaretskii wrote: >> From: Andy Moreton >> Date: Fri, 13 Jul 2018 20:35:18 +0100 >> >> The mpz_* API from libgmp uses "long" as the widest type for native >> integers, which does not work on 64bit mingw64 on Windows, where "long" is >> 32bit and "long long" (used for EMACS_INT) is 64bit. > > Isn't that a problem in how GMP was configured for MinGW64? I see in > the GMP sources that it does check for "long long", so why didn't that > work during the build? > > In the file gmp-h.in (from which gmp.h is generated during the build), > I see this: [snipped] The choice of word size for the limbs internal to GMP is irrelevant here. The problem is that if EMACS_INT is "long long", then the calls to mpz_*_si() API routines will truncate any values passed to GMP. This means that emacs cannot use any the mpz_*_si() routines directly. Alternatives include: a) Build 64bit emacs on Windows using 32bit long for EMACS_INT. This seems undesirable as all values larger than 32bits are then bignums. b) Use 64bit long long for EMACS_INT, and do extra work to pass native values into GMP in two halves, i.e. something like: EMACS_INT i; mpz_t val, tmp; mpz_init_set_si(val, (i >> 32)); mpz_mul_2exp(val, val, 32); mpz_init_set_si(tmp, (i & 0xffffffff); void mpz_ior(val, val, tmp); mpz_clear(tmp); GMP does not yet support C99 types, so will result in awkward and inefficient handling of 64bit vlaues on LLP64 systems. AndyM