]> granicus.if.org Git - php/commitdiff
Whatnot:
authorZeev Suraski <zeev@php.net>
Sun, 18 Apr 1999 15:11:52 +0000 (15:11 +0000)
committerZeev Suraski <zeev@php.net>
Sun, 18 Apr 1999 15:11:52 +0000 (15:11 +0000)
* updated alloc_persist to use critical sections
* changed extension shutdown to two-phase
* updated dependencies
* PR support (don't remember if there was any really)

14 files changed:
Zend/configure.in
Zend/zend-scanner.l
Zend/zend.c
Zend/zend.h
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_alloc.c
Zend/zend_compile.c
Zend/zend_extensions.c
Zend/zend_extensions.h
Zend/zend_globals.h
Zend/zend_llist.c
Zend/zend_modules.h
Zend/zend_opcode.c

index 201755a27257aafc2b88fe270aba92f53a821296..7a126467a50eeeb5290e2b6a298b6bc18e9d8230 100644 (file)
@@ -70,20 +70,11 @@ if test -d /usr/pkg/include -a -d /usr/pkg/lib ; then
        LDFLAGS="$LDFLAGS -L/usr/pkg/lib"
 fi
 
-AC_CHECK_LIB(nsl, gethostname, [
-  LIBS="-lnsl $LIBS"
-  AC_DEFINE(HAVE_LIBNSL) ], [])
-
 AC_CHECK_LIB(c, socket, [:], [
  AC_CHECK_LIB(socket, socket, [
   LIBS="-lsocket $LIBS"
   AC_DEFINE(HAVE_LIBSOCKET) ], []) ])
 
-AC_CHECK_LIB(c, gethostbyaddr, [:], [
- AC_CHECK_LIB(nsl, gethostbyaddr, [
-  LIBS="-lnsl $LIBS"
-  AC_DEFINE(HAVE_LIBNSL) ], []) ])
-
 AC_CHECK_LIB(c, dlopen, [
  # fake it
  AC_DEFINE(HAVE_LIBDL) ], [
@@ -96,24 +87,6 @@ dnl as well as res_search resides in libsocket
 AC_CHECK_LIB(c, sin, [:], [
  AC_CHECK_LIB(m, sin) ])
 
-dnl The res_search may be in libsocket as well, and if it is
-dnl make sure to check for dn_skipname in libresolv, or if res_search
-dnl is in neither of these libs, still check for dn_skipname in libresolv
-AC_CHECK_LIB(socket, res_search, [
- AC_CHECK_LIB(resolv, dn_skipname)
- AC_CHECK_LIB(resolv, __dn_skipname)
- LIBS="$LIBS -lsocket"
- AC_DEFINE(HAVE_LIBSOCKET) 
-], [
- AC_CHECK_LIB(resolv, res_search, [
-  LIBS="$LIBS -lresolv"
-  AC_DEFINE(HAVE_LIBRESOLV) 
- ], [
-  AC_CHECK_LIB(resolv, dn_skipname)
-  AC_CHECK_LIB(resolv, __dn_skipname)
- ]) 
-])
-
 dnl Checks for header files.
 AC_HEADER_STDC
 
index f6132dee7628b56f1948348d0b8fbace2a235adc..279c94da42ce3ff42b271fe397f749f78479b400 100644 (file)
@@ -243,7 +243,7 @@ zend_op_array *compile_filename(zval *filename CLS_DC)
        }
        file_handle.filename = filename->value.str.val;
        file_handle.type = ZEND_HANDLE_FILENAME;
-       retval = compile_files(0 CLS_CC, 1, &file_handle);
+       retval = zend_compile_files(0 CLS_CC, 1, &file_handle);
        if (filename==&tmp) {
                zval_dtor(&tmp);
        }
index 485256beaef489269a02b173fdec31ea34692893..df5f38ce2c6a438ba376ce29ee17cd34f3ef4af1 100644 (file)
@@ -154,6 +154,8 @@ static void register_standard_class()
        standard_class.handle_function_call = NULL;
        standard_class.handle_property_get = NULL;
        standard_class.handle_property_set = NULL;
+       standard_class.refcount = (int *) malloc(sizeof(int));
+       *standard_class.refcount = 1;
        zend_hash_add(CG(class_table), "stdClass", sizeof("stdClass"), &standard_class, sizeof(zend_class_entry), NULL);
 }
 
@@ -206,7 +208,7 @@ void zend_shutdown()
        free(CG(function_table));
        zend_hash_destroy(CG(class_table));
        free(CG(class_table));
-       zend_llist_destroy(&zend_extensions);
+       zend_shutdown_extensions();
        free(zend_version_info);
        zend_shutdown_constants();
 }
index 716e8622995ccaee3f9fe2e82e0f5e2e862b7f56..250455af4b044d266e237fe5b636d9e98a8cd285 100644 (file)
@@ -85,7 +85,7 @@ typedef struct {
        char *fname;
        void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
        unsigned char *func_arg_types;
-} function_entry;
+} zend_function_entry;
 
 
 typedef struct {
@@ -107,6 +107,7 @@ struct _zend_class_entry {
        char *name;
        uint name_length;
        struct _zend_class_entry *parent; 
+       int *refcount;
 
        HashTable function_table;
        HashTable default_properties;
index 67cfd785465a91c35c3be08ab3abe28e39b33745..f456c8b04f69378242f26866dc81a2b370dd663f 100644 (file)
@@ -592,9 +592,9 @@ ZEND_API int _register_list_destructors(void (*list_destructor)(void *), void (*
 
 
 /* registers all functions in *library_functions in the function hash */
-int register_functions(function_entry *functions)
+int register_functions(zend_function_entry *functions)
 {
-       function_entry *ptr = functions;
+       zend_function_entry *ptr = functions;
        zend_internal_function internal_function;
        int count=0,unload=0;
        CLS_FETCH();
@@ -633,9 +633,9 @@ int register_functions(function_entry *functions)
 /* count=-1 means erase all functions, otherwise, 
  * erase the first count functions
  */
-void unregister_functions(function_entry *functions,int count)
+void unregister_functions(zend_function_entry *functions,int count)
 {
-       function_entry *ptr = functions;
+       zend_function_entry *ptr = functions;
        int i=0;
        CLS_FETCH();
 
@@ -753,6 +753,8 @@ zend_class_entry *register_internal_class(zend_class_entry *class_entry)
 
        class_entry->type = ZEND_INTERNAL_CLASS;
        class_entry->parent = NULL;
+       class_entry->refcount = (int *) malloc(sizeof(int));
+       *class_entry->refcount = 1;
        zend_hash_init(&class_entry->default_properties, 0, NULL, PVAL_PTR_DTOR, 1);
        zend_hash_init(&class_entry->function_table, 0, NULL, (void (*)(void *)) destroy_zend_function, 1);
 
index 0399748cb3b2813535a3fd74c4ad892faf5a3bac..100b5750bafd5eebcadcd216c273e64caf26cb13 100644 (file)
 #include "zend_list.h"
 
 
+#define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
+#define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(zend_if_##name)
+
+#define ZEND_NAMED_FE(runtime_name, name, arg_types) { #runtime_name, name, arg_types },
+#define ZEND_FE(name, arg_types) ZEND_NAMED_FE(name, zend_if_##name, arg_types)
+
+
 int zend_next_free_module(void);
 
 int getParameters(int ht, int param_count,...);
@@ -32,8 +39,8 @@ int getThis(zval **this);
 
 
 int ParameterPassedByReference(int ht, uint n);
-int register_functions(function_entry *functions);
-void unregister_functions(function_entry *functions, int count);
+int register_functions(zend_function_entry *functions);
+void unregister_functions(zend_function_entry *functions, int count);
 int register_module(zend_module_entry *module_entry);
 zend_class_entry *register_internal_class(zend_class_entry *class_entry);
 
index 6831ae31af1ef296e7609093635e3c896eb1aece..92c939cd3f1e9365a2de1af23cd5f6e9c18904d4 100644 (file)
@@ -494,6 +494,8 @@ ZEND_API void _persist_alloc(void *ptr)
        _mem_block_check(ptr, 1, filename, lineno);
 #endif
 
+       HANDLE_BLOCK_INTERRUPTIONS();
+
        /* remove the block from the non persistent list */
        REMOVE_POINTER_FROM_LIST(p);
 
@@ -501,6 +503,7 @@ ZEND_API void _persist_alloc(void *ptr)
 
        /* add the block to the persistent list */
        ADD_POINTER_TO_LIST(p);
+       HANDLE_UNBLOCK_INTERRUPTIONS();
 }
 
 
index 9ce269104f60f48688f930a2ac31c899d0b34f98..4db89e6a3ce7c733336a02c4e3b4c639036c95df 100644 (file)
@@ -1107,6 +1107,8 @@ void do_begin_class_declaration(znode *class_name, znode *parent_class_name CLS_
        CG(class_entry).type = ZEND_USER_CLASS;
        CG(class_entry).name = class_name->u.constant.value.str.val;
        CG(class_entry).name_length = class_name->u.constant.value.str.len;
+       CG(class_entry).refcount = (int *) emalloc(sizeof(int));
+       *CG(class_entry).refcount = 1;
        
        zend_str_tolower(CG(class_entry).name, CG(class_entry).name_length);
 
index fe63768dba9ecc05975e4bbbe158bb95ed8438d7..ce49505f12b09898537a6f8731e4874ccbce2181 100644 (file)
@@ -100,13 +100,26 @@ int zend_load_extension(char *path)
 #endif
 }
 
-
-void zend_extension_dtor(zend_extension *extension)
+static void zend_extension_shutdown(zend_extension *extension)
 {
 #if ZEND_EXTENSIONS_SUPPORT
        if (extension->shutdown) {
                extension->shutdown(extension);
        }
+#endif
+}
+
+
+void zend_shutdown_extensions()
+{
+       zend_llist_apply(&zend_extensions, (void (*)(void *)) zend_extension_shutdown);
+       zend_llist_destroy(&zend_extensions);
+}
+
+
+void zend_extension_dtor(zend_extension *extension)
+{
+#if ZEND_EXTENSIONS_SUPPORT
        DL_UNLOAD(extension->handle);
 #endif
 }
index 97c2243e1a0f1a4dad7bd5b5aefb185c26f01512..502f807600c425d2e334eeb2fca6de47a446110c 100644 (file)
@@ -86,5 +86,6 @@ void zend_extension_dtor(zend_extension *extension);
 int zend_load_extension(char *path);
 int zend_load_extensions(char **extension_paths);
 void zend_append_version_info(zend_extension *extension);
+void zend_shutdown_extensions();
 
 #endif /* _ZEND_EXTENSIONS_H */
index 9e447d7afe3f711258f9bf7be71ef753196c3a9c..727eb312a6b45e56ed5f0e1441165a36b2340cc9 100644 (file)
@@ -187,6 +187,7 @@ struct _zend_executor_globals {
 
        zend_ptr_stack argument_stack;
 
+       void *reserved[4];
 #if SUPPORT_INTERACTIVE
        int interactive;
 #endif
index ec19038dd0701bad6b8cab3de76c7a74bddc34c2..2a659cef88dfb9dfc14972aad8fe7b2b2a339edd 100644 (file)
@@ -72,18 +72,26 @@ ZEND_API void zend_llist_del_element(zend_llist *l, void *element)
 
 ZEND_API void zend_llist_destroy(zend_llist *l)
 {
-       zend_llist_element *current=l->head, *next;
+       zend_llist_element *current, *next;
 
-       while (current) {
-               next = current->next;
-               if (l->dtor) {
+       if (l->dtor) {
+               current = l->head;
+
+               while (current) {
                        l->dtor(current->data);
+                       current = current->next;
                }
+       }
+       
+       current = l->head;
+       while (current) {
+               next = current->next;
                pefree(current, l->persistent);
                current = next;
        }
 }
 
+
 ZEND_API void zend_llist_remove_tail(zend_llist *l)
 {
        zend_llist_element *old_tail;
index ee0b879c541750c6e95eb4afadcd1213a86e0695..f4805f0663002482f95a8c445864de22a124c7a7 100644 (file)
@@ -28,7 +28,7 @@
 
 typedef struct {
        char *name;
-       function_entry *functions;
+       zend_function_entry *functions;
        int (*module_startup_func)(INIT_FUNC_ARGS);
        int (*module_shutdown_func)(SHUTDOWN_FUNC_ARGS);
        int (*request_startup_func)(INIT_FUNC_ARGS);
index a6d9e8aca023187d45b4f9a559bd7ea72b097177..8c53e3e8077cb17bdf0583656eaf4a0d42b9a651 100644 (file)
@@ -111,6 +111,9 @@ ZEND_API void destroy_zend_function(zend_function *function)
 
 ZEND_API void destroy_zend_class(zend_class_entry *ce)
 {
+       if (--(*ce->refcount)>0) {
+               return;
+       }
        switch (ce->type) {
                case ZEND_USER_CLASS:
                        efree(ce->name);