diff --git a/ext/ftp/config.m4 b/ext/ftp/config.m4 index e060c9000fd1a..df668e1a5af03 100644 --- a/ext/ftp/config.m4 +++ b/ext/ftp/config.m4 @@ -20,7 +20,7 @@ if test "$PHP_FTP" = "yes"; then AC_DEFINE([HAVE_FTP], [1], [Define to 1 if the PHP extension 'ftp' is available.]) PHP_NEW_EXTENSION([ftp], [php_ftp.c ftp.c], [$ext_shared]) - + PHP_INSTALL_HEADERS([ext/ftp], [php_ftp.h]) AS_VAR_IF([PHP_FTP_SSL], [no],, [ PHP_SETUP_OPENSSL([FTP_SHARED_LIBADD]) PHP_SUBST([FTP_SHARED_LIBADD]) diff --git a/ext/ftp/config.w32 b/ext/ftp/config.w32 index 057552c1d39e9..9e85378bdf5d6 100644 --- a/ext/ftp/config.w32 +++ b/ext/ftp/config.w32 @@ -5,7 +5,7 @@ ARG_ENABLE("ftp", "ftp support", "no"); if (PHP_FTP != "no") { EXTENSION("ftp", "php_ftp.c ftp.c"); - + PHP_INSTALL_HEADERS("ext/ftp/", "php_ftp.h"); var ret = SETUP_OPENSSL("ftp", PHP_FTP); if (ret >= 2) { diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index f9c61748efdda..dab01881b6aa8 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -20,6 +20,7 @@ #endif #include "php.h" +#include "php_ftp.h" #include #include @@ -1378,7 +1379,7 @@ static int my_poll(php_socket_t fd, int events, int timeout) { while (true) { zend_hrtime_t start_ns = zend_hrtime(); - n = php_pollfd_for_ms(fd, events, (int) (timeout_hr / 1000000)); + n = php_ftp_pollfd_for_ms(fd, events, (int) (timeout_hr / 1000000)); if (n == -1 && php_socket_errno() == EINTR) { zend_hrtime_t delta_ns = zend_hrtime() - start_ns; diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index d7acb3edef68e..fe13a0e76bd24 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -38,6 +38,7 @@ static zend_class_entry *php_ftp_ce = NULL; static zend_object_handlers ftp_object_handlers; +PHP_FTP_API int(*php_ftp_pollfd_for_ms)(php_socket_t, int, int); zend_module_entry php_ftp_module_entry = { STANDARD_MODULE_HEADER_EX, @@ -109,6 +110,7 @@ PHP_MINIT_FUNCTION(ftp) ftp_object_handlers.clone_obj = NULL; register_ftp_symbols(module_number); + php_ftp_pollfd_for_ms = php_pollfd_for_ms; return SUCCESS; } diff --git a/ext/ftp/php_ftp.h b/ext/ftp/php_ftp.h index b701f1331d0be..b32ccfe02719c 100644 --- a/ext/ftp/php_ftp.h +++ b/ext/ftp/php_ftp.h @@ -22,6 +22,7 @@ extern zend_module_entry php_ftp_module_entry; #define phpext_ftp_ptr &php_ftp_module_entry #include "php_version.h" +#include "php_network.h" #define PHP_FTP_VERSION PHP_VERSION #define PHP_FTP_OPT_TIMEOUT_SEC 0 @@ -32,4 +33,16 @@ extern zend_module_entry php_ftp_module_entry; PHP_MINIT_FUNCTION(ftp); PHP_MINFO_FUNCTION(ftp); +#ifdef PHP_WIN32 +#define PHP_FTP_API __declspec(dllexport) +#elif defined(__GNUC__) && __GNUC__ >= 4 +#define PHP_FTP_API __attribute__ ((visibility("default"))) +#else +#define PHP_FTP_API +#endif + +/* expose this interface to enable coroutine support for FTP in other extensions + */ +PHP_FTP_API extern int(*php_ftp_pollfd_for_ms)(php_socket_t, int, int); + #endif