improve several things

This commit is contained in:
Shuhei Tanuma 2014-01-03 15:37:18 +09:00
parent 6eaff02395
commit 6f4331d0f5
5 changed files with 15 additions and 17 deletions

View File

@ -1,6 +1,5 @@
phpuv_dtrace.h: phpuv_dtrace.h:
dtrace -h -s $(srcdir)/phpuv_dtrace.d; \ dtrace -h -s $(srcdir)/phpuv_dtrace.d; \
$(srcdir)/libuv/uv.a: $(srcdir)/libuv/libuv.a:
$(MAKE) -C $(srcdir)/libuv $(MAKE) -C $(srcdir)/libuv
cp $(srcdir)/libuv/uv.a $(srcdir)/libuv/libuv.a

View File

@ -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 git clone https://github.com/chobie/php-uv.git --recursive
cd php-uv cd php-uv
(cd libuv && make) make -C libuv
# Note: please use `make libuv.a CFLAGS=-fPIC` instead of `make` on 64bit box.
phpize phpize
./configure ./configure
make make

View File

@ -22,7 +22,6 @@ fi
if test "$PHP_UV_DEBUG" != "no"; then if test "$PHP_UV_DEBUG" != "no"; then
CFLAGS="$CFLAGS -Wall -g -ggdb -O0 -DPHP_UV_DEBUG=1" CFLAGS="$CFLAGS -Wall -g -ggdb -O0 -DPHP_UV_DEBUG=1"
AC_DEFINE(PHP_UV_DEBUG, 1, [Enable uv debug support]) AC_DEFINE(PHP_UV_DEBUG, 1, [Enable uv debug support])
echo "damepo"
fi fi
if test "$PHP_DTRACE" != "no"; then if test "$PHP_DTRACE" != "no"; then

View File

@ -198,8 +198,6 @@ static uv_loop_t *_php_uv_default_loop;
static int uv_resource_handle; static int uv_resource_handle;
static int uv_ares_handle;
static int uv_loop_handle; static int uv_loop_handle;
static int uv_sockaddr_handle; static int uv_sockaddr_handle;
@ -210,8 +208,6 @@ static int uv_httpparser_handle;
static int uv_stdio_handle; static int uv_stdio_handle;
static int uv_ares_initialized;
char *php_uv_resource_map[IS_UV_MAX] = { char *php_uv_resource_map[IS_UV_MAX] = {
"uv_tcp", "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); 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; zval *retval_ptr = NULL;
php_uv_t *uv = (php_uv_t*)req->data; 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) PHP_FUNCTION(uv_run)
{ {
zval *zloop = NULL; zval *zloop = NULL;
uv_loop_t *loop; uv_loop_t *loop;
long run_mode = UV_RUN_DEFAULT;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"|z",&zloop) == FAILURE) { "|zl",&zloop, &run_mode) == FAILURE) {
return; return;
} }
PHP_UV_FETCH_UV_DEFAULT_LOOP(loop, zloop); PHP_UV_FETCH_UV_DEFAULT_LOOP(loop, zloop);
//TODO: implement this uv_run(loop, run_mode);
uv_run(loop, UV_RUN_DEFAULT);
} }
/* }}} */ /* }}} */
@ -3386,12 +3382,13 @@ PHP_FUNCTION(uv_run_once)
uv_loop_t *loop; uv_loop_t *loop;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"|z",&zloop) == FAILURE) { "|z", &zloop) == FAILURE) {
return; 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); PHP_UV_FETCH_UV_DEFAULT_LOOP(loop, zloop);
RETURN_LONG(uv_run(loop, UV_RUN_ONCE));
RETURN_LONG(uv_run_once(loop));
} }
/* }}} */ /* }}} */

4
uv.c
View File

@ -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 = zend_register_internal_class(&ce TSRMLS_CC);
//uv_class_entry->create_object = php_uv_new; //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, "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, "RENAME", sizeof("RENAME")-1, UV_RENAME TSRMLS_CC);
zend_declare_class_constant_long(uv_class_entry, "READABLE",sizeof("READABLE")-1, UV_READABLE TSRMLS_CC); zend_declare_class_constant_long(uv_class_entry, "READABLE",sizeof("READABLE")-1, UV_READABLE TSRMLS_CC);