Re: cvs: php-src /ext/spl config.m4 spl_observer.c
| From: | Andi Gutmans | Date: | Thu, 22 Dec 2005 19:07:26 +0000 |
| Subject: | Re: cvs: php-src /ext/spl config.m4 spl_observer.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-36151@lists.php.net to get a copy of this message | ||
Are you sure you want to fix it this way? It'll make things less maintainable. I'm sure there's a way to make it one implementation that works everywhere.
At 01:36 PM 12/20/2005, Marcus Boerger wrote:
helly Tue Dec 20 21:36:48 2005 EDTModified files:/php-src/ext/spl config.m4 spl_observer.cLog: - Only apply workaround solution for 64 bit machines when necessary # Actually this can already be necessary on 32 bit machine and also not be # necessary on 64 bit machines. It all depends on the compiler settings. http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/config.m4?r1=1.14&r2=1.15&diff_format=u Index: php-src/ext/spl/config.m4 diff -u php-src/ext/spl/config.m4:1.14 php-src/ext/spl/config.m4:1.15--- php-src/ext/spl/config.m4:1.14 Sat Oct 1 15:55:27 2005+++ php-src/ext/spl/config.m4 Tue Dec 20 21:36:47 2005 @@ -1,4 +1,4 @@ -dnl $Id: config.m4,v 1.14 2005/10/01 15:55:27 helly Exp $ +dnl $Id: config.m4,v 1.15 2005/12/20 21:36:47 helly Exp $ dnl config.m4 for extension SPL PHP_ARG_ENABLE(spl, enable SPL suppport, @@ -8,6 +8,23 @@ if test "$ext_shared" = "yes"; thenAC_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 http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_observer.c?r1=1.6&r2=1.7&diff_format=u Index: php-src/ext/spl/spl_observer.c diff -u php-src/ext/spl/spl_observer.c:1.6 php-src/ext/spl/spl_observer.c:1.7 --- php-src/ext/spl/spl_observer.c:1.6 Mon Dec 19 13:53:28 2005+++ php-src/ext/spl/spl_observer.c Tue Dec 20 21:36:47 2005@@ -16,7 +16,7 @@+----------------------------------------------------------------------+*/ -/* $Id: spl_observer.c,v 1.6 2005/12/19 13:53:28 tony2001 Exp $ */ +/* $Id: spl_observer.c,v 1.7 2005/12/20 21:36:47 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -129,17 +129,25 @@ 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, 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, 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() -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php