From: Tjerk Meesters Date: Thu, 9 Oct 2014 23:05:36 +0000 (+0800) Subject: Merge branch 'PHP-5.6' X-Git-Tag: POST_NATIVE_TLS_MERGE^2~76^2~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=284358b317d3066be12552bdc0ab7e0c032f6e29;p=php Merge branch 'PHP-5.6' * PHP-5.6: Add 64 bit formats to pack() and unpack() --- 284358b317d3066be12552bdc0ab7e0c032f6e29 diff --cc ext/standard/pack.c index f2bcb09723,9427db90a0..a690b7bee8 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@@ -82,9 -82,16 +82,16 @@@ static int machine_endian_long_map[4] static int big_endian_long_map[4]; static int little_endian_long_map[4]; + #if SIZEOF_LONG > 4 + /* Mappings of bytes from quads (64bit) for all endian environments */ + static int machine_endian_longlong_map[8]; + static int big_endian_longlong_map[8]; + static int little_endian_longlong_map[8]; + #endif + /* {{{ php_pack */ -static void php_pack(zval **val, int size, int *map, char *output) +static void php_pack(zval *val, size_t size, int *map, char *output) { int i; char *v; @@@ -430,9 -464,34 +457,30 @@@ PHP_FUNCTION(pack break; } + #if SIZEOF_LONG > 4 + case 'q': + case 'Q': + case 'J': + case 'P': { + int *map = machine_endian_longlong_map; + + if (code == 'J') { + map = big_endian_longlong_map; + } else if (code == 'P') { + map = little_endian_longlong_map; + } + + while (arg-- > 0) { + php_pack(argv[currentarg++], 8, map, &output[outputpos]); + outputpos += 8; + } + break; + } + #endif + case 'f': { - float v; - while (arg-- > 0) { - val = argv[currentarg++]; - convert_to_double_ex(val); - v = (float) Z_DVAL_PP(val); + float v = (float) zval_get_double(&argv[currentarg++]); memcpy(&output[outputpos], &v, sizeof(v)); outputpos += sizeof(v); }