I am trying to call CG(function_table) from within my
PHP_RINIT_FUNCTION() and from what I have found I need to call
TSRMSLS_FETCH() first to populate the function table in a thread safe way.
When I run the extension I get:
dyld: lazy symbol binding failed: Symbol not found: _TSRMSLS_FETCH
Referenced from:
/Library/PHP5/lib/php/extensions/no-debug-zts-20060613/vardumpoverload.so
Expected in: flat namespace
dyld: Symbol not found: _TSRMSLS_FETCH
Referenced from:
/Library/PHP5/lib/php/extensions/no-debug-zts-20060613/vardumpoverload.so
Expected in: flat namespace
Any pointers?
Is there a more specific mailing list than php internals to get help
with writing extensions for PHP? I don't want to bother people here with
my newbie questions unless you don't mind.
Thanks
Christoph
Hi!
I am trying to call CG(function_table) from within my
PHP_RINIT_FUNCTION() and from what I have found I need to call
TSRMSLS_FETCH() first to populate the function table in a thread safe way.
That's TSRMLS_FETCH() (you have extra S).
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com
That's TSRMLS_FETCH() (you have extra S).
So now I have:
PHP_RINIT_FUNCTION(vardumpoverload)
{
zend_function *orig_1;
TSRMLS_FETCH();
/* Override require_once with our own function */
zend_hash_find(CG(function_table), "require_once", 13, (void
**)&orig_1);
VARDUMPOVERLOAD_G(orig_require_once_func) =
orig_1->internal_function.handler;
orig_1->internal_function.handler = zif_vardumpoverload_require_once;
return SUCCESS;
}
and when I compile it I get the following error:
VarDumpOverloadExtension/vardumpoverload.c:66: error: 'tsrm_ls'
redeclared as different kind of symbol
VarDumpOverloadExtension/vardumpoverload.c:62: error: previous
definition of 'tsrm_ls' was here
When I don't use TSRMLS_FETCH(); at all I get a "Bus error" when running
the extension and calling require_once().
Christoph
So now I have:
PHP_RINIT_FUNCTION(vardumpoverload)
{
zend_function *orig_1;TSRMLS_FETCH();
You don't need fetch here, RINIT already gets it as a parameter.
When I don't use TSRMLS_FETCH(); at all I get a "Bus error" when running
the extension and calling require_once().
You shouldn't look for require_once in function table, it's not a
function, it's syntax construct. If you do look stuff up, it is a good
idea to check the return value of the lookup function.
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com