Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78149 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84806 invoked from network); 17 Oct 2014 19:00:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Oct 2014 19:00:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 198.187.29.244 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 198.187.29.244 imap1-3.ox.privateemail.com Received: from [198.187.29.244] ([198.187.29.244:52801] helo=imap1-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/21-09495-94761445 for ; Fri, 17 Oct 2014 15:00:26 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 8E8E4B0008B for ; Fri, 17 Oct 2014 15:00:23 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id xdapQg-poTtP for ; Fri, 17 Oct 2014 15:00:23 -0400 (EDT) Received: from oa-res-26-28.wireless.abdn.ac.uk (oa-res-26-28.wireless.abdn.ac.uk [137.50.26.28]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 1518FB0008A for ; Fri, 17 Oct 2014 15:00:22 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) In-Reply-To: <8C47FA53-0964-49C0-963C-332A936348A5@ajf.me> Date: Fri, 17 Oct 2014 20:00:20 +0100 Content-Transfer-Encoding: quoted-printable Message-ID: References: <8C47FA53-0964-49C0-963C-332A936348A5@ajf.me> To: PHP Internals X-Mailer: Apple Mail (2.1990.1) Subject: Re: [PHP-DEV] [RFC] Big Integer Support From: ajf@ajf.me (Andrea Faulds) > On 10 Oct 2014, at 22:33, Andrea Faulds wrote: >=20 > The RFC can be found here: https://wiki.php.net/rfc/bigint >=20 > The patch is, as I mentioned, incomplete. Additionally, there are = quite a few matters left to be decided (see Open Questions). However, I = think I should put this formally under discussion now. I promise not to mail the list for every change I make to this RFC. ;) But I do have quite a big one to announce. Previously, some issues with = the GNU Multiple Precision Arithmetic Library (GMP) had been discovered. = In particular, it is not liberally licensed (LGPL), it only has one set = of custom allocators, which causes segfaults from other libraries which = use it because PHP defines its own allocators, and it immediately calls = an un-hookable abort() in certain failure cases. I was unaware of any good alternatives, however today I was pointed by = Chris Wright (DaveRandom) on StackOverflow towards a new possibility: = LibTomMath. It is liberally licensed (dual-licensed as Public Domain and = WTFPL), written in pure C, packaged for multiple platforms, and it lacks = the immediate abort() problem to the best of my knowledge. Plus, it will = not cause any segfaults when we use custom allocators, as I do not = believe PHP uses any libraries which use LibTomMath at present. If = you=92re worried about whether it=92s battle-tested, it=92s used by = another dynamic language, Tcl. Because it appears to solve all three major issues with GMP, I am = currently porting my bigint branch to use it. This is possible because = the entire implementation of bigints is abstracted, meaning you can swap = out back-ends. If we wished to, we could quite simply allow the choice = of GMP at compile-time, or indeed any other back-end. I should note that LibTomMath certainly isn=92t perfect. I don=92t = believe it is optimised to the same degree GMP is. That being said, = again, it does seem to solve all the major problems I had with GMP. So I = have few qualms in making the patch use it, especially given that it is = easy to swap out the back-end. I=92ve updated the RFC to reflect this new state of affairs: = https://wiki.php.net/rfc/bigint Thoughts? -- Andrea Faulds http://ajf.me/