Merge remote-tracking branch 'origin/master' into native-tls

* origin/master:
  remove the remains of dsp files handling
  fix EX usage
  remove misprint parentheses
  remove misprint parentheses
  Replaced EG(This) and EX(object) with EX(This). Internal functions now recieves zend_execute_data as the first argument.
  And this one...
  It should be in extern c
  Remove useless condition
  NEWS entry for previous commit
  NEWS entry for previous commit
  add IPv6 support to php-fpm
  Micro optimization for the most frequency case
  Add hash to EXTENSIONS file
  Remove extensions which are long gone
  we also have xz release tarballs since 5.5
  Fix ZTS build
  improved file size computation in stat()
  Fixed incorrect compilation
  5.5.19 now
This commit is contained in:
Anatol Belski 2014-10-03 20:30:49 +02:00
commit ee4ae7fbc3
48 changed files with 489 additions and 1195 deletions

1
.gitignore vendored
View file

@ -20,6 +20,7 @@
*.tgz
*.tar.gz
*.tar.bz2
*.tar.xz
.FBCIndex
.FBCLockFolder
.deps

View file

@ -228,13 +228,6 @@ MAINTENANCE: Maintained
STATUS: Working
COMMENT: Use PostgreSQL 7.0.x or later. PostgreSQL 6.5.3 or less have fatal bug.
-------------------------------------------------------------------------------
EXTENSION: sqlite
PRIMARY MAINTAINER: Marcus Boerger <helly@php.net>, Wez Furlong <wez@php.net>, Ilia Alshanetsky <iliaa@php.net>
MAINTENANCE: Maintained
STATUS: Working
SINCE: 5.0 (Since 4.3.2 in PECL)
COMMENT: Integrates SQLite 2 embeddable SQL database engine.
-------------------------------------------------------------------------------
EXTENSION: sqlite3
PRIMARY MAINTAINER: Scott MacVicar <scottmac@php.net>
MAINTENANCE: Maintained
@ -385,6 +378,12 @@ MAINTENANCE: Maintained
STATUS: Working
SINCE: 4.0.4
-------------------------------------------------------------------------------
EXTENSION: hash
PRIMARY MAINTAINER: Sara Golemon <pollita@php.net>, Mike Wallner <mike@php.net>, Anatol Belski <ab@php.net>
MAINTENANCE: Maintained
STATUS: Working
SINCE: 5.1.2
-------------------------------------------------------------------------------
EXTENSION: iconv
PRIMARY MAINTAINER: Moriyoshi Koizumi <moriyoshi@php.net>
MAINTENANCE: Maintained
@ -422,22 +421,6 @@ PRIMARY MAINTAINER: Derick Rethans <derick@derickrethans.nl>
MAINTENANCE: Maintained
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: mhash
PRIMARY MAINTAINER: Sascha Schumann <sascha@schumann.cx>, Scott MacVicar <scottmac@php.net>
MAINTENANCE: Unknown
STATUS: Working
-------------------------------------------------------------------------------
EXTENSION: mime_magic
PRIMARY MAINTAINER: Unknown
MAINTENANCE: Deprecated
STATUS: Experimental
COMMENT: Use the fileinfo extension instead
-------------------------------------------------------------------------------
EXTENSION: ming
PRIMARY MAINTAINER: Frank M. Kromann
MAINTENANCE: Unknown
STATUS: Experimental
-------------------------------------------------------------------------------
EXTENSION: openssl
PRIMARY MAINTAINER: Wez Furlong <wez@php.net>, Pierre-Alain Joye <pajoye@php.net>
MAINTENANCE: Maintained

View file

@ -605,13 +605,13 @@ TSRM_API int shmget(int key, int size, int flags)
shm_handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, shm_segment);
info_handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, shm_info);
if ((!shm_handle && !info_handle)) {
if (!shm_handle && !info_handle) {
if (flags & IPC_CREAT) {
shm_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, shm_segment);
info_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(shm->descriptor), shm_info);
created = TRUE;
}
if ((!shm_handle || !info_handle)) {
if (!shm_handle || !info_handle) {
return -1;
}
} else {

View file

@ -52,14 +52,13 @@
# define HANDLE_UNBLOCK_INTERRUPTIONS() ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
#endif
#define INTERNAL_FUNCTION_PARAMETERS uint32_t param_count, zval *return_value TSRMLS_DC
#define INTERNAL_FUNCTION_PARAM_PASSTHRU param_count, return_value TSRMLS_CC
#define INTERNAL_FUNCTION_PARAMETERS zend_execute_data *execute_data, zval *return_value TSRMLS_DC
#define INTERNAL_FUNCTION_PARAM_PASSTHRU execute_data, return_value TSRMLS_CC
#define USED_RET() \
(!EG(current_execute_data) || \
!EG(current_execute_data)->prev_execute_data || \
!ZEND_USER_CODE(EG(current_execute_data)->prev_execute_data->func->common.type) || \
!(EG(current_execute_data)->prev_execute_data->opline->result_type & EXT_TYPE_UNUSED))
(!EX(prev_execute_data) || \
!ZEND_USER_CODE(EX(prev_execute_data)->func->common.type) || \
!(EX(prev_execute_data)->opline->result_type & EXT_TYPE_UNUSED))
#ifdef ZEND_ENABLE_STATIC_TSRMLS_CACHE
#define ZEND_TSRMG TSRMG_STATIC

View file

@ -2850,8 +2850,8 @@ static int zend_is_callable_check_class(zend_string *name, zend_fcall_info_cache
} else {
fcc->called_scope = EG(current_execute_data) ? EG(current_execute_data)->called_scope : NULL;
fcc->calling_scope = EG(scope);
if (!fcc->object && Z_OBJ(EG(This))) {
fcc->object = Z_OBJ(EG(This));
if (!fcc->object && EG(current_execute_data) && Z_OBJ(EG(current_execute_data)->This)) {
fcc->object = Z_OBJ(EG(current_execute_data)->This);
}
ret = 1;
}
@ -2863,8 +2863,8 @@ static int zend_is_callable_check_class(zend_string *name, zend_fcall_info_cache
} else {
fcc->called_scope = EG(current_execute_data) ? EG(current_execute_data)->called_scope : NULL;
fcc->calling_scope = EG(scope)->parent;
if (!fcc->object && Z_OBJ(EG(This))) {
fcc->object = Z_OBJ(EG(This));
if (!fcc->object && EG(current_execute_data) && Z_OBJ(EG(current_execute_data)->This)) {
fcc->object = Z_OBJ(EG(current_execute_data)->This);
}
*strict_class = 1;
ret = 1;
@ -2875,8 +2875,8 @@ static int zend_is_callable_check_class(zend_string *name, zend_fcall_info_cache
} else {
fcc->called_scope = EG(current_execute_data)->called_scope;
fcc->calling_scope = EG(current_execute_data)->called_scope;
if (!fcc->object && Z_OBJ(EG(This))) {
fcc->object = Z_OBJ(EG(This));
if (!fcc->object && Z_OBJ(EG(current_execute_data)->This)) {
fcc->object = Z_OBJ(EG(current_execute_data)->This);
}
*strict_class = 1;
ret = 1;
@ -2890,11 +2890,11 @@ static int zend_is_callable_check_class(zend_string *name, zend_fcall_info_cache
}
scope = ex ? ex->func->common.scope : NULL;
fcc->calling_scope = ce;
if (scope && !fcc->object && Z_OBJ(EG(This)) &&
instanceof_function(Z_OBJCE(EG(This)), scope TSRMLS_CC) &&
if (scope && !fcc->object && EG(current_execute_data) && Z_OBJ(EG(current_execute_data)->This) &&
instanceof_function(Z_OBJCE(EG(current_execute_data)->This), scope TSRMLS_CC) &&
instanceof_function(scope, fcc->calling_scope TSRMLS_CC)) {
fcc->object = Z_OBJ(EG(This));
fcc->called_scope = Z_OBJCE(EG(This));
fcc->object = Z_OBJ(EG(current_execute_data)->This);
fcc->called_scope = Z_OBJCE(EG(current_execute_data)->This);
} else {
fcc->called_scope = fcc->object ? zend_get_class_entry(fcc->object TSRMLS_CC) : fcc->calling_scope;
}
@ -3095,10 +3095,10 @@ get_function_via_handler:
if (fcc->function_handler) {
retval = 1;
call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
if (call_via_handler && !fcc->object && Z_OBJ(EG(This)) &&
Z_OBJ_HT(EG(This))->get_class_entry &&
instanceof_function(Z_OBJCE(EG(This)), fcc->calling_scope TSRMLS_CC)) {
fcc->object = Z_OBJ(EG(This));
if (call_via_handler && !fcc->object && EG(current_execute_data) && Z_OBJ(EG(current_execute_data)->This) &&
Z_OBJ_HT(EG(current_execute_data)->This)->get_class_entry &&
instanceof_function(Z_OBJCE(EG(current_execute_data)->This), fcc->calling_scope TSRMLS_CC)) {
fcc->object = Z_OBJ(EG(current_execute_data)->This);
}
}
}
@ -3127,15 +3127,15 @@ get_function_via_handler:
if ((check_flags & IS_CALLABLE_CHECK_IS_STATIC) != 0) {
retval = 0;
}
if (Z_OBJ(EG(This)) && instanceof_function(Z_OBJCE(EG(This)), fcc->calling_scope TSRMLS_CC)) {
fcc->object = Z_OBJ(EG(This));
if (EG(current_execute_data) && Z_OBJ(EG(current_execute_data)->This) && instanceof_function(Z_OBJCE(EG(current_execute_data)->This), fcc->calling_scope TSRMLS_CC)) {
fcc->object = Z_OBJ(EG(current_execute_data)->This);
if (error) {
zend_spprintf(error, 0, "non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val, verb, Z_OBJCE(EG(This))->name->val);
zend_spprintf(error, 0, "non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val, verb, Z_OBJCE(EG(current_execute_data)->This)->name->val);
if (severity == E_ERROR) {
retval = 0;
}
} else if (retval) {
zend_error(severity, "Non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val, verb, Z_OBJCE(EG(This))->name->val);
zend_error(severity, "Non-static method %s::%s() %s be called statically, assuming $this from compatible context %s", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val, verb, Z_OBJCE(EG(current_execute_data)->This)->name->val);
}
} else {
if (error) {
@ -4143,6 +4143,39 @@ ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_functi
}
/* }}} */
ZEND_API void zend_ctor_make_null(zend_execute_data *execute_data) /* {{{ */
{
if (EX(return_value)) {
/*
if (Z_TYPE_P(EX(return_value)) == IS_OBJECT) {
zend_object *object = Z_OBJ_P(EX(return_value));
zend_execute_data *ex = EX(prev_execute_data);
while (ex && Z_OBJ(ex->This) == object) {
if (ex->func) {
if (ZEND_USER_CODE(ex->func->type)) {
if (ex->func->op_array.this_var != -1) {
zval *this_var = EX_VAR_2(ex, ex->func->op_array.this_var);
if (this_var != EX(return_value)) {
zval_ptr_dtor(this_var);
ZVAL_NULL(this_var);
}
}
}
}
Z_OBJ(ex->This) = NULL;
ZVAL_NULL(&ex->This);
ex = ex->prev_execute_data;
}
}
*/
zval_ptr_dtor(EX(return_value));
Z_OBJ_P(EX(return_value)) = NULL;
ZVAL_NULL(EX(return_value));
}
}
/* }}} */
/*
* Local variables:
* tab-width: 4

View file

@ -343,12 +343,12 @@ ZEND_API zend_class_entry *zend_get_class_entry(const zend_object *object TSRMLS
ZEND_API zend_string *zend_get_object_classname(const zend_object *object TSRMLS_DC);
ZEND_API char *zend_get_type_by_const(int type);
#define getThis() (Z_OBJ(EG(This)) ? &EG(This) : NULL)
#define getThis() (Z_OBJ(EX(This)) ? &EX(This) : NULL)
#define WRONG_PARAM_COUNT ZEND_WRONG_PARAM_COUNT()
#define WRONG_PARAM_COUNT_WITH_RETVAL(ret) ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret)
#define ARG_COUNT(dummy) (param_count)
#define ZEND_NUM_ARGS() (param_count)
#define ARG_COUNT(dummy) EX(num_args)
#define ZEND_NUM_ARGS() EX(num_args)
#define ZEND_WRONG_PARAM_COUNT() { zend_wrong_param_count(TSRMLS_C); return; }
#define ZEND_WRONG_PARAM_COUNT_WITH_RETVAL(ret) { zend_wrong_param_count(TSRMLS_C); return ret; }
@ -531,6 +531,8 @@ ZEND_API int zend_set_local_var_str(const char *name, int len, zval *value, int
ZEND_API zend_string *zend_find_alias_name(zend_class_entry *ce, zend_string *name);
ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_function *f);
ZEND_API void zend_ctor_make_null(zend_execute_data *execute_data);
#define add_method(arg, key, method) add_assoc_function((arg), (key), (method))
ZEND_API ZEND_FUNCTION(display_disabled_function);
@ -639,26 +641,8 @@ END_EXTERN_C()
} while (0)
/* May be used in internal constructors to make them return NULL */
#if 1 // support for directly called constructors only ???
#define ZEND_CTOR_MAKE_NULL() do { \
if (EG(current_execute_data)->return_value) { \
zval_ptr_dtor(EG(current_execute_data)->return_value); \
ZVAL_NULL(EG(current_execute_data)->return_value); \
} \
} while (0)
#else // attempt to support calls to parent::__construct() ???
// see: ext/date/tests/bug67118.phpt
#define ZEND_CTOR_MAKE_NULL() do { \
if (EG(current_execute_data)->return_value) { \
zval_ptr_dtor(EG(current_execute_data)->return_value); \
ZVAL_NULL(EG(current_execute_data)->return_value); \
} else if (EG(current_execute_data)->prev_execute_data && \
EG(current_execute_data)->prev_execute_data->object == \
EG(current_execute_data)->object) { \
EG(current_execute_data)->prev_execute_data->object = NULL; \
} \
} while (0)
#endif
#define ZEND_CTOR_MAKE_NULL() \
zend_ctor_make_null(execute_data)
#define RETURN_ZVAL_FAST(z) { RETVAL_ZVAL_FAST(z); return; }
@ -729,7 +713,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
const int _flags = (flags); \
int _min_num_args = (min_num_args); \
int _max_num_args = (max_num_args); \
int _num_args = EG(current_execute_data)->num_args; \
int _num_args = EX(num_args); \
int _i; \
zval *_real_arg, *_arg = NULL; \
zend_expected_type _expected_type = IS_UNDEF; \
@ -756,7 +740,7 @@ ZEND_API int _z_param_class(zval *arg, zend_class_entry **pce, int num, int chec
break; \
} \
_i = 0; \
_real_arg = ZEND_CALL_ARG(EG(current_execute_data), 0);
_real_arg = ZEND_CALL_ARG(execute_data, 0);
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args) \
ZEND_PARSE_PARAMETERS_START_EX(0, min_num_args, max_num_args)

View file

@ -400,7 +400,7 @@ ZEND_FUNCTION(gc_disable)
Get the number of arguments that were passed to the function */
ZEND_FUNCTION(func_num_args)
{
zend_execute_data *ex = EG(current_execute_data)->prev_execute_data;
zend_execute_data *ex = EX(prev_execute_data);
if (ex->frame_kind == VM_FRAME_NESTED_FUNCTION || ex->frame_kind == VM_FRAME_TOP_FUNCTION) {
RETURN_LONG(ex->num_args);
@ -429,7 +429,7 @@ ZEND_FUNCTION(func_get_arg)
RETURN_FALSE;
}
ex = EG(current_execute_data)->prev_execute_data;
ex = EX(prev_execute_data);
if (ex->frame_kind != VM_FRAME_NESTED_FUNCTION && ex->frame_kind != VM_FRAME_TOP_FUNCTION) {
zend_error(E_WARNING, "func_get_arg(): Called from the global scope - no function context");
RETURN_FALSE;
@ -462,7 +462,7 @@ ZEND_FUNCTION(func_get_args)
zval *p;
uint32_t arg_count, first_extra_arg;
uint32_t i;
zend_execute_data *ex = EG(current_execute_data)->prev_execute_data;
zend_execute_data *ex = EX(prev_execute_data);
if (ex->frame_kind != VM_FRAME_NESTED_FUNCTION && ex->frame_kind != VM_FRAME_TOP_FUNCTION) {
zend_error(E_WARNING, "func_get_args(): Called from the global scope - no function context");
@ -823,8 +823,8 @@ ZEND_FUNCTION(get_called_class)
return;
}
if (EG(current_execute_data)->called_scope) {
RETURN_STR(zend_string_copy(EG(current_execute_data)->called_scope->name));
if (EX(called_scope)) {
RETURN_STR(zend_string_copy(EX(called_scope)->name));
} else if (!EG(scope)) {
zend_error(E_WARNING, "get_called_class() called from outside a class");
}
@ -2132,7 +2132,7 @@ ZEND_FUNCTION(debug_print_backtrace)
}
ZVAL_UNDEF(&arg_array);
ptr = EG(current_execute_data)->prev_execute_data;
ptr = EX(prev_execute_data);
/* skip debug_backtrace() */
call = ptr;
@ -2172,7 +2172,7 @@ ZEND_FUNCTION(debug_print_backtrace)
}
/* $this may be passed into regular internal functions */
object = call->object;
object = Z_OBJ(call->This);
if (object &&
call &&
call->func->type == ZEND_INTERNAL_FUNCTION &&
@ -2394,7 +2394,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
}
/* $this may be passed into regular internal functions */
object = call ? call->object : NULL;
object = call ? Z_OBJ(call->This) : NULL;
if (object &&
call->func &&
call->func->type == ZEND_INTERNAL_FUNCTION &&

View file

@ -47,7 +47,7 @@ static zend_object_handlers closure_handlers;
ZEND_METHOD(Closure, __invoke) /* {{{ */
{
zend_function *func = EG(current_execute_data)->func;
zend_function *func = EX(func);
zval *arguments;
arguments = emalloc(sizeof(zval) * ZEND_NUM_ARGS());

View file

@ -5557,7 +5557,7 @@ void zend_compile_array(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
{
zend_ast_list *list = zend_ast_get_list(ast);
zend_op *opline;
uint32_t i, opnum_init;
uint32_t i, opnum_init = -1;
zend_bool packed = 1;
if (zend_try_ct_eval_array(&result->u.constant, ast TSRMLS_CC)) {
@ -5565,8 +5565,6 @@ void zend_compile_array(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
return;
}
opnum_init = get_next_op_number(CG(active_op_array));
for (i = 0; i < list->children; ++i) {
zend_ast *elem_ast = list->child[i];
zend_ast *value_ast = elem_ast->child[0];
@ -5589,6 +5587,7 @@ void zend_compile_array(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
}
if (i == 0) {
opnum_init = get_next_op_number(CG(active_op_array));
opline = zend_emit_op_tmp(result, ZEND_INIT_ARRAY, &value_node, key_node_ptr TSRMLS_CC);
opline->extended_value = list->children << ZEND_ARRAY_SIZE_SHIFT;
} else {
@ -5610,6 +5609,7 @@ void zend_compile_array(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
/* Add a flag to INIT_ARRAY if we know this array cannot be packed */
if (!packed) {
ZEND_ASSERT(opnum_init != -1);
opline = &CG(active_op_array)->opcodes[opnum_init];
opline->extended_value |= ZEND_ARRAY_NOT_PACKED;
}

View file

@ -100,8 +100,6 @@ void zend_compile_var(znode *node, zend_ast *ast, uint32_t type TSRMLS_DC);
void zend_eval_const_expr(zend_ast **ast_ptr TSRMLS_DC);
void zend_const_expr_to_zval(zval *result, zend_ast *ast TSRMLS_DC);
typedef struct _zend_execute_data zend_execute_data;
#define ZEND_OPCODE_HANDLER_ARGS zend_execute_data *execute_data TSRMLS_DC
#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU execute_data TSRMLS_CC
@ -366,7 +364,7 @@ struct _zend_execute_data {
zend_uchar flags;
zend_uchar frame_kind;
zend_class_entry *called_scope;
zend_object *object;
zval This;
zend_execute_data *prev_execute_data;
zval *return_value;
zend_class_entry *scope; /* function scope (self) */
@ -385,7 +383,7 @@ struct _zend_execute_data {
#define ZEND_CALL_ARG(call, n) \
(((zval*)(call)) + ((n) + (ZEND_CALL_FRAME_SLOT - 1)))
#define EX(element) execute_data.element
#define EX(element) ((execute_data)->element)
#define EX_VAR_2(ex, n) ((zval*)(((char*)(ex)) + ((int)(n))))
#define EX_VAR_NUM_2(ex, n) (((zval*)(ex)) + (ZEND_CALL_FRAME_SLOT + ((int)(n))))

View file

@ -123,9 +123,6 @@ static const zend_internal_function zend_pass_function = {
#define DECODE_CTOR(ce) \
((zend_class_entry*)(((zend_uintptr_t)(ce)) & ~(CTOR_CALL_BIT|CTOR_USED_BIT)))
#undef EX
#define EX(element) execute_data->element
ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data, uint32_t var)
{
return EX_VAR(var);
@ -426,22 +423,22 @@ static inline zval *_get_zval_ptr_ptr(int op_type, const znode_op *node, const z
}
}
static zend_always_inline zval *_get_obj_zval_ptr_unused(TSRMLS_D)
static zend_always_inline zval *_get_obj_zval_ptr_unused(zend_execute_data *execute_data TSRMLS_DC)
{
if (EXPECTED(Z_OBJ(EG(This)) != NULL)) {
return &EG(This);
if (EXPECTED(Z_OBJ(EX(This)) != NULL)) {
return &EX(This);
} else {
zend_error_noreturn(E_ERROR, "Using $this when not in object context");
return NULL;
}
}
static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
{
if (op_type == IS_UNUSED) {
if (EXPECTED(Z_OBJ(EG(This)) != NULL)) {
if (EXPECTED(Z_OBJ(EX(This)) != NULL)) {
should_free->var = NULL;
return &EG(This);
return &EX(This);
} else {
zend_error_noreturn(E_ERROR, "Using $this when not in object context");
}
@ -449,12 +446,12 @@ static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, const zend_exec
return get_zval_ptr(op_type, op, execute_data, should_free, type);
}
static inline zval *_get_obj_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
static inline zval *_get_obj_zval_ptr_ptr(int op_type, const znode_op *node, zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
{
if (op_type == IS_UNUSED) {
if (EXPECTED(Z_OBJ(EG(This)) != NULL)) {
if (EXPECTED(Z_OBJ(EX(This)) != NULL)) {
should_free->var = NULL;
return &EG(This);
return &EX(This);
} else {
zend_error_noreturn(E_ERROR, "Using $this when not in object context");
}
@ -1217,14 +1214,13 @@ static zend_always_inline void zend_fetch_dimension_address_read(zval *result, z
} else {
retval = Z_OBJ_HT_P(container)->read_dimension(container, dim, type, result TSRMLS_CC);
if (result) {
if (retval) {
if (result != retval) {
ZVAL_COPY(result, retval);
}
} else {
ZVAL_NULL(result);
ZEND_ASSERT(result != NULL);
if (retval) {
if (result != retval) {
ZVAL_COPY(result, retval);
}
} else {
ZVAL_NULL(result);
}
}
} else {
@ -1368,7 +1364,7 @@ ZEND_API opcode_handler_t *zend_opcode_handlers;
ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value TSRMLS_DC)
{
execute_data->func->internal_function.handler(execute_data->num_args, return_value TSRMLS_CC);
execute_data->func->internal_function.handler(execute_data, return_value TSRMLS_CC);
}
void zend_clean_and_cache_symbol_table(zend_array *symbol_table TSRMLS_DC) /* {{{ */
@ -1428,7 +1424,6 @@ static zend_always_inline void i_init_func_execute_data(zend_execute_data *execu
{
uint32_t first_extra_arg, num_args;
ZEND_ASSERT(EX(func) == (zend_function*)op_array);
ZEND_ASSERT(EX(object) == Z_OBJ(EG(This)));
EX(opline) = op_array->opcodes;
EX(call) = NULL;
@ -1480,9 +1475,9 @@ static zend_always_inline void i_init_func_execute_data(zend_execute_data *execu
} while (var != end);
}
if (op_array->this_var != -1 && EX(object)) {
ZVAL_OBJ(EX_VAR(op_array->this_var), EX(object));
GC_REFCOUNT(EX(object))++;
if (op_array->this_var != -1 && Z_OBJ(EX(This))) {
ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
GC_REFCOUNT(Z_OBJ(EX(This)))++;
}
if (!op_array->run_time_cache && op_array->last_cache_slot) {
@ -1497,7 +1492,6 @@ static zend_always_inline void i_init_func_execute_data(zend_execute_data *execu
static zend_always_inline void i_init_code_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value, vm_frame_kind frame_kind TSRMLS_DC) /* {{{ */
{
ZEND_ASSERT(EX(func) == (zend_function*)op_array);
ZEND_ASSERT(EX(object) == Z_OBJ(EG(This)));
EX(opline) = op_array->opcodes;
EX(call) = NULL;
@ -1521,7 +1515,6 @@ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execu
static zend_always_inline void i_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value, vm_frame_kind frame_kind TSRMLS_DC) /* {{{ */
{
ZEND_ASSERT(EX(func) == (zend_function*)op_array);
ZEND_ASSERT(EX(object) == Z_OBJ(EG(This)));
EX(opline) = op_array->opcodes;
EX(call) = NULL;
@ -1578,9 +1571,9 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da
} while (var != end);
}
if (op_array->this_var != -1 && EX(object)) {
ZVAL_OBJ(EX_VAR(op_array->this_var), EX(object));
GC_REFCOUNT(EX(object))++;
if (op_array->this_var != -1 && Z_OBJ(EX(This))) {
ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
GC_REFCOUNT(Z_OBJ(EX(This)))++;
}
}
@ -1623,7 +1616,7 @@ ZEND_API zend_execute_data *zend_create_generator_execute_data(zend_execute_data
num_args,
call->flags,
call->called_scope,
call->object,
Z_OBJ(call->This),
NULL TSRMLS_CC);
EX(num_args) = num_args;

View file

@ -218,7 +218,7 @@ static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(zend_
call->num_args = 0;
call->flags = flags;
call->called_scope = called_scope;
call->object = object;
ZVAL_OBJ(&call->This, object);
call->prev_execute_data = prev;
return call;
}

View file

@ -187,8 +187,6 @@ void init_executor(TSRMLS_D) /* {{{ */
EG(scope) = NULL;
ZVAL_OBJ(&EG(This), NULL);
EG(active) = 1;
}
/* }}} */
@ -660,7 +658,6 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
zend_execute_data *call, dummy_execute_data;
zend_fcall_info_cache fci_cache_local;
zend_function *func;
zend_object *orig_object;
zend_class_entry *orig_scope;
zval tmp;
@ -682,7 +679,6 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
break;
}
orig_object = Z_OBJ(EG(This));
orig_scope = EG(scope);
/* Initialize execute_data */
@ -832,10 +828,11 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
EG(scope) = calling_scope;
if (!fci->object ||
(func->common.fn_flags & ZEND_ACC_STATIC)) {
Z_OBJ(EG(This)) = call->object = NULL;
Z_OBJ(call->This) = NULL;
Z_TYPE_INFO(call->This) = IS_UNDEF;
} else {
Z_OBJ(EG(This)) = fci->object;
Z_ADDREF(EG(This));
ZVAL_OBJ(&call->This, fci->object);
GC_REFCOUNT(fci->object)++;
}
if (func->type == ZEND_USER_FUNCTION) {
@ -858,7 +855,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
EG(current_execute_data) = call;
if (EXPECTED(zend_execute_internal == NULL)) {
/* saves one function call if zend_execute_internal is not used */
func->internal_function.handler(fci->param_count, fci->retval TSRMLS_CC);
func->internal_function.handler(call, fci->retval TSRMLS_CC);
} else {
zend_execute_internal(call, fci->retval TSRMLS_CC);
}
@ -888,7 +885,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
if (fci->object) {
call->prev_execute_data = EG(current_execute_data);
EG(current_execute_data) = call;
fci->object->handlers->call_method(func->common.function_name, fci->object, fci->param_count, fci->retval TSRMLS_CC);
fci->object->handlers->call_method(func->common.function_name, fci->object, call, fci->retval TSRMLS_CC);
EG(current_execute_data) = call->prev_execute_data;
} else {
zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object");
@ -908,11 +905,10 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
}
}
if (Z_OBJ(EG(This))) {
zval_ptr_dtor(&EG(This));
if (fci->object && !(func->common.fn_flags & ZEND_ACC_STATIC)) {
OBJ_RELEASE(fci->object);
}
Z_OBJ(EG(This)) = orig_object;
EG(scope) = orig_scope;
if (EG(current_execute_data) == &dummy_execute_data) {
EG(current_execute_data) = dummy_execute_data.prev_execute_data;

View file

@ -68,8 +68,8 @@ static void zend_generator_cleanup_unfinished_execution(zend_generator *generato
/* If yield was used as a function argument there may be active
* method calls those objects need to be freed */
while (execute_data->call) {
if (execute_data->call->object) {
OBJ_RELEASE(execute_data->call->object);
if (Z_OBJ(execute_data->call->This)) {
OBJ_RELEASE(Z_OBJ(execute_data->call->This));
}
execute_data->call = execute_data->call->prev_execute_data;
}
@ -98,8 +98,8 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
zend_clean_and_cache_symbol_table(execute_data->symbol_table TSRMLS_CC);
}
if (execute_data->object) {
OBJ_RELEASE(execute_data->object);
if (Z_OBJ(execute_data->This)) {
OBJ_RELEASE(Z_OBJ(execute_data->This));
}
/* A fatal error / die occurred during the generator execution. Trying to clean
@ -251,8 +251,8 @@ ZEND_API void zend_generator_create_zval(zend_execute_data *call, zend_op_array
object_init_ex(return_value, zend_ce_generator);
if (Z_OBJ(EG(This))) {
Z_ADDREF(EG(This));
if (Z_OBJ(call->This)) {
Z_ADDREF(call->This);
}
/* Save execution context in generator object. */
@ -292,15 +292,11 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{
{
/* Backup executor globals */
zend_execute_data *original_execute_data = EG(current_execute_data);
zend_object *original_This;
zend_class_entry *original_scope = EG(scope);
zend_vm_stack original_stack = EG(argument_stack);
original_This = Z_OBJ(EG(This));
/* Set executor globals */
EG(current_execute_data) = generator->execute_data;
Z_OBJ(EG(This)) = generator->execute_data->object;
EG(scope) = generator->execute_data->scope;
EG(argument_stack) = generator->stack;
@ -322,7 +318,6 @@ ZEND_API void zend_generator_resume(zend_generator *generator TSRMLS_DC) /* {{{
/* Restore executor globals */
EG(current_execute_data) = original_execute_data;
Z_OBJ(EG(This)) = original_This;
EG(scope) = original_scope;
EG(argument_stack) = original_stack;

View file

@ -174,8 +174,6 @@ struct _zend_executor_globals {
zend_class_entry *scope;
zval This;
zend_long precision;
int ticks_count;

View file

@ -221,6 +221,8 @@ void zend_hash_display_pListTail(const HashTable *ht);
void zend_hash_display(const HashTable *ht);
#endif
ZEND_API int _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx);
END_EXTERN_C()
#define ZEND_INIT_SYMTABLE(ht) \
@ -229,8 +231,6 @@ END_EXTERN_C()
#define ZEND_INIT_SYMTABLE_EX(ht, n, persistent) \
zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent)
ZEND_API int _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx);
static zend_always_inline int _zend_handle_numeric_str(const char *key, size_t length, zend_ulong *idx)
{
register const char *tmp = key;

View file

@ -921,7 +921,7 @@ static void zend_std_unset_dimension(zval *object, zval *offset TSRMLS_DC) /* {{
ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
{
zend_internal_function *func = (zend_internal_function *)EG(current_execute_data)->func;
zend_internal_function *func = (zend_internal_function *)EX(func);
zval method_name, method_args;
zval method_result;
zend_class_entry *ce = Z_OBJCE_P(getThis());
@ -1139,7 +1139,7 @@ static union _zend_function *zend_std_get_method(zend_object **obj_ptr, zend_str
ZEND_API void zend_std_callstatic_user_call(INTERNAL_FUNCTION_PARAMETERS) /* {{{ */
{
zend_internal_function *func = (zend_internal_function *)EG(current_execute_data)->func;
zend_internal_function *func = (zend_internal_function *)EX(func);
zval method_name, method_args;
zval method_result;
zend_class_entry *ce = EG(scope);
@ -1231,9 +1231,9 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st
zend_string_free(lc_function_name);
}
if (ce->__call &&
Z_OBJ(EG(This)) &&
Z_OBJ_HT(EG(This))->get_class_entry &&
instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) {
Z_OBJ(EG(current_execute_data)->This) &&
Z_OBJ_HT(EG(current_execute_data)->This)->get_class_entry &&
instanceof_function(Z_OBJCE(EG(current_execute_data)->This), ce TSRMLS_CC)) {
return zend_get_user_call_function(ce, function_name);
} else if (ce->__callstatic) {
return zend_get_user_callstatic_function(ce, function_name);

View file

@ -71,7 +71,7 @@ ZEND_API zend_object *zend_object_create_proxy(zval *object, zval *member TSRMLS
ZEND_API zend_object_handlers *zend_get_std_object_handlers(void);
END_EXTERN_C()
static zend_always_inline void zend_object_release(zend_object *obj TSRMLS_CC)
static zend_always_inline void zend_object_release(zend_object *obj TSRMLS_DC)
{
if (--GC_REFCOUNT(obj) == 0) {
zend_objects_store_del(obj TSRMLS_CC);

View file

@ -69,6 +69,24 @@ ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSR
ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool interfaces_only TSRMLS_DC);
ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce TSRMLS_DC);
/**
* Checks whether the string "str" with length "length" is numeric. The value
* of allow_errors determines whether it's required to be entirely numeric, or
* just its prefix. Leading whitespace is allowed.
*
* The function returns 0 if the string did not contain a valid number; IS_LONG
* if it contained a number that fits within the range of a long; or IS_DOUBLE
* if the number was out of long range or contained a decimal point/exponent.
* The number's value is returned into the respective pointer, *lval or *dval,
* if that pointer is not NULL.
*
* This variant also gives information if a string that represents an integer
* could not be represented as such due to overflow. It writes 1 to oflow_info
* if the integer is larger than ZEND_LONG_MAX and -1 if it's smaller than ZEND_LONG_MIN.
*/
ZEND_API zend_uchar _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors, int *oflow_info);
END_EXTERN_C()
#if ZEND_DVAL_TO_LVAL_CAST_OK
@ -125,23 +143,6 @@ static zend_always_inline zend_long zend_dval_to_lval(double d)
#define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
#define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
/**
* Checks whether the string "str" with length "length" is numeric. The value
* of allow_errors determines whether it's required to be entirely numeric, or
* just its prefix. Leading whitespace is allowed.
*
* The function returns 0 if the string did not contain a valid number; IS_LONG
* if it contained a number that fits within the range of a long; or IS_DOUBLE
* if the number was out of long range or contained a decimal point/exponent.
* The number's value is returned into the respective pointer, *lval or *dval,
* if that pointer is not NULL.
*
* This variant also gives information if a string that represents an integer
* could not be represented as such due to overflow. It writes 1 to oflow_info
* if the integer is larger than ZEND_LONG_MAX and -1 if it's smaller than ZEND_LONG_MIN.
*/
ZEND_API zend_uchar _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors, int *oflow_info);
static zend_always_inline zend_uchar is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors, int *oflow_info)
{
if (*str > '9') {

View file

@ -90,6 +90,7 @@ typedef uint32_t zend_uintptr_t;
typedef struct _zend_object_handlers zend_object_handlers;
typedef struct _zend_class_entry zend_class_entry;
typedef union _zend_function zend_function;
typedef struct _zend_execute_data zend_execute_data;
typedef struct _zval_struct zval;

View file

@ -294,7 +294,7 @@ CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){
CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{{ */
{
WIN32_FILE_ATTRIBUTE_DATA data;
__int64 t;
LARGE_INTEGER t;
const size_t path_len = strlen(path);
ALLOCA_FLAG(use_heap_large);
@ -393,10 +393,11 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{
}
buf->st_nlink = 1;
t = data.nFileSizeHigh;
t = t << 32;
t |= data.nFileSizeLow;
buf->st_size = t;
t.HighPart = data.nFileSizeHigh;
t.LowPart = data.nFileSizeLow;
/* It's an overflow on 32 bit, however it won't fix as long
as zend_long is 32 bit. */
buf->st_size = (zend_long)t.QuadPart;
buf->st_atime = FileTimeToUnixTime(&data.ftLastAccessTime);
buf->st_ctime = FileTimeToUnixTime(&data.ftCreationTime);
buf->st_mtime = FileTimeToUnixTime(&data.ftLastWriteTime);

View file

@ -70,7 +70,7 @@ typedef unsigned short mode_t;
#define IS_UNC_PATH(path, len) \
(len >= 2 && IS_SLASH(path[0]) && IS_SLASH(path[1]))
#define IS_ABSOLUTE_PATH(path, len) \
(len >= 2 && ((/* is local */isalpha(path[0]) && path[1] == ':') || /* is UNC */IS_SLASH(path[0]) && IS_SLASH(path[1])))
(len >= 2 && (/* is local */isalpha(path[0]) && path[1] == ':' || /* is UNC */IS_SLASH(path[0]) && IS_SLASH(path[1])))
#elif defined(NETWARE)
#ifdef HAVE_DIRENT_H

View file

@ -1711,6 +1711,8 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
vm_frame_kind frame_kind = EX(frame_kind);
if (frame_kind == VM_FRAME_NESTED_FUNCTION) {
zend_object *object;
i_free_compiled_variables(execute_data TSRMLS_CC);
if (UNEXPECTED(EX(symbol_table) != NULL)) {
zend_clean_and_cache_symbol_table(EX(symbol_table) TSRMLS_CC);
@ -1720,26 +1722,22 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_CLOSURE) != 0) && EX(func)->op_array.prototype) {
OBJ_RELEASE((zend_object*)EX(func)->op_array.prototype);
}
object = Z_OBJ(EX(This));
zend_vm_stack_free_call_frame(execute_data TSRMLS_CC);
execute_data = EG(current_execute_data);
if (Z_OBJ(EG(This))) {
if (object) {
if (UNEXPECTED(EG(exception) != NULL) && (EX(opline)->op1.num & ZEND_CALL_CTOR)) {
if (!(EX(opline)->op1.num & ZEND_CALL_CTOR_RESULT_UNUSED)) {
Z_DELREF(EG(This));
GC_REFCOUNT(object)--;
}
if (Z_REFCOUNT(EG(This)) == 1) {
zend_object_store_ctor_failed(Z_OBJ(EG(This)) TSRMLS_CC);
if (GC_REFCOUNT(object) == 1) {
zend_object_store_ctor_failed(object TSRMLS_CC);
}
}
if (!Z_DELREF(EG(This))) {
_zval_dtor_func_for_ptr(Z_COUNTED(EG(This)) ZEND_FILE_LINE_CC);
} else if (UNEXPECTED(!Z_GC_INFO(EG(This)))) {
gc_possible_root(Z_COUNTED(EG(This)) TSRMLS_CC);
}
OBJ_RELEASE(object);
}
Z_OBJ(EG(This)) = EX(object);
EG(scope) = EX(scope);
if (UNEXPECTED(EG(exception) != NULL)) {
@ -2252,7 +2250,7 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS
if (UNEXPECTED(ce->constructor == NULL)) {
zend_error_noreturn(E_ERROR, "Cannot call constructor");
}
if (EX(object) && zend_get_class_entry(EX(object) TSRMLS_CC) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) {
if (Z_OBJ(EX(This)) && zend_get_class_entry(Z_OBJ(EX(This)) TSRMLS_CC) != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) {
zend_error_noreturn(E_ERROR, "Cannot call private %s::__construct()", ce->name->val);
}
fbc = ce->constructor;
@ -2260,8 +2258,8 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS
object = NULL;
if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
if (EX(object)) {
object = EX(object);
if (Z_OBJ(EX(This))) {
object = Z_OBJ(EX(This));
GC_REFCOUNT(object)++;
if (object->handlers->get_class_entry &&
!instanceof_function(zend_get_class_entry(object TSRMLS_CC), ce TSRMLS_CC)) {
@ -2532,6 +2530,7 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
USE_OPLINE
zend_execute_data *call = EX(call);
zend_function *fbc = call->func;
zend_object *object = Z_OBJ(call->This);
SAVE_OPLINE();
EX(call) = call->prev_execute_data;
@ -2551,7 +2550,7 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
}
if (fbc->common.scope &&
!(fbc->common.fn_flags & ZEND_ACC_STATIC) &&
!call->object) {
!object) {
if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
/* FIXME: output identifiers properly */
@ -2574,16 +2573,16 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
if (fbc->common.scope) {
should_change_scope = 1;
Z_OBJ(EG(This)) = call->object;
/* TODO: we don't set scope if we call an object method ??? */
/* See: ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt */
#if 1
EG(scope) = (call->object) ? NULL : fbc->common.scope;
EG(scope) = object ? NULL : fbc->common.scope;
#else
EG(scope) = fbc->common.scope;
#endif
} else {
call->called_scope = EX(called_scope);
Z_OBJ(call->This) = Z_OBJ(EX(This));
}
call->prev_execute_data = execute_data;
@ -2618,7 +2617,7 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
if (!zend_execute_internal) {
/* saves one function call if zend_execute_internal is not used */
fbc->internal_function.handler(call->num_args, ret TSRMLS_CC);
fbc->internal_function.handler(call, ret TSRMLS_CC);
} else {
zend_execute_internal(call, ret TSRMLS_CC);
}
@ -2638,7 +2637,6 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
} else if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
zval *return_value = NULL;
Z_OBJ(EG(This)) = call->object;
EG(scope) = fbc->common.scope;
call->symbol_table = NULL;
if (RETURN_VALUE_USED(opline)) {
@ -2658,25 +2656,25 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
zend_vm_stack_free_call_frame(call TSRMLS_CC);
} else {
call->prev_execute_data = execute_data;
i_init_func_execute_data(call, &fbc->op_array, return_value, EXPECTED(zend_execute_ex == execute_ex) ? VM_FRAME_NESTED_FUNCTION : VM_FRAME_TOP_FUNCTION TSRMLS_CC);
i_init_func_execute_data(call, &fbc->op_array, return_value, VM_FRAME_NESTED_FUNCTION TSRMLS_CC);
if (EXPECTED(zend_execute_ex == execute_ex)) {
ZEND_VM_ENTER();
} else {
call->frame_kind = VM_FRAME_TOP_FUNCTION;
zend_execute_ex(call TSRMLS_CC);
}
}
} else { /* ZEND_OVERLOADED_FUNCTION */
Z_OBJ(EG(This)) = call->object;
EG(scope) = fbc->common.scope;
ZVAL_NULL(EX_VAR(opline->result.var));
/* Not sure what should be done here if it's a static method */
if (EXPECTED(call->object != NULL)) {
if (EXPECTED(object != NULL)) {
call->prev_execute_data = execute_data;
EG(current_execute_data) = call;
call->object->handlers->call_method(fbc->common.function_name, call->object, call->num_args, EX_VAR(opline->result.var) TSRMLS_CC);
object->handlers->call_method(fbc->common.function_name, object, call, EX_VAR(opline->result.var) TSRMLS_CC);
EG(current_execute_data) = call->prev_execute_data;
} else {
zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object");
@ -2701,18 +2699,17 @@ ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY)
}
ZEND_VM_C_LABEL(fcall_end_change_scope):
if (Z_OBJ(EG(This))) {
if (object) {
if (UNEXPECTED(EG(exception) != NULL) && (opline->op1.num & ZEND_CALL_CTOR)) {
if (!(opline->op1.num & ZEND_CALL_CTOR_RESULT_UNUSED)) {
Z_DELREF(EG(This));
GC_REFCOUNT(object)--;
}
if (Z_REFCOUNT(EG(This)) == 1) {
zend_object_store_ctor_failed(Z_OBJ(EG(This)) TSRMLS_CC);
if (GC_REFCOUNT(object) == 1) {
zend_object_store_ctor_failed(object TSRMLS_CC);
}
}
OBJ_RELEASE(Z_OBJ(EG(This)));
OBJ_RELEASE(object);
}
Z_OBJ(EG(This)) = EX(object);
EG(scope) = EX(scope);
ZEND_VM_C_LABEL(fcall_end):
@ -3256,12 +3253,12 @@ ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY)
if (EX(call)->func->common.fn_flags & ZEND_ACC_CLOSURE) {
OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
}
if (EX(call)->object) {
OBJ_RELEASE(EX(call)->object);
if (Z_OBJ(EX(call)->This)) {
OBJ_RELEASE(Z_OBJ(EX(call)->This));
}
EX(call)->func = (zend_function*)&zend_pass_function;
EX(call)->called_scope = NULL;
EX(call)->object = NULL;
Z_OBJ(EX(call)->This) = NULL;
} else {
uint32_t arg_num = 1;
@ -3319,12 +3316,12 @@ ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY)
if (EX(call)->func->common.fn_flags & ZEND_ACC_CLOSURE) {
OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
}
if (EX(call)->object) {
OBJ_RELEASE(EX(call)->object);
if (Z_OBJ(EX(call)->This)) {
OBJ_RELEASE(Z_OBJ(EX(call)->This));
}
EX(call)->func = (zend_function*)&zend_pass_function;
EX(call)->called_scope = NULL;
EX(call)->object = NULL;
Z_OBJ(EX(call)->This) = NULL;
break;
}
@ -3398,12 +3395,12 @@ ZEND_VM_HANDLER(120, ZEND_SEND_USER, VAR|CV, ANY)
if (EX(call)->func->common.fn_flags & ZEND_ACC_CLOSURE) {
OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
}
if (EX(call)->object) {
OBJ_RELEASE(EX(call)->object);
if (Z_OBJ(EX(call)->This)) {
OBJ_RELEASE(Z_OBJ(EX(call)->This));
}
EX(call)->func = (zend_function*)&zend_pass_function;
EX(call)->called_scope = NULL;
EX(call)->object = NULL;
Z_OBJ(EX(call)->This) = NULL;
FREE_OP1();
CHECK_EXCEPTION();
@ -4121,7 +4118,7 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
}
call = zend_vm_stack_push_call_frame(
(zend_function*)new_op_array, 0, 0, EX(called_scope), EX(object), NULL TSRMLS_CC);
(zend_function*)new_op_array, 0, 0, EX(called_scope), Z_OBJ(EX(This)), NULL TSRMLS_CC);
if (EX(symbol_table)) {
call->symbol_table = EX(symbol_table);
@ -4130,10 +4127,11 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
}
call->prev_execute_data = execute_data;
i_init_code_execute_data(call, new_op_array, return_value, EXPECTED(zend_execute_ex == execute_ex) ? VM_FRAME_NESTED_CODE : VM_FRAME_TOP_CODE TSRMLS_CC);
i_init_code_execute_data(call, new_op_array, return_value, VM_FRAME_NESTED_CODE TSRMLS_CC);
if (EXPECTED(zend_execute_ex == execute_ex)) {
ZEND_VM_ENTER();
} else {
call->frame_kind = VM_FRAME_TOP_CODE;
zend_execute_ex(call TSRMLS_CC);
}
@ -5394,16 +5392,16 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
* arguments pushed to the stack that have to be dtor'ed. */
zend_vm_stack_free_args(EX(call) TSRMLS_CC);
if (call->object) {
if (Z_OBJ(call->This)) {
if (call->flags & ZEND_CALL_CTOR) {
if (!(call->flags & ZEND_CALL_CTOR_RESULT_UNUSED)) {
GC_REFCOUNT(call->object)--;
GC_REFCOUNT(Z_OBJ(call->This))--;
}
if (GC_REFCOUNT(call->object) == 1) {
zend_object_store_ctor_failed(call->object TSRMLS_CC);
if (GC_REFCOUNT(Z_OBJ(call->This)) == 1) {
zend_object_store_ctor_failed(Z_OBJ(call->This) TSRMLS_CC);
}
}
OBJ_RELEASE(call->object);
OBJ_RELEASE(Z_OBJ(call->This));
}
EX(call) = call->prev_execute_data;
zend_vm_stack_free_call_frame(call TSRMLS_CC);
@ -5560,7 +5558,7 @@ ZEND_VM_HANDLER(153, ZEND_DECLARE_LAMBDA_FUNCTION, CONST, UNUSED)
if (closure_is_static || closure_is_being_defined_inside_static_context) {
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EX(called_scope), NULL TSRMLS_CC);
} else {
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EX(scope), Z_OBJ(EG(This)) ? &EG(This) : NULL TSRMLS_CC);
zend_create_closure(EX_VAR(opline->result.var), Z_FUNC_P(zfunc), EX(scope), Z_OBJ(EX(This)) ? &EX(This) : NULL TSRMLS_CC);
}
CHECK_EXCEPTION();

File diff suppressed because it is too large Load diff

View file

@ -35,7 +35,7 @@ ZEND_API void zend_{%EXECUTOR_NAME%}(zend_op_array *op_array, zval *return_value
}
execute_data = zend_vm_stack_push_call_frame(
(zend_function*)op_array, 0, 0, EG(current_execute_data) ? EG(current_execute_data)->called_scope : NULL, Z_OBJ(EG(This)), NULL TSRMLS_CC);
(zend_function*)op_array, 0, 0, EG(current_execute_data) ? EG(current_execute_data)->called_scope : NULL, EG(current_execute_data) ? Z_OBJ(EG(current_execute_data)->This) : NULL, NULL TSRMLS_CC);
if (EG(current_execute_data)) {
execute_data->symbol_table = zend_rebuild_symbol_table(TSRMLS_C);
} else {

View file

@ -212,7 +212,7 @@ $op1_get_obj_zval_ptr_deref = array(
"TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_var_deref(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"CONST" => "opline->op1.zv",
"UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)",
"CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op1.var TSRMLS_CC)",
);
@ -221,7 +221,7 @@ $op2_get_obj_zval_ptr_deref = array(
"TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"VAR" => "_get_zval_ptr_var_deref(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"CONST" => "opline->op2.zv",
"UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)",
"CV" => "_get_zval_ptr_cv_deref_\\1(execute_data, opline->op2.var TSRMLS_CC)",
);
@ -230,7 +230,7 @@ $op1_get_obj_zval_ptr_ptr = array(
"TMP" => "NULL",
"VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
"CONST" => "NULL",
"UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)",
"CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op1.var TSRMLS_CC)",
);
@ -239,7 +239,7 @@ $op2_get_obj_zval_ptr_ptr = array(
"TMP" => "NULL",
"VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
"CONST" => "NULL",
"UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)",
"UNUSED" => "_get_obj_zval_ptr_unused(execute_data TSRMLS_CC)",
"CV" => "_get_zval_ptr_cv_\\1(execute_data, opline->op2.var TSRMLS_CC)",
);

View file

@ -464,7 +464,7 @@ HRESULT php_com_get_id_of_name(php_com_dotnet_object *obj, char *name,
}
/* the core of COM */
int php_com_do_invoke_byref(php_com_dotnet_object *obj, char *name, int namelen,
int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *f,
WORD flags, VARIANT *v, int nargs, zval *args TSRMLS_DC)
{
DISPID dispid, altdispid;
@ -472,20 +472,19 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, char *name, int namelen,
HRESULT hr;
VARIANT *vargs = NULL, *byref_vals = NULL;
int i, byref_count = 0, j;
zend_internal_function *f = (zend_internal_function*)EG(current_execute_data)->func;
/* assumption: that the active function (f) is the function we generated for the engine */
if (!f || f->arg_info == NULL) {
f = NULL;
}
hr = php_com_get_id_of_name(obj, name, namelen, &dispid TSRMLS_CC);
hr = php_com_get_id_of_name(obj, f->function_name->val, f->function_name->len, &dispid TSRMLS_CC);
if (FAILED(hr)) {
char *winerr = NULL;
char *msg = NULL;
winerr = php_win32_error_to_msg(hr);
spprintf(&msg, 0, "Unable to lookup `%s': %s", name, winerr);
spprintf(&msg, 0, "Unable to lookup `%s': %s", f->function_name->val, winerr);
LocalFree(winerr);
php_com_throw_exception(hr, msg TSRMLS_CC);
efree(msg);

View file

@ -250,7 +250,7 @@ static PHP_FUNCTION(com_method_handler)
zval *object = getThis();
Z_OBJ_HANDLER_P(object, call_method)(
((zend_internal_function*)EG(current_execute_data)->func)->function_name,
((zend_internal_function*)EX(func))->function_name,
Z_OBJ_P(object),
INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
@ -378,7 +378,7 @@ static int com_call_method(zend_string *method, zend_object *object, INTERNAL_FU
VariantInit(&v);
if (SUCCESS == php_com_do_invoke_byref(obj, method->val, method->len, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, nargs, args TSRMLS_CC)) {
if (SUCCESS == php_com_do_invoke_byref(obj, (zend_internal_function*)EX(func), DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, nargs, args TSRMLS_CC)) {
php_com_zval_from_variant(return_value, &v, obj->code_page TSRMLS_CC);
ret = SUCCESS;
VariantClear(&v);

View file

@ -109,7 +109,7 @@ int php_com_do_invoke_by_id(php_com_dotnet_object *obj, DISPID dispid,
WORD flags, VARIANT *v, int nargs, zval *args, int silent, int allow_noarg TSRMLS_DC);
int php_com_do_invoke(php_com_dotnet_object *obj, char *name, int namelen,
WORD flags, VARIANT *v, int nargs, zval *args, int allow_noarg TSRMLS_DC);
int php_com_do_invoke_byref(php_com_dotnet_object *obj, char *name, int namelen,
int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function *f,
WORD flags, VARIANT *v, int nargs, zval *args TSRMLS_DC);
/* com_wrapper.c */

View file

@ -35,20 +35,6 @@ foreach($argv as $arg) {
}
}
$fp = fopen("$skel/skeleton.dsp", "rb");
if ($fp) {
$dsp_file = fread($fp, filesize("$skel/skeleton.dsp"));
fclose($fp);
$dsp_file = str_replace("extname", $extname, $dsp_file);
$dsp_file = str_replace("EXTNAME", strtoupper($extname), $dsp_file);
$fp = fopen("$extname/$extname.dsp", "wb");
if ($fp) {
fwrite($fp, $dsp_file);
fclose($fp);
}
}
$fp = fopen("$extname/$extname.php", "rb");
if ($fp) {
$php_file = fread($fp, filesize("$extname/$extname.php"));
@ -63,3 +49,4 @@ if ($fp) {
}
?>

View file

@ -425,7 +425,7 @@ static zval *pdo_stmt_instantiate(pdo_dbh_t *dbh, zval *object, zend_class_entry
return object;
} /* }}} */
static void pdo_stmt_construct(pdo_stmt_t *stmt, zval *object, zend_class_entry *dbstmt_ce, zval *ctor_args TSRMLS_DC) /* {{{ */
static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt, zval *object, zend_class_entry *dbstmt_ce, zval *ctor_args TSRMLS_DC) /* {{{ */
{
zval query_string;
zval z_key;
@ -556,7 +556,7 @@ static PHP_METHOD(PDO, prepare)
ZVAL_UNDEF(&stmt->lazy_object_ref);
if (dbh->methods->preparer(dbh, statement, statement_len, stmt, options TSRMLS_CC)) {
pdo_stmt_construct(stmt, return_value, dbstmt_ce, &ctor_args TSRMLS_CC);
pdo_stmt_construct(execute_data, stmt, return_value, dbstmt_ce, &ctor_args TSRMLS_CC);
return;
}
@ -1109,7 +1109,7 @@ static PHP_METHOD(PDO, query)
stmt->executed = 1;
}
if (ret) {
pdo_stmt_construct(stmt, return_value, dbh->def_stmt_ce, &dbh->def_stmt_ctor_args TSRMLS_CC);
pdo_stmt_construct(execute_data, stmt, return_value, dbh->def_stmt_ce, &dbh->def_stmt_ctor_args TSRMLS_CC);
return;
}
}

View file

@ -83,7 +83,7 @@ ZEND_DECLARE_MODULE_GLOBALS(reflection)
/* Method macros */
#define METHOD_NOTSTATIC(ce) \
if (!Z_OBJ(EG(This)) || !instanceof_function(Z_OBJCE(EG(This)), ce TSRMLS_CC)) { \
if (!Z_OBJ(EX(This)) || !instanceof_function(Z_OBJCE(EX(This)), ce TSRMLS_CC)) { \
php_error_docref(NULL TSRMLS_CC, E_ERROR, "%s() cannot be called statically", get_active_function_name(TSRMLS_C)); \
return; \
} \

View file

@ -78,7 +78,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
int _old_soap_version = SOAP_GLOBAL(soap_version);\
SOAP_GLOBAL(use_soap_error_handler) = 1;\
SOAP_GLOBAL(error_code) = "Server";\
Z_OBJ(SOAP_GLOBAL(error_object)) = Z_OBJ(EG(This));
Z_OBJ(SOAP_GLOBAL(error_object)) = Z_OBJ(EX(This));
#define SOAP_SERVER_END_CODE() \
SOAP_GLOBAL(use_soap_error_handler) = _old_handler;\
@ -97,7 +97,7 @@ static void soap_error_handler(int error_num, const char *error_filename, const
int _bailout = 0;\
SOAP_GLOBAL(use_soap_error_handler) = 1;\
SOAP_GLOBAL(error_code) = "Client";\
Z_OBJ(SOAP_GLOBAL(error_object)) = Z_OBJ(EG(This));\
Z_OBJ(SOAP_GLOBAL(error_object)) = Z_OBJ(EX(This));\
zend_try {
#define SOAP_CLIENT_END_CODE() \
@ -946,7 +946,7 @@ PHP_METHOD(SoapFault, __toString)
fci.function_table = &Z_OBJCE_P(getThis())->function_table;
ZVAL_STRINGL(&fci.function_name, "gettraceasstring", sizeof("gettraceasstring")-1);
fci.symbol_table = NULL;
fci.object = Z_OBJ(EG(This));
fci.object = Z_OBJ(EX(This));
fci.retval = &trace;
fci.param_count = 0;
fci.params = NULL;
@ -2620,7 +2620,8 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act
return ret;
}
static void do_soap_call(zval* this_ptr,
static void do_soap_call(zend_execute_data *execute_data,
zval* this_ptr,
char* function,
size_t function_len,
int arg_count,
@ -2935,7 +2936,7 @@ PHP_METHOD(SoapClient, __call)
if (output_headers) {
array_init(output_headers);
}
do_soap_call(this_ptr, function, function_len, arg_count, real_args, return_value, location, soap_action, uri, soap_headers, output_headers TSRMLS_CC);
do_soap_call(execute_data, this_ptr, function, function_len, arg_count, real_args, return_value, location, soap_action, uri, soap_headers, output_headers TSRMLS_CC);
if (arg_count > 0) {
efree(real_args);
}

View file

@ -346,7 +346,7 @@ PHP_FUNCTION(spl_autoload)
* The "scope" is determined by an opcode, if it is ZEND_FETCH_CLASS we know function was called indirectly by
* the Zend engine.
*/
zend_execute_data *ex = EG(current_execute_data);
zend_execute_data *ex = EX(prev_execute_data);
while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
ex = ex->prev_execute_data;

View file

@ -821,12 +821,12 @@ SPL_METHOD(DirectoryIterator, seek)
if (intern->u.dir.index > pos) {
/* we first rewind */
zend_call_method_with_0_params(&EG(This), Z_OBJCE(EG(This)), &intern->u.dir.func_rewind, "rewind", NULL);
zend_call_method_with_0_params(&EX(This), Z_OBJCE(EX(This)), &intern->u.dir.func_rewind, "rewind", NULL);
}
while (intern->u.dir.index < pos) {
int valid = 0;
zend_call_method_with_0_params(&EG(This), Z_OBJCE(EG(This)), &intern->u.dir.func_valid, "valid", &retval);
zend_call_method_with_0_params(&EX(This), Z_OBJCE(EX(This)), &intern->u.dir.func_valid, "valid", &retval);
if (!Z_ISUNDEF(retval)) {
valid = zend_is_true(&retval TSRMLS_CC);
zval_ptr_dtor(&retval);
@ -834,7 +834,7 @@ SPL_METHOD(DirectoryIterator, seek)
if (!valid) {
break;
}
zend_call_method_with_0_params(&EG(This), Z_OBJCE(EG(This)), &intern->u.dir.func_next, "next", NULL);
zend_call_method_with_0_params(&EX(This), Z_OBJCE(EX(This)), &intern->u.dir.func_next, "next", NULL);
}
} /* }}} */
@ -2170,7 +2170,8 @@ static int spl_filesystem_file_read_line_ex(zval * this_ptr, spl_filesystem_obje
if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_CSV)) {
return spl_filesystem_file_read_csv(intern, intern->u.file.delimiter, intern->u.file.enclosure, intern->u.file.escape, NULL TSRMLS_CC);
} else {
zend_call_method_with_0_params(this_ptr, Z_OBJCE_P(getThis()), &intern->u.file.func_getCurr, "getCurrentLine", &retval);
zend_execute_data *execute_data = EG(current_execute_data);
zend_call_method_with_0_params(this_ptr, Z_OBJCE(EX(This)), &intern->u.file.func_getCurr, "getCurrentLine", &retval);
}
if (!Z_ISUNDEF(retval)) {
if (intern->u.file.current_line || !Z_ISUNDEF(intern->u.file.current_zval)) {

View file

@ -4786,15 +4786,15 @@ PHP_FUNCTION(forward_static_call)
return;
}
if (!EG(current_execute_data)->prev_execute_data->func->common.scope) {
if (!EX(prev_execute_data)->func->common.scope) {
zend_error(E_ERROR, "Cannot call forward_static_call() when no class scope is active");
}
fci.retval = &retval;
if (EG(current_execute_data)->called_scope &&
instanceof_function(EG(current_execute_data)->called_scope, fci_cache.calling_scope TSRMLS_CC)) {
fci_cache.called_scope = EG(current_execute_data)->called_scope;
if (EX(called_scope) &&
instanceof_function(EX(called_scope), fci_cache.calling_scope TSRMLS_CC)) {
fci_cache.called_scope = EX(called_scope);
}
if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
@ -4818,9 +4818,9 @@ PHP_FUNCTION(forward_static_call_array)
zend_fcall_info_args(&fci, params TSRMLS_CC);
fci.retval = &retval;
if (EG(current_execute_data)->called_scope &&
instanceof_function(EG(current_execute_data)->called_scope, fci_cache.calling_scope TSRMLS_CC)) {
fci_cache.called_scope = EG(current_execute_data)->called_scope;
if (EX(called_scope) &&
instanceof_function(EX(called_scope), fci_cache.calling_scope TSRMLS_CC)) {
fci_cache.called_scope = EX(called_scope);
}
if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {

View file

@ -378,7 +378,7 @@ php_formatted_print(int param_count, int use_array, int format_offset TSRMLS_DC)
int always_sign;
int format_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &argc) == FAILURE) {
if (zend_parse_parameters(param_count TSRMLS_CC, "+", &args, &argc) == FAILURE) {
return NULL;
}

View file

@ -39,29 +39,6 @@ struct listening_socket_s {
static struct fpm_array_s sockets_list;
static int fpm_sockets_resolve_af_inet(char *node, char *service, struct sockaddr_in *addr) /* {{{ */
{
struct addrinfo *res;
struct addrinfo hints;
int ret;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
ret = getaddrinfo(node, service, &hints, &res);
if (ret != 0) {
zlog(ZLOG_ERROR, "can't resolve hostname '%s%s%s': getaddrinfo said: %s%s%s\n",
node, service ? ":" : "", service ? service : "",
gai_strerror(ret), ret == EAI_SYSTEM ? ", system error: " : "", ret == EAI_SYSTEM ? strerror(errno) : "");
return -1;
}
*addr = *(struct sockaddr_in *) res->ai_addr;
freeaddrinfo(res);
return 0;
}
/* }}} */
enum { FPM_GET_USE_SOCKET = 1, FPM_STORE_SOCKET = 2, FPM_STORE_USE_SOCKET = 3 };
static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
@ -98,14 +75,23 @@ static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
}
/* }}} */
static void *fpm_get_in_addr(struct sockaddr *sa) /* {{{ */
{
if (sa->sa_family == AF_INET) {
return &(((struct sockaddr_in*)sa)->sin_addr);
}
return &(((struct sockaddr_in6*)sa)->sin6_addr);
}
/* }}} */
static int fpm_sockets_hash_op(int sock, struct sockaddr *sa, char *key, int type, int op) /* {{{ */
{
if (key == NULL) {
switch (type) {
case FPM_AF_INET : {
struct sockaddr_in *sa_in = (struct sockaddr_in *) sa;
key = alloca(sizeof("xxx.xxx.xxx.xxx:ppppp"));
sprintf(key, "%u.%u.%u.%u:%u", IPQUAD(&sa_in->sin_addr), (unsigned int) ntohs(sa_in->sin_port));
key = alloca(INET6_ADDRSTRLEN);
inet_ntop(sa->sa_family, fpm_get_in_addr(sa), key, sizeof key);
break;
}
@ -254,11 +240,14 @@ enum fpm_address_domain fpm_sockets_domain_from_address(char *address) /* {{{ */
static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /* {{{ */
{
struct sockaddr_in sa_in;
struct addrinfo hints, *servinfo, *p;
char *dup_address = strdup(wp->config->listen_address);
char *port_str = strchr(dup_address, ':');
char *port_str = strrchr(dup_address, ':');
char *addr = NULL;
int addr_len;
int port = 0;
int sock;
int status;
if (port_str) { /* this is host:port pair */
*port_str++ = '\0';
@ -274,23 +263,35 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /*
return -1;
}
memset(&sa_in, 0, sizeof(sa_in));
if (addr) {
sa_in.sin_addr.s_addr = inet_addr(addr);
if (sa_in.sin_addr.s_addr == INADDR_NONE) { /* do resolve */
if (0 > fpm_sockets_resolve_af_inet(addr, NULL, &sa_in)) {
return -1;
}
zlog(ZLOG_NOTICE, "address '%s' resolved as %u.%u.%u.%u", addr, IPQUAD(&sa_in.sin_addr));
// strip brackets from address for getaddrinfo
if (addr != NULL) {
addr_len = strlen(addr);
if (addr[0] == '[' && addr[addr_len - 1] == ']') {
addr[addr_len - 1] = '\0';
addr++;
}
} else {
sa_in.sin_addr.s_addr = htonl(INADDR_ANY);
}
sa_in.sin_family = AF_INET;
sa_in.sin_port = htons(port);
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if ((status = getaddrinfo(addr, port_str, &hints, &servinfo)) != 0) {
zlog(ZLOG_ERROR, "getaddrinfo: %s\n", gai_strerror(status));
return -1;
}
free(dup_address);
return fpm_sockets_get_listening_socket(wp, (struct sockaddr *) &sa_in, sizeof(struct sockaddr_in));
for (p = servinfo; p != NULL; p = p->ai_next) {
if ((sock = fpm_sockets_get_listening_socket(wp, p->ai_addr, p->ai_addrlen)) != -1) {
break;
}
}
freeaddrinfo(servinfo);
return sock;
}
/* }}} */

View file

@ -45,10 +45,4 @@ static inline int fd_set_blocked(int fd, int blocked) /* {{{ */
}
/* }}} */
#define IPQUAD(sin_addr) \
(unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[0], \
(unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[1], \
(unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[2], \
(unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[3]
#endif

View file

@ -152,6 +152,8 @@ group = @php_fpm_group@
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.

53
sapi/fpm/tests/003.phpt Normal file
View file

@ -0,0 +1,53 @@
--TEST--
FPM: Test IPv6 support
--SKIPIF--
<?php include "skipif.inc"; ?>
--FILE--
<?php
include "include.inc";
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
$cfg = <<<EOT
[global]
error_log = $logfile
[unconfined]
listen = [::1]:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
EOT;
$fpm = run_fpm($cfg, $tail);
if (is_resource($fpm)) {
var_dump(fgets($tail));
var_dump(fgets($tail));
$i = 0;
while (($i++ < 30) && !($fp = fsockopen('[::1]', 9000))) {
usleep(10000);
}
if ($fp) {
echo "Done\n";
fclose($fp);
}
proc_terminate($fpm);
stream_get_contents($tail);
fclose($tail);
proc_close($fpm);
}
?>
--EXPECTF--
string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d
"
string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections
"
Done
--CLEAN--
<?php
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
@unlink($logfile);
?>

View file

@ -1,37 +0,0 @@
MSVC++ project file generation
==============================
These files are only intended for use in debugging and profiling,
but can be used to create working binaries. However, they are very
unlikely to match the official PHP distributed binaries.
With this in mind, the script will only generate basic .dsp files
for the modules that are currently configured.
The switch for project file generation is a buildconf switch and
not a configure switch:
> buildconf --add-project-files
> configure ...
The resulting workspace files should appear at /win32/phpdll[ts].dsw
and (if any shared modules are configured) at /win32/php_modules.dsw,
after configure is run.
If the .dsw files haven't generated in a sane way, the most likely reason
will be that the template files have become corrupted. They need DOS
line endings (CR/LF) in order to function. The affected files are:
/win32/build/block.template.dsw
/win32/build/template.dsp
/win32/build/template.dsw
Simply save them with DOS line endings, and bug it to me if basic
project file generation still fails (as in, you ran the command and
configure again after saving, and you have a working copy of MSVS
installed, but clicking on the workspace(s) doesn't give you anything).
- Steph
sfox@php.net
July 2008

View file

@ -23,7 +23,6 @@ WScript.StdOut.WriteLine("Rebuilding configure.js");
var FSO = WScript.CreateObject("Scripting.FileSystemObject");
var C = FSO.CreateTextFile("configure.js", true);
var B = FSO.CreateTextFile("configure.bat", true);
var DSP = false;
var modules = "";
var MODULES = WScript.CreateObject("Scripting.Dictionary");
@ -197,11 +196,6 @@ function buildconf_process_args()
WScript.StdOut.WriteLine("Adding " + argval + " to the module search path");
module_dirs[module_dirs.length] = argval;
}
if (argname == '--add-project-files') {
WScript.StdOut.WriteLine("Adding dsp templates into the mix");
DSP = true;
}
}
}
@ -212,16 +206,6 @@ C.WriteLine("/* This file automatically generated from win32/build/confutils.js
C.WriteLine("MODE_PHPIZE=false;");
C.Write(file_get_contents("win32/build/confutils.js"));
// If project files were requested, pull in the code to generate them
if (DSP == true) {
C.WriteLine('PHP_DSP="yes"');
C.WriteBlankLines(1);
C.Write(file_get_contents("win32/build/projectgen.js"));
} else {
C.WriteLine('PHP_DSP="no"');
C.WriteBlankLines(1);
}
// Pull in code from sapi and extensions
modules = file_get_contents("win32/build/config.w32");

View file

@ -433,13 +433,6 @@ if (PHP_SNAPSHOT_TEMPLATE == "no") {
DEFINE('SNAPSHOT_TEMPLATE', PHP_SNAPSHOT_TEMPLATE);
if (PHP_DSP != "no") {
if (FSO.FolderExists("tmp")) {
FSO.DeleteFolder("tmp");
}
FSO.CreateFolder("tmp");
}
ARG_ENABLE("security-flags", "Disable the compiler security flags", "yes");
if (PHP_SECURITY_FLAGS == "yes") {
ADD_FLAG("LDFLAGS", "/NXCOMPAT /DYNAMICBASE ");

View file

@ -352,12 +352,5 @@ if (PHP_SNAPSHOT_TEMPLATE == "no") {
DEFINE('SNAPSHOT_TEMPLATE', PHP_SNAPSHOT_TEMPLATE);
if (PHP_DSP != "no") {
if (FSO.FolderExists("tmp")) {
FSO.DeleteFolder("tmp");
}
FSO.CreateFolder("tmp");
}
AC_DEFINE("PHP_DIR", PHP_DIR);
DEFINE("PHP_DIR", PHP_DIR);

View file

@ -28,7 +28,6 @@ var SYSTEM_DRIVE = WshShell.Environment("Process").Item("SystemDrive");
var PROGRAM_FILES = WshShell.Environment("Process").Item("ProgramFiles");
var PROGRAM_FILESx86 = WshShell.Environment("Process").Item("ProgramFiles(x86)");
var VCINSTALLDIR = WshShell.Environment("Process").Item("VCINSTALLDIR");
var DSP_FLAGS = new Array();
var PHP_SRC_DIR=FSO.GetParentFolderName(WScript.ScriptFullName);
/* Store the enabled extensions (summary + QA check) */
@ -1130,10 +1129,6 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir)
ADD_FLAG("SAPI_TARGETS", makefiletarget);
}
if (PHP_DSP != "no") {
generate_dsp_file(sapiname, configure_module_dirname, file_list, false);
}
MFO.WriteBlankLines(1);
sapi_enabled[sapi_enabled.length] = [sapiname];
}
@ -1366,10 +1361,6 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
}
ADD_FLAG("CFLAGS_" + EXT, cflags);
if (PHP_DSP != "no") {
generate_dsp_file(extname, configure_module_dirname, file_list, shared);
}
extensions_enabled[extensions_enabled.length] = [extname, shared ? 'shared' : 'static'];
}
@ -1665,15 +1656,6 @@ function generate_files()
}
}
if (PHP_DSP != "no") {
generate_dsp_file("TSRM", "TSRM", null, false);
generate_dsp_file("Zend", "Zend", null, false);
generate_dsp_file("win32", "win32", null, false);
generate_dsp_file("main", "main", null, false);
generate_dsp_file("streams", "main\\streams", null, false);
copy_dsp_files();
}
STDOUT.WriteLine("Generating files...");
generate_makefile();
if (!MODE_PHPIZE) {
@ -2043,12 +2025,6 @@ function ADD_FLAG(name, flags, target)
configure_subst.Remove(name);
}
configure_subst.Add(name, flags);
if (PHP_DSP != "no") {
if (flags && (name.substr(name.length-3) != "PHP") && (name.substr(0, 7) == "CFLAGS_")) {
DSP_FLAGS[DSP_FLAGS.length] = new Array(name, flags);
}
}
}
function get_define(name)

View file

@ -24,7 +24,6 @@ var STDOUT = WScript.StdOut;
var FSO = WScript.CreateObject("Scripting.FileSystemObject");
var C = FSO.CreateTextFile("configure.js", true);
var B = FSO.CreateTextFile("configure.bat", true);
var DSP = false;
re = /\\script/i;
var PHP_DIR=FSO.GetParentFolderName(WScript.ScriptFullName).replace(re,"");
@ -222,16 +221,6 @@ if (FSO.FileExists(PHP_DIR + "/script/ext_pickle.js")) {
C.Write(file_get_contents(PHP_DIR + "/script/confutils.js"));
C.Write(file_get_contents(PHP_DIR + "/script/config.phpize.js"));
// If project files were requested, pull in the code to generate them
if (DSP == true) {
C.WriteLine('PHP_DSP="yes"');
C.WriteBlankLines(1);
C.Write(file_get_contents(PHP_DIR + "win32/build/projectgen.js"));
} else {
C.WriteLine('PHP_DSP="no"');
C.WriteBlankLines(1);
}
// Pull in code for the base detection
modules = file_get_contents(PHP_DIR + "/script/config.w32.phpize.in");

View file

@ -1,624 +0,0 @@
/* check for duplicate entries */
function check_duplicates(local, core)
{
if (!local) {
return core;
}
arr = local.split(" ");
for(i = 0; i < arr.length; i++) {
if (core.match(arr[i])) {
continue;
}
core += " " + arr[i];
}
return core;
}
/* read .dsp source blocks */
function read_src_files(ext, tmpl, path)
{
sources = file_get_contents("tmp\\src\\" + ext + ".sources.tmp");
sources = (path ? sources.replace(/\.\//g, path) : sources);
tmpl = tmpl.replace("SOURCEFILES", sources);
FSO.DeleteFile("tmp\\src\\" + ext + ".sources.tmp");
headers = file_get_contents("tmp\\src\\" + ext + ".headers.tmp");
headers = (path ? headers.replace(/\.\//g, path) : headers);
tmpl = tmpl.replace("HEADERFILES", headers);
FSO.DeleteFile("tmp\\src\\" + ext + ".headers.tmp");
return tmpl;
}
/* write a .dsp source block */
function write_src_file(fname, path, intpath, arr)
{
FSO.FolderExists("tmp\\src") ? "" : FSO.CreateFolder("tmp\\src");
var src = FSO.CreateTextFile("tmp\\src\\" + fname, true);
var out = get_define("BUILD_DIR");
var libpath = "";
for (i = 0; i < arr.length; i++) {
if (arr[i].length > 1) {
if (arr[i].match('alloca.c') ||
arr[i].match(/internal_functions_(nw|win32)\.c/) ||
arr[i].match(/flock\.(c|h)/) ||
arr[i].match(/zend_(ini|language)_scanner_defs\.h/)) {
continue;
}
libpath = arr[i].substr(2, arr[i].lastIndexOf("\\") - 2);
if (libpath) {
libpath = "\\" + libpath;
}
src.WriteLine("# Begin Source File");
src.WriteLine("SOURCE=" + arr[i]);
src.WriteLine('# PROP Intermediate_Dir "' + intpath + out + '\\' + path + libpath + '"');
src.WriteLine("# End Source File");
src.WriteBlankLines(1);
}
}
src.Close();
return;
}
/* generate list of text files */
function generate_text_filelist(ext, ext_dir)
{
var txtdir = FSO.GetFolder(ext_dir);
block = '# Begin Group "Text Files"\r\n\# PROP Default_Filter ""\r\n\r\n';
txt = new Enumerator(txtdir.Files);
for (; !txt.atEnd(); txt.moveNext()) {
fname = FSO.GetFileName(txt.item());
munged = fname.replace(ext, ""); /* TSRM...! */
if (munged.match(/[A-Z]{4}/)){
block += "# Begin Source File\r\n";
block += "SOURCE=./" + fname + "\r\n";
block += "# End Source File\r\n\r\n";
}
}
block += "# End Group\r\n";
return block;
}
/* generate list of resource files */
function generate_resource_filelist(ext, ext_dir)
{
var resdir = FSO.GetFolder(ext_dir);
res = new Enumerator(resdir.Files);
block = "";
for (; !res.atEnd(); res.moveNext()) {
fname = FSO.GetFileName(res.item());
if (fname.match(/\.(ico|rc)/)) {
block += "# Begin Source File\r\n";
block += "SOURCE=./" + fname + "\r\n";
block += "# End Source File\r\n\r\n";
}
}
return block;
}
/* generate parser and scanner files for Zend */
function generate_parsers_or_scanners(arr, type)
{
var filter = (type.match("Parsers") ? "y" : "l");
ret = '# Begin Group "' + type + '"\r\n# PROP Default_Filter "' + filter + '"\r\n\r\n';
for (i = 0; i < arr.length; i++) {
fl = "zend_" + arr[i] + "_" + type.toLowerCase().substr(0, type.length - 1);
ret += "# Begin Source File\r\n";
ret += "SOURCE=.\\" + fl + "." + filter + "\r\n\r\n";
ret += '# Begin Custom Build\r\n\r\n';
if (type.match("Parsers")) {
pre = (arr[i].match(/ini/) ? "ini_ " : "zend ");
ret += fl + ".c " + fl + ".h: " + fl + ".y\r\n";
ret += "\tbison --output=" + fl + ".c -v -d -p " + pre + fl + ".y\r\n\r\n";
} else {
ret += fl + ".c: " + fl + ".l\r\n";
ret += "\tre2c --case-inverted -cbdFt " + fl + "_defs.h -o" + fl + ".c " + fl + ".l\r\n\r\n";
}
ret += "# End Custom Build\r\n";
ret += "# End Source File\r\n";
}
ret += "# End Group\r\n\r\n";
return ret;
}
/* generate .defs file for php7[ts].dll */
function generate_php_defs()
{
var defs = get_define("PHP_DLL_DEF_SOURCES").split(" ");
var bdir = get_define("BUILD_DIR") + "\\";
var file = get_define("PHPLIB").replace("lib", "def");
var path = "..\\" + bdir + file;
var deps = "USERDEP__PHP7TS=";
var cmds = "BuildCmds= \\\r\n";
var cmd = '$(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r\n\t$(BuildCmds)\r\n';
for (i = 0; i < defs.length; i++) {
deps += '"..\\' + defs[i] + '" ';
cmds += "\ttype ..\\" + defs[i] + (i == 0 ? " > " : " >> ") + path + " \\\r\n";
}
ret = '# Begin Group "Defs Files"\r\n\r\n';
ret += "# Begin Source File\r\nSOURCE=" + path + "\r\n\r\n";
ret += deps.substr(0, deps.length-1) + "\r\n# Begin Custom Build - ";
ret += "Generating $(InputPath)\r\nInputPath=" + path + "\r\n\r\n";
ret += cmds + '\r\n\"' + path + '" : ' + cmd + "\r\n";
ret += "# End Custom Build\r\n# End Source File\r\n\r\n";
ret += "# End Group\r\n";
return ret;
}
/* generate win32\wsyslog.h for php7[ts].dll */
function generate_wsyslog()
{
var path = ".\\build\\wsyslog.mc\r\n\r\n";
var intdir = "..\\" + get_define("BUILD_DIR");
ret = "# Begin Source File\r\nSOURCE=" + path;
ret += "# Begin Custom Build\r\nInputDir=.\\build\r\n";
ret += "IntDir=" + intdir + "\r\nInputPath=" + path;
ret += '"wsyslog.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r\n';
ret += "\tmc -h $(InputDir)/.. -r $(InputDir) -x $(IntDir) $(InputPath)\r\n\r\n";
ret += "# End Custom Build\r\n# End Source File\r\n";
return ret;
}
/* generate ext\date\lib\timelib_config.h for php7[ts].dll */
function generate_timelib_conf(headers)
{
var file = "timelib_config.h";
var path = "..\\ext\\date\\lib\\timelib_config.h";
var pos = headers.search(file);
var entry = headers.slice(pos, pos + 64);
replace = entry.replace(file, file + ".win32");
replace += "\r\n\r\n# Begin Custom Build\r\nInputDir=..\\ext\\date\\lib\r\n";
replace += "InputPath=" + path + ".win32\r\n\r\n";
replace += '"' + path + '" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r\n';
replace += "\tcopy $(InputPath) $(InputDir)\\" + file + "\r\n\r\n";
replace += "# End Custom Build";
headers = headers.replace(entry, replace);
return headers;
}
/* generate php7[ts].dsp */
function generate_core_dsp(core_headers, core_sources, headers, sources, cflags, ldflags, libs)
{
var ts = (PHP_ZTS != "no" ? "ts" : "");
var extname = "php7" + ts;
var tmpl = generate_dsp_file(extname, ".", false, false);
cflags += get_define("CFLAGS_PHP").replace("/D _USRDLL", "");
cflags = cflags.replace(/\/(I|D)(\S)/g, "/$1 $2");
ldflags += get_define("LDFLAGS_PHP");
libs += get_define("LIBS_PHP");
tmpl = tmpl.replace(/LOCALCPP/, cflags.replace(/\"ext/g, '"../ext') + " /c");
tmpl = tmpl.replace(/LOCALLIBS/, libs);
tmpl = tmpl.replace(/LOCALLDFLAGS/, ldflags);
tmpl = tmpl.replace(extname + ".dll", get_define("PHPDLL"));
wsyslog = (core_headers.match("wsyslog.h") ? "" : generate_wsyslog(core_headers));
core_sources = '# Begin Group "CORE"\r\n' + core_sources + "# End Group\r\n";
tmpl = tmpl.replace(/CORESOURCES/, core_sources);
core_headers = '# Begin Group "CORE "\r\n' + core_headers + "# End Group\r\n";
tmpl = tmpl.replace(/COREHEADERS/, core_headers + wsyslog);
headers = generate_timelib_conf(headers);
tmpl = tmpl.replace(/SOURCEFILES/, sources);
tmpl = tmpl.replace(/HEADERFILES/, headers);
defs = generate_php_defs();
tmpl = tmpl.replace(/DEFS/, defs);
dsp = FSO.CreateTextFile("win32\\php7" + ts + ".dsp", true);
STDOUT.WriteLine("\tGenerating win32\\php7" + ts + ".dsp");
dsp.Write(tmpl);
dsp.Close();
return;
}
/* generate .dsw files */
function generate_dsw_files(sblocks, mblocks)
{
var stmpl = file_get_contents("win32\\build\\template.dsw");
var mtmpl = file_get_contents("win32\\build\\template.dsw");
var ts = (PHP_ZTS != "no" ? "ts" : "");
/* push all the sapi blocks to the same tag */
stmpl = stmpl.replace("INSERT", sblocks);
stmpl = (PHP_ZTS != "no" ? stmpl : stmpl.replace(/dllts/g, "dll"));
sdsw = FSO.CreateTextFile("win32\\php7" + ts + ".dsw", true);
STDOUT.WriteLine("\tGenerating win32\\php7" + ts + ".dsw");
sdsw.Write(stmpl);
sdsw.Close();
/* same for shared modules - except that nothing else goes in here */
garbage = mtmpl.slice(200, mtmpl.search("INSERT"));
mtmpl = mtmpl.replace(garbage, "\r\n");
mtmpl = mtmpl.replace("INSERT", mblocks);
mtmpl = (PHP_ZTS != "no" ? mtmpl : mtmpl.replace(/dllts/g, "dll"));
mdsw = FSO.CreateTextFile("win32\\php_modules.dsw", true);
STDOUT.WriteLine("\tGenerating win32\\php_modules.dsw");
mdsw.Write(mtmpl);
mdsw.Close();
return;
}
/* finalize .dsp files and copy to final destination */
function copy_dsp_files()
{
var tmp = FSO.GetFolder("tmp");
var CORE_HEADERS = "";
var CORE_SOURCES = "";
var EXT_HEADERS = "";
var EXT_SOURCES = "";
var EXT_CFLAGS = "";
var EXT_LDFLAGS = "";
var EXT_LIBS = "";
var sblocks = ""; /* for sapis */
var mblocks = ""; /* for modules */
f = new Enumerator(tmp.Files);
for (; !f.atEnd(); f.moveNext()) {
/* retrieve the path */
contents = file_get_contents(f.item());
address = contents.slice(0, contents.indexOf("#"));
contents = contents.slice(contents.indexOf("#")+1);
shared = contents.slice(0, contents.indexOf("#"));
contents = contents.slice(contents.indexOf("#"));
/* pick up module name and path */
path = address.slice(0, address.lastIndexOf("\\")+1);
ext = address.slice(address.lastIndexOf("\\")+1, address.length-4);
EXT = ext.toUpperCase();
if (path.match(/(sapi|ext)/)) {
rel = "..\\..\\";
} else {
rel = "..\\";
}
/* pick up local flags and libs */
cflags = get_define("CFLAGS_" + EXT);
cflags += (ext.match(/(TSRM|Zend)/) ? "/D TSRM_EXPORTS " : "");
cflags += (ext.match(/Zend/) ? "/D LIBZEND_EXPORTS " : "");
libs = get_define("LIBS_" + EXT);
ldflags = get_define("LDFLAGS_" + EXT);
ldflags = ldflags.replace(/(\.\.\\)/g, rel + "$1");
contents = contents.replace(/LOCALCPP/, cflags + " /c");
contents = contents.replace(/LOCALLIBS/, libs);
contents = contents.replace(/LOCALLDFLAGS/, ldflags);
if (ext.match("Zend")) {
arr = new Array("ini", "language");
parsers = generate_parsers_or_scanners(arr, "Parsers");
scanners = generate_parsers_or_scanners(arr, "Scanners");
contents = contents.replace(/DEFS/, parsers + scanners);
}
/* none of these are core... */
contents = contents.replace(/\r\n(CORESOURCES|COREHEADERS|EXTSOURCES|EXTHEADERS|DEFS)\r\n/g, "");
if (address.match("sapi")) {
/* most sapis are .dlls, just not cgi, cli, embed */
if (ext == "cli") {
/* change of address: php.dsp */
newext = "cli";
address = "win32\\php.dsp";
srcpath = "..\\" + path;
contents = contents.replace(/cli\.exe/g, "php.exe");
} else if (ext == "cgi") {
/* change of address: php-cgi.dsp */
newext = "cgi";
address = "win32\\php-cgi.dsp";
srcpath = "..\\" + path;
contents = contents.replace(/cgi\.exe/g, "php-cgi.exe");
} else {
/* there's always one... most sapis just get a 'php7' prefix */
newext = (ext.match(/apache2handler/) ? "php7apache2" : "php7" + ext);
address = address.replace(ext + ".dsp", newext + ".dsp");
srcpath = ".\\";
oldext = new RegExp(('[^=\\\\]'+ext), "g");
contents = contents.replace(oldext, newext);
contents = contents.replace(ext + ".dll", newext + ".dll");
contents = contents.replace("CFG=" + ext, "CFG=" + newext);
}
contents = read_src_files(ext, contents, (srcpath ? srcpath : false));
dsp = FSO.CreateTextFile(address, true);
STDOUT.WriteLine("\tGenerating " + address);
dsp.Write(contents);
dsp.Close();
/* add all configured sapis to the list in php7ts.dsw */
sblocks += file_get_contents("win32\\build\\block.template.dsw");
sblocks = sblocks.replace("ADDRESS", address);
sblocks = sblocks.replace("EXTNAME", newext);
} else if (address.match("ext") && shared == "true") {
/* independent modules with their own .dsp */
contents = read_src_files(ext, contents, false);
dsp = FSO.CreateTextFile(address, true);
STDOUT.WriteLine("\tGenerating " + address);
dsp.Write(contents);
dsp.Close();
mblocks += file_get_contents("win32\\build\\block.template.dsw");
mblocks = mblocks.replace("ADDRESS", address);
mblocks = mblocks.replace("EXTNAME", ext);
} else if (ext.match(/(TSRM|Zend)/)) {
contents = read_src_files(ext, contents, false);
dsp = FSO.CreateTextFile(address, true);
STDOUT.WriteLine("\tGenerating " + address);
dsp.Write(contents);
dsp.Close();
} else {
/* bound for php7[ts].dsp */
cflags = get_define("CFLAGS_" + EXT);
cflags = cflags ? cflags.replace(/-(I|D)/g, " /$1") : "";
cflags = cflags? cflags.replace(/\/(I|D)\s+/g, "/$1") : "";
cflags = cflags ? cflags.replace(/\/I(?!\")(\S+)/g, '/I"$1"') : "";
EXT_CFLAGS = check_duplicates(cflags, EXT_CFLAGS);
EXT_LDFLAGS = check_duplicates(ldflags, EXT_LDFLAGS);
EXT_LIBS = check_duplicates(libs, EXT_LIBS);
beginh = '# Begin Group "' + ext + ' "\r\n';
begins = '# Begin Group "' + ext + '"\r\n';
hdr = file_get_contents("tmp\\src\\" + ext + ".headers.tmp");
hdr = hdr.replace(/\.\//g, "..\\" + path);
hdr = hdr.replace(/\.\.\\\.\.\\/g, "..\\");
src = file_get_contents("tmp\\src\\" + ext + ".sources.tmp");
src = src.replace(/\.\//g, "..\\" + path);
src = src.replace(/\.\.\\\.\.\\/g, "..\\");
if (ext.match(/(main|standard|streams|win32)/)) {
CORE_HEADERS += beginh + hdr + "# End Group\r\n";
CORE_SOURCES += begins + src + "# End Group\r\n";
} else {
EXT_HEADERS += beginh + hdr + "# End Group\r\n";
EXT_SOURCES += begins + src + "# End Group\r\n";
}
FSO.DeleteFile("tmp\\src\\" + ext + ".headers.tmp");
FSO.DeleteFile("tmp\\src\\" + ext + ".sources.tmp");
}
FSO.DeleteFile(f.item());
}
generate_core_dsp(CORE_HEADERS, CORE_SOURCES, EXT_HEADERS, EXT_SOURCES, EXT_CFLAGS, EXT_LDFLAGS, EXT_LIBS);
generate_dsw_files(sblocks, mblocks);
/* goodnight vienna */
FSO.DeleteFolder("tmp\\src");
FSO.DeleteFolder("tmp");
}
/* generate source and header entries for .dsp files */
function generate_dsp_filelist(ext, ext_dir, files, intpath)
{
var EXT = ext.toUpperCase();
var tabs = new RegExp("[\t\r\n\'\"]", "gm");
var ws = new RegExp("\\s+", "g");
var dir = FSO.GetFolder(ext_dir);
var configfile = FSO.BuildPath(ext_dir, "config.w32");
var headers = "";
var path = "";
if (!files) {
/* module either lacks a config.w32 or is core
* either way, we know nothing about its sources
*/
files = "";
f = new Enumerator(dir.Files);
for (; !f.atEnd(); f.moveNext()) {
name = FSO.GetFileName(f.item());
if (name.substr(name.length-2) == ".c") {
files += " ./" + name;
}
}
} else {
files = files.replace(tabs, "");
files = "./" + files.replace(/ /g, " ./");
}
DSP_SOURCES = files.split(" ");
/* pick up headers (all modules) */
f = new Enumerator(dir.Files);
for (; !f.atEnd(); f.moveNext()) {
name = FSO.GetFileName(f.item());
if (name.substr(name.length-2) == ".h") {
headers += " ./" + name;
}
}
DSP_HEADERS = headers.split(" ");
/* check for bundled library paths and sourcefiles */
if (FSO.FileExists(configfile)) {
config = file_get_contents(configfile);
if (config.match("ADD_SOURCES")) {
sources = new RegExp("ADD_SOURCES\\([^,]*\\s*,\\s*['\"]([^'\"]+)['\"].*\\)", "gm");
arr = config.match(sources);
line = arr[0].replace(tabs, "");
line = line.replace(/ADD_SOURCES\((.+)\)/, "$1");
newarr = line.split(',');
orig_path = newarr[0].replace(/\//g, "\\");
orig_path = orig_path.replace(/configure_module_dirname(\s?\+\s?)?/, ext_dir);
path = orig_path.replace(ext_dir + '\\', "");
if (path.length > 0 && path != ext_dir) {
subdir = FSO.GetFolder(orig_path);
lib = new Enumerator(subdir.Files);
libheaders = "";
for (; !lib.atEnd(); lib.moveNext()) {
name = FSO.GetFileName(lib.item());
if (name.substr(name.length-2) == ".h") {
libheaders += " ./" + path + "\\" + name;
}
}
DSP_HEADERS = DSP_HEADERS.concat(libheaders.split(" "));
} else {
path = "";
}
sources = newarr[1].replace(/\\/g, ""); /* continuation lines */
sources = sources.replace(ws, " ");
sources = sources.replace(/\s/g, (path ? " ./" + path + "\\" : " ./"));
sources = check_duplicates(DSP_SOURCES.join(" "), sources);
DSP_SOURCES = sources.split(" ");
}
}
/* store the array contents in temp files for now */
write_src_file(ext + ".headers.tmp", ext_dir, intpath, DSP_HEADERS);
write_src_file(ext + ".sources.tmp", ext_dir, intpath, DSP_SOURCES);
return;
}
/* entry point. Called from EXTENSION(), SAPI() and generate_files() (confutils.js) */
function generate_dsp_file(ext, ext_dir, files, shared)
{
var dsp = FSO.CreateTextFile("tmp\\" + ext + ".dsp", true);
var tmpl = file_get_contents("win32\\build\\template.dsp");
var ts = (PHP_ZTS != "no" ? "ts" : "");
var debug = (PHP_DEBUG != "no" ? " /debug" : "");
var ld = (debug ? "/LDd" : "/LD");
var status = (PHP_DEBUG == "no" ? 'Release' : 'Debug');
var statusts = status + (ts ? "_" + ts.toUpperCase() : "");
var baseflags = "";
/* store the final path and value of shared in the tmp file */
if (!ext.match("php7")) {
tmpl = ext_dir + "\\" + ext + ".dsp#" + shared + tmpl;
}
tmpl = tmpl.replace(/extname/g, ext);
tmpl = tmpl.replace(/Status_TS/g, statusts);
if (debug) {
tmpl = tmpl.replace(/Use_Debug_Libraries 0/g, "Use_Debug_Libraries 1");
tmpl = tmpl.replace(/NDEBUG/g, "_DEBUG");
}
if (ext == "cli" || ext == "cgi") {
tmpl = tmpl.replace(/Dynamic-Link Library/g, "Console Application");
tmpl = tmpl.replace(/0x0102/, "0x0103");
path = "..\\";
type = ".exe";
} else if (ext == "embed" || ext == "TSRM" || ext == "Zend") {
tmpl = tmpl.replace(/Dynamic-Link/g, "Static");
tmpl = tmpl.replace(/0x0102/, "0x0104");
tmpl = tmpl.replace(/LINK32/g, "LIB32");
tmpl = tmpl.replace("link.exe", "link.exe -lib");
tmpl = tmpl.replace(/BASELIBS/g, "/nologo");
tmpl = tmpl.replace(/\s(LOCALLIBS|BASELDFLAGS|LOCALLDFLAGS|OUTPATH)/g, "");
path = "..\\";
if (ext == "embed") {
path += "..\\";
}
type = ".lib";
} else if (ext.match("php7")) {
path = "..\\";
type = ".dll";
} else {
path = "..\\..\\";
type = ".dll";
}
outpath = path + get_define("BUILD_DIR");
tmpl = tmpl.replace(/OUTPUTDIR/g, outpath);
/* populate the baseline CFLAGS and libs */
cflags = get_define("CFLAGS").replace(/\s+/g, " ");
cflags = cflags.replace('/I "..\\bindlib_w32" ', "");
bcflags = (cflags.replace(/\/([A-Z])\s/g, "/$1")).split(" ");
for (i= 0; i < bcflags.length; i++) {
baseflags += (bcflags[i].match(/(PHP|ZEND|ZTS|BASE|FD|WINDOWS)/) ? "" : bcflags[i]);
}
baseflags = baseflags.replace(/\//g, " /");
baseflags = baseflags.substr(1).replace(/(\/D)/g, "$1 ") + " /c";
tmpl = tmpl.replace(/BASECPP/, (type == ".dll" ? baseflags : baseflags.replace(ld + " ", "")));
tmpl = tmpl.replace(/BASELIBS/, "/nologo " + get_define("LIBS").replace(/\sresolv.lib/, ""));
/* now populate the bases in the 'local' lines */
incs = get_define("BASE_INCLUDES").replace(/\/I (\S+)/g, '/I "' + path + '$1"');
incs = incs.replace('"' + path + '."', '".."');
lcflags = cflags.replace(/\$\(BASE_INCLUDES\)/, incs + (type == ".exe" ? '/I "..\\sapi" ' : "") + '/I "' + path + '..\\bindlib_w32"');
tmpl = tmpl.replace(/BASECPP/, (type == ".dll" ? lcflags : lcflags.replace(ld + " ", "")));
tmpl = tmpl.replace(/BASELIBS/, "/nologo " + get_define("LIBS") + " " + (ext.match("php7") ? "" : get_define("PHPLIB")));
ldflags = get_define("LDFLAGS").replace(/\s?(\/nologo|\/libpath:\S+)\s?/g, "");
tmpl = tmpl.replace(/BASELDFLAGS/, ldflags + (type == ".dll" ? " " + get_define("DLL_LDFLAGS") : "") + (debug ? ' /nodefaultlib:"msvcrt"' : ""));
out = '/out:"' + outpath + "\\" + ext + type + '"' + ' /libpath:"' + outpath + '"' + ' /libpath:"..\\' + path + 'bindlib_w32\\' + status + '"';
tmpl = tmpl.replace(/OUTPATH/, out);
txt = generate_text_filelist(ext, ext_dir);
res = generate_resource_filelist(ext, ext_dir);
tmpl = tmpl.replace(/TEXTFILES/, txt);
tmpl = tmpl.replace(/RESOURCEFILES/, res);
if (ext.match("php7")) {
return tmpl;
}
/* generate source and header blocks for .dsp */
generate_dsp_filelist(ext, ext_dir, files, path);
dsp.Write(tmpl);
dsp.Close();
return;
}