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;
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);
}