On Thu, 20 Sep 2007, Stefan Esser wrote:

> Derick Rethans schrieb:
> > On Thu, 20 Sep 2007, Stefan Esser wrote:
> >
> >   
> >> One problem I and others have run into is that from time to time we need
> >> to store extra information for specific opcode arrays. For simple values
> >> it is possible to use one of the reserved slots in the op_array
> >> structure, but in the past that has been unrelieable because APC for
> >> example simply overwrote the first slots without asking the Zend Engine
> >> to reserve some space.
> >>     
> >
> > Have a pointer on how this is done? I sortof need/want to do this in 
> > Xdebug as well, however I don't want opcode caches to remember this 
> > value.
> >   
> Well the "official" way to use the reserved area of an opcode array is
> to get an handle from the zend engine for reserved space.
> This is done by
> ZEND_API int zend_get_resource_handle(zend_extension *extension)
> it returns an index you can simply use. (I think meanwhile APC will
> honor this and will not overwrite the first bytes).

Yes, it does:

void apc_zend_init(TSRMLS_D)
{
    zend_extension dummy_ext;
#ifdef ZEND_ENGINE_2
    APCG(reserved_offset) = zend_get_resource_handle(&dummy_ext);
    assert(APCG(reserved_offset) == dummy_ext.resource_number);
    assert(APCG(reserved_offset) != -1);
    assert(sizeof(apc_opflags_t) <= sizeof(void*));
#endif

For Xdebug I don't need to use the dummy ext though as it's a real zend 
extension.

regards,
Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to