diff --git a/Makefile.frag b/Makefile.frag index dad79b9..3ece02c 100644 --- a/Makefile.frag +++ b/Makefile.frag @@ -1,6 +1,5 @@ phpuv_dtrace.h: dtrace -h -s $(srcdir)/phpuv_dtrace.d; \ -$(srcdir)/libuv/uv.a: +$(srcdir)/libuv/libuv.a: $(MAKE) -C $(srcdir)/libuv - cp $(srcdir)/libuv/uv.a $(srcdir)/libuv/libuv.a diff --git a/README.md b/README.md index 3fe0876..78217c5 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,7 @@ or move to extension all together so do not rely to much on them you have been w ```` git clone https://github.com/chobie/php-uv.git --recursive cd php-uv -(cd libuv && make) -# Note: please use `make libuv.a CFLAGS=-fPIC` instead of `make` on 64bit box. +make -C libuv phpize ./configure make diff --git a/config.m4 b/config.m4 index ea6bbe1..c1d0916 100644 --- a/config.m4 +++ b/config.m4 @@ -22,7 +22,6 @@ fi if test "$PHP_UV_DEBUG" != "no"; then CFLAGS="$CFLAGS -Wall -g -ggdb -O0 -DPHP_UV_DEBUG=1" AC_DEFINE(PHP_UV_DEBUG, 1, [Enable uv debug support]) - echo "damepo" fi if test "$PHP_DTRACE" != "no"; then diff --git a/php_uv.c b/php_uv.c index ea1fb87..96abeda 100644 --- a/php_uv.c +++ b/php_uv.c @@ -198,8 +198,6 @@ static uv_loop_t *_php_uv_default_loop; static int uv_resource_handle; -static int uv_ares_handle; - static int uv_loop_handle; static int uv_sockaddr_handle; @@ -210,8 +208,6 @@ static int uv_httpparser_handle; static int uv_stdio_handle; -static int uv_ares_initialized; - char *php_uv_resource_map[IS_UV_MAX] = { "uv_tcp", @@ -1662,7 +1658,7 @@ static void php_uv_work_cb(uv_work_t* req) PHP_UV_DEBUG_RESOURCE_REFCOUNT(uv_work_cb, uv->resource_id); } -static void php_uv_after_work_cb(uv_work_t* req) +static void php_uv_after_work_cb(uv_work_t* req, int status) { zval *retval_ptr = NULL; php_uv_t *uv = (php_uv_t*)req->data; @@ -3361,20 +3357,20 @@ PHP_FUNCTION(uv_ref) } /* }}} */ -/* {{{ proto void uv_run([resource $uv_loop]) +/* {{{ proto void uv_run([resource $uv_loop, long $run_mode]) */ PHP_FUNCTION(uv_run) { zval *zloop = NULL; uv_loop_t *loop; + long run_mode = UV_RUN_DEFAULT; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "|z",&zloop) == FAILURE) { + "|zl",&zloop, &run_mode) == FAILURE) { return; } PHP_UV_FETCH_UV_DEFAULT_LOOP(loop, zloop); - //TODO: implement this - uv_run(loop, UV_RUN_DEFAULT); + uv_run(loop, run_mode); } /* }}} */ @@ -3386,12 +3382,13 @@ PHP_FUNCTION(uv_run_once) uv_loop_t *loop; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "|z",&zloop) == FAILURE) { + "|z", &zloop) == FAILURE) { return; } + php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "uv_run_once is deprecated; use uv_run(uv_default_loop(), UV::RUN_ONCE) instead"); + PHP_UV_FETCH_UV_DEFAULT_LOOP(loop, zloop); - - RETURN_LONG(uv_run_once(loop)); + RETURN_LONG(uv_run(loop, UV_RUN_ONCE)); } /* }}} */ diff --git a/uv.c b/uv.c index 8c4c369..f043768 100644 --- a/uv.c +++ b/uv.c @@ -34,6 +34,10 @@ static int php_uv_class_init(TSRMLS_D) uv_class_entry = zend_register_internal_class(&ce TSRMLS_CC); //uv_class_entry->create_object = php_uv_new; + zend_declare_class_constant_long(uv_class_entry, "RUN_DEFAULT", sizeof("RUN_DEFAULT")-1, UV_RUN_DEFAULT TSRMLS_CC); + zend_declare_class_constant_long(uv_class_entry, "RUN_ONCE", sizeof("RUN_ONCE")-1, UV_RUN_ONCE TSRMLS_CC); + zend_declare_class_constant_long(uv_class_entry, "RUN_NOWAIT", sizeof("RUN_NOWAIT")-1, UV_RUN_NOWAIT TSRMLS_CC); + zend_declare_class_constant_long(uv_class_entry, "CHANGE", sizeof("CHANGE")-1, UV_CHANGE TSRMLS_CC); zend_declare_class_constant_long(uv_class_entry, "RENAME", sizeof("RENAME")-1, UV_RENAME TSRMLS_CC); zend_declare_class_constant_long(uv_class_entry, "READABLE",sizeof("READABLE")-1, UV_READABLE TSRMLS_CC);