From: Andi Gutmans Date: Wed, 14 Jul 1999 16:00:47 +0000 (+0000) Subject: - License update X-Git-Tag: php-4.0b1~139 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fec59d3b4da7fdc111dd0af19a4b0488dc817fc7;p=php - License update - Fix multithreaded constants startup --- diff --git a/Zend/LICENSE b/Zend/LICENSE index df4543ee10..8353c3db20 100644 --- a/Zend/LICENSE +++ b/Zend/LICENSE @@ -1,37 +1,46 @@ -Zend Temporary License -====================== - -This is a temporary license, that is in effect until the final Zend license -is available. - -* The final license will include the ability to distribute Zend freely, - as a part of PHP (in both compiled and source code formats). It may - (and probably will) allow to redistribute Zend under other circumstances - as well, but at the very least, it'll be freely distributed as a part - of PHP. - -* The source code in the Zend engine is the property of Andi Gutmans and - Zeev Suraski. Parts of this code are based on source code taken from - PHP 3.0, which may include several patches and enhancements that weren't - made by us (Andi&Zeev). If you're the author of such a patch and you're - not willing to give up ownership over your patch to us, please contact - us as soon as possible, so we can remove it. We're doing this so that - we'd be eligible to sell the Zend engine for uses other than PHP, most - notably - as an embedded part of possible commercial products that we'd - have. - -* Patches submitted to the Zend CVS automatically fall under this license, - and by submitting them you're implicitly giving up your ownership over - this patch to us. - -* Until further notice, Zend is in a status of a closed beta test. That means - that only people that were explicitly given the right to access the Zend - CVS repository are allowed to use it. If you're reading this file and you - weren't explicitly given the right to access the Zend CVS repository from - either Andi Gutmans or Zeev Suraski - you're not supposed to have it - please - erase the Zend files from your system. When the closed beta period finishes, - the Zend CVS tree will be open for the public (in read-only mode, of course). - - -Any questions regarding Zend or this license should be addressed via Email to -zend@zend.com. +------------------------------------------------------------------------ + The Zend License, version 0.90 +Copyright (c) 1999 Andi Gutmans, Zeev Suraski. All Rights Reserved. +------------------------------------------------------------------------ + +1. The Zend engine (``SOFTWARE'') can be distributed or redistributed + free of charge as an integral part of PHP; It may not be embedded in + other products nor reused separately from PHP, without prior written + permission from both Andi Gutmans and Zeev Suraski (``AUTHORS''). + +2. Distribution or redistribution of larger works derived from or works + which bundle the SOFTWARE require prior written permission from the + AUTHORS. + +3. Any modifications made to the SOFTWARE will not grant the modifier + any rights whatsoever to the SOFTWARE. Moreover, by publishing any + modifications made to the SOFTWARE, the publisher explicitly signs + over to the AUTHORS all and any rights to the published modified + code. + +4. Redistribution of the SOFTWARE in both source and binary forms must + retain the above copyright notice, a copy of these license terms and + the following disclaimer. + +5. The name Zend must not be used to endorse or promote products + derived from this software without prior written permission from + the AUTHORS. + + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESSED +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +----------------------------------------------------------------------- + +- For more information about Zend, please visit http://www.zend.com/ +- For more information about PHP, please visit http://www.php.net/ diff --git a/Zend/zend.c b/Zend/zend.c index 737f288508..1f948c92f4 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -27,9 +27,11 @@ #ifdef ZTS # define GLOBAL_FUNCTION_TABLE global_function_table # define GLOBAL_CLASS_TABLE global_class_table +# define GLOBAL_CONSTANTS_TABLE global_constants_table #else # define GLOBAL_FUNCTION_TABLE CG(function_table) # define GLOBAL_CLASS_TABLE CG(class_table) +# define GLOBAL_CONSTANTS_TABLE CG(zend_constants) #endif /* true multithread-shared globals */ @@ -49,6 +51,7 @@ ZEND_API int executor_globals_id; int alloc_globals_id; HashTable *global_function_table; HashTable *global_class_table; +HashTable *global_constants_table; #endif zend_utility_values zend_uv; @@ -245,7 +248,10 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) static void executor_globals_ctor(zend_executor_globals *executor_globals) { - zend_startup_constants(ELS_C); + if (global_constants_table) { + zend_startup_constants(executor_globals->zend_constants ELS_CC); + zend_copy_constants(executor_globals->zend_constants, global_constants_table); + } init_resource_plist(ELS_C); } @@ -298,10 +304,6 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions) zend_version_info = strdup(ZEND_CORE_VERSION_INFO); zend_version_info_length = sizeof(ZEND_CORE_VERSION_INFO)-1; - /* Prepare data structures */ -#ifndef ZTS - zend_startup_constants(ELS_C); -#endif GLOBAL_FUNCTION_TABLE = (HashTable *) malloc(sizeof(HashTable)); GLOBAL_CLASS_TABLE = (HashTable *) malloc(sizeof(HashTable)); zend_hash_init(GLOBAL_FUNCTION_TABLE, 100, NULL, ZEND_FUNCTION_DTOR, 1); @@ -311,6 +313,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions) zend_hash_init(&list_destructors, 50, NULL, NULL, 1); #ifdef ZTS + global_constants_table = NULL; 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); @@ -318,6 +321,9 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions) compiler_globals_dtor(compiler_globals); compiler_globals->function_table = GLOBAL_FUNCTION_TABLE; compiler_globals->class_table = GLOBAL_CLASS_TABLE; + zend_startup_constants(executor_globals->zend_constants, executor_globals); + GLOBAL_CONSTANTS_TABLE = executor_globals->zend_constants; + zend_register_standard_constants(ELS_C); #endif #ifndef ZTS diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index cce14b8cc7..a452312d47 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -32,6 +32,21 @@ int free_zend_constant(zend_constant *c) } +void copy_zend_constant(zend_constant *c) +{ + c->name = zend_strndup(c->name, c->name_len); + zval_copy_ctor(&c->value); +} + + +void zend_copy_constants(HashTable *target, HashTable *source) +{ + zend_constant tmp_constant; + + zend_hash_copy(target, source, (void (*)(void *)) copy_zend_constant, &tmp_constant, sizeof(zend_constant)); +} + + static int clean_non_persistent_constant(zend_constant *c) { if (c->flags & CONST_PERSISTENT) { @@ -60,7 +75,7 @@ void clean_module_constants(int module_number) } -int zend_startup_constants(ELS_D) +int zend_startup_constants(HashTable *constants ELS_DC) { #if WIN32|WINNT DWORD dwBuild=0; @@ -69,8 +84,19 @@ int zend_startup_constants(ELS_D) DWORD dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); #endif + EG(zend_constants) = (HashTable *) malloc(sizeof(HashTable)); -/* ZEND_FIX: Move to PHP */ + if (zend_hash_init(EG(zend_constants), 20, NULL, ZEND_CONSTANT_DTOR, 1)==FAILURE) { + return FAILURE; + } + return SUCCESS; +} + + + +void zend_register_standard_constants(ELS_D) +{ + /* ZEND_FIX: Move to PHP */ #if 0 #if WIN32|WINNT // Get build numbers for Windows NT or Win95 @@ -85,12 +111,6 @@ int zend_startup_constants(ELS_D) #endif - EG(zend_constants) = (HashTable *) malloc(sizeof(HashTable)); - - if (zend_hash_init(EG(zend_constants), 20, NULL, ZEND_CONSTANT_DTOR, 1)==FAILURE) { - return FAILURE; - } - #if 0 /* This should go back to PHP */ REGISTER_MAIN_STRINGL_CONSTANT("PHP_VERSION", PHP_VERSION, sizeof(PHP_VERSION)-1, CONST_PERSISTENT | CONST_CS); @@ -122,8 +142,6 @@ int zend_startup_constants(ELS_D) c.value.type = IS_BOOL; zend_register_constant(&c ELS_CC); } - - return SUCCESS; } diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h index efc52fdb2f..34fb16eaee 100644 --- a/Zend/zend_constants.h +++ b/Zend/zend_constants.h @@ -42,8 +42,9 @@ typedef struct _zend_constant { void clean_module_constants(int module_number); int free_zend_constant(zend_constant *c); -int zend_startup_constants(ELS_D); +int zend_startup_constants(HashTable *constants ELS_DC); int zend_shutdown_constants(ELS_D); +void zend_register_standard_constants(ELS_D); void clean_non_persistent_constants(void); ZEND_API int zend_get_constant(char *name, uint name_len, zval *result); ZEND_API void zend_register_long_constant(char *name, uint name_len, long lval, int flags, int module_number ELS_DC); @@ -51,6 +52,7 @@ ZEND_API void zend_register_double_constant(char *name, uint name_len, double dv ZEND_API void zend_register_string_constant(char *name, uint name_len, char *strval, int flags, int module_number ELS_DC); ZEND_API void zend_register_stringl_constant(char *name, uint name_len, char *strval, uint strlen, int flags, int module_number ELS_DC); ZEND_API void zend_register_constant(zend_constant *c ELS_DC); +void zend_copy_constants(HashTable *target, HashTable *sourc); #define ZEND_CONSTANT_DTOR (int (*)(void *)) free_zend_constant