From bebcdcc74573b015c22238dbc9b2698c88b7a601 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 2 Mar 2019 14:42:21 +0100 Subject: [PATCH] Remove legacy AC_CHECK_TYPE calls for uint and ulong The AC_CHECK_TYPE was refactored in more recent versions of Autoconf and the call with two arguments is obsolete and not recommended anymore. This patch also refactors some leftovers of using ulong and uint which are not standard nor common usages of types in C. The ulong can be used as zend_ulong and uint usage is actually `unsigned int`. The usage of HAVE_ULONG removed since it is not used in current code base. Legacy edgecase for some legacy HPUX systems removed: - sys/stream.h header is not checked and the HAVE_SYS_STREAM_H is not defined with current build system. - flags are unsigned int - max_allowed_packet changed to unsigned int --- Zend/Zend.m4 | 4 ---- Zend/zend_config.w32.h | 3 --- configure.ac | 3 --- ext/com_dotnet/com_iterator.c | 10 +++++----- ext/com_dotnet/com_wrapper.c | 2 +- ext/mysqli/php_mysqli_structs.h | 4 ---- ext/mysqlnd/mysqlnd_charset.c | 8 ++++---- ext/mysqlnd/mysqlnd_portability.h | 6 ------ ext/mysqlnd/mysqlnd_structs.h | 4 ++-- ext/opcache/zend_accelerator_util_funcs.c | 2 +- ext/pdo/pdo_stmt.c | 6 +++--- ext/standard/array.c | 2 +- ext/standard/url_scanner_ex.re | 2 +- main/php.h | 2 -- sapi/phpdbg/phpdbg_cmd.c | 2 +- 15 files changed, 19 insertions(+), 41 deletions(-) diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index 1768a4e8937..f5099710b6d 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -39,10 +39,6 @@ _LT_AC_TRY_DLOPEN_SELF([ ], []) ]) -dnl This is required for QNX and may be some BSD derived systems -AC_CHECK_TYPE( uint, unsigned int ) -AC_CHECK_TYPE( ulong, unsigned long ) - dnl Checks for library functions. AC_FUNC_ALLOCA AC_CHECK_FUNCS(strdup getpid kill strtod strtol finite fpclass sigsetjmp) diff --git a/Zend/zend_config.w32.h b/Zend/zend_config.w32.h index d61ba27b9dc..19a5165e4b2 100644 --- a/Zend/zend_config.w32.h +++ b/Zend/zend_config.w32.h @@ -38,9 +38,6 @@ #include -typedef unsigned long ulong; -typedef unsigned int uint; - #define HAVE_STDIOSTR_H 1 #define HAVE_CLASS_ISTDIOSTREAM #define istdiostream stdiostream diff --git a/configure.ac b/configure.ac index f79d8fef1bc..2d279f2c7e9 100644 --- a/configure.ac +++ b/configure.ac @@ -31,9 +31,6 @@ AH_TOP([ #endif #define ZEND_DLIMPORT - -#undef uint -#undef ulong ]) AH_BOTTOM([ #ifndef ZEND_ACCONFIG_H_NO_C_PROTOS diff --git a/ext/com_dotnet/com_iterator.c b/ext/com_dotnet/com_iterator.c index d4c30a935a8..e6f5b84cbdc 100644 --- a/ext/com_dotnet/com_iterator.c +++ b/ext/com_dotnet/com_iterator.c @@ -100,18 +100,18 @@ static void com_iter_move_forwards(zend_object_iterator *iter) I->key++; } else { /* indicate that there are no more items */ - I->key = (ulong)-1; + I->key = (zend_ulong)-1; return; } } else { /* safe array */ if (I->key >= (ULONG) I->sa_max) { - I->key = (ulong)-1; + I->key = (zend_ulong)-1; return; } I->key++; if (php_com_safearray_get_elem(&I->safe_array, &I->v, (LONG)I->key) == 0) { - I->key = (ulong)-1; + I->key = (zend_ulong)-1; return; } } @@ -193,7 +193,7 @@ zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int b php_com_zval_from_variant(&ptr, &I->v, I->code_page); ZVAL_COPY_VALUE(&I->zdata, &ptr); } else { - I->key = (ulong)-1; + I->key = (zend_ulong)-1; } } else { @@ -228,7 +228,7 @@ zend_object_iterator *php_com_iter_get(zend_class_entry *ce, zval *object, int b ZVAL_COPY_VALUE(&I->zdata, &ptr); } else { /* indicate that there are no more items */ - I->key = (ulong)-1; + I->key = (zend_ulong)-1; } } diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c index 1f98baa0e36..eee51c3cca0 100644 --- a/ext/com_dotnet/com_wrapper.c +++ b/ext/com_dotnet/com_wrapper.c @@ -397,7 +397,7 @@ static HRESULT STDMETHODCALLTYPE disp_getnextdispid( /* [in] */ DISPID id, /* [out] */ DISPID *pid) { - ulong next = id+1; + zend_ulong next = id+1; FETCH_DISP("GetNextDispID"); while(!zend_hash_index_exists(disp->dispid_to_name, next)) diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h index b309c21070c..93fbc15e91b 100644 --- a/ext/mysqli/php_mysqli_structs.h +++ b/ext/mysqli/php_mysqli_structs.h @@ -54,10 +54,6 @@ #define WE_HAD_MBSTATE_T #endif -#if defined(ulong) && !defined(HAVE_ULONG) -#define HAVE_ULONG -#endif - #include #if !defined(HAVE_MBRLEN) && defined(WE_HAD_MBRLEN) diff --git a/ext/mysqlnd/mysqlnd_charset.c b/ext/mysqlnd/mysqlnd_charset.c index 7e72f6a82da..729cdcd11f8 100644 --- a/ext/mysqlnd/mysqlnd_charset.c +++ b/ext/mysqlnd/mysqlnd_charset.c @@ -819,9 +819,9 @@ PHPAPI zend_ulong mysqlnd_cset_escape_quotes(const MYSQLND_CHARSET * const cset, *newstr = '\0'; if (escape_overflow) { - DBG_RETURN((ulong)~0); + DBG_RETURN((zend_ulong)~0); } - DBG_RETURN((ulong)(newstr - newstr_s)); + DBG_RETURN((zend_ulong)(newstr - newstr_s)); } /* }}} */ @@ -899,9 +899,9 @@ PHPAPI zend_ulong mysqlnd_cset_escape_slashes(const MYSQLND_CHARSET * const cset *newstr = '\0'; if (escape_overflow) { - DBG_RETURN((ulong)~0); + DBG_RETURN((zend_ulong)~0); } - DBG_RETURN((ulong)(newstr - newstr_s)); + DBG_RETURN((zend_ulong)(newstr - newstr_s)); } /* }}} */ diff --git a/ext/mysqlnd/mysqlnd_portability.h b/ext/mysqlnd/mysqlnd_portability.h index 6816a8af3a1..7736ae9fa89 100644 --- a/ext/mysqlnd/mysqlnd_portability.h +++ b/ext/mysqlnd/mysqlnd_portability.h @@ -49,13 +49,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ #define _LONG_LONG 1 /* For AIX string library */ #endif - /* Go around some bugs in different OS and compilers */ -#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H) -#include /* HPUX 10.20 defines ulong here. UGLY !!! */ -#define HAVE_ULONG -#endif - #if SIZEOF_LONG_LONG > 4 #define HAVE_LONG_LONG 1 diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h index 5aede259c9c..62128a2799b 100644 --- a/ext/mysqlnd/mysqlnd_structs.h +++ b/ext/mysqlnd/mysqlnd_structs.h @@ -206,7 +206,7 @@ typedef struct st_mysqlnd_infile typedef struct st_mysqlnd_session_options { - ulong flags; + unsigned int flags; /* init commands - we need to send them to server directly after connect */ unsigned int num_commands; @@ -231,7 +231,7 @@ typedef struct st_mysqlnd_session_options char *charset_name; /* maximum allowed packet size for communication */ - ulong max_allowed_packet; + unsigned int max_allowed_packet; #ifdef MYSQLND_STRING_TO_INT_CONVERSION zend_bool int_and_float_native; diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index 0ccd882c0b8..9692b4023ca 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -26,7 +26,7 @@ #include "zend_shared_alloc.h" #if SIZEOF_SIZE_T <= SIZEOF_ZEND_LONG -/* If sizeof(void*) == sizeof(ulong) we can use zend_hash index functions */ +/* If sizeof(void*) == sizeof(zend_ulong) we can use zend_hash index functions */ # define accel_xlat_set(old, new) zend_hash_index_add_new_ptr(&ZCG(bind_hash), (zend_ulong)(zend_uintptr_t)(old), (new)) # define accel_xlat_get(old) zend_hash_index_find_ptr(&ZCG(bind_hash), (zend_ulong)(zend_uintptr_t)(old)) #else diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index d18782437a6..c3e79f5b68d 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2382,7 +2382,7 @@ static void pdo_stmt_iter_get_key(zend_object_iterator *iter, zval *key) { struct php_pdo_iterator *I = (struct php_pdo_iterator*)iter; - if (I->key == (ulong)-1) { + if (I->key == (zend_ulong)-1) { ZVAL_NULL(key); } else { ZVAL_LONG(key, I->key); @@ -2402,7 +2402,7 @@ static void pdo_stmt_iter_move_forwards(zend_object_iterator *iter) PDO_FETCH_ORI_NEXT, 0, 0)) { PDO_HANDLE_STMT_ERR(); - I->key = (ulong)-1; + I->key = (zend_ulong)-1; ZVAL_UNDEF(&I->fetch_ahead); return; @@ -2439,7 +2439,7 @@ zend_object_iterator *pdo_stmt_iter_get(zend_class_entry *ce, zval *object, int if (!do_fetch(stmt, 1, &I->fetch_ahead, PDO_FETCH_USE_DEFAULT, PDO_FETCH_ORI_NEXT, 0, 0)) { PDO_HANDLE_STMT_ERR(); - I->key = (ulong)-1; + I->key = (zend_ulong)-1; ZVAL_UNDEF(&I->fetch_ahead); } diff --git a/ext/standard/array.c b/ext/standard/array.c index 7b6fca06478..297b0c0f380 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -2864,7 +2864,7 @@ double_str: } } else { zend_long low, high; - /* lstep is a ulong so that comparisons to it don't overflow, i.e. low - high < lstep */ + /* lstep is a zend_ulong so that comparisons to it don't overflow, i.e. low - high < lstep */ zend_ulong lstep; uint32_t i, size; long_str: diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index 01575f82b42..0386d0e955f 100644 --- a/ext/standard/url_scanner_ex.re +++ b/ext/standard/url_scanner_ex.re @@ -695,7 +695,7 @@ static inline void php_url_scanner_session_handler_impl(char *output, size_t out if (ZSTR_LEN(url_state->url_app.s) != 0) { *handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT | PHP_OUTPUT_HANDLER_FLUSH | PHP_OUTPUT_HANDLER_FINAL) ? 1 : 0), url_state); - if (sizeof(uint) < sizeof(size_t)) { + if (sizeof(unsigned int) < sizeof(size_t)) { if (len > UINT_MAX) len = UINT_MAX; } diff --git a/main/php.h b/main/php.h index 066685cf9b4..17aa3b3de58 100644 --- a/main/php.h +++ b/main/php.h @@ -95,8 +95,6 @@ typedef int uid_t; typedef int gid_t; typedef char * caddr_t; -typedef unsigned int uint; -typedef unsigned long ulong; typedef int pid_t; # ifndef PHP_DEBUG diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c index de06992226a..0357b63bdae 100644 --- a/sapi/phpdbg/phpdbg_cmd.c +++ b/sapi/phpdbg/phpdbg_cmd.c @@ -573,7 +573,7 @@ PHPDBG_API const phpdbg_command_t *phpdbg_stack_resolve(const phpdbg_command_t * const phpdbg_command_t *command = commands; phpdbg_param_t *name = *top; const phpdbg_command_t *matched[3] = {NULL, NULL, NULL}; - ulong matches = 0L; + zend_ulong matches = 0L; while (command && command->name && command->handler) { if (name->len == 1 || command->name_len >= name->len) {