mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
- Apply workaround only when neccessary
This commit is contained in:
parent
eb99c74567
commit
8e43f0085b
@ -8,6 +8,23 @@ if test "$PHP_SPL" != "no"; then
|
||||
if test "$ext_shared" = "yes"; then
|
||||
AC_MSG_ERROR(Cannot build SPL as a shared module)
|
||||
fi
|
||||
AC_MSG_CHECKING(whether zend_object_value is packed)
|
||||
AC_TRY_RUN([
|
||||
#include "Zend/zend_types.h"
|
||||
int main(int argc, char **argv) {
|
||||
return ((sizeof(zend_object_handle) + sizeof(zend_object_handlers*)) == sizeof(zend_object_value)) ? 0 : 1;
|
||||
}
|
||||
], [
|
||||
ac_result=1
|
||||
AC_MSG_RESULT(yes)
|
||||
],[
|
||||
ac_result=0
|
||||
AC_MSG_RESULT(no)
|
||||
], [
|
||||
ac_result=0
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
AC_DEFINE(HAVE_PACKED_OBJECT_VALUE, $ac_result, [Whether struct _zend_object_value is packed])
|
||||
AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support])
|
||||
PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_sxe.c spl_exceptions.c spl_observer.c, $ext_shared)
|
||||
fi
|
||||
|
@ -129,17 +129,25 @@ static zend_object_value spl_SplObjectStorage_new(zend_class_entry *class_type T
|
||||
SPL_METHOD(SplObjectStorage, attach)
|
||||
{
|
||||
zval *obj;
|
||||
zend_object_value zvalue;
|
||||
|
||||
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
memset(&zvalue, 0, sizeof(zend_object_value));
|
||||
zvalue.handle = obj->value.obj.handle;
|
||||
zvalue.handlers = obj->value.obj.handlers;
|
||||
|
||||
zend_hash_update(&intern->storage, (char*)&zvalue, sizeof(zend_object_value), &obj, sizeof(zval*), NULL);
|
||||
|
||||
#if HAVE_PACKED_OBJECT_VALUE
|
||||
zend_hash_update(&intern->storage, (char*)&Z_OBJVAL_P(obj), sizeof(zend_object_value), &obj, sizeof(zval*), NULL);
|
||||
#else
|
||||
{
|
||||
zend_object_value zvalue;
|
||||
memset(&zvalue, 0, sizeof(zend_object_value));
|
||||
zvalue.handle = Z_OBJ_HANDLE_P(obj);
|
||||
zvalue.handlers = Z_OBJ_HT_P(obj);
|
||||
zend_hash_update(&intern->storage, (char*)&zvalue, sizeof(zend_object_value), &obj, sizeof(zval*), NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
obj->refcount++;
|
||||
} /* }}} */
|
||||
|
||||
@ -148,17 +156,24 @@ SPL_METHOD(SplObjectStorage, attach)
|
||||
SPL_METHOD(SplObjectStorage, detach)
|
||||
{
|
||||
zval *obj;
|
||||
zend_object_value zvalue;
|
||||
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
memset(&zvalue, 0, sizeof(zend_object_value));
|
||||
zvalue.handle = obj->value.obj.handle;
|
||||
zvalue.handlers = obj->value.obj.handlers;
|
||||
|
||||
zend_hash_del(&intern->storage, (char*)&zvalue, sizeof(zend_object_value));
|
||||
|
||||
#if HAVE_PACKED_OBJECT_VALUE
|
||||
zend_hash_del(&intern->storage, (char*)&Z_OBJVAL_P(obj), sizeof(zend_object_value));
|
||||
#else
|
||||
{
|
||||
zend_object_value zvalue;
|
||||
memset(&zvalue, 0, sizeof(zend_object_value));
|
||||
zvalue.handle = Z_OBJ_HANDLE_P(obj);
|
||||
zvalue.handlers = Z_OBJ_HT_P(obj);
|
||||
zend_hash_del(&intern->storage, (char*)&zvalue, sizeof(zend_object_value));
|
||||
}
|
||||
#endif
|
||||
|
||||
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
|
||||
intern->index = 0;
|
||||
} /* }}} */
|
||||
@ -168,17 +183,23 @@ SPL_METHOD(SplObjectStorage, detach)
|
||||
SPL_METHOD(SplObjectStorage, contains)
|
||||
{
|
||||
zval *obj;
|
||||
zend_object_value zvalue;
|
||||
spl_SplObjectStorage *intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
memset(&zvalue, 0, sizeof(zend_object_value));
|
||||
zvalue.handle = obj->value.obj.handle;
|
||||
zvalue.handlers = obj->value.obj.handlers;
|
||||
|
||||
RETURN_BOOL(zend_hash_exists(&intern->storage, (char*)&zvalue, sizeof(zend_object_value)));
|
||||
|
||||
#if HAVE_PACKED_OBJECT_VALUE
|
||||
RETURN_BOOL(zend_hash_exists(&intern->storage, (char*)&Z_OBJVAL_P(obj), sizeof(zend_object_value)));
|
||||
#else
|
||||
{
|
||||
zend_object_value zvalue;
|
||||
memset(&zvalue, 0, sizeof(zend_object_value));
|
||||
zvalue.handle = Z_OBJ_HANDLE_P(obj);
|
||||
zvalue.handlers = Z_OBJ_HT_P(obj);
|
||||
RETURN_BOOL(zend_hash_exists(&intern->storage, (char*)&zvalue, sizeof(zend_object_value)));
|
||||
}
|
||||
#endif
|
||||
} /* }}} */
|
||||
|
||||
/* {{{ proto int SplObjectStorage::count()
|
||||
|
Loading…
Reference in New Issue
Block a user