Current, broken PHP 7 port...

This commit is contained in:
Bob Weinand 2015-01-18 02:58:40 +01:00
parent 605a20a568
commit 4332fe7aa1
26 changed files with 1431 additions and 1718 deletions

2199
php_uv.c

File diff suppressed because it is too large Load Diff

View File

@ -39,9 +39,7 @@
#include "php_network.h" #include "php_network.h"
#include "php_streams.h" #include "php_streams.h"
#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION >= 3)
#include "ext/sockets/php_sockets.h" #include "ext/sockets/php_sockets.h"
#endif
#include <Zend/zend.h> #include <Zend/zend.h>
#include <Zend/zend_compile.h> #include <Zend/zend_compile.h>
@ -134,7 +132,7 @@ typedef struct {
#ifdef ZTS #ifdef ZTS
void ***thread_ctx; void ***thread_ctx;
#endif #endif
int resource_id; zend_resource *resource_id;
int type; int type;
uv_os_sock_t sock; uv_os_sock_t sock;
union { union {
@ -167,7 +165,7 @@ typedef struct {
typedef struct { typedef struct {
int is_ipv4; int is_ipv4;
int resource_id; zend_resource *resource_id;
union { union {
struct sockaddr_in ipv4; struct sockaddr_in ipv4;
struct sockaddr_in6 ipv6; struct sockaddr_in6 ipv6;
@ -177,7 +175,7 @@ typedef struct {
typedef struct { typedef struct {
int locked; int locked;
enum php_uv_lock_type type; enum php_uv_lock_type type;
int resource_id; zend_resource *resource_id;
union { union {
uv_rwlock_t rwlock; uv_rwlock_t rwlock;
uv_mutex_t mutex; uv_mutex_t mutex;
@ -186,7 +184,7 @@ typedef struct {
} php_uv_lock_t; } php_uv_lock_t;
typedef struct { typedef struct {
int resource_id; zend_resource *resource_id;
int fd; int fd;
zval *stream; zval *stream;
int flags; int flags;
@ -201,11 +199,7 @@ typedef struct {
#define PHP_UV_STDIO_RESOURCE_NAME "uv_stdio" #define PHP_UV_STDIO_RESOURCE_NAME "uv_stdio"
#if PHP_VERSION_ID>=50399 #define PHP_UV_LIST_INSERT(type, handle) Z_RES_P(zend_list_insert(type, handle))
#define PHP_UV_LIST_INSERT(type, handle) zend_list_insert(type, handle TSRMLS_CC)
#else
#define PHP_UV_LIST_INSERT(type, handle) zend_list_insert(type, handle)
#endif
/* File/directory stat mode constants*/ /* File/directory stat mode constants*/

View File

@ -11,5 +11,6 @@ $async = uv_async_init($loop, function($async){
uv_async_send($async); uv_async_send($async);
uv_run(); uv_run();
?>
--EXPECT-- --EXPECT--
Hello Hello

View File

@ -6,9 +6,7 @@ $loop = uv_default_loop();
$timer = uv_timer_init(); $timer = uv_timer_init();
$i = 0; $i = 0;
uv_timer_start($timer, 10, 10, function($timer) uv_timer_start($timer, 10, 10, function($timer) use (&$i) {
use (&$i) {
echo "count: {$i}" . PHP_EOL; echo "count: {$i}" . PHP_EOL;
$i++; $i++;

View File

@ -11,8 +11,7 @@ uv_fs_open(uv_default_loop(),FIXTURE_PATH, UV::O_RDONLY, 0, function($r){
throw new Exception("read error"); throw new Exception("read error");
} }
uv_fs_close(uv_default_loop(), $stream, function(){ uv_fs_close(uv_default_loop(), $stream, function() { });
});
} else { } else {
echo $data ; echo $data ;
} }
@ -27,8 +26,7 @@ uv_fs_open(uv_default_loop(),FIXTURE_PATH, UV::O_RDONLY, 0, function($r){
throw new Exception("read error"); throw new Exception("read error");
} }
uv_fs_close(uv_default_loop(), $stream, function(){ uv_fs_close(uv_default_loop(), $stream, function() { });
});
} else { } else {
echo $data; echo $data;
} }

View File

@ -12,5 +12,5 @@ uv_fs_mkdir(uv_default_loop(), DIRECTORY_PATH, 0755, function($result){
uv_run(); uv_run();
--EXPECT-- --EXPECTF--
0 Resource id #%d

View File

@ -12,5 +12,5 @@ uv_fs_rmdir(uv_default_loop(), DIRECTORY_PATH, function($result){
uv_run(); uv_run();
--EXPECT-- --EXPECTF--
0 Resource id #%d

View File

@ -5,9 +5,8 @@ Check for fs_send_file
define("FIXTURE_PATH", dirname(__FILE__) . "/fixtures/hello.data"); define("FIXTURE_PATH", dirname(__FILE__) . "/fixtures/hello.data");
uv_fs_open(uv_default_loop(), FIXTURE_PATH, UV::O_RDONLY, 0, function($read_fd) { uv_fs_open(uv_default_loop(), FIXTURE_PATH, UV::O_RDONLY, 0, function($read_fd) {
$std_err = 1; // phpt doesn't catch stdout as uv_fs_sendfile uses stdout directly. $std_err = STDERR; // phpt doesn't catch stdout as uv_fs_sendfile uses stdout directly.
uv_fs_sendfile(uv_default_loop(),$std_err, $read_fd, 0, 6, function($result){ uv_fs_sendfile(uv_default_loop(), $std_err, $read_fd, 0, 6, function($result) { });
});
}); });
uv_run(); uv_run();

View File

@ -12,7 +12,6 @@ uv_poll_start($poll, UV::READABLE, function($poll, $stat, $ev, $socket){
uv_poll_stop($poll); uv_poll_stop($poll);
$pp = uv_poll_init(uv_default_loop(), $conn); $pp = uv_poll_init(uv_default_loop(), $conn);
uv_poll_start($pp, UV::WRITABLE, function($poll, $stat, $ev, $conn) use (&$pp) { uv_poll_start($pp, UV::WRITABLE, function($poll, $stat, $ev, $conn) use (&$pp) {
uv_poll_stop($poll); uv_poll_stop($poll);
uv_fs_write(uv_default_loop(), $conn, "OK", -1, function($conn, $nwrite){ uv_fs_write(uv_default_loop(), $conn, "OK", -1, function($conn, $nwrite){
fclose($conn); fclose($conn);
@ -30,7 +29,6 @@ EOF;
if ($stat == 0) { if ($stat == 0) {
uv_read_start($client, function($client, $nread, $buffer) { uv_read_start($client, function($client, $nread, $buffer) {
echo "$buffer\n"; echo "$buffer\n";
//var_dump($buffer);
uv_close($client); uv_close($client);
}); });
} else { } else {

View File

@ -19,7 +19,7 @@ uv_spawn(uv_default_loop(), "php", array('-r','echo "WORLD";'), $stdio, dirname(
}, $flags); }, $flags);
uv_read_start($out, function($out, $nread, $buffer) { uv_read2_start($out, function($out, $nread, $buffer, $stat){
echo $buffer; echo $buffer;
uv_close($out, function() { }); uv_close($out, function() { });

View File

@ -4,12 +4,7 @@ Check for uv_chdir
<?php <?php
uv_chdir(); // don't SEGV uv_chdir(); // don't SEGV
if(uv_chdir(dirname(__FILE__))) { uv_chdir(dirname(__FILE__));
echo "OK\n";
} else {
echo "FAILED: expected uv_chdir to return true";
}
if (uv_cwd() == dirname(__FILE__)) { if (uv_cwd() == dirname(__FILE__)) {
echo "OK"; echo "OK";
} else { } else {
@ -20,4 +15,3 @@ if (uv_cwd() == dirname(__FILE__)) {
Warning: uv_chdir() expects exactly 1 parameter, 0 given in %s on line %d Warning: uv_chdir() expects exactly 1 parameter, 0 given in %s on line %d
OK OK
OK

2
uv.c
View File

@ -190,7 +190,7 @@ static int php_uv_class_init(TSRMLS_D)
zend_declare_class_constant_long(uv_class_entry, "HTTP_RESPONSE", sizeof("HTTP_RESPONSE")-1, HTTP_RESPONSE TSRMLS_CC); zend_declare_class_constant_long(uv_class_entry, "HTTP_RESPONSE", sizeof("HTTP_RESPONSE")-1, HTTP_RESPONSE TSRMLS_CC);
#endif #endif
#define PHP_UV_ERRNO_GEN(name, msg_notused) zend_declare_class_constant_long(uv_class_entry, #name, sizeof(#name)-1, UV_##name TSRMLS_CC); #define PHP_UV_ERRNO_GEN(name, msg_notused) zend_declare_class_constant_long(uv_class_entry, ZEND_STRL(#name), UV_##name);
UV_ERRNO_MAP(PHP_UV_ERRNO_GEN) UV_ERRNO_MAP(PHP_UV_ERRNO_GEN)
#undef PHP_UV_ERRNO_GEN #undef PHP_UV_ERRNO_GEN