[PECL-DEV] What is "module_number"?

[email protected] (Nicholas Williams)
Newsgroups php.pecl.dev
Message-ID <[email protected]>
I got it working. Turns out "#if HAVE_RAWSOCKETS" will evaluate to true 
in php_rawsockets.h but to false in rawsockets.c. Not sure why this is, 
but when I took "#if HAVE_RAWSOCKETS" out of rawsockets.c (and left it 
in php_rawsockets.h), it started working. I get the right output from nm 
now, PHP loads the extension, it prints phpinfo() information as 
requested ... all in all, it works well.

Now, I have another question. There's a little-documented integer called 
module_number that is implicitly declared inside the PHP_MINIT_FUNCTION. 
However, module_number does not seem to be available inside a 
PHP_FUNCTION, and I need it to be. Does anyone know what exactly this 
variable is and does and how I can have it made available inside a 
PHP_FUNCTION?

Thanks,

Nick

Nicholas Williams wrote:
> You were right, my .so does not have get_module():
>
> $ nm -o rawsockets.so
> rawsockets.so: 00000000 s __mh_bundle_header
> rawsockets.so:          U dyld_stub_binder
>
> However, in my source file rawsockets.c, I have the following:
>
> #ifdef COMPILE_DL_RAWSOCKETS
> ZEND_GET_MODULE(rawsockets)
> #endif
>
> Which is nearly identical to that in the sockets extension, sockets.c:
>
> #ifdef COMPILE_DL_SOCKETS
> ZEND_GET_MODULE(sockets)
> # ifdef PHP_WIN32
> # include "zend_arg_defs.c"
> # endif
> #endif
>
> And after phpize and configure I can grep the directory and find 
> COMPILE_DL_RAWSOCKETS in about a dozen files. Just to be safe, 
> however, I commented out #ifdef COMPILE_DL_RAWSOCKETS and it nm -o 
> rawsockets.o still doesn't report a get_module() available. *scratches 
> head*
>
> N
>
> Rasmus Lerdorf wrote:
>> Nicholas Williams wrote:
>>   
>>> for Mac OS X Snow Leopard 10.6.2. It compiles without error and says
>>> that the extension has been copied to the proper directory. However, if
>>> I try to load the extension either with dl('rawsockets.so') or
>>> extension=rawsockets.so in the INI file, I get the error "PHP Warning: 
>>> PHP Startup: Invalid library (maybe not a PHP library) 'rawsockets.so' 
>>> in Unknown on line 0 phpinfo()". If, per some suggestions I found
>>> online, I try to load it with
>>> zend_extension=/usr/lib/php5/extensions/rawsockets.so, I get the error
>>> "/usr/lib/php5/extensions/rawsockets.so doesn't appear to be a valid
>>> Zend extension."
>>>     
>>
>> This happens when your .so does not have get_module().
>>
>> Check it with:
>>
>> nm -o rawsockets.so | grep get_module
>>
>> -Rasmus
>>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.