Skip to content

Commit

Permalink
Whatnot:
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
zsuraski committed Apr 18, 1999
1 parent 2e8fb4e commit 342c6e0
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 43 deletions.
27 changes: 0 additions & 27 deletions Zend/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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) ], [
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Zend/zend-scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();
}
Expand Down
3 changes: 2 additions & 1 deletion Zend/zend.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);

Expand Down
11 changes: 9 additions & 2 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
#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,...);
Expand All @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions Zend/zend_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,13 +494,16 @@ 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);

p->persistent = 1;

/* add the block to the persistent list */
ADD_POINTER_TO_LIST(p);
HANDLE_UNBLOCK_INTERRUPTIONS();
}


Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
17 changes: 15 additions & 2 deletions Zend/zend_extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
1 change: 1 addition & 0 deletions Zend/zend_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ struct _zend_executor_globals {

zend_ptr_stack argument_stack;

void *reserved[4];
#if SUPPORT_INTERACTIVE
int interactive;
#endif
Expand Down
16 changes: 12 additions & 4 deletions Zend/zend_llist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions Zend/zend_opcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 342c6e0

Please sign in to comment.