[PHP-DEV] [PATCH] random_int: Fix power of two check.

2015-05-10 Thread Lauri Kenttä
(x & ~x) is always 0. ((x & (~x + 1)) != x) works. ((x & (x - 1)) != 0) works too. --- ext/standard/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/random.c b/ext/standard/random.c index 12c2503..4a1adbf 100644 --- a/ext/standard/random.c +++ b/ext/standar

Re: [PHP-DEV] [PATCH] random_int: Fix power of two check.

2015-05-10 Thread Nikita Popov
On Sun, May 10, 2015 at 12:40 PM, Lauri Kenttä wrote: > (x & ~x) is always 0. > ((x & (~x + 1)) != x) works. > ((x & (x - 1)) != 0) works too. > --- > ext/standard/random.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/ext/standard/random.c b/ext/standard/random.c > in

Re: [PHP-DEV] Thoughts on C version supported for PHP-Next

2015-05-10 Thread Levi Morrison
> It is hard to judge what "widely supported" means. PHP is so widespread > that people run it on embedded systems, 10+ year old servers (see old > masters.php.net) and compile them with compiler most of us have never > touched (suncc, pcc). Both suncc and pcc support C99. Are you aware of any oth

Re: [PHP-DEV] Thoughts on C version supported for PHP-Next

2015-05-10 Thread Levi Morrison
A feature of C11 that would be useful is anonymous unions: struct zval { union { long lval; double dval; }; enum { IS_LONG, IS_DOUBLE } type; }; int main(void) { struct zval zv; zv.lval = 1; zv.type = IS_LONG; return 0; } Again, thi

Re: [PHP-DEV] Thoughts on C version supported for PHP-Next

2015-05-10 Thread Levi Morrison
> Again, this is a C11 feature. It is supported by clang, gcc and MSVC. To clarify this a bit: they permit anonymous unions in C89 and C99 code (meaning you do not need to pass flags like -std=c11 to enable it). -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http: