On Thu, Jan 20, 2022 at 1:56 AM Su, Tao <tao...@intel.com> wrote:
>
> Hello internals,
>
> I am trying to read Zend header files to understand its functional interfaces,
> but have got confusion and anybody knows why zend_startup_system_id() and 
> zend_finalize_system_id()
> do not have to be protected by BEGIN_EXTERN_C()/END_EXTERN_C() enclosure,
> but zend_add_system_entropy() has to.
>
> Is the following code intentional for any reason?
> And also, these two functions do not have ZEND_API attribute. Thanks.
>
> Zend/zend_system_id.h
> BEGIN_EXTERN_C()
> /* True global; Write-only during MINIT/startup */
> extern ZEND_API char zend_system_id[32];
>
> ZEND_API ZEND_RESULT_CODE zend_add_system_entropy(const char *module_name, 
> const char *hook_name, const void *data, size_t size);
> END_EXTERN_C()
>
> void zend_startup_system_id(void);
> void zend_finalize_system_id(void);
>
>
> =======================================
> Tony Su (Su, Tao)
> make a 'lazy' programmer diligently with efficiency
>

I haven't looked at the details of these specific functions recently,
but in general functions which are marked ZEND_API are capable of
being called from extensions and modules. These same ZEND_API
functions need to be in `extern "C"` sections for that to happen if
the extension or module is using C++.

I would guess that `zend_startup_system_id` and
`zend_finalize_system_id` do not need to be used outside of the engine
but needed to have a forward declaration for code organization
reasons.

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

Reply via email to