From f051af840a423cc5b7e791287791584a085ea918 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 12 Jul 2021 18:32:29 +0200 Subject: [PATCH 1/3] Remove zend_atoi() It's the same as (int) zend_atol() -- it doesn't try to do anything integer size specific. Canonicalize to one function in prepation for preparting zend_atol() to something less misleading. FFI test is adjusted to use a zend_test function. It just calls zend_atol() internally, but could really be anything. --- Zend/zend_operators.c | 28 ---------------------------- Zend/zend_operators.h | 1 - ext/ffi/tests/bug78270_1.phpt | 7 ++++--- ext/ffi/tests/bug78270_2.phpt | 3 ++- ext/zend_test/php_test.h | 2 ++ ext/zend_test/test.c | 6 ++++++ ext/zlib/zlib.c | 2 +- 7 files changed, 15 insertions(+), 34 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 1db18168564a3..b80b089e294d5 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -91,34 +91,6 @@ static const unsigned char tolower_map[256] = { zend_binary_strncasecmp */ -ZEND_API int ZEND_FASTCALL zend_atoi(const char *str, size_t str_len) /* {{{ */ -{ - int retval; - - if (!str_len) { - str_len = strlen(str); - } - retval = ZEND_STRTOL(str, NULL, 0); - if (str_len>0) { - switch (str[str_len-1]) { - case 'g': - case 'G': - retval *= 1024; - ZEND_FALLTHROUGH; - case 'm': - case 'M': - retval *= 1024; - ZEND_FALLTHROUGH; - case 'k': - case 'K': - retval *= 1024; - break; - } - } - return retval; -} -/* }}} */ - ZEND_API zend_long ZEND_FASTCALL zend_atol(const char *str, size_t str_len) /* {{{ */ { zend_long retval; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 90df4b42fe5f1..f4dd47f58ded0 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -458,7 +458,6 @@ ZEND_API int ZEND_FASTCALL zend_compare_symbol_tables(HashTable *ht1, HashTable ZEND_API int ZEND_FASTCALL zend_compare_arrays(zval *a1, zval *a2); ZEND_API int ZEND_FASTCALL zend_compare_objects(zval *o1, zval *o2); -ZEND_API int ZEND_FASTCALL zend_atoi(const char *str, size_t str_len); ZEND_API zend_long ZEND_FASTCALL zend_atol(const char *str, size_t str_len); #define convert_to_null_ex(zv) convert_to_null(zv) diff --git a/ext/ffi/tests/bug78270_1.phpt b/ext/ffi/tests/bug78270_1.phpt index 7544ccb5ebcfa..094aa5bc2c66d 100644 --- a/ext/ffi/tests/bug78270_1.phpt +++ b/ext/ffi/tests/bug78270_1.phpt @@ -2,6 +2,7 @@ FR #78270 (Usage of __vectorcall convention with FFI) --EXTENSIONS-- ffi +zend_test --SKIPIF-- .*clang.*/', $info)) die("skip not for clang"); try { FFI::cdef(<<zend_atoi("17.4", 4)); +var_dump($ffi->bug78270("17.4", 4)); ?> --EXPECT-- int(17) diff --git a/ext/ffi/tests/bug78270_2.phpt b/ext/ffi/tests/bug78270_2.phpt index b454d277ea81b..e7c2d7253baaf 100644 --- a/ext/ffi/tests/bug78270_2.phpt +++ b/ext/ffi/tests/bug78270_2.phpt @@ -2,6 +2,7 @@ FR #78270 (Usage of __vectorcall convention with FFI) --EXTENSIONS-- ffi +zend_test --SKIPIF-- Date: Mon, 12 Jul 2021 23:03:25 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Christoph M. Becker --- ext/ffi/tests/bug78270_1.phpt | 2 +- ext/ffi/tests/bug78270_2.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/ffi/tests/bug78270_1.phpt b/ext/ffi/tests/bug78270_1.phpt index 094aa5bc2c66d..84b812d29dc4b 100644 --- a/ext/ffi/tests/bug78270_1.phpt +++ b/ext/ffi/tests/bug78270_1.phpt @@ -26,7 +26,7 @@ try { require_once('utils.inc'); $ffi = FFI::cdef(<<bug78270("17.4", 4)); ?> --EXPECT-- diff --git a/ext/ffi/tests/bug78270_2.phpt b/ext/ffi/tests/bug78270_2.phpt index e7c2d7253baaf..c17b143cf7d0b 100644 --- a/ext/ffi/tests/bug78270_2.phpt +++ b/ext/ffi/tests/bug78270_2.phpt @@ -11,7 +11,7 @@ require_once('utils.inc'); try { FFI::cdef(<< Date: Mon, 12 Jul 2021 23:45:41 +0200 Subject: [PATCH 3/3] fix --- ext/ffi/tests/bug78270_1.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ffi/tests/bug78270_1.phpt b/ext/ffi/tests/bug78270_1.phpt index 84b812d29dc4b..edc212bdd2cf5 100644 --- a/ext/ffi/tests/bug78270_1.phpt +++ b/ext/ffi/tests/bug78270_1.phpt @@ -16,7 +16,7 @@ if (preg_match('/Compiler => .*clang.*/', $info)) die("skip not for clang"); try { FFI::cdef(<<