Permalink
Browse files

Various thread safety fixes and DLL updates

  • Loading branch information...
1 parent 7942eaf commit 7c4a08381e458a7efe470185336c3f9c02276d45 @zsuraski zsuraski committed Apr 26, 1999
View
@@ -31,7 +31,7 @@ typedef unsigned int uint;
#define DL_HANDLE HMODULE
#define ZEND_EXTENSIONS_SUPPORT 1
-#ifdef COMPILE_LIBZEND
+#ifdef LIBZEND_EXPORTS
# define ZEND_API __declspec(dllexport)
#else
# define ZEND_API __declspec(dllimport)
View
@@ -31,17 +31,15 @@ RSC=rc.exe
!IF "$(CFG)" == "libzend - Win32 Release"
# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDebug" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDebug" /D "_MBCS" /D "_LIB" /D "COMPILE_LIBZEND" /FR /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDebug" /D "_LIB" /D "TSRM_EXPORTS" /D "LIBZEND_EXPORTS" /D "WIN32" /D "_MBCS" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40d /d "NDebug"
# ADD RSC /l 0x40d /d "NDebug"
@@ -55,17 +53,15 @@ LIB32=link.exe -lib
!ELSEIF "$(CFG)" == "libzend - Win32 Debug"
# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_Debug" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_Debug" /D "_MBCS" /D "_LIB" /D "COMPILE_LIBZEND" /FR /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "_Debug" /D "_LIB" /D "LIBZEND_EXPORTS" /D "TSRM_EXPORTS" /D "WIN32" /D "_MBCS" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x40d /d "_Debug"
# ADD RSC /l 0x40d /d "_Debug"
BSC32=bscmake.exe
@@ -178,6 +174,10 @@ SOURCE=.\config.w32.h
# End Source File
# Begin Source File
+SOURCE=.\FlexLexer.h
+# End Source File
+# Begin Source File
+
SOURCE=.\modules.h
# End Source File
# Begin Source File
@@ -313,6 +313,14 @@ SOURCE=".\zend-scanner.l"
!IF "$(CFG)" == "libzend - Win32 Release"
+# Begin Custom Build
+InputPath=".\zend-scanner.l"
+
+"zend-scanner.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ flex -i -Pzend -ozend-scanner.c zend-scanner.l
+
+# End Custom Build
+
!ELSEIF "$(CFG)" == "libzend - Win32 Debug"
# Begin Custom Build
View
@@ -39,7 +39,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release_TS"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDebug_TS" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /D "NDebug_TS" /D "WIN32" /D "_MBCS" /D "_LIB" /D "COMPILE_LIBZEND" /D "ZTS" /D "TSRM_EXPORTS" /FR /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDebug_TS" /D "_LIB" /D "TSRM_EXPORTS" /D "LIBZEND_EXPORTS" /D "ZTS" /D "WIN32" /D "_MBCS" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x40d /d "NDebug_TS"
# ADD RSC /l 0x40d /d "NDebug_TS"
@@ -61,7 +61,7 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Debug_TS"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_Debug_TS" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "." /D "_Debug_TS" /D "WIN32" /D "_MBCS" /D "_LIB" /D "COMPILE_LIBZEND" /D "ZTS" /D "TSRM_EXPORTS" /FR /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /D "_Debug_TS" /D "WIN32" /D "_MBCS" /D "_LIB" /D "LIBZEND_EXPORTS" /D "ZTS" /D "TSRM_EXPORTS" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x40d /d "_Debug_TS"
# ADD RSC /l 0x40d /d "_Debug_TS"
BSC32=bscmake.exe
@@ -82,10 +82,6 @@ LIB32=link.exe -lib
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
-SOURCE=".\zend-parser.c"
-# End Source File
-# Begin Source File
-
SOURCE=".\zend-scanner.cpp"
# End Source File
# Begin Source File
@@ -313,6 +309,14 @@ SOURCE=".\zend-scanner.l"
!IF "$(CFG)" == "libzendts - Win32 Release_TS"
+# Begin Custom Build
+InputPath=".\zend-scanner.l"
+
+"zend-scanner.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ flex -+ -i -Sflex.skl -Pzend -ozend-scanner.cpp zend-scanner.l
+
+# End Custom Build
+
!ELSEIF "$(CFG)" == "libzendts - Win32 Debug_TS"
# Begin Custom Build
View
@@ -145,7 +145,7 @@ inline void restore_lexical_state(zend_lex_state *lex_state CLS_DC)
BEGIN_EXTERN_C()
-inline int open_file_for_scanning(zend_file_handle *file_handle CLS_DC)
+ZEND_API inline int open_file_for_scanning(zend_file_handle *file_handle CLS_DC)
{
#ifndef ZTS
FILE *tmp;
@@ -170,8 +170,7 @@ inline int open_file_for_scanning(zend_file_handle *file_handle CLS_DC)
yyin = tmp;
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
BEGIN(INITIAL);
-
-#else
+ #else
ifstream *input_file = new ifstream(file_handle->filename);
CG(ZFL) = new ZendFlexLexer;
View
@@ -179,13 +179,16 @@ static void register_standard_class()
#ifdef ZTS
static void compiler_globals_ctor(zend_compiler_globals *compiler_globals)
{
+ zend_function tmp_func;
+ zend_class_entry tmp_class;
+
compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init(compiler_globals->function_table, 100, NULL, (void (*)(void *)) destroy_zend_function, 1);
- zend_hash_copy(compiler_globals->function_table, global_function_table, NULL, NULL, 0);
+ zend_hash_copy(compiler_globals->function_table, global_function_table, NULL, &tmp_func, sizeof(zend_function));
compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init(compiler_globals->class_table, 10, NULL, (void (*)(void *)) destroy_zend_class, 1);
- zend_hash_copy(compiler_globals->class_table, global_class_table, NULL, NULL, 0);
+ zend_hash_copy(compiler_globals->class_table, global_class_table, zend_class_add_ref, &tmp_class, sizeof(zend_class_entry));
}
@@ -210,12 +213,18 @@ static void executor_globals_dtor(zend_executor_globals *executor_globals)
}
+static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
+{
+ start_memory_manager();
+}
+
#endif
int zend_startup(zend_utility_functions *utility_functions, char **extensions)
{
#ifdef ZTS
+ zend_compiler_globals *compiler_globals;
zend_executor_globals *executor_globals;
tsrm_startup(1,1,0);
@@ -259,7 +268,12 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions)
#ifdef ZTS
compiler_globals_id = ts_allocate_id(sizeof(zend_compiler_globals), (void (*)(void *)) compiler_globals_ctor, (void (*)(void *)) compiler_globals_dtor);
executor_globals_id = ts_allocate_id(sizeof(zend_executor_globals), (void (*)(void *)) executor_globals_ctor, (void (*)(void *)) executor_globals_dtor);
+ compiler_globals = ts_resource(compiler_globals_id);
executor_globals = ts_resource(executor_globals_id);
+ zend_hash_destroy(compiler_globals->function_table);
+ zend_hash_destroy(compiler_globals->class_table);
+ compiler_globals->function_table = GLOBAL_FUNCTION_TABLE;
+ compiler_globals->class_table = GLOBAL_CLASS_TABLE;
#endif
init_resource_plist(ELS_C);
View
@@ -517,15 +517,6 @@ ZEND_API void _persist_alloc(void *ptr)
}
-#ifdef ZTS
-
-void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
-{
- start_memory_manager();
-}
-
-
-#endif
/*
* Local variables:
* tab-width: 4
View
@@ -321,6 +321,8 @@ void do_extended_info(CLS_D);
void do_extended_fcall_begin(CLS_D);
void do_extended_fcall_end(CLS_D);
+#define INITIAL_OP_ARRAY_SIZE 64
+
/* helper functions in zend-scanner.l */
BEGIN_EXTERN_C()
@@ -330,19 +332,15 @@ ZEND_API zend_op_array *compile_files(int mark_as_ref CLS_DC, int file_count, ..
ZEND_API zend_op_array *v_compile_files(int mark_as_ref CLS_DC, int file_count, va_list files);
ZEND_API zend_op_array *compile_string(zval *source_string CLS_DC);
ZEND_API zend_op_array *compile_filename(zval *filename CLS_DC);
-inline int open_file_for_scanning(zend_file_handle *file_handle CLS_DC);
-END_EXTERN_C()
-
-#define INITIAL_OP_ARRAY_SIZE 64
-
-
-BEGIN_EXTERN_C()
+ZEND_API inline int open_file_for_scanning(zend_file_handle *file_handle CLS_DC);
ZEND_API void init_op_array(zend_op_array *op_array, int initial_ops_size);
ZEND_API void destroy_op_array(zend_op_array *op_array);
END_EXTERN_C()
ZEND_API void destroy_zend_function(zend_function *function);
ZEND_API void destroy_zend_class(zend_class_entry *ce);
+void zend_class_add_ref(zend_class_entry *ce);
+
zend_op *get_next_op(zend_op_array *op_array CLS_DC);
int get_next_op_number(zend_op_array *op_array);
int print_class(zend_class_entry *class_entry);
View
@@ -101,7 +101,6 @@ extern ZEND_API zend_executor_globals executor_globals;
# define ALS_CC , ALS_C
# define AG(v) (((zend_alloc_globals *) alloc_globals)->v)
# define ALS_FETCH() zend_alloc_globals *alloc_globals = (zend_alloc_globals *) ts_resource(alloc_globals_id)
-void alloc_globals_ctor(zend_alloc_globals *alloc_globals);
#else
# define ALS_D
# define ALS_DC
View
@@ -67,7 +67,7 @@ static void html_puts(char *s, uint len)
-void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini)
+ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini)
{
zval token;
int token_type;
View
@@ -35,7 +35,7 @@ typedef struct {
BEGIN_EXTERN_C()
-void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini);
+ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini);
int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini);
int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini);
END_EXTERN_C()
View
@@ -46,7 +46,7 @@ static void handle_whitespace(int *emit_whitespace)
}
-void zend_indent()
+ZEND_API void zend_indent()
{
zval token;
int token_type;
View
@@ -17,6 +17,6 @@
#ifndef _ZEND_INDENT_H
#define _ZEND_INDENT_H
-void zend_indent();
+ZEND_API void zend_indent();
#endif /* _ZEND_INDENT_H */
View
@@ -24,6 +24,7 @@
#include "zend_extensions.h"
#include "zend_API.h"
+
static void zend_extension_op_array_ctor_handler(zend_extension *extension, zend_op_array *op_array)
{
if (extension->op_array_ctor) {
@@ -131,6 +132,12 @@ ZEND_API void destroy_zend_class(zend_class_entry *ce)
}
+void zend_class_add_ref(zend_class_entry *ce)
+{
+ (*ce->refcount)++;
+}
+
+
ZEND_API void destroy_op_array(zend_op_array *op_array)
{
zend_op *opline = op_array->opcodes;
View
@@ -22,6 +22,7 @@
#include <stdarg.h>
#endif
+#if BROKEN_SPRINTF
int zend_sprintf(char *buffer, const char *format, ...)
{
va_list args;
@@ -32,3 +33,4 @@ int zend_sprintf(char *buffer, const char *format, ...)
return strlen(buffer);
}
+#endif

0 comments on commit 7c4a083

Please sign in to comment.