]> granicus.if.org Git - php/commitdiff
Improved PHP extension loading mechanism with support for module dependencies and...
authorDmitry Stogov <dmitry@php.net>
Fri, 17 Jun 2005 09:39:23 +0000 (09:39 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 17 Jun 2005 09:39:23 +0000 (09:39 +0000)
16 files changed:
build/genif.sh
ext/dom/php_dom.c
ext/pdo/pdo.c
ext/pdo_mysql/pdo_mysql.c
ext/pdo_sqlite/pdo_sqlite.c
ext/sqlite/sqlite.c
ext/standard/dl.c
ext/standard/dl.h
main/internal_functions.c.in
main/internal_functions_nw.c
main/internal_functions_win32.c
main/main.c
main/php.h
main/php_ini.c
main/php_ini.h
main/php_main.h

index 6fb8fc391fbc08192f03f0370ed83b675d9372ad..f40ad57a83c7afea3122cb0d8cf073fc4c9536e2 100644 (file)
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $Id: genif.sh,v 1.4 2004-07-18 12:03:51 wez Exp $
+# $Id: genif.sh,v 1.5 2005-06-17 09:39:20 dmitry Exp $
 # replacement for genif.pl
 
 infile=$1
@@ -17,13 +17,13 @@ if test -z "$infile" || test -z "$srcdir"; then
        exit 1
 fi
 
+module_ptrs=$extra_module_ptrs
 header_list=
 olddir=`pwd`
 cd $srcdir
 
-module_ptrs="$extra_module_ptrs`echo $@ | $awk -f ./build/order_by_dep.awk`"
-
 for ext in ${1+"$@"} ; do
+       module_ptrs="   phpext_${ext}_ptr,@NEWLINE@$module_ptrs"
        header_list="$header_list ext/$ext/*.h"
 done
 
index 8253cab243da9b3d52d6cead0904714f0217b04f..de5179f052191a86ed7d6b3bf1035f128685e71b 100644 (file)
@@ -404,8 +404,18 @@ static zend_object_handlers* dom_get_obj_handlers(TSRMLS_D) {
        }
 }
 
+static zend_module_dep dom_deps[] = {
+       ZEND_MOD_REQUIRED("libxml")
+       ZEND_MOD_CONFLICTS("domxml")
+#ifdef HAVE_SIMPLEXML
+       ZEND_MOD_REQUIRED("simplexml")
+#endif
+       {NULL, NULL, NULL}
+};
+
 zend_module_entry dom_module_entry = {
-       STANDARD_MODULE_HEADER,
+       STANDARD_MODULE_HEADER_EX, NULL,
+       dom_deps,
        "dom",
        dom_functions,
        PHP_MINIT(dom),
index ddbc8478b7260875e3a7b99034d105b4c2623d3e..27b05f24e47b72cff31f28ec0b0094e5622cf331 100755 (executable)
@@ -86,9 +86,20 @@ function_entry pdo_functions[] = {
 };
 /* }}} */
 
+/* {{{ pdo_functions[] */
+static zend_module_dep pdo_deps[] = {
+#ifdef HAVE_SPL
+       ZEND_MOD_REQUIRED("spl")
+#endif
+       {NULL, NULL, NULL}
+};
+
+/* }}} */
+
 /* {{{ pdo_module_entry */
 zend_module_entry pdo_module_entry = {
-       STANDARD_MODULE_HEADER,
+       STANDARD_MODULE_HEADER_EX, NULL,
+       pdo_deps,
        "PDO",
        pdo_functions,
        PHP_MINIT(pdo),
index 819c44f0d7ca27d12c1f60bdca02e1459b2eddd3..ff3321376dfec5e19e2e0fe5585699bb61d678af 100755 (executable)
@@ -36,9 +36,17 @@ function_entry pdo_mysql_functions[] = {
 };
 /* }}} */
 
+/* {{{ pdo_mysql_functions[] */
+static zend_module_dep pdo_mysql_deps[] = {
+       ZEND_MOD_REQUIRED("pdo")
+       {NULL, NULL, NULL}
+};
+/* }}} */
+
 /* {{{ pdo_mysql_module_entry */
 zend_module_entry pdo_mysql_module_entry = {
-       STANDARD_MODULE_HEADER,
+       STANDARD_MODULE_HEADER_EX, NULL,
+       pdo_mysql_deps,
        "pdo_mysql",
        pdo_mysql_functions,
        PHP_MINIT(pdo_mysql),
index 10ac1acb6f43fa946e055a4b00996bb928dfb5ad..d641f2d2f6086420289626bf537313331cd2cdcd 100644 (file)
@@ -39,10 +39,19 @@ function_entry pdo_sqlite_functions[] = {
 };
 /* }}} */
 
+/* {{{ pdo_sqlite_deps
+ */
+static zend_module_dep pdo_sqlite_deps[] = {
+       ZEND_MOD_REQUIRED("pdo")
+       {NULL, NULL, NULL}
+};
+/* }}} */
+
 /* {{{ pdo_sqlite_module_entry
  */
 zend_module_entry pdo_sqlite_module_entry = {
-       STANDARD_MODULE_HEADER,
+       STANDARD_MODULE_HEADER_EX, NULL,
+       pdo_sqlite_deps,
        "pdo_sqlite",
        pdo_sqlite_functions,
        PHP_MINIT(pdo_sqlite),
index f0cf2480763d183a2f6f5787de1ee646f70f696b..7673b428fba1c160a95fe123625cefcb694e4f02 100644 (file)
@@ -267,8 +267,25 @@ function_entry sqlite_funcs_exception[] = {
        {NULL, NULL, NULL}
 };
 
+/* Dependancies */
+static zend_module_dep sqlite_deps[] = {
+#if defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
+       ZEND_MOD_REQUIRED("spl")
+#endif
+#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
+       ZEND_MOD_REQUIRED("session")
+#endif
+#if PHP_SQLITE2_HAVE_PDO
+       ZEND_MOD_REQUIRED("pdo")
+#endif
+       {NULL, NULL, NULL}
+};
+
 zend_module_entry sqlite_module_entry = {
-#if ZEND_MODULE_API_NO >= 20010901
+#if ZEND_MODULE_API_NO >= 20050608
+       STANDARD_MODULE_HEADER_EX, NULL,
+       sqlite_deps,
+#elif ZEND_MODULE_API_NO >= 20010901
        STANDARD_MODULE_HEADER,
 #endif
        "SQLite",
index 8d311aa2dfbaff2b3c42808ef406fc5384c8f6c4..5d83fc745190940d67913241e84a6f8fdc37ea42 100644 (file)
@@ -54,7 +54,7 @@
    Load a PHP extension at runtime */
 PHP_FUNCTION(dl)
 {
-       pval **file;
+       zval **file;
 
        /* obtain arguments */
        if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &file) == FAILURE) {
@@ -99,7 +99,7 @@ PHP_FUNCTION(dl)
 
 /* {{{ php_dl
  */
-void php_dl(pval *file, int type, pval *return_value TSRMLS_DC)
+void php_dl(zval *file, int type, zval *return_value TSRMLS_DC)
 {
        void *handle;
        char *libpath;
@@ -224,14 +224,18 @@ void php_dl(pval *file, int type, pval *return_value TSRMLS_DC)
                RETURN_FALSE;
        }
 
+       if (type == MODULE_TEMPORARY && zend_startup_module(module_entry TSRMLS_CC) == FAILURE) {
+               DL_UNLOAD(handle);
+               RETURN_FALSE;
+       }
+
        if ((type == MODULE_TEMPORARY) && module_entry->request_startup_func) {
-               if (module_entry->request_startup_func(type, module_entry->module_number TSRMLS_CC)) {
+               if (module_entry->request_startup_func(type, module_entry->module_number TSRMLS_CC) == FAILURE) {
                        php_error_docref(NULL TSRMLS_CC, error_type, "Unable to initialize module '%s'", module_entry->name);
                        DL_UNLOAD(handle);
                        RETURN_FALSE;
                }
        }
-       
        RETURN_TRUE;
 }
 /* }}} */
@@ -243,7 +247,7 @@ PHP_MINFO_FUNCTION(dl)
 
 #else
 
-void php_dl(pval *file, int type, pval *return_value TSRMLS_DC)
+void php_dl(zval *file, int type, zval *return_value TSRMLS_DC)
 {
        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot dynamically load %s - dynamic modules are not supported", Z_STRVAL_P(file));
        RETURN_FALSE;
index 1f5c9b5ecffbacf9d609b1f40609c3858e049f64..81bb8697dfce923f34af529071559741161b9524 100644 (file)
@@ -23,8 +23,7 @@
 #ifndef DL_H
 #define DL_H
 
-PHPAPI void php_dl(pval *file,int type,pval *return_value TSRMLS_DC);
-
+PHPAPI void php_dl(zval *file,int type, zval *return_value TSRMLS_DC);
 
 /* dynamic loading functions */
 PHP_FUNCTION(dl);
index 8e2b7b85189be8f7377e16f851711672d8da1477..065807162b42ac500b724b9e18eae411c2447180 100644 (file)
@@ -36,9 +36,9 @@ zend_module_entry *php_builtin_extensions[] = {
 #define EXTCOUNT (sizeof(php_builtin_extensions)/sizeof(zend_module_entry *))
        
 
-int php_startup_internal_extensions(void)
+int php_register_internal_extensions(TSRMLS_D)
 {
-       return php_startup_extensions(php_builtin_extensions, EXTCOUNT);
+       return php_register_extensions(php_builtin_extensions, EXTCOUNT TSRMLS_CC);
 }
 
 /*
index 9500a6d95ca52af79d1deb42f4756f624d392c11..b3baf2a62c0cee12af8c24ce2813d1561e9c72d1 100644 (file)
@@ -85,9 +85,9 @@ zend_module_entry *php_builtin_extensions[] = {
 #define EXTCOUNT (sizeof(php_builtin_extensions)/sizeof(zend_module_entry *))
 
        
-int php_startup_internal_extensions(void)
+int php_register_internal_extensions(TSRMLS_D)
 {
-       return php_startup_extensions(php_builtin_extensions, EXTCOUNT);
+       return php_register_extensions(php_builtin_extensions, EXTCOUNT TSRMLS_CC);
 }
 
 
index 75257a69fe990bf62ef00e7ed470f02e2db38959..5254be43939838a555bbfd1135abff953c1826af 100644 (file)
@@ -158,9 +158,9 @@ zend_module_entry *php_builtin_extensions[] = {
 
 #define EXTCOUNT (sizeof(php_builtin_extensions)/sizeof(zend_module_entry *))
        
-int php_startup_internal_extensions(void)
+int php_register_internal_extensions(TSRMLS_D)
 {
-       return php_startup_extensions(php_builtin_extensions, EXTCOUNT);
+       return php_register_extensions(php_builtin_extensions, EXTCOUNT TSRMLS_CC);
 }
 
 /*
index bffb89fb1cc7166c6b383d2ce97e8dc2a7624616..ff632841d7dca5d35305d59633cdee23d57b489f 100644 (file)
@@ -1287,15 +1287,15 @@ static void core_globals_ctor(php_core_globals *core_globals TSRMLS_DC)
 /* }}} */
 #endif
 
-/* {{{ php_startup_extensions
+/* {{{ php_register_extensions
  */
-int php_startup_extensions(zend_module_entry **ptr, int count)
+int php_register_extensions(zend_module_entry **ptr, int count TSRMLS_DC)
 {
-       zend_module_entry **end = ptr+count;
+       zend_module_entry **end = ptr + count;
 
        while (ptr < end) {
                if (*ptr) {
-                       if (zend_startup_module(*ptr)==FAILURE) {
+                       if (zend_register_internal_module(*ptr TSRMLS_CC)==FAILURE) {
                                return FAILURE;
                        }
                }
@@ -1480,13 +1480,13 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
        zend_register_default_classes(TSRMLS_C);
 
        /* startup extensions staticly compiled in */
-       if (php_startup_internal_extensions() == FAILURE) {
+       if (php_register_internal_extensions(TSRMLS_C) == FAILURE) {
                php_printf("Unable to start builtin modules\n");
                return FAILURE;
        }
 
        /* start additional PHP extensions */
-       php_startup_extensions(&additional_modules, num_additional_modules);
+       php_register_extensions(&additional_modules, num_additional_modules TSRMLS_CC);
 
 
        /* load and startup extensions compiled as shared objects (aka DLLs)
@@ -1496,7 +1496,8 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
           which is always an internal extension and to be initialized
           ahead of all other internals
         */
-       php_ini_delayed_modules_startup(TSRMLS_C);
+       php_ini_register_extensions(TSRMLS_C);
+       zend_startup_modules(TSRMLS_C);
 
        /* disable certain classes and functions as requested by php.ini */
        php_disable_functions(TSRMLS_C);
index 60977dc59c60308eb8c75ea57cc47e1bc8bf2400..25869aaa429b781456abc10c4a3729cabc7999a6 100644 (file)
@@ -319,7 +319,7 @@ END_EXTERN_C()
 
 /* functions */
 BEGIN_EXTERN_C()
-int php_startup_internal_extensions(void);
+int php_register_internal_extensions(TSRMLS_D);
 
 int php_mergesort(void *base, size_t nmemb, register size_t size, int (*cmp)(const void *, const void * TSRMLS_DC) TSRMLS_DC);
 
index a8c1129dbb550e66817602e451bc9e51d7f05afd..e6dd1b8a347c40f3014089ed62ef1d08bb621a5a 100644 (file)
@@ -544,9 +544,9 @@ int php_shutdown_config(void)
 }
 /* }}} */
 
-/* {{{ php_ini_delayed_modules_startup
+/* {{{ php_ini_register_extensions
  */
-void php_ini_delayed_modules_startup(TSRMLS_D)
+void php_ini_register_extensions(TSRMLS_D)
 {
        zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb TSRMLS_CC);
        zend_llist_apply(&extension_lists.functions, php_load_function_extension_cb TSRMLS_CC);
index 94b5d3271f6a514b48370053b4a5195caf20c984..4a733b522aedab6c0d6b39344f648dcc554ef704 100644 (file)
@@ -26,7 +26,7 @@
 BEGIN_EXTERN_C()
 int php_init_config();
 int php_shutdown_config(void);
-void php_ini_delayed_modules_startup(TSRMLS_D);
+void php_ini_register_extensions(TSRMLS_D);
 zval *cfg_get_entry(char *name, uint name_length);
 END_EXTERN_C()
 
index 883953643f584eb54c0f9b0d0dc5e5c9e659c80b..e22ffd6ef3428e3d3410d22b3daba2b8800cffb0 100644 (file)
@@ -36,7 +36,7 @@ PHPAPI void php_module_shutdown_for_exec(void);
 PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals);
 PHPAPI int php_request_startup_for_hook(TSRMLS_D);
 
-PHPAPI int php_startup_extensions(zend_module_entry **ptr, int count);
+PHPAPI int php_register_extensions(zend_module_entry **ptr, int count TSRMLS_DC);
 
 PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC);
 PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval **ret TSRMLS_DC);