com php-src: the very first porting try, many things not worky: Zend/zend.h Zend/zend_API.c Zend/zend_builtin_functions.c Zen d/zend_constants.c
Zend/zend_constants.h Zend/zend _exceptions.c Zend/zend_multiply.h Zend/zend_oper ators.c Zend/zend_operators.h Zend/zend_types.h configure.in
ext/date/php_date.c ext/spl/spl_arr ay.c ext/spl/spl_iterators.c ext/standard/array.c ext/standard/basic_functions.c ext/standard/file.c
ext/standard/filestat.c ext/s
| From: | Anatol Belski | Date: | Wed, 16 Oct 2013 09:37:11 +0000 |
| Subject: | com php-src: the very first porting try, many things not worky: Zend/zend.h Zend/zend_API.c Zend/zend_builtin_functions.c Zen d/zend_constants.c Zend/zend_constants.h Zend/zend _exceptions.c Zend/zend_multiply.h Zend/zend_oper ators.c Zend/zend_operators.h Zend/zend_types.h configure.in ext/date/php_date.c ext/spl/spl_arr ay.c ext/spl/spl_iterators.c ext/standard/array.c ext/standard/basic_functions.c ext/standard/file.c ext/standard/filestat.c ext/s |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-73503@lists.php.net to get a copy of this message | ||
Commit: f6cf006496124081aeb944dd762390449b33d6c5
Author: Anatol Belski <ab@php.net> Wed, 17 Jul 2013 09:48:13 -0700
Parents: baf3937c37b6fccbf8b7d4dad87bc221b3056699
Branches: str_size_and_int64
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f6cf006496124081aeb944dd762390449b33d6c5
Log:
the very first porting try, many things not worky
Changed paths:
M Zend/zend.h
M Zend/zend_API.c
M Zend/zend_builtin_functions.c
M Zend/zend_constants.c
M Zend/zend_constants.h
M Zend/zend_exceptions.c
M Zend/zend_multiply.h
M Zend/zend_operators.c
M Zend/zend_operators.h
M Zend/zend_types.h
M configure.in
M ext/date/php_date.c
M ext/spl/spl_array.c
M ext/spl/spl_iterators.c
M ext/standard/array.c
M ext/standard/basic_functions.c
M ext/standard/file.c
M ext/standard/filestat.c
M ext/standard/string.c
M main/main.c
M main/output.c
M main/php.h
M win32/build/config.w32
diff --git a/Zend/zend.h b/Zend/zend.h index 524b5eb..5ccc8ed 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -266,14 +266,14 @@ char *alloca (); #define LONG_MIN (- LONG_MAX - 1) #endif -#if SIZEOF_LONG == 4 +#if SIZEOF_ZEND_INT == 4 #define MAX_LENGTH_OF_LONG 11 static const char long_min_digits[] = "2147483648"; -#elif SIZEOF_LONG == 8 +#elif SIZEOF_ZEND_INT == 8 #define MAX_LENGTH_OF_LONG 20 static const char long_min_digits[] = "9223372036854775808"; #else -#error "Unknown SIZEOF_LONG" +#error "Unknown SIZEOF_ZEND_INT" #endif #define MAX_LENGTH_OF_DOUBLE 32 @@ -319,7 +319,7 @@ typedef struct _zend_object { #include "zend_object_handlers.h" typedef union _zvalue_value { - long lval; /* long value */ + zend_int_t lval; /* long value */ double dval; /* double value */ struct { char *val; @@ -578,7 +578,7 @@ typedef int (*zend_write_func_t)(const char *str, zend_str_size_uint str_length) /* data types */ /* All data types <= IS_BOOL have their constructor/destructors skipped */ #define IS_NULL 0 -#define IS_LONG 1 +#define IS_INT 1 #define IS_DOUBLE 2 #define IS_BOOL 3 #define IS_ARRAY 4 @@ -588,6 +588,7 @@ typedef int (*zend_write_func_t)(const char *str, zend_str_size_uint str_length) #define IS_CONSTANT 8 #define IS_CONSTANT_ARRAY 9 #define IS_CALLABLE 10 +#define IS_LONG IS_INT /* Ugly hack to support constants as static array indices */ #define IS_CONSTANT_TYPE_MASK 0x00f diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 3df2772..92b9805 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -320,11 +320,21 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con spec_walk++; } +#ifdef ZEND_ENABLE_INT64 +# define ZEND_CHECK_INT_RANGE c == 'I' +#else +# define ZEND_CHECK_INT_RANGE c == 'I' || c == 'L' +#endif + switch (c) { +#ifdef ZEND_ENABLE_INT64 case 'l': case 'L': +#endif + case 'i': + case 'I': { - long *p = va_arg(*va, long *); + zend_int_t *p = va_arg(*va, zend_int_t *); if (check_null) { zend_bool *p = va_arg(*va, zend_bool *); @@ -340,12 +350,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRSIZE_PP(arg), p, &d, -1)) == 0) { return "long"; } else if (type == IS_DOUBLE) { - if (c == 'L') { - if (d > LONG_MAX) { - *p = LONG_MAX; + if (ZEND_CHECK_INT_RANGE) { + if (d > ZEND_INT_MAX) { + *p = ZEND_INT_MAX; break; - } else if (d < LONG_MIN) { - *p = LONG_MIN; + } else if (d < ZEND_INT_MIN) { + *p = ZEND_INT_MIN; break; } } @@ -356,12 +366,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con break; case IS_DOUBLE: - if (c == 'L') { - if (Z_DVAL_PP(arg) > LONG_MAX) { - *p = LONG_MAX; + if (ZEND_CHECK_INT_RANGE) { + if (Z_DVAL_PP(arg) > ZEND_INT_MAX) { + *p = ZEND_INT_MAX; break; - } else if (Z_DVAL_PP(arg) < LONG_MIN) { - *p = LONG_MIN; + } else if (Z_DVAL_PP(arg) < ZEND_INT_MIN) { + *p = ZEND_INT_MIN; break; } } @@ -380,7 +390,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con } } break; - +#undef ZEND_CHECK_INT_RANGE case 'd': { double *p = va_arg(*va, double *); @@ -393,7 +403,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con switch (Z_TYPE_PP(arg)) { case IS_STRING: { - long l; + zend_int_t l; int type; if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRSIZE_PP(arg), &l, p, -1)) == 0) { @@ -771,6 +781,7 @@ static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va, case 'f': case 'A': case 'H': case 'p': case 'S': case 'P': + case 'i': max_num_args++; break; diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 682f6c7..74000ef 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -409,10 +409,10 @@ ZEND_FUNCTION(func_get_arg) void **p; int arg_count; zval *arg; - long requested_offset; + zend_int_t requested_offset; zend_execute_data *ex = EG(current_execute_data)->prev_execute_data; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &requested_offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &requested_offset) == FAILURE) { return; } @@ -484,7 +484,7 @@ ZEND_FUNCTION(strlen) return; } - RETVAL_LONG((long) s1_len); + RETVAL_LONG((zend_int_t) s1_len); } /* }}} */ @@ -511,9 +511,9 @@ ZEND_FUNCTION(strncmp) { char *s1, *s2; zend_str_size s1_len, s2_len; - long len; + zend_int_t len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSl", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSi", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) { return; } @@ -549,9 +549,9 @@ ZEND_FUNCTION(strncasecmp) { char *s1, *s2; zend_str_size s1_len, s2_len; - long len; + zend_int_t len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSl", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSi", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) { return; } @@ -1014,7 +1014,7 @@ ZEND_FUNCTION(get_object_vars) while (zend_hash_get_current_data_ex(properties, (void **) &value, &pos) == SUCCESS) { if (zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) { if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) == SUCCESS) { - zend_unmangle_property_name_ex(key, key_len - 1, &class_name, &prop_name, (int*) &prop_len); + zend_unmangle_property_name_ex(key, key_len - 1, &class_name, &prop_name, &prop_len); /* Not separating references */ Z_ADDREF_PP(value); add_assoc_zval_ex(return_value, prop_name, prop_len + 1, *value); @@ -1424,9 +1424,9 @@ ZEND_FUNCTION(class_alias) Cause an intentional memory leak, for testing/debugging purposes */ ZEND_FUNCTION(leak) { - long leakbytes=3; + zend_int_t leakbytes=3; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &leakbytes) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &leakbytes) == FAILURE) { return; } @@ -1492,11 +1492,11 @@ ZEND_FUNCTION(get_included_files) Generates a user-level error/warning/notice message */ ZEND_FUNCTION(trigger_error) { - long error_type = E_USER_NOTICE; + zend_int_t error_type = E_USER_NOTICE; char *message; zend_str_size message_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|l", &message, &message_len, &error_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|i", &message, &message_len, &error_type) == FAILURE) { return; } @@ -1524,9 +1524,9 @@ ZEND_FUNCTION(set_error_handler) { zval *error_handler; char *error_handler_name = NULL; - long error_type = E_ALL; + zend_int_t error_type = E_ALL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|i", &error_handler, &error_type) == FAILURE) { return; } @@ -2067,10 +2067,10 @@ ZEND_FUNCTION(debug_print_backtrace) const char *include_filename = NULL; zval *arg_array = NULL; int indent = 0; - long options = 0; - long limit = 0; + zend_int_t options = 0; + zend_int_t limit = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &options, &limit) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ii", &options, &limit) == FAILURE) { return; } @@ -2398,10 +2398,10 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int Return backtrace as array */ ZEND_FUNCTION(debug_backtrace) { - long options = DEBUG_BACKTRACE_PROVIDE_OBJECT; - long limit = 0; + zend_int_t options = DEBUG_BACKTRACE_PROVIDE_OBJECT; + zend_int_t limit = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &options, &limit) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ii", &options, &limit) == FAILURE) { return; } diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 539871d..5feec9d 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -167,7 +167,7 @@ ZEND_API void zend_register_bool_constant(const char *name, uint name_len, zend_ zend_register_constant(&c TSRMLS_CC); } -ZEND_API void zend_register_long_constant(const char *name, zend_str_size_uint name_len, long lval, int flags, int module_number TSRMLS_DC) +ZEND_API void zend_register_long_constant(const char *name, zend_str_size_uint name_len, zend_int_t lval, int flags, int module_number TSRMLS_DC) { zend_constant c; diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h index 6d6f08a..c6cf014 100644 --- a/Zend/zend_constants.h +++ b/Zend/zend_constants.h @@ -68,7 +68,7 @@ void zend_register_standard_constants(TSRMLS_D); void clean_non_persistent_constants(TSRMLS_D); ZEND_API int zend_get_constant(const char *name, zend_str_size_uint name_len, zval *result TSRMLS_DC); ZEND_API int zend_get_constant_ex(const char *name, zend_str_size_uint name_len, zval *result, zend_class_entry *scope, ulong flags TSRMLS_DC); -ZEND_API void zend_register_long_constant(const char *name, zend_str_size_uint name_len, long lval, int flags, int module_number TSRMLS_DC); +ZEND_API void zend_register_long_constant(const char *name, zend_str_size_uint name_len, zend_int_t lval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_double_constant(const char *name, zend_str_size_uint name_len, double dval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_string_constant(const char *name, zend_str_size_uint name_len, char *strval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_stringl_constant(const char *name, zend_str_size_uint name_len, char *strval, zend_str_size_uint strlen, int flags, int module_number TSRMLS_DC); diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 32c8927..1100c52 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -194,12 +194,12 @@ ZEND_METHOD(exception, __clone) ZEND_METHOD(exception, __construct) { char *message = NULL; - long code = 0; + zend_int_t code = 0; zval *object, *previous = NULL; int argc = ZEND_NUM_ARGS(); zend_str_size message_len; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|SlO!", &message, &message_len, &code, &previous, default_exception_ce) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|SiO!", &message, &message_len, &code, &previous, default_exception_ce) == FAILURE) { zend_error(E_ERROR, "Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])"); } @@ -224,12 +224,12 @@ ZEND_METHOD(exception, __construct) ZEND_METHOD(error_exception, __construct) { char *message = NULL, *filename = NULL; - long code = 0, severity = E_ERROR, lineno; + zend_int_t code = 0, severity = E_ERROR, lineno; zval *object, *previous = NULL; int argc = ZEND_NUM_ARGS(); zend_str_size message_len, filename_len; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|SllSlO!", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno, &previous, default_exception_ce) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|SiiSiO!", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno, &previous, default_exception_ce) == FAILURE) { zend_error(E_ERROR, "Wrong parameters for ErrorException([string $exception [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous = NULL]]]]]])"); } diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index 0d8977f..050ff31 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -68,11 +68,24 @@ else (lval) = __tmpvar; \ } while (0) +#elif defined(PHP_WIN32) && defined(_WIN32) + +#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ + zend_int_t __lres = (a) * (b); \ + long double __dres = (long double)(a) * (long double)(b); \ + long double __delta = (long double) __lres - __dres; \ + if ( ((usedval) = (( __dres + __delta ) != __dres))) { \ + (dval) = __dres; \ + } else { \ + (lval) = __lres; \ + } \ +} while (0) + #elif SIZEOF_LONG == 4 && defined(HAVE_ZEND_LONG64) #define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ zend_long64 __result = (zend_long64) (a) * (zend_long64) (b); \ - if (__result > LONG_MAX || __result < LONG_MIN) { \ + if (__result > ZEND_INT_MAX || __result < ZEND_INT_MIN) { \ (dval) = (double) __result; \ (usedval) = 1; \ } else { \ diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 054a767..35d7aad 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -368,7 +368,7 @@ ZEND_API void convert_to_long(zval *op) /* {{{ */ ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */ { - long tmp; + zend_int_t tmp; switch (Z_TYPE_P(op)) { case IS_NULL: @@ -592,7 +592,7 @@ ZEND_API void _convert_to_cstring(zval *op ZEND_FILE_LINE_DC) /* {{{ */ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */ { - long lval; + zend_int_t lval; double dval; switch (Z_TYPE_P(op)) { @@ -612,7 +612,7 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */ } break; case IS_RESOURCE: { - long tmp = Z_LVAL_P(op); + zend_int_t tmp = Z_LVAL_P(op); TSRMLS_FETCH(); zend_list_delete(Z_LVAL_P(op)); @@ -621,8 +621,11 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */ } case IS_LONG: lval = Z_LVAL_P(op); - +#ifdef ZEND_ENABLE_INT64 + Z_STRSIZE_P(op) = zend_spprintf(&Z_STRVAL_P(op), 0, "%lld", lval); +#else Z_STRSIZE_P(op) = zend_spprintf(&Z_STRVAL_P(op), 0, "%ld", lval); +#endif break; case IS_DOUBLE: { TSRMLS_FETCH(); @@ -975,9 +978,9 @@ ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * zend_error(E_WARNING, "Division by zero"); ZVAL_BOOL(result, 0); return FAILURE; /* division by zero */ - } else if (Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN) { + } else if (Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == ZEND_INT_MIN) { /* Prevent overflow error/crash */ - ZVAL_DOUBLE(result, (double) LONG_MIN / -1); + ZVAL_DOUBLE(result, (double) ZEND_INT_MIN / -1); return SUCCESS; } if (Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0) { /* integer */ @@ -1131,7 +1134,7 @@ ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) { zval *longer, *shorter; @@ -1178,7 +1181,7 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) / ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) { zval *longer, *shorter; @@ -1225,7 +1228,7 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) { zval *longer, *shorter; @@ -1272,7 +1275,7 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) { ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SL); @@ -1292,7 +1295,7 @@ ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) / ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) { ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SR); @@ -1905,7 +1908,7 @@ ZEND_API int increment_function(zval *op1) /* {{{ */ { switch (Z_TYPE_P(op1)) { case IS_LONG: - if (Z_LVAL_P(op1) == LONG_MAX) { + if (Z_LVAL_P(op1) == ZEND_INT_MAX) { /* switch to double */ double d = (double)Z_LVAL_P(op1); ZVAL_DOUBLE(op1, d+1); @@ -1920,13 +1923,13 @@ ZEND_API int increment_function(zval *op1) /* {{{ */ ZVAL_LONG(op1, 1); break; case IS_STRING: { - long lval; + zend_int_t lval; double dval; switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRSIZE_P(op1), &lval, &dval, 0)) { case IS_LONG: str_efree(Z_STRVAL_P(op1)); - if (lval == LONG_MAX) { + if (lval == ZEND_INT_MAX) { /* switch to double */ double d = (double)lval; ZVAL_DOUBLE(op1, d+1); @@ -1968,12 +1971,12 @@ ZEND_API int increment_function(zval *op1) /* {{{ */ ZEND_API int decrement_function(zval *op1) /* {{{ */ { - long lval; + zend_int_t lval; double dval; switch (Z_TYPE_P(op1)) { case IS_LONG: - if (Z_LVAL_P(op1) == LONG_MIN) { + if (Z_LVAL_P(op1) == ZEND_INT_MIN) { double d = (double)Z_LVAL_P(op1); ZVAL_DOUBLE(op1, d-1); } else { @@ -1992,7 +1995,7 @@ ZEND_API int decrement_function(zval *op1) /* {{{ */ switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRSIZE_P(op1), &lval, &dval, 0)) { case IS_LONG: str_efree(Z_STRVAL_P(op1)); - if (lval == LONG_MIN) { + if (lval == ZEND_INT_MIN) { double d = (double)lval; ZVAL_DOUBLE(op1, d-1); } else { @@ -2221,7 +2224,7 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) /* {{{ */ { int ret1, ret2; int oflow1, oflow2; - long lval1 = 0, lval2 = 0; + zend_int_t lval1 = 0, lval2 = 0; double dval1 = 0.0, dval2 = 0.0; if ((ret1=is_numeric_string_ex(Z_STRVAL_P(s1), Z_STRSIZE_P(s1), &lval1, &dval1, 0, &oflow1)) && diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 597aa5e..a2fd016 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -41,7 +41,7 @@ #include "ext/bcmath/libbcmath/src/bcmath.h" #endif -#define LONG_SIGN_MASK (1L << (8*sizeof(long)-1)) +#define LONG_SIGN_MASK (((zend_int_t)1) << (8*sizeof(zend_int_t)-1)) BEGIN_EXTERN_C() ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); @@ -71,11 +71,11 @@ ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, cons END_EXTERN_C() #if ZEND_DVAL_TO_LVAL_CAST_OK -# define zend_dval_to_lval(d) ((long) (d)) -#elif SIZEOF_LONG == 4 -static zend_always_inline long zend_dval_to_lval(double d) +# define zend_dval_to_lval(d) ((zend_int_t) (d)) +#elif SIZEOF_ZEND_INT == 4 +static zend_always_inline zend_int_t zend_dval_to_lval(double d) { - if (d > LONG_MAX || d < LONG_MIN) { + if (d > ZEND_INT_MAX || d < ZEND_INT_MIN) { double two_pow_32 = pow(2., 32.), dmod; @@ -85,15 +85,15 @@ static zend_always_inline long zend_dval_to_lval(double d) * to simulate rounding towards 0 of the negative number */ dmod = ceil(dmod) + two_pow_32; } - return (long)(unsigned long)dmod; + return (zend_int_t)(zend_uint_t)dmod; } - return (long)d; + return (zend_int_t)d; } #else -static zend_always_inline long zend_dval_to_lval(double d) +static zend_always_inline zend_int_t zend_dval_to_lval(double d) { /* >= as (double)LONG_MAX is outside signed range */ - if (d >= LONG_MAX || d < LONG_MIN) { + if (d >= ZEND_INT_MAX || d < ZEND_INT_MIN) { double two_pow_64 = pow(2., 64.), dmod; @@ -103,9 +103,9 @@ static zend_always_inline long zend_dval_to_lval(double d) * fractional part, hence dmod does not have one either */ dmod += two_pow_64; } - return (long)(unsigned long)dmod; + return (zend_int_t)(zend_uint_t)dmod; } - return (long)d; + return (zend_int_t)d; } #endif /* }}} */ @@ -128,7 +128,7 @@ static zend_always_inline long zend_dval_to_lval(double d) * could not be represented as such due to overflow. It writes 1 to oflow_info * if the integer is larger than LONG_MAX and -1 if it's smaller than LONG_MIN. */ -static inline zend_uchar is_numeric_string_ex(const char *str, zend_str_size_int length, long *lval, double *dval, int allow_errors, int *oflow_info) +static inline zend_uchar is_numeric_string_ex(const char *str, zend_str_size_int length, zend_int_t *lval, double *dval, int allow_errors, int *oflow_info) { const char *ptr; int base = 10, digits = 0, dp_or_e = 0; @@ -265,7 +265,7 @@ process_double: } } -static inline zend_uchar is_numeric_string(const char *str, zend_str_size_int length, long *lval, double *dval, int allow_errors) { +static inline zend_uchar is_numeric_string(const char *str, zend_str_size_int length, zend_int_t *lval, double *dval, int allow_errors) { return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL); } @@ -800,6 +800,7 @@ static zend_always_inline int fast_mul_function(zval *result, zval *op1, zval *o static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { + if (EXPECTED(Z_TYPE_P(op1) == IS_LONG) && 0) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { if (UNEXPECTED(Z_LVAL_P(op2) == 0)) { @@ -807,9 +808,9 @@ static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *o Z_LVAL_P(result) = 0; Z_TYPE_P(result) = IS_BOOL; return FAILURE; - } else if (UNEXPECTED(Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN)) { + } else if (UNEXPECTED(Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == ZEND_INT_MIN)) { /* Prevent overflow error/crash */ - Z_DVAL_P(result) = (double) LONG_MIN / -1; + Z_DVAL_P(result) = (double) ZEND_INT_MIN / -1; Z_TYPE_P(result) = IS_DOUBLE; } else if (EXPECTED(Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0)) { /* integer */ diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 8ae0e68..d67d4b6 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -28,18 +28,31 @@ typedef unsigned int zend_uint; typedef unsigned long zend_ulong; typedef unsigned short zend_ushort; - #ifdef ZEND_USE_LEGACY_STRING_TYPES -#define zend_str_size_int int -#define zend_str_size_uint unsigned int -#define zend_str_size_size_t size_t -#define zend_str_size_long long +# define zend_str_size_int int +# define zend_str_size_uint unsigned int +# define zend_str_size_size_t size_t +# define zend_str_size_long long +# define ZEND_SIZE_MAX_LONG LONG_MAX +# define ZEND_SIZE_MAX_INT INT_MAX typedef int zend_str_size; #else -#define zend_str_size_int zend_str_size -#define zend_str_size_uint zend_str_size -#define zend_str_size_size_t zend_str_size -#define zend_str_size_long zend_str_size +# define zend_str_size_int zend_str_size +# define zend_str_size_uint zend_str_size +# define zend_str_size_size_t zend_str_size +# define zend_str_size_long zend_str_size +# ifdef PHP_WIN32 +# ifdef _WIN64 +# define ZEND_SIZE_MAX_LONG _UI64_MAX +# define ZEND_SIZE_MAX_INT _UI64_MAX +# else +# define ZEND_SIZE_MAX_LONG _UI32_MAX +# define ZEND_SIZE_MAX_INT _UI32_MAX +# endif +# else +# define ZEND_SIZE_MAX_LONG SIZE_MAX +# define ZEND_SIZE_MAX_INT SIZE_MAX +# endif typedef size_t zend_str_size; #endif @@ -74,6 +87,38 @@ typedef struct _zend_object_value { const zend_object_handlers *handlers; } zend_object_value; +#ifdef ZEND_ENABLE_INT64 +# ifdef ZEND_WIN32 +# ifdef _WIN64 +typedef __int64 zend_int_t; +typedef unsigned __int64 zend_uint_t; +# define ZEND_INT_MAX _I64_MAX +# define ZEND_INT_MIN _I64_MIN +# define ZEND_UINT_MAX _UI64_MAX +# else +# error Cant enable 64 bit integers on non 64 bit platform +# endif +# else +# if defined(__LP64__) || defined(_LP64) +typedef int64_t zend_int_t; +typedef uint64_t zend_uint_t; +# define ZEND_INT_MAX INT64_MAX +# define ZEND_INT_MIN INT64_MIN +# define ZEND_UINT_MAX UINT64_MAX +# else +# error Cant enable 64 bit integers on non 64 bit platform +# endif +# endif +# define SIZEOF_ZEND_INT 8 +#else +typedef long zend_int_t; +typedef unsigned long zend_uint_t; +# define ZEND_INT_MAX LONG_MAX +# define ZEND_INT_MIN LONG_MIN +# define ZEND_UINT_MAX ULONG_MAX +# define SIZEOF_ZEND_INT SIZEOF_LONG +#endif + #endif /* ZEND_TYPES_H */ /* diff --git a/configure.in b/configure.in index 8530b54..241710d 100644 --- a/configure.in +++ b/configure.in @@ -871,6 +871,13 @@ if test "$PHP_ZSTRLEN" = "yes"; then AC_DEFINE(ZEND_USE_LEGACY_STRING_TYPES, "1", [ ]) fi +PHP_ARG_ENABLE(zint64, whether to enable 64 bit integers, +[ --enable-zint64 Enable 64 bit integers], no, no) + +if test "$PHP_ZINT64" = "yes"; then + AC_DEFINE(ZEND_ENABLE_INT64, "1", []) +fi + PHP_ARG_WITH(layout, layout of installed files, [ --with-layout=TYPE Set how installed files will be laid out. Type can be either PHP or GNU @<:@PHP@:>@], PHP, no) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 7c7a95a..aa2fd40 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1484,13 +1484,13 @@ PHP_FUNCTION(strtotime) /* {{{ php_mktime - (gm)mktime helper */ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt) { - long hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0, dst = -1; + php_int_t hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0, dst = -1; timelib_time *now; timelib_tzinfo *tzi = NULL; - long ts, adjust_seconds = 0; + php_int_t ts, adjust_seconds = 0; int error; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lllllll", &hou, &min, &sec, &mon, &day, &yea, &dst) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|iiiiiii", &hou, &min, &sec, &mon, &day, &yea, &dst) == FAILURE) { RETURN_FALSE; } /* Initialize structure with current time */ diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index aa1aa64..6ca6c6d 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1179,7 +1179,7 @@ SPL_METHOD(Array, __construct) zval *object = getThis(); spl_array_object *intern; zval **array; - long ar_flags = 0; + php_int_t ar_flags = 0; zend_class_entry *ce_get_iterator = spl_ce_Iterator; zend_error_handling error_handling; @@ -1191,7 +1191,7 @@ SPL_METHOD(Array, __construct) intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|iC", &array, &ar_flags, &ce_get_iterator) == FAILURE) { zend_restore_error_handling(&error_handling TSRMLS_CC); return; } diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index e3046f0..e890dbd 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -447,7 +447,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla spl_recursive_it_object *intern; zval *iterator; zend_class_entry *ce_iterator; - long mode, flags; + php_int_t mode, flags; int inc_refcount = 1; zend_error_handling error_handling; @@ -460,7 +460,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla mode = RIT_SELF_FIRST; flags = RTIT_BYPASS_KEY; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "o|lzl", &iterator, &flags, &user_caching_it_flags, &mode) == SUCCESS) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "o|izi", &iterator, &flags, &user_caching_it_flags, &mode) == SUCCESS) { if (instanceof_function(Z_OBJCE_P(iterator), zend_ce_aggregate TSRMLS_CC)) { zval *aggregate = iterator; zend_call_method_with_0_params(&aggregate, Z_OBJCE_P(aggregate), &Z_OBJCE_P(aggregate)->iterator_funcs.zf_new_iterator, "getiterator", &iterator); @@ -490,7 +490,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla mode = RIT_LEAVES_ONLY; flags = 0; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "o|ll", &iterator, &mode, &flags) == SUCCESS) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "o|ii", &iterator, &mode, &flags) == SUCCESS) { if (instanceof_function(Z_OBJCE_P(iterator), zend_ce_aggregate TSRMLS_CC)) { zval *aggregate = iterator; zend_call_method_with_0_params(&aggregate, Z_OBJCE_P(aggregate), &Z_OBJCE_P(aggregate)->iterator_funcs.zf_new_iterator, "getiterator", &iterator); diff --git a/ext/standard/array.c b/ext/standard/array.c index f557cfd..df9836e 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -141,7 +141,7 @@ PHP_MSHUTDOWN_FUNCTION(array) /* {{{ */ } /* }}} */ -static void php_set_compare_func(int sort_type TSRMLS_DC) /* {{{ */ +static void php_set_compare_func(php_int_t sort_type TSRMLS_DC) /* {{{ */ { switch (sort_type & ~PHP_SORT_FLAG_CASE) { case PHP_SORT_NUMERIC: @@ -236,9 +236,9 @@ static int php_array_reverse_key_compare(const void *a, const void *b TSRMLS_DC) PHP_FUNCTION(krsort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &sort_type) == FAILURE) { RETURN_FALSE; } @@ -256,7 +256,7 @@ PHP_FUNCTION(krsort) PHP_FUNCTION(ksort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { RETURN_FALSE; @@ -271,7 +271,7 @@ PHP_FUNCTION(ksort) } /* }}} */ -static int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */ +static int php_count_recursive(zval *array, php_int_t mode TSRMLS_DC) /* {{{ */ { long cnt = 0; zval **element; @@ -306,9 +306,9 @@ static int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */ PHP_FUNCTION(count) { zval *array; - long mode = COUNT_NORMAL; + php_int_t mode = COUNT_NORMAL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &array, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|i", &array, &mode) == FAILURE) { return; } @@ -496,9 +496,9 @@ PHP_FUNCTION(natcasesort) PHP_FUNCTION(asort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &sort_type) == FAILURE) { RETURN_FALSE; } @@ -516,9 +516,9 @@ PHP_FUNCTION(asort) PHP_FUNCTION(arsort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &sort_type) == FAILURE) { RETURN_FALSE; } @@ -536,9 +536,9 @@ PHP_FUNCTION(arsort) PHP_FUNCTION(sort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &sort_type) == FAILURE) { RETURN_FALSE; } @@ -556,9 +556,9 @@ PHP_FUNCTION(sort) PHP_FUNCTION(rsort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &sort_type) == FAILURE) { RETURN_FALSE; } @@ -1513,9 +1513,9 @@ PHP_FUNCTION(compact) PHP_FUNCTION(array_fill) { zval *val; - long start_key, num; + php_int_t start_key, num; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llz", &start_key, &num, &val) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iiz", &start_key, &num, &val) == FAILURE) { return; } @@ -1809,10 +1809,10 @@ PHP_FUNCTION(shuffle) } /* }}} */ -PHPAPI HashTable* php_splice(HashTable *in_hash, int offset, int length, zval ***list, int list_count, HashTable **removed) /* {{{ */ +PHPAPI HashTable* php_splice(HashTable *in_hash, php_int_t offset, php_int_t length, zval ***list, php_int_t list_count, HashTable **removed) /* {{{ */ { HashTable *out_hash = NULL; /* Output hashtable */ - int num_in, /* Number of entries in the input hashtable */ + php_int_t num_in, /* Number of entries in the input hashtable */ pos, /* Current position in the hashtable */ i; /* Loop counter */ Bucket *p; /* Pointer to hash bucket */ @@ -2053,13 +2053,13 @@ PHP_FUNCTION(array_splice) **rem_hash = NULL; /* Removed elements' hash */ HashTable old_hash; Bucket *p; /* Bucket used for traversing hash */ - long i, - offset, - length = 0, - repl_num = 0; /* Number of replacement elements */ + long i; + php_int_t offset, + length = 0; + long repl_num = 0; /* Number of replacement elements */ int num_in; /* Number of elements in the input array */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|lz/", &array, &offset, &length, &repl_array) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ai|iz/", &array, &offset, &length, &repl_array) == FAILURE) { return; } @@ -2084,7 +2084,7 @@ PHP_FUNCTION(array_splice) /* Don't create the array of removed elements if it's not going * to be used; e.g. only removing and/or replacing elements */ if (return_value_used) { - int size = length; + php_int_t size = length; /* Clamp the offset.. */ if (offset > num_in) { @@ -2131,17 +2131,17 @@ PHP_FUNCTION(array_slice) zval *input, /* Input array */ **z_length = NULL, /* How many elements to get */ **entry; /* An array entry */ - long offset, /* Offset to get elements from */ + php_int_t offset, /* Offset to get elements from */ length = 0; zend_bool preserve_keys = 0; /* Whether to preserve keys while copying to the new array or not */ - int num_in, /* Number of elements in the input array */ + php_int_t num_in, /* Number of elements in the input array */ pos; /* Current position in the array */ char *string_key; zend_str_size string_key_len; ulong num_key; HashPosition hpos; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|Zb", &input, &offset, &z_length, &preserve_keys) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ai|Zb", &input, &offset, &z_length, &preserve_keys) == FAILURE) { return; } @@ -2910,7 +2910,7 @@ static int zval_compare(zval **a, zval **b TSRMLS_DC) /* {{{ */ } /* }}} */ -static int zval_user_compare(zval **a, zval **b TSRMLS_DC) /* {{{ */ +static php_int_t zval_user_compare(zval **a, zval **b TSRMLS_DC) /* {{{ */ { zval **args[2]; zval *retval_ptr = NULL; @@ -2924,7 +2924,7 @@ static int zval_user_compare(zval **a, zval **b TSRMLS_DC) /* {{{ */ BG(user_compare_fci).no_separation = 0; if (zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache) TSRMLS_CC) == SUCCESS && retval_ptr) { - long retval; + php_int_t retval; convert_to_long_ex(&retval_ptr); retval = Z_LVAL_P(retval_ptr); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 2069d55..b4aaf7d 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4682,9 +4682,9 @@ PHP_FUNCTION(error_log) char *message, *opt = NULL, *headers = NULL; zend_str_size message_len, opt_len = 0, headers_len = 0; int opt_err = 0, argc = ZEND_NUM_ARGS(); - long erropt = 0; + php_int_t erropt = 0; - if (zend_parse_parameters(argc TSRMLS_CC, "S|lPS", &message, &message_len, &erropt, &opt, &opt_len, &headers, &headers_len) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "S|iPS", &message, &message_len, &erropt, &opt, &opt_len, &headers, &headers_len) == FAILURE) { return; } @@ -5973,11 +5973,11 @@ PHP_FUNCTION(parse_ini_file) char *filename = NULL; zend_str_size filename_len = 0; zend_bool process_sections = 0; - long scanner_mode = ZEND_INI_SCANNER_NORMAL; + php_int_t scanner_mode = ZEND_INI_SCANNER_NORMAL; zend_file_handle fh; zend_ini_parser_cb_t ini_parser_cb; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "P|bl", &filename, &filename_len, &process_sections, &scanner_mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "P|bi", &filename, &filename_len, &process_sections, &scanner_mode) == FAILURE) { RETURN_FALSE; } diff --git a/ext/standard/file.c b/ext/standard/file.c index 6935a2e..577aa5e 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -571,13 +571,13 @@ PHP_FUNCTION(file_put_contents) zend_str_size filename_len; zval *data; zend_str_size numbytes = 0; - long flags = 0; + php_int_t flags = 0; zval *zcontext = NULL; php_stream_context *context = NULL; php_stream *srcstream = NULL; char mode[3] = "wb"; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Pz/|lr!", &filename, &filename_len, &data, &flags, &zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Pz/|ir!", &filename, &filename_len, &data, &flags, &zcontext) == FAILURE) { return; } @@ -1171,11 +1171,11 @@ PHPAPI PHP_FUNCTION(fwrite) zend_str_size arg2len; int ret; zend_str_size num_bytes; - long arg3 = 0; + php_int_t arg3 = 0; char *buffer = NULL; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rS|l", &arg1, &arg2, &arg2len, &arg3) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rS|i", &arg1, &arg2, &arg2len, &arg3) == FAILURE) { RETURN_FALSE; } @@ -1269,10 +1269,10 @@ PHPAPI PHP_FUNCTION(ftell) PHPAPI PHP_FUNCTION(fseek) { zval *arg1; - long arg2, whence = SEEK_SET; + php_int_t arg2, whence = SEEK_SET; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &arg2, &whence) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri|i", &arg1, &arg2, &whence) == FAILURE) { RETURN_FALSE; } @@ -1738,10 +1738,10 @@ safe_to_copy: PHPAPI PHP_FUNCTION(fread) { zval *arg1; - long len; + php_int_t len; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri", &arg1, &len) == FAILURE) { RETURN_FALSE; } diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index df58607..2c57d27 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -668,12 +668,12 @@ PHP_FUNCTION(chmod) { char *filename; zend_str_size filename_len; - long mode; + php_int_t mode; int ret; mode_t imode; php_stream_wrapper *wrapper; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Pl", &filename, &filename_len, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Pi", &filename, &filename_len, &mode) == FAILURE) { return; } @@ -714,14 +714,14 @@ PHP_FUNCTION(touch) { char *filename; zend_str_size filename_len; - long filetime = 0, fileatime = 0; + php_int_t filetime = 0, fileatime = 0; int ret, argc = ZEND_NUM_ARGS(); FILE *file; struct utimbuf newtimebuf; struct utimbuf *newtime = &newtimebuf; php_stream_wrapper *wrapper; - if (zend_parse_parameters(argc TSRMLS_CC, "P|ll", &filename, &filename_len, &filetime, &fileatime) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "P|ii", &filename, &filename_len, &filetime, &fileatime) == FAILURE) { return; } diff --git a/ext/standard/string.c b/ext/standard/string.c index cd59954..c448eec 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1007,7 +1007,7 @@ PHP_FUNCTION(wordwrap) /* {{{ php_explode */ -PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, long limit) +PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, php_int_t limit) { char *p1, *p2, *endp; @@ -1033,7 +1033,7 @@ PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, long limit) /* {{{ php_explode_negative_limit */ -PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_value, long limit) +PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_value, php_int_t limit) { #define EXPLODE_ALLOC_STEP 64 char *p1, *p2, *endp; @@ -1082,10 +1082,10 @@ PHP_FUNCTION(explode) { char *str, *delim; zend_str_size str_len = 0, delim_len = 0; - long limit = LONG_MAX; /* No limit */ + php_int_t limit = PHP_SIZE_MAX_LONG; /* No limit */ zval zdelim, zstr; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|l", &delim, &delim_len, &str, &str_len, &limit) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|i", &delim, &delim_len, &str, &str_len, &limit) == FAILURE) { return; } @@ -1797,10 +1797,10 @@ PHP_FUNCTION(strpos) char *haystack; char *found = NULL; char needle_char[2]; - long offset = 0; + php_int_t offset = 0; zend_str_size haystack_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|l", &haystack, &haystack_len, &needle, &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|i", &haystack, &haystack_len, &needle, &offset) == FAILURE) { return; } @@ -2215,11 +2215,11 @@ PHP_FUNCTION(chunk_split) PHP_FUNCTION(substr) { char *str; - long l = 0, f; + php_int_t l = 0, f; zend_str_size str_len; int argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl|l", &str, &str_len, &f, &l) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Si|i", &str, &str_len, &f, &l) == FAILURE) { return; } @@ -2641,14 +2641,14 @@ PHP_FUNCTION(ord) Converts ASCII code to a character */ PHP_FUNCTION(chr) { - long c; + php_int_t c; char temp[2]; if (ZEND_NUM_ARGS() != 1) { WRONG_PARAM_COUNT; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "l", &c) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "i", &c) == FAILURE) { c = 0; } @@ -4853,11 +4853,11 @@ PHP_FUNCTION(str_repeat) { char *input_str; /* Input string */ zend_str_size input_len; - long mult; /* Multiplier */ + php_int_t mult; /* Multiplier */ char *result; /* Resulting string */ zend_str_size result_len; /* Length of the resulting string */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl", &input_str, &input_len, &mult) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Si", &input_str, &input_len, &mult) == FAILURE) { return; } @@ -5202,7 +5202,7 @@ PHP_FUNCTION(str_pad) /* Input arguments */ char *input; /* Input string */ zend_str_size input_len; - long pad_length; /* Length to pad to */ + php_int_t pad_length; /* Length to pad to */ /* Helper variables */ zend_str_size num_pad_chars; /* Number of padding characters (total - input size) */ @@ -5210,10 +5210,10 @@ PHP_FUNCTION(str_pad) zend_str_size result_len = 0; /* Length of the resulting string */ char *pad_str_val = " "; /* Pointer to padding string */ zend_str_size pad_str_len = 1; /* Length of the padding string */ - long pad_type_val = STR_PAD_RIGHT; /* The padding type value */ + php_int_t pad_type_val = STR_PAD_RIGHT; /* The padding type value */ zend_str_size i, left_pad=0, right_pad=0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl|Sl", &input, &input_len, &pad_length, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Si|Si", &input, &input_len, &pad_length, &pad_str_val, &pad_str_len, &pad_type_val) == FAILURE) { return; } diff --git a/main/main.c b/main/main.c index e65608c..7291767 100644 --- a/main/main.c +++ b/main/main.c @@ -1266,11 +1266,11 @@ PHPAPI char *php_get_current_user(TSRMLS_D) Sets the maximum time a script can run */ PHP_FUNCTION(set_time_limit) { - long new_timeout; + php_int_t new_timeout; char *new_timeout_str; zend_str_size_int new_timeout_strlen; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &new_timeout) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &new_timeout) == FAILURE) { return; } @@ -2132,8 +2132,8 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod REGISTER_MAIN_STRINGL_CONSTANT("PHP_SHLIB_SUFFIX", PHP_SHLIB_SUFFIX, sizeof(PHP_SHLIB_SUFFIX)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_LONG_CONSTANT("PHP_MAXPATHLEN", MAXPATHLEN, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", LONG_MAX, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", sizeof(long), CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", PHP_INT_MAX, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", SIZEOF_ZEND_INT, CONST_PERSISTENT | CONST_CS); #ifdef PHP_WIN32 REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_MAJOR", EG(windows_version_info).dwMajorVersion, CONST_PERSISTENT | CONST_CS); diff --git a/main/output.c b/main/output.c index 4f9e76c..6fe1a3a 100644 --- a/main/output.c +++ b/main/output.c @@ -1304,10 +1304,10 @@ static int php_output_handler_devnull_func(void **handler_context, php_output_co PHP_FUNCTION(ob_start) { zval *output_handler = NULL; - long chunk_size = 0; - long flags = PHP_OUTPUT_HANDLER_STDFLAGS; + php_int_t chunk_size = 0; + php_int_t flags = PHP_OUTPUT_HANDLER_STDFLAGS; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/ll", &output_handler, &chunk_size, &flags) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/ii", &output_handler, &chunk_size, &flags) == FAILURE) { return; } @@ -1527,9 +1527,9 @@ PHP_FUNCTION(ob_get_status) Turn implicit flush on/off and is equivalent to calling flush() after every output call */ PHP_FUNCTION(ob_implicit_flush) { - long flag = 1; + php_int_t flag = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &flag) == FAILURE) { return; } diff --git a/main/php.h b/main/php.h index 48830f8..80cd84b 100644 --- a/main/php.h +++ b/main/php.h @@ -446,6 +446,14 @@ END_EXTERN_C() #endif #endif /* !XtOffsetOf */ +#define php_int_t zend_int_t +#define php_uint_t zend_uint_t +#define PHP_INT_MAX ZEND_INT_MAX +#define PHP_INT_MIN ZEND_INT_MIN +#define PHP_UINT_MAX ZEND_UINT_MAX +#define PHP_SIZE_MAX_LONG ZEND_SIZE_MAX_LONG +#define PHP_SIZE_MAX_INT ZEND_SIZE_MAX_INT + #endif /* diff --git a/win32/build/config.w32 b/win32/build/config.w32 index f2c6e3a..4ffb99c 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -455,3 +455,8 @@ if (PHP_ZSTRLEN == "yes") { AC_DEFINE('ZEND_USE_LEGACY_STRING_TYPES', 1, ""); } +ARG_ENABLE("zint64", "Enable 64 bit integers", "no"); +if (PHP_ZINT64== "yes") { + AC_DEFINE('ZEND_ENABLE_INT64', 1, ""); +} +
diff --git a/Zend/zend.h b/Zend/zend.h index 524b5eb..5ccc8ed 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -266,14 +266,14 @@ char *alloca (); #define LONG_MIN (- LONG_MAX - 1) #endif -#if SIZEOF_LONG == 4 +#if SIZEOF_ZEND_INT == 4 #define MAX_LENGTH_OF_LONG 11 static const char long_min_digits[] = "2147483648"; -#elif SIZEOF_LONG == 8 +#elif SIZEOF_ZEND_INT == 8 #define MAX_LENGTH_OF_LONG 20 static const char long_min_digits[] = "9223372036854775808"; #else -#error "Unknown SIZEOF_LONG" +#error "Unknown SIZEOF_ZEND_INT" #endif #define MAX_LENGTH_OF_DOUBLE 32 @@ -319,7 +319,7 @@ typedef struct _zend_object { #include "zend_object_handlers.h" typedef union _zvalue_value { - long lval; /* long value */ + zend_int_t lval; /* long value */ double dval; /* double value */ struct { char *val; @@ -578,7 +578,7 @@ typedef int (*zend_write_func_t)(const char *str, zend_str_size_uint str_length) /* data types */ /* All data types <= IS_BOOL have their constructor/destructors skipped */ #define IS_NULL 0 -#define IS_LONG 1 +#define IS_INT 1 #define IS_DOUBLE 2 #define IS_BOOL 3 #define IS_ARRAY 4 @@ -588,6 +588,7 @@ typedef int (*zend_write_func_t)(const char *str, zend_str_size_uint str_length) #define IS_CONSTANT 8 #define IS_CONSTANT_ARRAY 9 #define IS_CALLABLE 10 +#define IS_LONG IS_INT /* Ugly hack to support constants as static array indices */ #define IS_CONSTANT_TYPE_MASK 0x00f diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 3df2772..92b9805 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -320,11 +320,21 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con spec_walk++; } +#ifdef ZEND_ENABLE_INT64 +# define ZEND_CHECK_INT_RANGE c == 'I' +#else +# define ZEND_CHECK_INT_RANGE c == 'I' || c == 'L' +#endif + switch (c) { +#ifdef ZEND_ENABLE_INT64 case 'l': case 'L': +#endif + case 'i': + case 'I': { - long *p = va_arg(*va, long *); + zend_int_t *p = va_arg(*va, zend_int_t *); if (check_null) { zend_bool *p = va_arg(*va, zend_bool *); @@ -340,12 +350,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRSIZE_PP(arg), p, &d, -1)) == 0) { return "long"; } else if (type == IS_DOUBLE) { - if (c == 'L') { - if (d > LONG_MAX) { - *p = LONG_MAX; + if (ZEND_CHECK_INT_RANGE) { + if (d > ZEND_INT_MAX) { + *p = ZEND_INT_MAX; break; - } else if (d < LONG_MIN) { - *p = LONG_MIN; + } else if (d < ZEND_INT_MIN) { + *p = ZEND_INT_MIN; break; } } @@ -356,12 +366,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con break; case IS_DOUBLE: - if (c == 'L') { - if (Z_DVAL_PP(arg) > LONG_MAX) { - *p = LONG_MAX; + if (ZEND_CHECK_INT_RANGE) { + if (Z_DVAL_PP(arg) > ZEND_INT_MAX) { + *p = ZEND_INT_MAX; break; - } else if (Z_DVAL_PP(arg) < LONG_MIN) { - *p = LONG_MIN; + } else if (Z_DVAL_PP(arg) < ZEND_INT_MIN) { + *p = ZEND_INT_MIN; break; } } @@ -380,7 +390,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con } } break; - +#undef ZEND_CHECK_INT_RANGE case 'd': { double *p = va_arg(*va, double *); @@ -393,7 +403,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, con switch (Z_TYPE_PP(arg)) { case IS_STRING: { - long l; + zend_int_t l; int type; if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRSIZE_PP(arg), &l, p, -1)) == 0) { @@ -771,6 +781,7 @@ static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va, case 'f': case 'A': case 'H': case 'p': case 'S': case 'P': + case 'i': max_num_args++; break; diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 682f6c7..74000ef 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -409,10 +409,10 @@ ZEND_FUNCTION(func_get_arg) void **p; int arg_count; zval *arg; - long requested_offset; + zend_int_t requested_offset; zend_execute_data *ex = EG(current_execute_data)->prev_execute_data; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &requested_offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &requested_offset) == FAILURE) { return; } @@ -484,7 +484,7 @@ ZEND_FUNCTION(strlen) return; } - RETVAL_LONG((long) s1_len); + RETVAL_LONG((zend_int_t) s1_len); } /* }}} */ @@ -511,9 +511,9 @@ ZEND_FUNCTION(strncmp) { char *s1, *s2; zend_str_size s1_len, s2_len; - long len; + zend_int_t len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSl", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSi", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) { return; } @@ -549,9 +549,9 @@ ZEND_FUNCTION(strncasecmp) { char *s1, *s2; zend_str_size s1_len, s2_len; - long len; + zend_int_t len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSl", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SSi", &s1, &s1_len, &s2, &s2_len, &len) == FAILURE) { return; } @@ -1014,7 +1014,7 @@ ZEND_FUNCTION(get_object_vars) while (zend_hash_get_current_data_ex(properties, (void **) &value, &pos) == SUCCESS) { if (zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos) == HASH_KEY_IS_STRING) { if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) == SUCCESS) { - zend_unmangle_property_name_ex(key, key_len - 1, &class_name, &prop_name, (int*) &prop_len); + zend_unmangle_property_name_ex(key, key_len - 1, &class_name, &prop_name, &prop_len); /* Not separating references */ Z_ADDREF_PP(value); add_assoc_zval_ex(return_value, prop_name, prop_len + 1, *value); @@ -1424,9 +1424,9 @@ ZEND_FUNCTION(class_alias) Cause an intentional memory leak, for testing/debugging purposes */ ZEND_FUNCTION(leak) { - long leakbytes=3; + zend_int_t leakbytes=3; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &leakbytes) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &leakbytes) == FAILURE) { return; } @@ -1492,11 +1492,11 @@ ZEND_FUNCTION(get_included_files) Generates a user-level error/warning/notice message */ ZEND_FUNCTION(trigger_error) { - long error_type = E_USER_NOTICE; + zend_int_t error_type = E_USER_NOTICE; char *message; zend_str_size message_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|l", &message, &message_len, &error_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|i", &message, &message_len, &error_type) == FAILURE) { return; } @@ -1524,9 +1524,9 @@ ZEND_FUNCTION(set_error_handler) { zval *error_handler; char *error_handler_name = NULL; - long error_type = E_ALL; + zend_int_t error_type = E_ALL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &error_handler, &error_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|i", &error_handler, &error_type) == FAILURE) { return; } @@ -2067,10 +2067,10 @@ ZEND_FUNCTION(debug_print_backtrace) const char *include_filename = NULL; zval *arg_array = NULL; int indent = 0; - long options = 0; - long limit = 0; + zend_int_t options = 0; + zend_int_t limit = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &options, &limit) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ii", &options, &limit) == FAILURE) { return; } @@ -2398,10 +2398,10 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int Return backtrace as array */ ZEND_FUNCTION(debug_backtrace) { - long options = DEBUG_BACKTRACE_PROVIDE_OBJECT; - long limit = 0; + zend_int_t options = DEBUG_BACKTRACE_PROVIDE_OBJECT; + zend_int_t limit = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &options, &limit) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ii", &options, &limit) == FAILURE) { return; } diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index 539871d..5feec9d 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -167,7 +167,7 @@ ZEND_API void zend_register_bool_constant(const char *name, uint name_len, zend_ zend_register_constant(&c TSRMLS_CC); } -ZEND_API void zend_register_long_constant(const char *name, zend_str_size_uint name_len, long lval, int flags, int module_number TSRMLS_DC) +ZEND_API void zend_register_long_constant(const char *name, zend_str_size_uint name_len, zend_int_t lval, int flags, int module_number TSRMLS_DC) { zend_constant c; diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h index 6d6f08a..c6cf014 100644 --- a/Zend/zend_constants.h +++ b/Zend/zend_constants.h @@ -68,7 +68,7 @@ void zend_register_standard_constants(TSRMLS_D); void clean_non_persistent_constants(TSRMLS_D); ZEND_API int zend_get_constant(const char *name, zend_str_size_uint name_len, zval *result TSRMLS_DC); ZEND_API int zend_get_constant_ex(const char *name, zend_str_size_uint name_len, zval *result, zend_class_entry *scope, ulong flags TSRMLS_DC); -ZEND_API void zend_register_long_constant(const char *name, zend_str_size_uint name_len, long lval, int flags, int module_number TSRMLS_DC); +ZEND_API void zend_register_long_constant(const char *name, zend_str_size_uint name_len, zend_int_t lval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_double_constant(const char *name, zend_str_size_uint name_len, double dval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_string_constant(const char *name, zend_str_size_uint name_len, char *strval, int flags, int module_number TSRMLS_DC); ZEND_API void zend_register_stringl_constant(const char *name, zend_str_size_uint name_len, char *strval, zend_str_size_uint strlen, int flags, int module_number TSRMLS_DC); diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 32c8927..1100c52 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -194,12 +194,12 @@ ZEND_METHOD(exception, __clone) ZEND_METHOD(exception, __construct) { char *message = NULL; - long code = 0; + zend_int_t code = 0; zval *object, *previous = NULL; int argc = ZEND_NUM_ARGS(); zend_str_size message_len; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|SlO!", &message, &message_len, &code, &previous, default_exception_ce) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|SiO!", &message, &message_len, &code, &previous, default_exception_ce) == FAILURE) { zend_error(E_ERROR, "Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])"); } @@ -224,12 +224,12 @@ ZEND_METHOD(exception, __construct) ZEND_METHOD(error_exception, __construct) { char *message = NULL, *filename = NULL; - long code = 0, severity = E_ERROR, lineno; + zend_int_t code = 0, severity = E_ERROR, lineno; zval *object, *previous = NULL; int argc = ZEND_NUM_ARGS(); zend_str_size message_len, filename_len; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|SllSlO!", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno, &previous, default_exception_ce) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC, "|SiiSiO!", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno, &previous, default_exception_ce) == FAILURE) { zend_error(E_ERROR, "Wrong parameters for ErrorException([string $exception [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous = NULL]]]]]])"); } diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index 0d8977f..050ff31 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -68,11 +68,24 @@ else (lval) = __tmpvar; \ } while (0) +#elif defined(PHP_WIN32) && defined(_WIN32) + +#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ + zend_int_t __lres = (a) * (b); \ + long double __dres = (long double)(a) * (long double)(b); \ + long double __delta = (long double) __lres - __dres; \ + if ( ((usedval) = (( __dres + __delta ) != __dres))) { \ + (dval) = __dres; \ + } else { \ + (lval) = __lres; \ + } \ +} while (0) + #elif SIZEOF_LONG == 4 && defined(HAVE_ZEND_LONG64) #define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ zend_long64 __result = (zend_long64) (a) * (zend_long64) (b); \ - if (__result > LONG_MAX || __result < LONG_MIN) { \ + if (__result > ZEND_INT_MAX || __result < ZEND_INT_MIN) { \ (dval) = (double) __result; \ (usedval) = 1; \ } else { \ diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 054a767..35d7aad 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -368,7 +368,7 @@ ZEND_API void convert_to_long(zval *op) /* {{{ */ ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */ { - long tmp; + zend_int_t tmp; switch (Z_TYPE_P(op)) { case IS_NULL: @@ -592,7 +592,7 @@ ZEND_API void _convert_to_cstring(zval *op ZEND_FILE_LINE_DC) /* {{{ */ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */ { - long lval; + zend_int_t lval; double dval; switch (Z_TYPE_P(op)) { @@ -612,7 +612,7 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */ } break; case IS_RESOURCE: { - long tmp = Z_LVAL_P(op); + zend_int_t tmp = Z_LVAL_P(op); TSRMLS_FETCH(); zend_list_delete(Z_LVAL_P(op)); @@ -621,8 +621,11 @@ ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC) /* {{{ */ } case IS_LONG: lval = Z_LVAL_P(op); - +#ifdef ZEND_ENABLE_INT64 + Z_STRSIZE_P(op) = zend_spprintf(&Z_STRVAL_P(op), 0, "%lld", lval); +#else Z_STRSIZE_P(op) = zend_spprintf(&Z_STRVAL_P(op), 0, "%ld", lval); +#endif break; case IS_DOUBLE: { TSRMLS_FETCH(); @@ -975,9 +978,9 @@ ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ * zend_error(E_WARNING, "Division by zero"); ZVAL_BOOL(result, 0); return FAILURE; /* division by zero */ - } else if (Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN) { + } else if (Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == ZEND_INT_MIN) { /* Prevent overflow error/crash */ - ZVAL_DOUBLE(result, (double) LONG_MIN / -1); + ZVAL_DOUBLE(result, (double) ZEND_INT_MIN / -1); return SUCCESS; } if (Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0) { /* integer */ @@ -1131,7 +1134,7 @@ ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC) /* {{{ */ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) { zval *longer, *shorter; @@ -1178,7 +1181,7 @@ ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) / ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) { zval *longer, *shorter; @@ -1225,7 +1228,7 @@ ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) == IS_STRING && Z_TYPE_P(op2) == IS_STRING) { zval *longer, *shorter; @@ -1272,7 +1275,7 @@ ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) { ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SL); @@ -1292,7 +1295,7 @@ ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) / ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */ { zval op1_copy, op2_copy; - long op1_lval; + zend_int_t op1_lval; if (Z_TYPE_P(op1) != IS_LONG || Z_TYPE_P(op2) != IS_LONG) { ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SR); @@ -1905,7 +1908,7 @@ ZEND_API int increment_function(zval *op1) /* {{{ */ { switch (Z_TYPE_P(op1)) { case IS_LONG: - if (Z_LVAL_P(op1) == LONG_MAX) { + if (Z_LVAL_P(op1) == ZEND_INT_MAX) { /* switch to double */ double d = (double)Z_LVAL_P(op1); ZVAL_DOUBLE(op1, d+1); @@ -1920,13 +1923,13 @@ ZEND_API int increment_function(zval *op1) /* {{{ */ ZVAL_LONG(op1, 1); break; case IS_STRING: { - long lval; + zend_int_t lval; double dval; switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRSIZE_P(op1), &lval, &dval, 0)) { case IS_LONG: str_efree(Z_STRVAL_P(op1)); - if (lval == LONG_MAX) { + if (lval == ZEND_INT_MAX) { /* switch to double */ double d = (double)lval; ZVAL_DOUBLE(op1, d+1); @@ -1968,12 +1971,12 @@ ZEND_API int increment_function(zval *op1) /* {{{ */ ZEND_API int decrement_function(zval *op1) /* {{{ */ { - long lval; + zend_int_t lval; double dval; switch (Z_TYPE_P(op1)) { case IS_LONG: - if (Z_LVAL_P(op1) == LONG_MIN) { + if (Z_LVAL_P(op1) == ZEND_INT_MIN) { double d = (double)Z_LVAL_P(op1); ZVAL_DOUBLE(op1, d-1); } else { @@ -1992,7 +1995,7 @@ ZEND_API int decrement_function(zval *op1) /* {{{ */ switch (is_numeric_string(Z_STRVAL_P(op1), Z_STRSIZE_P(op1), &lval, &dval, 0)) { case IS_LONG: str_efree(Z_STRVAL_P(op1)); - if (lval == LONG_MIN) { + if (lval == ZEND_INT_MIN) { double d = (double)lval; ZVAL_DOUBLE(op1, d-1); } else { @@ -2221,7 +2224,7 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) /* {{{ */ { int ret1, ret2; int oflow1, oflow2; - long lval1 = 0, lval2 = 0; + zend_int_t lval1 = 0, lval2 = 0; double dval1 = 0.0, dval2 = 0.0; if ((ret1=is_numeric_string_ex(Z_STRVAL_P(s1), Z_STRSIZE_P(s1), &lval1, &dval1, 0, &oflow1)) && diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 597aa5e..a2fd016 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -41,7 +41,7 @@ #include "ext/bcmath/libbcmath/src/bcmath.h" #endif -#define LONG_SIGN_MASK (1L << (8*sizeof(long)-1)) +#define LONG_SIGN_MASK (((zend_int_t)1) << (8*sizeof(zend_int_t)-1)) BEGIN_EXTERN_C() ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); @@ -71,11 +71,11 @@ ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, cons END_EXTERN_C() #if ZEND_DVAL_TO_LVAL_CAST_OK -# define zend_dval_to_lval(d) ((long) (d)) -#elif SIZEOF_LONG == 4 -static zend_always_inline long zend_dval_to_lval(double d) +# define zend_dval_to_lval(d) ((zend_int_t) (d)) +#elif SIZEOF_ZEND_INT == 4 +static zend_always_inline zend_int_t zend_dval_to_lval(double d) { - if (d > LONG_MAX || d < LONG_MIN) { + if (d > ZEND_INT_MAX || d < ZEND_INT_MIN) { double two_pow_32 = pow(2., 32.), dmod; @@ -85,15 +85,15 @@ static zend_always_inline long zend_dval_to_lval(double d) * to simulate rounding towards 0 of the negative number */ dmod = ceil(dmod) + two_pow_32; } - return (long)(unsigned long)dmod; + return (zend_int_t)(zend_uint_t)dmod; } - return (long)d; + return (zend_int_t)d; } #else -static zend_always_inline long zend_dval_to_lval(double d) +static zend_always_inline zend_int_t zend_dval_to_lval(double d) { /* >= as (double)LONG_MAX is outside signed range */ - if (d >= LONG_MAX || d < LONG_MIN) { + if (d >= ZEND_INT_MAX || d < ZEND_INT_MIN) { double two_pow_64 = pow(2., 64.), dmod; @@ -103,9 +103,9 @@ static zend_always_inline long zend_dval_to_lval(double d) * fractional part, hence dmod does not have one either */ dmod += two_pow_64; } - return (long)(unsigned long)dmod; + return (zend_int_t)(zend_uint_t)dmod; } - return (long)d; + return (zend_int_t)d; } #endif /* }}} */ @@ -128,7 +128,7 @@ static zend_always_inline long zend_dval_to_lval(double d) * could not be represented as such due to overflow. It writes 1 to oflow_info * if the integer is larger than LONG_MAX and -1 if it's smaller than LONG_MIN. */ -static inline zend_uchar is_numeric_string_ex(const char *str, zend_str_size_int length, long *lval, double *dval, int allow_errors, int *oflow_info) +static inline zend_uchar is_numeric_string_ex(const char *str, zend_str_size_int length, zend_int_t *lval, double *dval, int allow_errors, int *oflow_info) { const char *ptr; int base = 10, digits = 0, dp_or_e = 0; @@ -265,7 +265,7 @@ process_double: } } -static inline zend_uchar is_numeric_string(const char *str, zend_str_size_int length, long *lval, double *dval, int allow_errors) { +static inline zend_uchar is_numeric_string(const char *str, zend_str_size_int length, zend_int_t *lval, double *dval, int allow_errors) { return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL); } @@ -800,6 +800,7 @@ static zend_always_inline int fast_mul_function(zval *result, zval *op1, zval *o static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) { + if (EXPECTED(Z_TYPE_P(op1) == IS_LONG) && 0) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { if (UNEXPECTED(Z_LVAL_P(op2) == 0)) { @@ -807,9 +808,9 @@ static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *o Z_LVAL_P(result) = 0; Z_TYPE_P(result) = IS_BOOL; return FAILURE; - } else if (UNEXPECTED(Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN)) { + } else if (UNEXPECTED(Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == ZEND_INT_MIN)) { /* Prevent overflow error/crash */ - Z_DVAL_P(result) = (double) LONG_MIN / -1; + Z_DVAL_P(result) = (double) ZEND_INT_MIN / -1; Z_TYPE_P(result) = IS_DOUBLE; } else if (EXPECTED(Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0)) { /* integer */ diff --git a/Zend/zend_types.h b/Zend/zend_types.h index 8ae0e68..d67d4b6 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -28,18 +28,31 @@ typedef unsigned int zend_uint; typedef unsigned long zend_ulong; typedef unsigned short zend_ushort; - #ifdef ZEND_USE_LEGACY_STRING_TYPES -#define zend_str_size_int int -#define zend_str_size_uint unsigned int -#define zend_str_size_size_t size_t -#define zend_str_size_long long +# define zend_str_size_int int +# define zend_str_size_uint unsigned int +# define zend_str_size_size_t size_t +# define zend_str_size_long long +# define ZEND_SIZE_MAX_LONG LONG_MAX +# define ZEND_SIZE_MAX_INT INT_MAX typedef int zend_str_size; #else -#define zend_str_size_int zend_str_size -#define zend_str_size_uint zend_str_size -#define zend_str_size_size_t zend_str_size -#define zend_str_size_long zend_str_size +# define zend_str_size_int zend_str_size +# define zend_str_size_uint zend_str_size +# define zend_str_size_size_t zend_str_size +# define zend_str_size_long zend_str_size +# ifdef PHP_WIN32 +# ifdef _WIN64 +# define ZEND_SIZE_MAX_LONG _UI64_MAX +# define ZEND_SIZE_MAX_INT _UI64_MAX +# else +# define ZEND_SIZE_MAX_LONG _UI32_MAX +# define ZEND_SIZE_MAX_INT _UI32_MAX +# endif +# else +# define ZEND_SIZE_MAX_LONG SIZE_MAX +# define ZEND_SIZE_MAX_INT SIZE_MAX +# endif typedef size_t zend_str_size; #endif @@ -74,6 +87,38 @@ typedef struct _zend_object_value { const zend_object_handlers *handlers; } zend_object_value; +#ifdef ZEND_ENABLE_INT64 +# ifdef ZEND_WIN32 +# ifdef _WIN64 +typedef __int64 zend_int_t; +typedef unsigned __int64 zend_uint_t; +# define ZEND_INT_MAX _I64_MAX +# define ZEND_INT_MIN _I64_MIN +# define ZEND_UINT_MAX _UI64_MAX +# else +# error Cant enable 64 bit integers on non 64 bit platform +# endif +# else +# if defined(__LP64__) || defined(_LP64) +typedef int64_t zend_int_t; +typedef uint64_t zend_uint_t; +# define ZEND_INT_MAX INT64_MAX +# define ZEND_INT_MIN INT64_MIN +# define ZEND_UINT_MAX UINT64_MAX +# else +# error Cant enable 64 bit integers on non 64 bit platform +# endif +# endif +# define SIZEOF_ZEND_INT 8 +#else +typedef long zend_int_t; +typedef unsigned long zend_uint_t; +# define ZEND_INT_MAX LONG_MAX +# define ZEND_INT_MIN LONG_MIN +# define ZEND_UINT_MAX ULONG_MAX +# define SIZEOF_ZEND_INT SIZEOF_LONG +#endif + #endif /* ZEND_TYPES_H */ /* diff --git a/configure.in b/configure.in index 8530b54..241710d 100644 --- a/configure.in +++ b/configure.in @@ -871,6 +871,13 @@ if test "$PHP_ZSTRLEN" = "yes"; then AC_DEFINE(ZEND_USE_LEGACY_STRING_TYPES, "1", [ ]) fi +PHP_ARG_ENABLE(zint64, whether to enable 64 bit integers, +[ --enable-zint64 Enable 64 bit integers], no, no) + +if test "$PHP_ZINT64" = "yes"; then + AC_DEFINE(ZEND_ENABLE_INT64, "1", []) +fi + PHP_ARG_WITH(layout, layout of installed files, [ --with-layout=TYPE Set how installed files will be laid out. Type can be either PHP or GNU @<:@PHP@:>@], PHP, no) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 7c7a95a..aa2fd40 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1484,13 +1484,13 @@ PHP_FUNCTION(strtotime) /* {{{ php_mktime - (gm)mktime helper */ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt) { - long hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0, dst = -1; + php_int_t hou = 0, min = 0, sec = 0, mon = 0, day = 0, yea = 0, dst = -1; timelib_time *now; timelib_tzinfo *tzi = NULL; - long ts, adjust_seconds = 0; + php_int_t ts, adjust_seconds = 0; int error; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lllllll", &hou, &min, &sec, &mon, &day, &yea, &dst) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|iiiiiii", &hou, &min, &sec, &mon, &day, &yea, &dst) == FAILURE) { RETURN_FALSE; } /* Initialize structure with current time */ diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index aa1aa64..6ca6c6d 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1179,7 +1179,7 @@ SPL_METHOD(Array, __construct) zval *object = getThis(); spl_array_object *intern; zval **array; - long ar_flags = 0; + php_int_t ar_flags = 0; zend_class_entry *ce_get_iterator = spl_ce_Iterator; zend_error_handling error_handling; @@ -1191,7 +1191,7 @@ SPL_METHOD(Array, __construct) intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|iC", &array, &ar_flags, &ce_get_iterator) == FAILURE) { zend_restore_error_handling(&error_handling TSRMLS_CC); return; } diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index e3046f0..e890dbd 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -447,7 +447,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla spl_recursive_it_object *intern; zval *iterator; zend_class_entry *ce_iterator; - long mode, flags; + php_int_t mode, flags; int inc_refcount = 1; zend_error_handling error_handling; @@ -460,7 +460,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla mode = RIT_SELF_FIRST; flags = RTIT_BYPASS_KEY; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "o|lzl", &iterator, &flags, &user_caching_it_flags, &mode) == SUCCESS) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "o|izi", &iterator, &flags, &user_caching_it_flags, &mode) == SUCCESS) { if (instanceof_function(Z_OBJCE_P(iterator), zend_ce_aggregate TSRMLS_CC)) { zval *aggregate = iterator; zend_call_method_with_0_params(&aggregate, Z_OBJCE_P(aggregate), &Z_OBJCE_P(aggregate)->iterator_funcs.zf_new_iterator, "getiterator", &iterator); @@ -490,7 +490,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla mode = RIT_LEAVES_ONLY; flags = 0; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "o|ll", &iterator, &mode, &flags) == SUCCESS) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "o|ii", &iterator, &mode, &flags) == SUCCESS) { if (instanceof_function(Z_OBJCE_P(iterator), zend_ce_aggregate TSRMLS_CC)) { zval *aggregate = iterator; zend_call_method_with_0_params(&aggregate, Z_OBJCE_P(aggregate), &Z_OBJCE_P(aggregate)->iterator_funcs.zf_new_iterator, "getiterator", &iterator); diff --git a/ext/standard/array.c b/ext/standard/array.c index f557cfd..df9836e 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -141,7 +141,7 @@ PHP_MSHUTDOWN_FUNCTION(array) /* {{{ */ } /* }}} */ -static void php_set_compare_func(int sort_type TSRMLS_DC) /* {{{ */ +static void php_set_compare_func(php_int_t sort_type TSRMLS_DC) /* {{{ */ { switch (sort_type & ~PHP_SORT_FLAG_CASE) { case PHP_SORT_NUMERIC: @@ -236,9 +236,9 @@ static int php_array_reverse_key_compare(const void *a, const void *b TSRMLS_DC) PHP_FUNCTION(krsort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &sort_type) == FAILURE) { RETURN_FALSE; } @@ -256,7 +256,7 @@ PHP_FUNCTION(krsort) PHP_FUNCTION(ksort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { RETURN_FALSE; @@ -271,7 +271,7 @@ PHP_FUNCTION(ksort) } /* }}} */ -static int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */ +static int php_count_recursive(zval *array, php_int_t mode TSRMLS_DC) /* {{{ */ { long cnt = 0; zval **element; @@ -306,9 +306,9 @@ static int php_count_recursive(zval *array, long mode TSRMLS_DC) /* {{{ */ PHP_FUNCTION(count) { zval *array; - long mode = COUNT_NORMAL; + php_int_t mode = COUNT_NORMAL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &array, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|i", &array, &mode) == FAILURE) { return; } @@ -496,9 +496,9 @@ PHP_FUNCTION(natcasesort) PHP_FUNCTION(asort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &sort_type) == FAILURE) { RETURN_FALSE; } @@ -516,9 +516,9 @@ PHP_FUNCTION(asort) PHP_FUNCTION(arsort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &sort_type) == FAILURE) { RETURN_FALSE; } @@ -536,9 +536,9 @@ PHP_FUNCTION(arsort) PHP_FUNCTION(sort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &sort_type) == FAILURE) { RETURN_FALSE; } @@ -556,9 +556,9 @@ PHP_FUNCTION(sort) PHP_FUNCTION(rsort) { zval *array; - long sort_type = PHP_SORT_REGULAR; + php_int_t sort_type = PHP_SORT_REGULAR; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", &array, &sort_type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|i", &array, &sort_type) == FAILURE) { RETURN_FALSE; } @@ -1513,9 +1513,9 @@ PHP_FUNCTION(compact) PHP_FUNCTION(array_fill) { zval *val; - long start_key, num; + php_int_t start_key, num; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llz", &start_key, &num, &val) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "iiz", &start_key, &num, &val) == FAILURE) { return; } @@ -1809,10 +1809,10 @@ PHP_FUNCTION(shuffle) } /* }}} */ -PHPAPI HashTable* php_splice(HashTable *in_hash, int offset, int length, zval ***list, int list_count, HashTable **removed) /* {{{ */ +PHPAPI HashTable* php_splice(HashTable *in_hash, php_int_t offset, php_int_t length, zval ***list, php_int_t list_count, HashTable **removed) /* {{{ */ { HashTable *out_hash = NULL; /* Output hashtable */ - int num_in, /* Number of entries in the input hashtable */ + php_int_t num_in, /* Number of entries in the input hashtable */ pos, /* Current position in the hashtable */ i; /* Loop counter */ Bucket *p; /* Pointer to hash bucket */ @@ -2053,13 +2053,13 @@ PHP_FUNCTION(array_splice) **rem_hash = NULL; /* Removed elements' hash */ HashTable old_hash; Bucket *p; /* Bucket used for traversing hash */ - long i, - offset, - length = 0, - repl_num = 0; /* Number of replacement elements */ + long i; + php_int_t offset, + length = 0; + long repl_num = 0; /* Number of replacement elements */ int num_in; /* Number of elements in the input array */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|lz/", &array, &offset, &length, &repl_array) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ai|iz/", &array, &offset, &length, &repl_array) == FAILURE) { return; } @@ -2084,7 +2084,7 @@ PHP_FUNCTION(array_splice) /* Don't create the array of removed elements if it's not going * to be used; e.g. only removing and/or replacing elements */ if (return_value_used) { - int size = length; + php_int_t size = length; /* Clamp the offset.. */ if (offset > num_in) { @@ -2131,17 +2131,17 @@ PHP_FUNCTION(array_slice) zval *input, /* Input array */ **z_length = NULL, /* How many elements to get */ **entry; /* An array entry */ - long offset, /* Offset to get elements from */ + php_int_t offset, /* Offset to get elements from */ length = 0; zend_bool preserve_keys = 0; /* Whether to preserve keys while copying to the new array or not */ - int num_in, /* Number of elements in the input array */ + php_int_t num_in, /* Number of elements in the input array */ pos; /* Current position in the array */ char *string_key; zend_str_size string_key_len; ulong num_key; HashPosition hpos; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|Zb", &input, &offset, &z_length, &preserve_keys) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ai|Zb", &input, &offset, &z_length, &preserve_keys) == FAILURE) { return; } @@ -2910,7 +2910,7 @@ static int zval_compare(zval **a, zval **b TSRMLS_DC) /* {{{ */ } /* }}} */ -static int zval_user_compare(zval **a, zval **b TSRMLS_DC) /* {{{ */ +static php_int_t zval_user_compare(zval **a, zval **b TSRMLS_DC) /* {{{ */ { zval **args[2]; zval *retval_ptr = NULL; @@ -2924,7 +2924,7 @@ static int zval_user_compare(zval **a, zval **b TSRMLS_DC) /* {{{ */ BG(user_compare_fci).no_separation = 0; if (zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache) TSRMLS_CC) == SUCCESS && retval_ptr) { - long retval; + php_int_t retval; convert_to_long_ex(&retval_ptr); retval = Z_LVAL_P(retval_ptr); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 2069d55..b4aaf7d 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4682,9 +4682,9 @@ PHP_FUNCTION(error_log) char *message, *opt = NULL, *headers = NULL; zend_str_size message_len, opt_len = 0, headers_len = 0; int opt_err = 0, argc = ZEND_NUM_ARGS(); - long erropt = 0; + php_int_t erropt = 0; - if (zend_parse_parameters(argc TSRMLS_CC, "S|lPS", &message, &message_len, &erropt, &opt, &opt_len, &headers, &headers_len) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "S|iPS", &message, &message_len, &erropt, &opt, &opt_len, &headers, &headers_len) == FAILURE) { return; } @@ -5973,11 +5973,11 @@ PHP_FUNCTION(parse_ini_file) char *filename = NULL; zend_str_size filename_len = 0; zend_bool process_sections = 0; - long scanner_mode = ZEND_INI_SCANNER_NORMAL; + php_int_t scanner_mode = ZEND_INI_SCANNER_NORMAL; zend_file_handle fh; zend_ini_parser_cb_t ini_parser_cb; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "P|bl", &filename, &filename_len, &process_sections, &scanner_mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "P|bi", &filename, &filename_len, &process_sections, &scanner_mode) == FAILURE) { RETURN_FALSE; } diff --git a/ext/standard/file.c b/ext/standard/file.c index 6935a2e..577aa5e 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -571,13 +571,13 @@ PHP_FUNCTION(file_put_contents) zend_str_size filename_len; zval *data; zend_str_size numbytes = 0; - long flags = 0; + php_int_t flags = 0; zval *zcontext = NULL; php_stream_context *context = NULL; php_stream *srcstream = NULL; char mode[3] = "wb"; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Pz/|lr!", &filename, &filename_len, &data, &flags, &zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Pz/|ir!", &filename, &filename_len, &data, &flags, &zcontext) == FAILURE) { return; } @@ -1171,11 +1171,11 @@ PHPAPI PHP_FUNCTION(fwrite) zend_str_size arg2len; int ret; zend_str_size num_bytes; - long arg3 = 0; + php_int_t arg3 = 0; char *buffer = NULL; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rS|l", &arg1, &arg2, &arg2len, &arg3) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rS|i", &arg1, &arg2, &arg2len, &arg3) == FAILURE) { RETURN_FALSE; } @@ -1269,10 +1269,10 @@ PHPAPI PHP_FUNCTION(ftell) PHPAPI PHP_FUNCTION(fseek) { zval *arg1; - long arg2, whence = SEEK_SET; + php_int_t arg2, whence = SEEK_SET; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &arg2, &whence) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri|i", &arg1, &arg2, &whence) == FAILURE) { RETURN_FALSE; } @@ -1738,10 +1738,10 @@ safe_to_copy: PHPAPI PHP_FUNCTION(fread) { zval *arg1; - long len; + php_int_t len; php_stream *stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &arg1, &len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ri", &arg1, &len) == FAILURE) { RETURN_FALSE; } diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index df58607..2c57d27 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -668,12 +668,12 @@ PHP_FUNCTION(chmod) { char *filename; zend_str_size filename_len; - long mode; + php_int_t mode; int ret; mode_t imode; php_stream_wrapper *wrapper; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Pl", &filename, &filename_len, &mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Pi", &filename, &filename_len, &mode) == FAILURE) { return; } @@ -714,14 +714,14 @@ PHP_FUNCTION(touch) { char *filename; zend_str_size filename_len; - long filetime = 0, fileatime = 0; + php_int_t filetime = 0, fileatime = 0; int ret, argc = ZEND_NUM_ARGS(); FILE *file; struct utimbuf newtimebuf; struct utimbuf *newtime = &newtimebuf; php_stream_wrapper *wrapper; - if (zend_parse_parameters(argc TSRMLS_CC, "P|ll", &filename, &filename_len, &filetime, &fileatime) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "P|ii", &filename, &filename_len, &filetime, &fileatime) == FAILURE) { return; } diff --git a/ext/standard/string.c b/ext/standard/string.c index cd59954..c448eec 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1007,7 +1007,7 @@ PHP_FUNCTION(wordwrap) /* {{{ php_explode */ -PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, long limit) +PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, php_int_t limit) { char *p1, *p2, *endp; @@ -1033,7 +1033,7 @@ PHPAPI void php_explode(zval *delim, zval *str, zval *return_value, long limit) /* {{{ php_explode_negative_limit */ -PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_value, long limit) +PHPAPI void php_explode_negative_limit(zval *delim, zval *str, zval *return_value, php_int_t limit) { #define EXPLODE_ALLOC_STEP 64 char *p1, *p2, *endp; @@ -1082,10 +1082,10 @@ PHP_FUNCTION(explode) { char *str, *delim; zend_str_size str_len = 0, delim_len = 0; - long limit = LONG_MAX; /* No limit */ + php_int_t limit = PHP_SIZE_MAX_LONG; /* No limit */ zval zdelim, zstr; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|l", &delim, &delim_len, &str, &str_len, &limit) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "SS|i", &delim, &delim_len, &str, &str_len, &limit) == FAILURE) { return; } @@ -1797,10 +1797,10 @@ PHP_FUNCTION(strpos) char *haystack; char *found = NULL; char needle_char[2]; - long offset = 0; + php_int_t offset = 0; zend_str_size haystack_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|l", &haystack, &haystack_len, &needle, &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sz|i", &haystack, &haystack_len, &needle, &offset) == FAILURE) { return; } @@ -2215,11 +2215,11 @@ PHP_FUNCTION(chunk_split) PHP_FUNCTION(substr) { char *str; - long l = 0, f; + php_int_t l = 0, f; zend_str_size str_len; int argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl|l", &str, &str_len, &f, &l) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Si|i", &str, &str_len, &f, &l) == FAILURE) { return; } @@ -2641,14 +2641,14 @@ PHP_FUNCTION(ord) Converts ASCII code to a character */ PHP_FUNCTION(chr) { - long c; + php_int_t c; char temp[2]; if (ZEND_NUM_ARGS() != 1) { WRONG_PARAM_COUNT; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "l", &c) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "i", &c) == FAILURE) { c = 0; } @@ -4853,11 +4853,11 @@ PHP_FUNCTION(str_repeat) { char *input_str; /* Input string */ zend_str_size input_len; - long mult; /* Multiplier */ + php_int_t mult; /* Multiplier */ char *result; /* Resulting string */ zend_str_size result_len; /* Length of the resulting string */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl", &input_str, &input_len, &mult) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Si", &input_str, &input_len, &mult) == FAILURE) { return; } @@ -5202,7 +5202,7 @@ PHP_FUNCTION(str_pad) /* Input arguments */ char *input; /* Input string */ zend_str_size input_len; - long pad_length; /* Length to pad to */ + php_int_t pad_length; /* Length to pad to */ /* Helper variables */ zend_str_size num_pad_chars; /* Number of padding characters (total - input size) */ @@ -5210,10 +5210,10 @@ PHP_FUNCTION(str_pad) zend_str_size result_len = 0; /* Length of the resulting string */ char *pad_str_val = " "; /* Pointer to padding string */ zend_str_size pad_str_len = 1; /* Length of the padding string */ - long pad_type_val = STR_PAD_RIGHT; /* The padding type value */ + php_int_t pad_type_val = STR_PAD_RIGHT; /* The padding type value */ zend_str_size i, left_pad=0, right_pad=0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Sl|Sl", &input, &input_len, &pad_length, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Si|Si", &input, &input_len, &pad_length, &pad_str_val, &pad_str_len, &pad_type_val) == FAILURE) { return; } diff --git a/main/main.c b/main/main.c index e65608c..7291767 100644 --- a/main/main.c +++ b/main/main.c @@ -1266,11 +1266,11 @@ PHPAPI char *php_get_current_user(TSRMLS_D) Sets the maximum time a script can run */ PHP_FUNCTION(set_time_limit) { - long new_timeout; + php_int_t new_timeout; char *new_timeout_str; zend_str_size_int new_timeout_strlen; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &new_timeout) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "i", &new_timeout) == FAILURE) { return; } @@ -2132,8 +2132,8 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod REGISTER_MAIN_STRINGL_CONSTANT("PHP_SHLIB_SUFFIX", PHP_SHLIB_SUFFIX, sizeof(PHP_SHLIB_SUFFIX)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_EOL", PHP_EOL, sizeof(PHP_EOL)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_LONG_CONSTANT("PHP_MAXPATHLEN", MAXPATHLEN, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", LONG_MAX, CONST_PERSISTENT | CONST_CS); - REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", sizeof(long), CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MAX", PHP_INT_MAX, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", SIZEOF_ZEND_INT, CONST_PERSISTENT | CONST_CS); #ifdef PHP_WIN32 REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_MAJOR", EG(windows_version_info).dwMajorVersion, CONST_PERSISTENT | CONST_CS); diff --git a/main/output.c b/main/output.c index 4f9e76c..6fe1a3a 100644 --- a/main/output.c +++ b/main/output.c @@ -1304,10 +1304,10 @@ static int php_output_handler_devnull_func(void **handler_context, php_output_co PHP_FUNCTION(ob_start) { zval *output_handler = NULL; - long chunk_size = 0; - long flags = PHP_OUTPUT_HANDLER_STDFLAGS; + php_int_t chunk_size = 0; + php_int_t flags = PHP_OUTPUT_HANDLER_STDFLAGS; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/ll", &output_handler, &chunk_size, &flags) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|z/ii", &output_handler, &chunk_size, &flags) == FAILURE) { return; } @@ -1527,9 +1527,9 @@ PHP_FUNCTION(ob_get_status) Turn implicit flush on/off and is equivalent to calling flush() after every output call */ PHP_FUNCTION(ob_implicit_flush) { - long flag = 1; + php_int_t flag = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flag) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|i", &flag) == FAILURE) { return; } diff --git a/main/php.h b/main/php.h index 48830f8..80cd84b 100644 --- a/main/php.h +++ b/main/php.h @@ -446,6 +446,14 @@ END_EXTERN_C() #endif #endif /* !XtOffsetOf */ +#define php_int_t zend_int_t +#define php_uint_t zend_uint_t +#define PHP_INT_MAX ZEND_INT_MAX +#define PHP_INT_MIN ZEND_INT_MIN +#define PHP_UINT_MAX ZEND_UINT_MAX +#define PHP_SIZE_MAX_LONG ZEND_SIZE_MAX_LONG +#define PHP_SIZE_MAX_INT ZEND_SIZE_MAX_INT + #endif /* diff --git a/win32/build/config.w32 b/win32/build/config.w32 index f2c6e3a..4ffb99c 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -455,3 +455,8 @@ if (PHP_ZSTRLEN == "yes") { AC_DEFINE('ZEND_USE_LEGACY_STRING_TYPES', 1, ""); } +ARG_ENABLE("zint64", "Enable 64 bit integers", "no"); +if (PHP_ZINT64== "yes") { + AC_DEFINE('ZEND_ENABLE_INT64', 1, ""); +} +