Skip to content

Commit

Permalink
- License update
Browse files Browse the repository at this point in the history
- Fix multithreaded constants startup
  • Loading branch information
Andi Gutmans committed Jul 14, 1999
1 parent d22cbad commit fec59d3
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 53 deletions.
83 changes: 46 additions & 37 deletions Zend/LICENSE
Original file line number Diff line number Diff line change
@@ -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/
16 changes: 11 additions & 5 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand All @@ -311,13 +313,17 @@ 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);
executor_globals = ts_resource(executor_globals_id);
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
Expand Down
38 changes: 28 additions & 10 deletions Zend/zend_constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -122,8 +142,6 @@ int zend_startup_constants(ELS_D)
c.value.type = IS_BOOL;
zend_register_constant(&c ELS_CC);
}

return SUCCESS;
}


Expand Down
4 changes: 3 additions & 1 deletion Zend/zend_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ 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);
ZEND_API void zend_register_double_constant(char *name, uint name_len, double dval, int flags, int module_number ELS_DC);
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

Expand Down

0 comments on commit fec59d3

Please sign in to comment.