mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Add php_build_provider()
(#18168)
* Add `ZEND_ATTRIBUTE_CONST` to php_version() and php_version_id() * Add `php_build_provider()` * Use `php_build_provider()` internally
This commit is contained in:
parent
314219387e
commit
5dd9b0dcef
4 changed files with 37 additions and 18 deletions
|
@ -23,6 +23,8 @@ PHP 8.5 INTERNALS UPGRADE NOTES
|
|||
for fake closures.
|
||||
. Added smart_string_append_printf() matching smart_str_append_printf() for
|
||||
char* instead of zend_string*-based smart strings.
|
||||
. Added php_build_provider() to retrieve the value of PHP_BUILD_PROVIDER at
|
||||
runtime.
|
||||
|
||||
========================
|
||||
2. Build system changes
|
||||
|
|
|
@ -805,9 +805,9 @@ PHPAPI ZEND_COLD void php_print_info(int flag)
|
|||
#ifdef PHP_BUILD_SYSTEM
|
||||
php_info_print_table_row(2, "Build System", PHP_BUILD_SYSTEM);
|
||||
#endif
|
||||
#ifdef PHP_BUILD_PROVIDER
|
||||
php_info_print_table_row(2, "Build Provider", PHP_BUILD_PROVIDER);
|
||||
#endif
|
||||
if (php_build_provider()) {
|
||||
php_info_print_table_row(2, "Build Provider", php_build_provider());
|
||||
}
|
||||
#ifdef PHP_BUILD_COMPILER
|
||||
php_info_print_table_row(2, "Compiler", PHP_BUILD_COMPILER);
|
||||
#endif
|
||||
|
|
36
main/main.c
36
main/main.c
|
@ -74,6 +74,7 @@
|
|||
#include "zend_dtrace.h"
|
||||
#include "zend_observer.h"
|
||||
#include "zend_system_id.h"
|
||||
#include "zend_smart_string.h"
|
||||
|
||||
#include "php_content_types.h"
|
||||
#include "php_ticks.h"
|
||||
|
@ -99,20 +100,30 @@ PHPAPI size_t core_globals_offset;
|
|||
|
||||
const char php_build_date[] = __DATE__ " " __TIME__;
|
||||
|
||||
PHPAPI const char *php_version(void)
|
||||
ZEND_ATTRIBUTE_CONST PHPAPI const char *php_version(void)
|
||||
{
|
||||
return PHP_VERSION;
|
||||
}
|
||||
|
||||
PHPAPI unsigned int php_version_id(void)
|
||||
ZEND_ATTRIBUTE_CONST PHPAPI unsigned int php_version_id(void)
|
||||
{
|
||||
return PHP_VERSION_ID;
|
||||
}
|
||||
|
||||
ZEND_ATTRIBUTE_CONST PHPAPI const char *php_build_provider(void)
|
||||
{
|
||||
#ifdef PHP_BUILD_PROVIDER
|
||||
return PHP_BUILD_PROVIDER;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
PHPAPI char *php_get_version(sapi_module_struct *sapi_module)
|
||||
{
|
||||
char *version_info;
|
||||
spprintf(&version_info, 0, "PHP %s (%s) (built: %s) (%s)\nCopyright (c) The PHP Group\n%s%s",
|
||||
smart_string version_info = {0};
|
||||
smart_string_append_printf(&version_info,
|
||||
"PHP %s (%s) (built: %s) (%s)\n",
|
||||
PHP_VERSION, sapi_module->name, php_build_date,
|
||||
#ifdef ZTS
|
||||
"ZTS"
|
||||
|
@ -131,16 +142,15 @@ PHPAPI char *php_get_version(sapi_module_struct *sapi_module)
|
|||
#ifdef HAVE_GCOV
|
||||
" GCOV"
|
||||
#endif
|
||||
,
|
||||
#ifdef PHP_BUILD_PROVIDER
|
||||
"Built by " PHP_BUILD_PROVIDER "\n"
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
,
|
||||
get_zend_version()
|
||||
);
|
||||
return version_info;
|
||||
smart_string_appends(&version_info, "Copyright (c) The PHP Group\n");
|
||||
if (php_build_provider()) {
|
||||
smart_string_append_printf(&version_info, "Built by %s\n", php_build_provider());
|
||||
}
|
||||
smart_string_appends(&version_info, get_zend_version());
|
||||
smart_string_0(&version_info);
|
||||
|
||||
return version_info.c;
|
||||
}
|
||||
|
||||
PHPAPI void php_print_version(sapi_module_struct *sapi_module)
|
||||
|
|
|
@ -28,13 +28,20 @@ BEGIN_EXTERN_C()
|
|||
* extensions which want to know the version of PHP at run-time, rather than
|
||||
* the version they were built with at compile-time.
|
||||
*/
|
||||
PHPAPI const char *php_version(void);
|
||||
ZEND_ATTRIBUTE_CONST PHPAPI const char *php_version(void);
|
||||
|
||||
/* Returns the PHP version id the engine was built with. This is useful for
|
||||
* extensions which want to know the version of PHP at run-time, rather than
|
||||
* the version they were built with at compile-time.
|
||||
*/
|
||||
PHPAPI unsigned int php_version_id(void);
|
||||
ZEND_ATTRIBUTE_CONST PHPAPI unsigned int php_version_id(void);
|
||||
|
||||
/* Returns the build provider specified at build time. NULL is returned if
|
||||
* no build provider was specified. This is useful for extensions which want
|
||||
* to know the origin of a PHP binary at run-time, for example to provide
|
||||
* statistics.
|
||||
*/
|
||||
ZEND_ATTRIBUTE_CONST PHPAPI const char *php_build_provider(void);
|
||||
|
||||
/* Prints the PHP version string for the -v option. It's in main/ so that
|
||||
* it can be shared between SAPIs.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue