diff --git a/build/php.m4 b/build/php.m4 index 74c069f5887b..83375bec5aa2 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -1396,7 +1396,11 @@ AC_DEFUN([PHP_POLL_MECHANISMS], AC_DEFINE([HAVE_EPOLL], [1], [Define if epoll is available]) poll_mechanisms="$poll_mechanisms epoll" - AC_CHECK_FUNCS([epoll_pwait2], [], [], [#include ]) + AC_CHECK_FUNCS([epoll_pwait2], [], + [AC_CHECK_DECL([epoll_pwait2], + [AC_DEFINE([HAVE_EPOLL_PWAIT2], [1])], + [], + [#include ])]) ]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ diff --git a/configure.ac b/configure.ac index 63c00f508c1c..b61b909b67b7 100644 --- a/configure.ac +++ b/configure.ac @@ -1817,6 +1817,7 @@ AC_DEFINE([HAVE_BUILD_DEFS_H], [1], PHP_ADD_BUILD_DIR([ main + main/poll main/streams scripts scripts/man1 diff --git a/ext/standard/io_poll.c b/ext/standard/io_poll.c index c36306a0b49b..e8366c7e8802 100644 --- a/ext/standard/io_poll.c +++ b/ext/standard/io_poll.c @@ -222,7 +222,7 @@ static const char *php_io_poll_backend_type_to_name(php_poll_backend_type type) static php_socket_t php_stream_poll_handle_get_fd(php_poll_handle_object *handle) { - php_stream_poll_handle_data *data = (php_stream_poll_handle_data *) handle->handle_data; + php_stream_poll_handle_data *data = handle->handle_data; php_socket_t fd; if (!data || !data->stream) { @@ -241,13 +241,13 @@ static php_socket_t php_stream_poll_handle_get_fd(php_poll_handle_object *handle static int php_stream_poll_handle_is_valid(php_poll_handle_object *handle) { - php_stream_poll_handle_data *data = (php_stream_poll_handle_data *) handle->handle_data; + php_stream_poll_handle_data *data = handle->handle_data; return data && data->stream && !php_stream_eof(data->stream); } static void php_stream_poll_handle_cleanup(php_poll_handle_object *handle) { - php_stream_poll_handle_data *data = (php_stream_poll_handle_data *) handle->handle_data; + php_stream_poll_handle_data *data = handle->handle_data; if (data) { if (data->res) { zend_list_delete(data->res); @@ -508,7 +508,7 @@ PHP_METHOD(StreamPollHandle, getStream) ZEND_PARSE_PARAMETERS_NONE(); php_poll_handle_object *intern = PHP_POLL_HANDLE_OBJ_FROM_ZV(getThis()); - php_stream_poll_handle_data *data = (php_stream_poll_handle_data *) intern->handle_data; + php_stream_poll_handle_data *data = intern->handle_data; if (!data || !data->stream) { RETURN_NULL(); @@ -851,7 +851,7 @@ PHP_METHOD(Io_Poll_Context, wait) RETURN_THROWS(); } - php_poll_event *events = emalloc(sizeof(php_poll_event) * max_events); + php_poll_event *events = safe_emalloc(max_events, sizeof(*events), 0); int num_events = php_poll_wait(intern->ctx, events, (int) max_events, timeout); if (num_events < 0) {