]> granicus.if.org Git - php/commitdiff
build IDs
authorStanislav Malyshev <stas@php.net>
Sat, 17 Jan 2009 02:07:46 +0000 (02:07 +0000)
committerStanislav Malyshev <stas@php.net>
Sat, 17 Jan 2009 02:07:46 +0000 (02:07 +0000)
Zend/zend_build.h [new file with mode: 0755]
Zend/zend_extensions.c
Zend/zend_modules.h
ext/standard/dl.c
ext/standard/info.c
win32/build/config.w32

diff --git a/Zend/zend_build.h b/Zend/zend_build.h
new file mode 100755 (executable)
index 0000000..d66a94e
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef ZEND_BUILD_H
+#define ZEND_BUILD_H
+
+#define ZEND_TOSTR_(x) #x
+#define ZEND_TOSTR(x) ZEND_TOSTR_(x)
+
+#ifdef ZTS
+#define ZEND_BUILD_TS ",TS"
+#else
+#define ZEND_BUILD_TS ",NTS"
+#endif
+
+#if ZEND_DEBUG
+#define ZEND_BUILD_DEBUG ",debug"
+#else
+#define ZEND_BUILD_DEBUG
+#endif
+
+#if defined(ZEND_WIN32) && defined(PHP_COMPILER_ID)
+#define ZEND_BUILD_SYSTEM "," PHP_COMPILER_ID
+#else
+#define ZEND_BUILD_SYSTEM
+#endif
+
+/* for private applications */
+#define ZEND_BUILD_EXTRA 
+
+#endif
\ No newline at end of file
index 68141f135d53c942d199b9f1eb12ad8ce3d90cb2..e20f1596fdd9b4d917634a13ecc7be30dda1054e 100644 (file)
@@ -79,18 +79,9 @@ int zend_load_extension(const char *path) /* {{{ */
                        DL_UNLOAD(handle);
                        return FAILURE;
                }
-       } else if (ZTS_V!=extension_version_info->thread_safe) {
-               fprintf(stderr, "Cannot load %s - it %s thread safe, whereas Zend %s\n",
-                                       new_extension->name,
-                                       (extension_version_info->thread_safe?"is":"isn't"),
-                                       (ZTS_V?"is":"isn't"));
-               DL_UNLOAD(handle);
-               return FAILURE;
-       } else if (ZEND_DEBUG!=extension_version_info->debug) {
-               fprintf(stderr, "Cannot load %s - it %s debug information, whereas Zend %s\n",
-                                       new_extension->name,
-                                       (extension_version_info->debug?"contains":"does not contain"),
-                                       (ZEND_DEBUG?"does":"does not"));
+       } else if (strcmp(ZEND_EXTENSION_BUILD_ID, extension_version_info->build_id)) {
+               fprintf(stderr, "Cannot load %s - it was build with configuration %s, whereas running engine is %s\n",
+                                       new_extension->name, extension_version_info->build_id, ZEND_EXTENSION_BUILD_ID);
                DL_UNLOAD(handle);
                return FAILURE;
        }
index a35e980ec35f7ef1071938a0b4f21fc2409ca9b1..3c0ed8813016d7028b3992058dcb50e56deefe55 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "zend.h"
 #include "zend_compile.h"
+#include "zend_build.h"
 
 #define INIT_FUNC_ARGS         int type, int module_number TSRMLS_DC
 #define INIT_FUNC_ARGS_PASSTHRU        type, module_number TSRMLS_CC
@@ -46,7 +47,9 @@
 #define ZE2_STANDARD_MODULE_HEADER \
        STANDARD_MODULE_HEADER_EX, ini_entries, NULL
 
-#define STANDARD_MODULE_PROPERTIES_EX 0, 0, NULL, 0
+#define ZEND_MODULE_BUILD_ID "API" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA
+
+#define STANDARD_MODULE_PROPERTIES_EX 0, 0, NULL, 0, ZEND_MODULE_BUILD_ID
 
 #define NO_MODULE_GLOBALS 0, NULL, NULL, NULL
 
@@ -96,6 +99,7 @@ struct _zend_module_entry {
        unsigned char type;
        void *handle;
        int module_number;
+       char *build_id;
 };
 
 #define MODULE_DEP_REQUIRED            1
index 1de8867a6e250284bde0422bcbf58d3ebbb5890a..82fb82e955ce975068ea196dcc2c2e697d5437e5 100644 (file)
@@ -162,10 +162,7 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now TSRMLS_DC)
                return FAILURE;
        }
        module_entry = get_module();
-       if ((module_entry->zend_debug != ZEND_DEBUG) ||
-               (module_entry->zts != USING_ZTS) ||
-               (module_entry->zend_api != ZEND_MODULE_API_NO)
-       ) {
+       if (module_entry->zend_api != ZEND_MODULE_API_NO) {
                /* Check for pre-4.1.0 module which has a slightly different module_entry structure :( */
                        struct pre_4_1_0_module_entry {
                                char *name;
@@ -189,32 +186,36 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now TSRMLS_DC)
 
                        const char *name;
                        int zend_api;
-                       unsigned char zend_debug, zts;
 
                        if ((((struct pre_4_1_0_module_entry *)module_entry)->zend_api > 20000000) &&
                                (((struct pre_4_1_0_module_entry *)module_entry)->zend_api < 20010901)
                        ) {
                                name            = ((struct pre_4_1_0_module_entry *)module_entry)->name;
                                zend_api        = ((struct pre_4_1_0_module_entry *)module_entry)->zend_api;
-                               zend_debug      = ((struct pre_4_1_0_module_entry *)module_entry)->zend_debug;
-                               zts                     = ((struct pre_4_1_0_module_entry *)module_entry)->zts;
                        } else {
                                name            = module_entry->name;
                                zend_api        = module_entry->zend_api;
-                               zend_debug      = module_entry->zend_debug;
-                               zts                     = module_entry->zts;
                        }
 
                        php_error_docref(NULL TSRMLS_CC, error_type,
                                        "%s: Unable to initialize module\n"
-                                       "Module compiled with module API=%d, debug=%d, thread-safety=%d\n"
-                                       "PHP    compiled with module API=%d, debug=%d, thread-safety=%d\n"
+                                       "Module compiled with module API=%d\n"
+                                       "PHP    compiled with module API=%d\n"
                                        "These options need to match\n",
-                                       name, zend_api, zend_debug, zts,
-                                       ZEND_MODULE_API_NO, ZEND_DEBUG, USING_ZTS);
+                                       name, zend_api, ZEND_MODULE_API_NO);
                        DL_UNLOAD(handle);
                        return FAILURE;
        }
+       if(strcmp(module_entry->build_id, ZEND_MODULE_BUILD_ID)) {
+               php_error_docref(NULL TSRMLS_CC, error_type,
+                               "%s: Unable to initialize module\n"
+                               "Module compiled with build ID=%s\n"
+                               "PHP    compiled with build ID=%s\n"
+                               "These options need to match\n",
+                               module_entry->name, module_entry->build_id, ZEND_MODULE_BUILD_ID);
+               DL_UNLOAD(handle);
+               return FAILURE;
+       }
        module_entry->type = type;
        module_entry->module_number = zend_next_free_module();
        module_entry->handle = handle;
index db69230e509c91db6ace2bd91668f618f477fe92..72e42ae979cd60ba05a71586082c383668068437 100644 (file)
@@ -782,6 +782,9 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
                snprintf(temp_api, sizeof(temp_api), "%d", ZEND_EXTENSION_API_NO);
                php_info_print_table_row(2, "Zend Extension", temp_api);
 
+               php_info_print_table_row(2, "Zend Extension Build", ZEND_EXTENSION_BUILD_ID);
+               php_info_print_table_row(2, "PHP Extension Build", ZEND_MODULE_BUILD_ID);
+
 #if ZEND_DEBUG
                php_info_print_table_row(2, "Debug Build", "yes" );
 #else
index 8d18aa58053d13e8d7918177e60d6ec5e917ea72..6365311ab34f57b0542ea2a98784b0b7b6418c95 100644 (file)
@@ -20,6 +20,7 @@ VCVERS = probe_binary(CL).substr(0, 5).replace('.', '');
 STDOUT.WriteLine("  Detected compiler " + VC_VERSIONS[VCVERS]);
 AC_DEFINE('COMPILER', VC_VERSIONS[VCVERS], "Detected compiler version");
 DEFINE("PHP_COMPILER_SHORT", VC_VERSIONS_SHORT[VCVERS]);
+AC_DEFINE('PHP_COMPILER_ID', VC_VERSIONS_SHORT[VCVERS], "Compiler compatibility ID");
 
 // do we use x64 or 80x86 version of compiler?
 X64 = probe_binary(CL, 64);