Skip to content

Commit fec59d3

Browse files
author
Andi Gutmans
committed
- License update
- Fix multithreaded constants startup
1 parent d22cbad commit fec59d3

File tree

4 files changed

+88
-53
lines changed

4 files changed

+88
-53
lines changed

Zend/LICENSE

+46-37
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,46 @@
1-
Zend Temporary License
2-
======================
3-
4-
This is a temporary license, that is in effect until the final Zend license
5-
is available.
6-
7-
* The final license will include the ability to distribute Zend freely,
8-
as a part of PHP (in both compiled and source code formats). It may
9-
(and probably will) allow to redistribute Zend under other circumstances
10-
as well, but at the very least, it'll be freely distributed as a part
11-
of PHP.
12-
13-
* The source code in the Zend engine is the property of Andi Gutmans and
14-
Zeev Suraski. Parts of this code are based on source code taken from
15-
PHP 3.0, which may include several patches and enhancements that weren't
16-
made by us (Andi&Zeev). If you're the author of such a patch and you're
17-
not willing to give up ownership over your patch to us, please contact
18-
us as soon as possible, so we can remove it. We're doing this so that
19-
we'd be eligible to sell the Zend engine for uses other than PHP, most
20-
notably - as an embedded part of possible commercial products that we'd
21-
have.
22-
23-
* Patches submitted to the Zend CVS automatically fall under this license,
24-
and by submitting them you're implicitly giving up your ownership over
25-
this patch to us.
26-
27-
* Until further notice, Zend is in a status of a closed beta test. That means
28-
that only people that were explicitly given the right to access the Zend
29-
CVS repository are allowed to use it. If you're reading this file and you
30-
weren't explicitly given the right to access the Zend CVS repository from
31-
either Andi Gutmans or Zeev Suraski - you're not supposed to have it - please
32-
erase the Zend files from your system. When the closed beta period finishes,
33-
the Zend CVS tree will be open for the public (in read-only mode, of course).
34-
35-
36-
Any questions regarding Zend or this license should be addressed via Email to
37-
zend@zend.com.
1+
------------------------------------------------------------------------
2+
The Zend License, version 0.90
3+
Copyright (c) 1999 Andi Gutmans, Zeev Suraski. All Rights Reserved.
4+
------------------------------------------------------------------------
5+
6+
1. The Zend engine (``SOFTWARE'') can be distributed or redistributed
7+
free of charge as an integral part of PHP; It may not be embedded in
8+
other products nor reused separately from PHP, without prior written
9+
permission from both Andi Gutmans and Zeev Suraski (``AUTHORS'').
10+
11+
2. Distribution or redistribution of larger works derived from or works
12+
which bundle the SOFTWARE require prior written permission from the
13+
AUTHORS.
14+
15+
3. Any modifications made to the SOFTWARE will not grant the modifier
16+
any rights whatsoever to the SOFTWARE. Moreover, by publishing any
17+
modifications made to the SOFTWARE, the publisher explicitly signs
18+
over to the AUTHORS all and any rights to the published modified
19+
code.
20+
21+
4. Redistribution of the SOFTWARE in both source and binary forms must
22+
retain the above copyright notice, a copy of these license terms and
23+
the following disclaimer.
24+
25+
5. The name Zend must not be used to endorse or promote products
26+
derived from this software without prior written permission from
27+
the AUTHORS.
28+
29+
30+
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESSED
31+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS
34+
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
35+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
36+
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
37+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
39+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41+
42+
43+
-----------------------------------------------------------------------
44+
45+
- For more information about Zend, please visit http://www.zend.com/
46+
- For more information about PHP, please visit http://www.php.net/

Zend/zend.c

+11-5
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
#ifdefZTS
2828
# defineGLOBAL_FUNCTION_TABLE global_function_table
2929
# defineGLOBAL_CLASS_TABLE global_class_table
30+
# defineGLOBAL_CONSTANTS_TABLE global_constants_table
3031
#else
3132
# defineGLOBAL_FUNCTION_TABLE CG(function_table)
3233
# defineGLOBAL_CLASS_TABLE CG(class_table)
34+
# defineGLOBAL_CONSTANTS_TABLE CG(zend_constants)
3335
#endif
3436

3537
/* true multithread-shared globals */
@@ -49,6 +51,7 @@ ZEND_API int executor_globals_id;
4951
intalloc_globals_id;
5052
HashTable*global_function_table;
5153
HashTable*global_class_table;
54+
HashTable*global_constants_table;
5255
#endif
5356

5457
zend_utility_valueszend_uv;
@@ -245,7 +248,10 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals)
245248

246249
staticvoidexecutor_globals_ctor(zend_executor_globals*executor_globals)
247250
{
248-
zend_startup_constants(ELS_C);
251+
if (global_constants_table) {
252+
zend_startup_constants(executor_globals->zend_constantsELS_CC);
253+
zend_copy_constants(executor_globals->zend_constants, global_constants_table);
254+
}
249255
init_resource_plist(ELS_C);
250256
}
251257

@@ -298,10 +304,6 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions)
298304
zend_version_info=strdup(ZEND_CORE_VERSION_INFO);
299305
zend_version_info_length=sizeof(ZEND_CORE_VERSION_INFO)-1;
300306

301-
/* Prepare data structures */
302-
#ifndefZTS
303-
zend_startup_constants(ELS_C);
304-
#endif
305307
GLOBAL_FUNCTION_TABLE= (HashTable*) malloc(sizeof(HashTable));
306308
GLOBAL_CLASS_TABLE= (HashTable*) malloc(sizeof(HashTable));
307309
zend_hash_init(GLOBAL_FUNCTION_TABLE, 100, NULL, ZEND_FUNCTION_DTOR, 1);
@@ -311,13 +313,17 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions)
311313
zend_hash_init(&list_destructors, 50, NULL, NULL, 1);
312314

313315
#ifdefZTS
316+
global_constants_table=NULL;
314317
compiler_globals_id=ts_allocate_id(sizeof(zend_compiler_globals), (void (*)(void*)) compiler_globals_ctor, (void (*)(void*)) compiler_globals_dtor);
315318
executor_globals_id=ts_allocate_id(sizeof(zend_executor_globals), (void (*)(void*)) executor_globals_ctor, (void (*)(void*)) executor_globals_dtor);
316319
compiler_globals=ts_resource(compiler_globals_id);
317320
executor_globals=ts_resource(executor_globals_id);
318321
compiler_globals_dtor(compiler_globals);
319322
compiler_globals->function_table=GLOBAL_FUNCTION_TABLE;
320323
compiler_globals->class_table=GLOBAL_CLASS_TABLE;
324+
zend_startup_constants(executor_globals->zend_constants, executor_globals);
325+
GLOBAL_CONSTANTS_TABLE=executor_globals->zend_constants;
326+
zend_register_standard_constants(ELS_C);
321327
#endif
322328

323329
#ifndefZTS

Zend/zend_constants.c

+28-10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ int free_zend_constant(zend_constant *c)
3232
}
3333

3434

35+
voidcopy_zend_constant(zend_constant*c)
36+
{
37+
c->name=zend_strndup(c->name, c->name_len);
38+
zval_copy_ctor(&c->value);
39+
}
40+
41+
42+
voidzend_copy_constants(HashTable*target, HashTable*source)
43+
{
44+
zend_constanttmp_constant;
45+
46+
zend_hash_copy(target, source, (void (*)(void*)) copy_zend_constant, &tmp_constant, sizeof(zend_constant));
47+
}
48+
49+
3550
staticintclean_non_persistent_constant(zend_constant*c)
3651
{
3752
if (c->flags&CONST_PERSISTENT) {
@@ -60,7 +75,7 @@ void clean_module_constants(int module_number)
6075
}
6176

6277

63-
intzend_startup_constants(ELS_D)
78+
intzend_startup_constants(HashTable*constantsELS_DC)
6479
{
6580
#ifWIN32|WINNT
6681
DWORDdwBuild=0;
@@ -69,8 +84,19 @@ int zend_startup_constants(ELS_D)
6984
DWORDdwWindowsMinorVersion= (DWORD)(HIBYTE(LOWORD(dwVersion)));
7085
#endif
7186

87+
EG(zend_constants) = (HashTable*) malloc(sizeof(HashTable));
7288

73-
/* ZEND_FIX: Move to PHP */
89+
if (zend_hash_init(EG(zend_constants), 20, NULL, ZEND_CONSTANT_DTOR, 1)==FAILURE) {
90+
returnFAILURE;
91+
}
92+
returnSUCCESS;
93+
}
94+
95+
96+
97+
voidzend_register_standard_constants(ELS_D)
98+
{
99+
/* ZEND_FIX: Move to PHP */
74100
#if0
75101
#ifWIN32|WINNT
76102
// Get build numbers for Windows NT or Win95
@@ -85,12 +111,6 @@ int zend_startup_constants(ELS_D)
85111
#endif
86112

87113

88-
EG(zend_constants) = (HashTable*) malloc(sizeof(HashTable));
89-
90-
if (zend_hash_init(EG(zend_constants), 20, NULL, ZEND_CONSTANT_DTOR, 1)==FAILURE) {
91-
returnFAILURE;
92-
}
93-
94114
#if0
95115
/* This should go back to PHP */
96116
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)
122142
c.value.type=IS_BOOL;
123143
zend_register_constant(&cELS_CC);
124144
}
125-
126-
returnSUCCESS;
127145
}
128146

129147

Zend/zend_constants.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ typedef struct _zend_constant {
4242

4343
voidclean_module_constants(intmodule_number);
4444
intfree_zend_constant(zend_constant*c);
45-
intzend_startup_constants(ELS_D);
45+
intzend_startup_constants(HashTable*constantsELS_DC);
4646
intzend_shutdown_constants(ELS_D);
47+
voidzend_register_standard_constants(ELS_D);
4748
voidclean_non_persistent_constants(void);
4849
ZEND_APIintzend_get_constant(char*name, uintname_len, zval*result);
4950
ZEND_APIvoidzend_register_long_constant(char*name, uintname_len, longlval, intflags, intmodule_numberELS_DC);
5051
ZEND_APIvoidzend_register_double_constant(char*name, uintname_len, doubledval, intflags, intmodule_numberELS_DC);
5152
ZEND_APIvoidzend_register_string_constant(char*name, uintname_len, char*strval, intflags, intmodule_numberELS_DC);
5253
ZEND_APIvoidzend_register_stringl_constant(char*name, uintname_len, char*strval, uintstrlen, intflags, intmodule_numberELS_DC);
5354
ZEND_APIvoidzend_register_constant(zend_constant*cELS_DC);
55+
voidzend_copy_constants(HashTable*target, HashTable*sourc);
5456

5557
#defineZEND_CONSTANT_DTOR (int (*)(void *)) free_zend_constant
5658

0 commit comments

Comments
 (0)
close