Re: [RFC] Big Integer Support

From: Date: Thu, 15 Jan 2015 11:13:05 +0000
Subject: Re: [RFC] Big Integer Support
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message


> On 15 Jan 2015, at 11:01, Andrea Faulds <[email protected]> wrote:
> 
> Hey Dmitry,
> 
>> On 15 Jan 2015, at 07:56, Dmitry Stogov <[email protected]> wrote:
>> 
>> ext/session and ext/json are required by most apps.
>> Actually I stopped attempts to build it when I saw compilation errors in ext/session.
>> 
>> Thanks. Dmitry.
> 
> Oh dear, does ext/session not build? :/
> 
> So far I've only built the branch with --disable-all.
> 
> In the case of most extensions, the main source of compilation errors will be changes to
> certain Zend Engine functions. In particular, is_numeric_string_ex needs to support bigints now and
> has an extra parameter. I don't think I changed very many other functions.
> 
> Porting extensions should for the most part be relatively simple. Most extensions are just sets
> of functions and use zpp. If they're using the 'l' specifier (Z_PARAM_LONG)
> they'll continue to work. In most cases there is no need to update an 'l' parameter
> to support bigints. The length of a string can't exceed PHP's max integer size, for
> example. Of course, there are some functions where it would have a clear benefit to add bigint
> support.
> 
> The main problem with extensions is 'z'

(Sorry, accidentally sent too early)

The main problem with most extensions is the 'z' format specifier which accepts any value.
If it accepts IS_LONG then it needs to accept IS_BIGINT too. In many cases you can just convert the
bigint to a long and maybe reject it or wrap it if it won't fit, if the function doesn't
need to support large integers:

case IS_BIGINT:
    if (!zend_bigint_can_fit_long(Z_BIG_P(some_zval))) {
        zend_error(E_WARNING, "$some_zval too large");
        RETURN_FALSE;
    } else {
        lval = zend_bigint_to_long(Z_BIG_P(some_zval));
    }
    break;

Something like that would work in most cases. There is also convert_to_long.

I probably should have focussed more on extension support, maybe I'll start try to port some of
them, there's not that much Zend stuff left to do really. I would have ported ext/json, but
there's now the jsond RFC.
    
Any help would be appreciated. I am panicking a bit as there's not that long to go before PHP7
feature freeze, assuming Zeev's timetable is actually followed. Though I think this feature
should be doable: as I said, there's not much Zend stuff left to do, and most extensions should
be quite simple to port.

Thanks.
--
Andrea Faulds
http://ajf.me/


Thread (70 messages)

« previous php.internals (#80529) next »