Fix windows errors

This commit is contained in:
stealth35 2012-06-18 15:32:15 +02:00
parent 31dec36418
commit 9bbc4e9ef8
3 changed files with 68 additions and 63 deletions

1
.gitignore vendored
View File

@ -6,7 +6,6 @@ acinclude.m4
aclocal.m4 aclocal.m4
autom4te.cache autom4te.cache
build build
config.*
configure configure
configure* configure*
install-sh install-sh

9
config.w32 Normal file
View File

@ -0,0 +1,9 @@
ARG_ENABLE("uv", "for uv support", "no");
if (PHP_UV != "no") {
if (CHECK_HEADER_ADD_INCLUDE("uv.h", "CFLAGS_UV") && CHECK_LIB("uv.lib", "uv", PHP_UV)) {
EXTENSION('uv', 'php_uv.c uv.c');
} else {
WARNING("uv not enabled; libraries and/or headers not found");
}
}

109
php_uv.c
View File

@ -391,11 +391,9 @@ static void php_uv_pipe_connect_cb(uv_connect_t *req, int status)
static void php_uv_write_cb(uv_write_t* req, int status) static void php_uv_write_cb(uv_write_t* req, int status)
{ {
write_req_t* wr; write_req_t* wr = (write_req_t*) req;
zval *retval_ptr, *stat, *client= NULL; zval *retval_ptr, *stat, *client= NULL;
zval **params[2]; zval **params[2];
wr = (write_req_t*) req;
php_uv_t *uv = (php_uv_t*)req->data; php_uv_t *uv = (php_uv_t*)req->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx); TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
@ -436,11 +434,10 @@ static void php_uv_write_cb(uv_write_t* req, int status)
static void php_uv_udp_send_cb(uv_udp_send_t* req, int status) static void php_uv_udp_send_cb(uv_udp_send_t* req, int status)
{ {
send_req_t* wr;
send_req_t* wr = (send_req_t*) req;
zval *retval_ptr, *stat, *client= NULL; zval *retval_ptr, *stat, *client= NULL;
zval **params[2]; zval **params[2];
wr = (send_req_t*) req;
php_uv_t *uv = (php_uv_t*)req->data; php_uv_t *uv = (php_uv_t*)req->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx); TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
@ -507,11 +504,13 @@ static void php_uv_read_cb(uv_stream_t* handle, ssize_t nread, uv_buf_t buf)
zval *retval_ptr = NULL; zval *retval_ptr = NULL;
zval **params[2]; zval **params[2];
zval *buffer; zval *buffer;
zval *rsc;
php_uv_t *uv = (php_uv_t*)handle->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
#if PHP_UV_DEBUG>=1 #if PHP_UV_DEBUG>=1
fprintf(stderr,"read_cb"); fprintf(stderr,"read_cb");
#endif #endif
php_uv_t *uv = (php_uv_t*)handle->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
if (nread < 0) { if (nread < 0) {
/* does this should be in user-land ? */ /* does this should be in user-land ? */
@ -542,7 +541,6 @@ static void php_uv_read_cb(uv_stream_t* handle, ssize_t nread, uv_buf_t buf)
MAKE_STD_ZVAL(buffer); MAKE_STD_ZVAL(buffer);
ZVAL_STRINGL(buffer,buf.base,nread, 1); ZVAL_STRINGL(buffer,buf.base,nread, 1);
zval *rsc;
MAKE_STD_ZVAL(rsc); MAKE_STD_ZVAL(rsc);
ZVAL_RESOURCE(rsc, uv->resource_id); ZVAL_RESOURCE(rsc, uv->resource_id);
//zend_list_addref(uv->resource_id); //zend_list_addref(uv->resource_id);
@ -575,13 +573,14 @@ static void php_uv_prepare_cb(uv_stream_t* handle, int status)
{ {
zval *retval_ptr = NULL; zval *retval_ptr = NULL;
zval **params[1]; zval **params[1];
#if PHP_UV_DEBUG>=1 zval *zstat;
fprintf(stderr,"prepare_cb");
#endif
php_uv_t *uv = (php_uv_t*)handle->data; php_uv_t *uv = (php_uv_t*)handle->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx); TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
zval *zstat; #if PHP_UV_DEBUG>=1
fprintf(stderr,"prepare_cb");
#endif
MAKE_STD_ZVAL(zstat); MAKE_STD_ZVAL(zstat);
ZVAL_LONG(zstat, status); ZVAL_LONG(zstat, status);
@ -608,13 +607,14 @@ static void php_uv_check_cb(uv_stream_t* handle, int status)
{ {
zval *retval_ptr = NULL; zval *retval_ptr = NULL;
zval **params[1]; zval **params[1];
#if PHP_UV_DEBUG>=1 zval *zstat;
fprintf(stderr,"check_cb");
#endif
php_uv_t *uv = (php_uv_t*)handle->data; php_uv_t *uv = (php_uv_t*)handle->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx); TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
zval *zstat; #if PHP_UV_DEBUG>=1
fprintf(stderr,"check_cb");
#endif
MAKE_STD_ZVAL(zstat); MAKE_STD_ZVAL(zstat);
ZVAL_LONG(zstat, status); ZVAL_LONG(zstat, status);
@ -642,13 +642,14 @@ static void php_uv_async_cb(uv_stream_t* handle, int status)
{ {
zval *retval_ptr = NULL; zval *retval_ptr = NULL;
zval **params[1]; zval **params[1];
#if PHP_UV_DEBUG>=1 zval *zstat;
fprintf(stderr,"async_cb");
#endif
php_uv_t *uv = (php_uv_t*)handle->data; php_uv_t *uv = (php_uv_t*)handle->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx); TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
zval *zstat; #if PHP_UV_DEBUG>=1
fprintf(stderr,"async_cb");
#endif
MAKE_STD_ZVAL(zstat); MAKE_STD_ZVAL(zstat);
ZVAL_LONG(zstat, status); ZVAL_LONG(zstat, status);
@ -675,11 +676,12 @@ static void php_uv_async_cb(uv_stream_t* handle, int status)
static void php_uv_work_cb(uv_work_t* req) static void php_uv_work_cb(uv_work_t* req)
{ {
zval *retval_ptr = NULL; zval *retval_ptr = NULL;
php_uv_t *uv = (uv_work_t*)req->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
#if PHP_UV_DEBUG>=1 #if PHP_UV_DEBUG>=1
fprintf(stderr,"work_cb"); fprintf(stderr,"work_cb");
#endif #endif
php_uv_t *uv = (uv_work_t*)req->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
php_uv_do_callback(&retval_ptr, uv->work_cb, NULL, 0 TSRMLS_CC); php_uv_do_callback(&retval_ptr, uv->work_cb, NULL, 0 TSRMLS_CC);
zval_ptr_dtor(&retval_ptr); zval_ptr_dtor(&retval_ptr);
@ -699,11 +701,12 @@ static void php_uv_work_cb(uv_work_t* req)
static void php_uv_after_work_cb(uv_work_t* req) static void php_uv_after_work_cb(uv_work_t* req)
{ {
zval *retval_ptr = NULL; zval *retval_ptr = NULL;
php_uv_t *uv = (php_uv_t*)req->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
#if PHP_UV_DEBUG>=1 #if PHP_UV_DEBUG>=1
fprintf(stderr,"after_work_cb"); fprintf(stderr,"after_work_cb");
#endif #endif
php_uv_t *uv = (php_uv_t*)req->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
php_uv_do_callback(&retval_ptr, uv->after_work_cb, NULL, 0 TSRMLS_CC); php_uv_do_callback(&retval_ptr, uv->after_work_cb, NULL, 0 TSRMLS_CC);
zval_ptr_dtor(&retval_ptr); zval_ptr_dtor(&retval_ptr);
@ -726,6 +729,7 @@ static void php_uv_udp_recv_cb(uv_udp_t* handle, ssize_t nread, uv_buf_t buf, st
zval *retval_ptr = NULL; zval *retval_ptr = NULL;
zval **params[2]; zval **params[2];
zval *buffer; zval *buffer;
zval *rsc;
php_uv_t *uv = (php_uv_t*)handle->data; php_uv_t *uv = (php_uv_t*)handle->data;
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx); TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
@ -754,7 +758,6 @@ static void php_uv_udp_recv_cb(uv_udp_t* handle, ssize_t nread, uv_buf_t buf, st
MAKE_STD_ZVAL(buffer); MAKE_STD_ZVAL(buffer);
ZVAL_STRINGL(buffer,buf.base,nread, 1); ZVAL_STRINGL(buffer,buf.base,nread, 1);
zval *rsc;
MAKE_STD_ZVAL(rsc); MAKE_STD_ZVAL(rsc);
ZVAL_RESOURCE(rsc, uv->resource_id); ZVAL_RESOURCE(rsc, uv->resource_id);
@ -1500,13 +1503,14 @@ PHP_FUNCTION(uv_close)
/* {{{ */ /* {{{ */
PHP_FUNCTION(uv_read_start) PHP_FUNCTION(uv_read_start)
{ {
#if PHP_UV_DEBUG>=1
fprintf(stderr,"uv_read_start");
#endif
zval *client, *callback; zval *client, *callback;
php_uv_t *uv; php_uv_t *uv;
int r; int r;
#if PHP_UV_DEBUG>=1
fprintf(stderr,"uv_read_start");
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rz",&client, &callback) == FAILURE) { "rz",&client, &callback) == FAILURE) {
return; return;
@ -1801,7 +1805,7 @@ PHP_FUNCTION(uv_getaddrinfo)
{ {
zval *z_loop, *callback = NULL; zval *z_loop, *callback = NULL;
uv_loop_t *loop; uv_loop_t *loop;
php_uv_t *uv; php_uv_t *uv = NULL;
uv_getaddrinfo_t *handle = (uv_getaddrinfo_t*)emalloc(sizeof(uv_getaddrinfo_t)); uv_getaddrinfo_t *handle = (uv_getaddrinfo_t*)emalloc(sizeof(uv_getaddrinfo_t));
/* FIXME: hints */ /* FIXME: hints */
@ -1924,7 +1928,7 @@ PHP_FUNCTION(uv_udp_init)
{ {
int r; int r;
zval *zloop; zval *zloop;
uv_loop_t *loop; uv_loop_t *loop = NULL;
php_uv_t *uv; php_uv_t *uv;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@ -2251,7 +2255,8 @@ PHP_FUNCTION(uv_pipe_bind)
/* {{{ */ /* {{{ */
PHP_FUNCTION(uv_pipe_connect) PHP_FUNCTION(uv_pipe_connect)
{ {
zval *resource,*address, *callback; zval *resource, *callback;
zval *address = NULL;
php_uv_t *uv; php_uv_t *uv;
char *name; char *name;
int name_len = 0; int name_len = 0;
@ -2339,7 +2344,6 @@ PHP_FUNCTION(uv_ares_init_options)
uv_loop_t *loop = NULL; uv_loop_t *loop = NULL;
php_uv_ares_t *uv; php_uv_ares_t *uv;
HashTable *h; HashTable *h;
struct sockaddr_in test_server = uv_ip4_addr("8.8.8.8", 53);
struct in_addr *addresses; struct in_addr *addresses;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@ -2408,14 +2412,10 @@ PHP_FUNCTION(uv_ares_init_options)
/* {{{ */ /* {{{ */
PHP_FUNCTION(ares_gethostbyname) PHP_FUNCTION(ares_gethostbyname)
{ {
int rc;
zval *handle, *byname_cb; zval *handle, *byname_cb;
long flag = AF_INET; long flag = AF_INET;
char *name; char *name;
int name_len; int name_len;
ares_channel channel;
struct ares_options options;
int optmask;
php_uv_ares_t *uv; php_uv_ares_t *uv;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@ -2537,7 +2537,6 @@ PHP_FUNCTION(uv_uptime)
PHP_FUNCTION(uv_get_process_title) PHP_FUNCTION(uv_get_process_title)
{ {
char buffer[512] = {0}; char buffer[512] = {0};
size_t size;
uv_err_t error; uv_err_t error;
/* TODO: check behavior */ /* TODO: check behavior */
@ -2652,7 +2651,7 @@ PHP_FUNCTION(uv_interface_addresses)
array_init(retval); array_init(retval);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
zval *tmp, *times; zval *tmp;
MAKE_STD_ZVAL(tmp); MAKE_STD_ZVAL(tmp);
array_init(tmp); array_init(tmp);
add_assoc_string_ex(tmp, "name", sizeof("name"), interfaces[i].name , 1); add_assoc_string_ex(tmp, "name", sizeof("name"), interfaces[i].name , 1);
@ -2676,10 +2675,8 @@ PHP_FUNCTION(uv_interface_addresses)
/* {{{ */ /* {{{ */
PHP_FUNCTION(uv_spawn) PHP_FUNCTION(uv_spawn)
{ {
int r;
zval *zloop = NULL; zval *zloop = NULL;
uv_loop_t *loop; uv_loop_t *loop;
uv_process_t *process;
uv_process_options_t options = {0}; uv_process_options_t options = {0};
php_uv_t *proc; php_uv_t *proc;
@ -2702,8 +2699,8 @@ PHP_FUNCTION(uv_spawn)
{ {
HashTable *h; HashTable *h;
h = Z_ARRVAL_P(context);
zval **data; zval **data;
h = Z_ARRVAL_P(context);
if (zend_hash_find(h, "cwd", sizeof("cwd"), (void **)&data) == SUCCESS) { if (zend_hash_find(h, "cwd", sizeof("cwd"), (void **)&data) == SUCCESS) {
options.cwd = Z_STRVAL_PP(data); options.cwd = Z_STRVAL_PP(data);
@ -2777,15 +2774,14 @@ PHP_FUNCTION(uv_spawn)
{ {
HashTable *h; HashTable *h;
h = Z_ARRVAL_P(args);
zval **data;
HashPosition pos; HashPosition pos;
char *key; char *key;
int key_type; int key_type;
uint key_len; uint key_len;
ulong key_index; ulong key_index;
int i, hash_len = 0; int hash_len = 0;
h = Z_ARRVAL_P(args);
hash_len = zend_hash_num_elements(h)+1; hash_len = zend_hash_num_elements(h)+1;
command_args = ecalloc(hash_len+1, sizeof(char**)); command_args = ecalloc(hash_len+1, sizeof(char**));
command_args[0] = options.cwd; command_args[0] = options.cwd;
@ -2794,7 +2790,6 @@ PHP_FUNCTION(uv_spawn)
zend_hash_move_forward_ex(h, &pos)) { zend_hash_move_forward_ex(h, &pos)) {
zval **value; zval **value;
php_uv_t *pipe;
zend_hash_get_current_data_ex(h, (void *) &value, &pos); zend_hash_get_current_data_ex(h, (void *) &value, &pos);
command_args[pos->h+1] = Z_STRVAL_PP(value); command_args[pos->h+1] = Z_STRVAL_PP(value);
@ -2858,7 +2853,6 @@ PHP_FUNCTION(uv_process_kill)
/* {{{ */ /* {{{ */
PHP_FUNCTION(uv_kill) PHP_FUNCTION(uv_kill)
{ {
uv_err_t error;
long pid, signal; long pid, signal;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
@ -2912,7 +2906,6 @@ PHP_FUNCTION(uv_rwlock_rdlock)
{ {
uv_rwlock_t *lock; uv_rwlock_t *lock;
zval *handle; zval *handle;
int error;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"z", &handle) == FAILURE) { "z", &handle) == FAILURE) {
@ -3113,13 +3106,14 @@ PHP_FUNCTION(uv_prepare_init)
/* {{{ */ /* {{{ */
PHP_FUNCTION(uv_prepare_start) PHP_FUNCTION(uv_prepare_start)
{ {
#if PHP_UV_DEBUG>=1
fprintf(stderr,"uv_prepare_start");
#endif
zval *handle, *callback; zval *handle, *callback;
php_uv_t *uv; php_uv_t *uv;
int r; int r;
#if PHP_UV_DEBUG>=1
fprintf(stderr,"uv_prepare_start");
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rz",&handle, &callback) == FAILURE) { "rz",&handle, &callback) == FAILURE) {
return; return;
@ -3224,13 +3218,14 @@ PHP_FUNCTION(uv_check_init)
/* {{{ */ /* {{{ */
PHP_FUNCTION(uv_check_start) PHP_FUNCTION(uv_check_start)
{ {
#if PHP_UV_DEBUG>=1
fprintf(stderr,"uv_check_start");
#endif
zval *handle, *callback; zval *handle, *callback;
php_uv_t *uv; php_uv_t *uv;
int r; int r;
#if PHP_UV_DEBUG>=1
fprintf(stderr,"uv_check_start");
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"rz",&handle, &callback) == FAILURE) { "rz",&handle, &callback) == FAILURE) {
return; return;
@ -3298,8 +3293,9 @@ PHP_FUNCTION(uv_async_init)
{ {
int r; int r;
zval *zloop = NULL; zval *zloop = NULL;
zval *callback;
uv_loop_t *loop; uv_loop_t *loop;
php_uv_t *uv, *callback;; php_uv_t *uv;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"zz",&zloop, &callback) == FAILURE) { "zz",&zloop, &callback) == FAILURE) {
@ -3367,8 +3363,9 @@ PHP_FUNCTION(uv_queue_work)
{ {
int r; int r;
zval *zloop = NULL; zval *zloop = NULL;
zval *callback, *after_callback;
uv_loop_t *loop; uv_loop_t *loop;
php_uv_t *uv, *callback, *after_callback; php_uv_t *uv;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"zzz",&zloop, &callback, &after_callback) == FAILURE) { "zzz",&zloop, &callback, &after_callback) == FAILURE) {