From 7fe7fd50ff16a9a6f743c638b49f929aae3546c3 Mon Sep 17 00:00:00 2001 From: Shuhei Tanuma Date: Thu, 31 May 2012 06:39:58 +0900 Subject: [PATCH] add uv_now api --- TODO.md | 1 - php_uv.c | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index 336f18b..c0f083f 100644 --- a/TODO.md +++ b/TODO.md @@ -4,7 +4,6 @@ # functions -* UV_EXTERN int64_t uv_now(uv_loop_t*); * UV_EXTERN int uv_is_active(uv_handle_t* handle); * UV_EXTERN int uv_read2_start(uv_stream_t*, uv_alloc_cb alloc_cb,uv_read2_cb read_cb); * UV_EXTERN int uv_read_stop(uv_stream_t*); diff --git a/php_uv.c b/php_uv.c index cd5e517..c489b94 100644 --- a/php_uv.c +++ b/php_uv.c @@ -568,6 +568,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_loop_delete, 0, 0, 1) ZEND_ARG_INFO(0, loop) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_now, 0, 0, 1) + ZEND_ARG_INFO(0, loop) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_uv_tcp_connect, 0, 0, 2) ZEND_ARG_INFO(0, resource) ZEND_ARG_INFO(0, callback) @@ -893,6 +897,25 @@ PHP_FUNCTION(uv_loop_delete) } /* }}} */ +/* {{{ */ +PHP_FUNCTION(uv_now) +{ + zval *z_loop = NULL; + uv_loop_t *loop; + int64_t now; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, + "z",&z_loop) == FAILURE) { + return; + } + + if (z_loop != NULL) { + ZEND_FETCH_RESOURCE(loop, uv_loop_t *, &z_loop, -1, PHP_UV_LOOP_RESOURCE_NAME, uv_loop_handle); + now = uv_now(loop); + RETURN_LONG((long)now); + } +} +/* }}} */ + /* {{{ */ PHP_FUNCTION(uv_tcp_bind) @@ -1508,6 +1531,7 @@ static zend_function_entry uv_functions[] = { PHP_FE(uv_ip4_addr, arginfo_uv_ip4_addr) PHP_FE(uv_write, arginfo_uv_write) PHP_FE(uv_close, arginfo_uv_close) + PHP_FE(uv_now, arginfo_uv_now) PHP_FE(uv_loop_delete, arginfo_uv_loop_delete) PHP_FE(uv_read_start, arginfo_uv_read_start) PHP_FE(uv_last_error, arginfo_uv_last_error)