Changeset 201
- Timestamp:
- 04/11/06 17:59:53 (4 years ago)
- Location:
- eaccelerator/trunk
- Files:
-
- 12 edited
-
ChangeLog (modified) (1 diff)
-
Makefile.in (modified) (1 diff)
-
cache.c (modified) (2 diffs)
-
content.c (modified) (10 diffs)
-
ea_dasm.c (modified) (12 diffs)
-
ea_restore.c (modified) (5 diffs)
-
ea_store.c (modified) (3 diffs)
-
eaccelerator.c (modified) (6 diffs)
-
encoder.c (modified) (9 diffs)
-
loader.c (modified) (6 diffs)
-
mm.c (modified) (3 diffs)
-
optimize.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
eaccelerator/trunk/ChangeLog
r199 r201 1 2006-04-11 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 2 3 * A lot of fixes to silence the compile warnings generated when compiling 4 with the default Fedora compiler options 5 1 6 2006-04-11 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 2 7 -
eaccelerator/trunk/Makefile.in
r178 r201 3 3 LTLIBRARY_SHARED_NAME = eaccelerator.la 4 4 5 EXTRA_CFLAGS = -O2 5 EXTRA_CFLAGS = -O2 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables 6 6 7 7 include $(top_srcdir)/build/dynlib.mk -
eaccelerator/trunk/cache.c
r191 r201 279 279 hdr.crc32 = eaccelerator_crc32((const char *) q, q->size); 280 280 if (write(f, &hdr, sizeof(hdr)) == sizeof(hdr)) { 281 write(f, q, q->size); 281 ssize_t result = 0; 282 result = write(f, q, q->size); 282 283 EACCELERATOR_FLOCK(f, LOCK_UN); 283 284 close(f); … … 597 598 unsigned int i, xlen; 598 599 zval *list; 599 char *xkey ;600 char *xkey = ""; 600 601 mm_user_cache_entry *p; 601 602 time_t t = time(0); -
eaccelerator/trunk/content.c
r182 r201 122 122 static int eaccelerator_is_not_modified(zval* return_value TSRMLS_DC) { 123 123 char etag[256]; 124 zval **server_vars, **match; 124 union { 125 zval **v; 126 void *ptr; 127 } server_vars, match; 125 128 126 129 if (!SG(headers_sent)) { 127 130 sprintf(etag,"ETag: eaccelerator-%u",eaccelerator_crc32(Z_STRVAL_P(return_value),Z_STRLEN_P(return_value))); 128 131 sapi_add_header(etag, strlen(etag), 1); 129 if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &server_vars) == SUCCESS &&130 Z_TYPE_PP(server_vars ) == IS_ARRAY &&131 zend_hash_find(Z_ARRVAL_PP(server_vars ), "HTTP_IF_NONE_MATCH", sizeof("HTTP_IF_NONE_MATCH"), (void **) &match)==SUCCESS &&132 Z_TYPE_PP(match ) == IS_STRING) {133 if (strcmp(etag+6,Z_STRVAL_PP(match )) == 0 &&132 if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), &server_vars.ptr) == SUCCESS && 133 Z_TYPE_PP(server_vars.v) == IS_ARRAY && 134 zend_hash_find(Z_ARRVAL_PP(server_vars.v), "HTTP_IF_NONE_MATCH", sizeof("HTTP_IF_NONE_MATCH"), &match.ptr)==SUCCESS && 135 Z_TYPE_PP(match.v) == IS_STRING) { 136 if (strcmp(etag+6,Z_STRVAL_PP(match.v)) == 0 && 134 137 sapi_add_header("HTTP/1.0 304", sizeof("HTTP/1.0 304") - 1, 1) == SUCCESS && 135 138 sapi_add_header("Status: 304 Not Modified", sizeof("Status: 304 Not Modified") - 1, 1) == SUCCESS) { … … 184 187 int ret = 0; 185 188 zval cache_array; 186 zval **headers; 187 zval **content; 189 union { 190 zval **v; 191 void *ptr; 192 } headers, content; 188 193 if (eaccelerator_get(key, key_len, &cache_array, eaccelerator_content_cache_place TSRMLS_CC)) { 189 194 if (Z_TYPE(cache_array) == IS_ARRAY) { 190 if (zend_hash_find(Z_ARRVAL(cache_array),"content",sizeof("content"), (void**)&content) == SUCCESS &&191 Z_TYPE_PP(content ) == IS_STRING) {192 if (zend_hash_find(Z_ARRVAL(cache_array),"headers",sizeof("headers"), (void**)&headers) == SUCCESS &&193 Z_TYPE_PP(headers ) == IS_ARRAY) {194 zend_hash_apply(Z_ARRVAL_PP(headers ), (apply_func_t)eaccelerator_send_header TSRMLS_CC);195 if (zend_hash_find(Z_ARRVAL(cache_array),"content",sizeof("content"),&content.ptr) == SUCCESS && 196 Z_TYPE_PP(content.v) == IS_STRING) { 197 if (zend_hash_find(Z_ARRVAL(cache_array),"headers",sizeof("headers"),&headers.ptr) == SUCCESS && 198 Z_TYPE_PP(headers.v) == IS_ARRAY) { 199 zend_hash_apply(Z_ARRVAL_PP(headers.v), (apply_func_t)eaccelerator_send_header TSRMLS_CC); 195 200 } 196 memcpy(return_value,*content , sizeof(zval));201 memcpy(return_value,*content.v, sizeof(zval)); 197 202 zval_copy_ctor(return_value); 198 203 ret = 1; … … 205 210 206 211 static void eaccelerator_compress(char* key, int key_len, zval* return_value, time_t ttl TSRMLS_DC) { 207 zval **server_vars, **encoding; 212 union { 213 zval **v; 214 void *ptr; 215 } server_vars, encoding; 208 216 209 217 if (EAG(compression_enabled) && 210 218 EAG(compress_content) && 211 219 !SG(headers_sent) && 212 zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &server_vars) == SUCCESS &&213 Z_TYPE_PP(server_vars ) == IS_ARRAY &&214 zend_hash_find(Z_ARRVAL_PP(server_vars ), "HTTP_ACCEPT_ENCODING", sizeof("HTTP_ACCEPT_ENCODING"), (void **) &encoding)==SUCCESS &&215 Z_TYPE_PP(encoding ) == IS_STRING &&220 zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), &server_vars.ptr) == SUCCESS && 221 Z_TYPE_PP(server_vars.v) == IS_ARRAY && 222 zend_hash_find(Z_ARRVAL_PP(server_vars.v), "HTTP_ACCEPT_ENCODING", sizeof("HTTP_ACCEPT_ENCODING"), &encoding.ptr)==SUCCESS && 223 Z_TYPE_PP(encoding.v) == IS_STRING && 216 224 Z_TYPE_P(return_value) == IS_STRING && 217 225 Z_STRLEN_P(return_value) >= EACCELERATOR_COMPRESS_MIN) { … … 235 243 } 236 244 237 if (strstr(Z_STRVAL_PP(encoding ),"x-gzip")) {245 if (strstr(Z_STRVAL_PP(encoding.v),"x-gzip")) { 238 246 zkey_len = sizeof("gzip_") + key_len - 1; 239 247 zkey = emalloc(zkey_len+1); … … 244 252 params[0] = return_value; 245 253 gzip = 1; 246 } else if (strstr(Z_STRVAL_PP(encoding ),"gzip")) {254 } else if (strstr(Z_STRVAL_PP(encoding.v),"gzip")) { 247 255 zkey_len = sizeof("gzip_") + key_len - 1; 248 256 zkey = emalloc(zkey_len+1); … … 253 261 params[0] = return_value; 254 262 gzip = 1; 255 } else if (strstr(Z_STRVAL_PP(encoding ),"deflate")) {263 } else if (strstr(Z_STRVAL_PP(encoding.v),"deflate")) { 256 264 zkey_len = sizeof("deflate_") + key_len - 1; 257 265 zkey = emalloc(zkey_len+1); … … 380 388 int key_len; 381 389 long ttl = 0; 382 zval **server_vars, **encoding; 390 union { 391 zval **v; 392 void *ptr; 393 } server_vars, encoding; 383 394 384 395 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, … … 395 406 EAG(compress_content) && 396 407 !SG(headers_sent) && 397 zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &server_vars) == SUCCESS &&398 Z_TYPE_PP(server_vars ) == IS_ARRAY &&399 zend_hash_find(Z_ARRVAL_PP(server_vars ), "HTTP_ACCEPT_ENCODING", sizeof("HTTP_ACCEPT_ENCODING"), (void **) &encoding)==SUCCESS &&400 Z_TYPE_PP(encoding ) == IS_STRING) {408 zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), &server_vars.ptr) == SUCCESS && 409 Z_TYPE_PP(server_vars.v) == IS_ARRAY && 410 zend_hash_find(Z_ARRVAL_PP(server_vars.v), "HTTP_ACCEPT_ENCODING", sizeof("HTTP_ACCEPT_ENCODING"), &encoding.ptr)==SUCCESS && 411 Z_TYPE_PP(encoding.v) == IS_STRING) { 401 412 char* zkey = NULL; 402 413 char* enc = NULL; 403 414 int zkey_len = 0; 404 if (strstr(Z_STRVAL_PP(encoding ),"x-gzip")) {415 if (strstr(Z_STRVAL_PP(encoding.v),"x-gzip")) { 405 416 zkey_len = sizeof("gzip_") + key_len - 1; 406 417 zkey = emalloc(zkey_len+1); … … 408 419 memcpy(zkey+sizeof("gzip_")-1,key,key_len+1); 409 420 enc = "Content-Encoding: x-gzip"; 410 } else if (strstr(Z_STRVAL_PP(encoding ),"gzip")) {421 } else if (strstr(Z_STRVAL_PP(encoding.v),"gzip")) { 411 422 zkey_len = sizeof("gzip_") + key_len - 1; 412 423 zkey = emalloc(zkey_len+1); … … 414 425 memcpy(zkey+sizeof("gzip_")-1,key,key_len+1); 415 426 enc = "Content-Encoding: gzip"; 416 } else if (strstr(Z_STRVAL_PP(encoding ),"deflate")) {427 } else if (strstr(Z_STRVAL_PP(encoding.v),"deflate")) { 417 428 zkey_len = sizeof("deflate_") + key_len - 1; 418 429 zkey = emalloc(zkey_len+1); -
eaccelerator/trunk/ea_dasm.c
r189 r201 270 270 snprintf(buf, sizeof(buf), "ZEND_ISEMPTY"); 271 271 } else { 272 snprintf(buf, sizeof(buf), "");272 buf[0] = '\0'; 273 273 } 274 274 #ifdef ZEND_ENGINE_2 … … 279 279 snprintf(buf, sizeof(buf), "ZEND_ASSIGN_DIM"); 280 280 } else { 281 snprintf(buf, sizeof(buf), "");281 buf[0] = '\0'; 282 282 } 283 283 #ifndef ZEND_ENGINE_2_1 … … 288 288 snprintf(buf, sizeof(buf), "ZEND_UNSET_OBJ"); 289 289 } else { 290 snprintf(buf, sizeof(buf), "");290 buf[0] = '\0'; 291 291 } 292 292 #endif … … 295 295 snprintf(buf, sizeof(buf), "%ld", opline->extended_value); 296 296 } else { 297 snprintf(buf, sizeof(buf), "");297 buf[0] = '\0'; 298 298 } 299 299 add_assoc_string(el, "extended_value", buf, 1); … … 315 315 } else if ((op->ops & OP1_MASK) == OP1_UCLASS) { 316 316 if (opline->op1.op_type == IS_UNUSED) { 317 snprintf(buf, sizeof(buf), "");317 buf[0] = '\0'; 318 318 } else { 319 319 snprintf(buf, sizeof(buf), "$class%u", VAR_NUM(opline->op1.u.var)); … … 329 329 goto brk_failed; 330 330 } 331 jmp_to = &op_array->brk_cont_array[offset]; 331 332 offset = jmp_to->parent; 332 333 } while (--level > 0); … … 368 369 snprintf(buf, sizeof(buf), "$var%u", VAR_NUM(opline->op1.u.var)); 369 370 } else if (opline->op1.op_type == IS_UNUSED) { 370 snprintf(buf, sizeof(buf), "");371 buf[0] = '\0'; 371 372 } else { 372 373 snprintf(buf, sizeof(buf), "UNKNOWN NODE %d", opline->op1.op_type); … … 416 417 snprintf(buf, sizeof(buf), "ZEND_REQUIRE_ONCE"); 417 418 } else { 418 snprintf(buf, sizeof(buf), "");419 buf[0] = '\0'; 419 420 } 420 421 } else if ((op->ops & OP2_MASK) == OP2_ARG) { … … 426 427 snprintf(buf, sizeof(buf), "ZEND_ISEMPTY"); 427 428 } else { 428 snprintf(buf, sizeof(buf), "");429 buf[0] = '\0'; 429 430 } 430 431 } else { … … 437 438 snprintf(buf, sizeof(buf), "$var%u", VAR_NUM(opline->op2.u.var)); 438 439 } else if (opline->op2.op_type == IS_UNUSED) { 439 snprintf(buf, sizeof(buf), "");440 buf[0] = '\0'; 440 441 } else { 441 442 snprintf(buf, sizeof(buf), "UNKNOWN NODE %d", opline->op2.op_type); … … 467 468 } 468 469 } else if (opline->result.op_type == IS_UNUSED) { 469 snprintf(buf, sizeof(buf), "");470 buf[0] = '\0'; 470 471 } else { 471 472 snprintf(buf, sizeof(buf), "UNKNOWN NODE %d", opline->result.op_type); … … 486 487 break; 487 488 case RES_UNUSED: 488 snprintf(buf, sizeof(buf), "");489 buf[0] = '\0'; 489 490 break; 490 491 default: -
eaccelerator/trunk/ea_restore.c
r195 r201 466 466 eaccelerator_op_array * from TSRMLS_DC) 467 467 { 468 zend_function *function; 468 union { 469 zend_function *v; 470 void *ptr; 471 } function; 469 472 #ifdef ZEND_ENGINE_2 470 473 int fname_len = 0; … … 530 533 */ 531 534 if (from->scope_name != NULL) { 535 union { 536 zend_class_entry *v; 537 void *ptr; 538 } scope; 532 539 char *from_scope_lc = zend_str_tolower_dup(from->scope_name, from->scope_name_len); 533 if (zend_hash_find (CG(class_table), (void *) from_scope_lc, from->scope_name_len + 1, (void **) &to->scope) != SUCCESS) { 540 scope.v = to->scope; 541 if (zend_hash_find (CG(class_table), (void *) from_scope_lc, from->scope_name_len + 1, &scope.ptr) != SUCCESS) { 534 542 DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 535 543 DBG(ea_debug_printf, (EA_DEBUG, "[%d] can't find '%s' in class_table. use EAG(class_entry).\n", getpid(), from->scope_name)); … … 549 557 DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 550 558 DBG(ea_debug_printf, (EA_DEBUG, "[%d] checking parent '%s' have '%s'\n", getpid(), p->name, fname_lc)); 551 if (zend_hash_find(&p->function_table, fname_lc, fname_len + 1, (void **) &function) == SUCCESS) {559 if (zend_hash_find(&p->function_table, fname_lc, fname_len + 1, &function.ptr) == SUCCESS) { 552 560 DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 553 561 DBG(ea_debug_printf, (EA_DEBUG, "[%d] '%s' has '%s' of scope '%s'\n", 554 getpid(), p->name, fname_lc, function ->common.scope->name));555 to->scope = function ->common.scope;562 getpid(), p->name, fname_lc, function.v->common.scope->name)); 563 to->scope = function.v->common.scope; 556 564 break; 557 565 } … … 583 591 to->function_name, strlen(to->function_name) + 1, 584 592 #endif 585 (void **) &function) == SUCCESS && function->type == ZEND_INTERNAL_FUNCTION) {593 &function.ptr) == SUCCESS && function.v->type == ZEND_INTERNAL_FUNCTION) { 586 594 DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 587 595 DBG(ea_debug_printf, (EA_DEBUG, "[%d] found in function table\n", getpid())); 588 ((zend_internal_function *) (to))->handler = ((zend_internal_function *) function )->handler;596 ((zend_internal_function *) (to))->handler = ((zend_internal_function *) function.v)->handler; 589 597 } else { 590 598 /* FIXME. I don't know how to fix handler. … … 806 814 { 807 815 zend_class_entry *old; 808 zend_function *f = NULL;809 816 810 817 DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); -
eaccelerator/trunk/ea_store.c
r195 r201 86 86 } 87 87 88 88 89 /* Calculate the size of a point to a class entry */ 90 /* not used 89 91 static void calc_class_entry_ptr(zend_class_entry ** from TSRMLS_DC) 90 92 { 91 93 calc_class_entry(*from TSRMLS_CC); 92 94 } 95 */ 93 96 #endif 94 97 … … 781 784 zend_class_entry *from = from_ce; 782 785 zend_class_entry *parent = from->parent; 783 zend_property_info *pinfo, *cinfo = NULL; 784 zval **pprop = NULL; 785 zval **cprop = p->pData; 786 union { 787 zend_property_info *v; 788 void *ptr; 789 } pinfo, cinfo; 790 union { 791 zval **v; 792 void *ptr; 793 } pprop, cprop; 786 794 char *mname, *cname = NULL; 787 795 796 cprop.v = p->pData; 788 797 /* Check if this is a parent class. If so, copy unconditionally */ 789 798 if (parent) { … … 792 801 793 802 /* lookup the member's info in parent and child */ 794 if((zend_hash_find(&parent->properties_info, mname, strlen(mname)+1, (void**)&pinfo) == SUCCESS) &&795 (zend_hash_find(&from->properties_info, mname, strlen(mname)+1, (void**)&cinfo) == SUCCESS)) {803 if((zend_hash_find(&parent->properties_info, mname, strlen(mname)+1, &pinfo.ptr) == SUCCESS) && 804 (zend_hash_find(&from->properties_info, mname, strlen(mname)+1, &cinfo.ptr) == SUCCESS)) { 796 805 /* don't copy this static property if protected in parent and static public in child. 797 806 inheritance will handle this properly on restore */ 798 if(cinfo ->flags & ZEND_ACC_STATIC && (pinfo->flags & ZEND_ACC_PROTECTED && cinfo->flags & ZEND_ACC_PUBLIC)) {807 if(cinfo.v->flags & ZEND_ACC_STATIC && (pinfo.v->flags & ZEND_ACC_PROTECTED && cinfo.v->flags & ZEND_ACC_PUBLIC)) { 799 808 return ZEND_HASH_APPLY_REMOVE; 800 809 } 801 810 /* If the static member points to the same value in parent and child, remove for proper inheritance during restore */ 802 811 # ifdef ZEND_ENGINE_2_1 803 if(zend_hash_quick_find(&parent->default_static_members, p->arKey, p->nKeyLength, p->h, (void**)&pprop) == SUCCESS) {812 if(zend_hash_quick_find(&parent->default_static_members, p->arKey, p->nKeyLength, p->h, &pprop.ptr) == SUCCESS) { 804 813 # else 805 if(zend_hash_quick_find(parent->static_members, p->arKey, p->nKeyLength, p->h, (void**)&pprop) == SUCCESS) {814 if(zend_hash_quick_find(parent->static_members, p->arKey, p->nKeyLength, p->h, &pprop.ptr) == SUCCESS) { 806 815 # endif 807 if(*pprop == *cprop) {816 if(*pprop.v == *cprop.v) { 808 817 return ZEND_HASH_APPLY_REMOVE; 809 818 } -
eaccelerator/trunk/eaccelerator.c
r193 r201 350 350 } 351 351 352 /* This function isn't used. So disable it for now 352 353 static void decode_version(char *version, int v) { 353 354 int t = (v & 0x000f00) >> 8; … … 364 365 c, 365 366 (v & 0x0000ff)); 366 } 367 } 368 */ 367 369 368 370 #ifdef EACCELERATOR_USE_INODE … … 1034 1036 } 1035 1037 1038 #ifndef EACCELERATOR_USE_INODE 1036 1039 static char* eaccelerator_realpath(const char* name, char* realname TSRMLS_DC) { 1037 1040 /* ???TODO it is possibe to cache name->realname mapping to avoid lstat() calls */ … … 1042 1045 #endif 1043 1046 } 1047 #endif 1044 1048 1045 1049 static int eaccelerator_stat(zend_file_handle *file_handle, … … 1227 1231 time_t compile_time; 1228 1232 int stat_result = 0; 1233 #ifdef DEBUG 1229 1234 struct timeval tv_start; 1235 #endif 1230 1236 1231 1237 #ifdef EACCELERATOR_USE_INODE … … 2096 2102 EAG(hostname)[0] = '\000'; 2097 2103 { 2098 zval **server_vars, **hostname; 2099 2100 if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **) &server_vars) == SUCCESS && 2101 Z_TYPE_PP(server_vars) == IS_ARRAY && 2102 zend_hash_find(Z_ARRVAL_PP(server_vars), "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &hostname)==SUCCESS && 2103 Z_TYPE_PP(hostname) == IS_STRING && 2104 Z_STRLEN_PP(hostname) > 0) 2104 union { 2105 zval **v; 2106 void *ptr; 2107 } server_vars; 2108 union { 2109 zval **v; 2110 void *ptr; 2111 } hostname; 2112 2113 if (zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), &server_vars.ptr) == SUCCESS && 2114 Z_TYPE_PP(server_vars.v) == IS_ARRAY && 2115 zend_hash_find(Z_ARRVAL_PP(server_vars.v), "SERVER_NAME", sizeof("SERVER_NAME"), &hostname.ptr)==SUCCESS && 2116 Z_TYPE_PP(hostname.v) == IS_STRING && 2117 Z_STRLEN_PP(hostname.v) > 0) 2105 2118 { 2106 if (sizeof(EAG(hostname)) > Z_STRLEN_PP(hostname ))2119 if (sizeof(EAG(hostname)) > Z_STRLEN_PP(hostname.v)) 2107 2120 { 2108 memcpy(EAG(hostname),Z_STRVAL_PP(hostname ),Z_STRLEN_PP(hostname)+1);2121 memcpy(EAG(hostname),Z_STRVAL_PP(hostname.v),Z_STRLEN_PP(hostname.v)+1); 2109 2122 } 2110 2123 else 2111 2124 { 2112 memcpy(EAG(hostname),Z_STRVAL_PP(hostname ),sizeof(EAG(hostname))-1);2125 memcpy(EAG(hostname),Z_STRVAL_PP(hostname.v),sizeof(EAG(hostname))-1); 2113 2126 EAG(hostname)[sizeof(EAG(hostname))-1] = '\000'; 2114 2127 } -
eaccelerator/trunk/encoder.c
r191 r201 250 250 allow = 1; 251 251 } else if (allow && ch == '_') { 252 size_t result = 0; 252 253 label[0] = ch = fgetc(yyin); 253 254 if (ch == EOF) {break;} 254 255 if (ch == '_') { 255 256 label[1] = ch = fgetc(yyin); 256 if (ch == EOF) { fwrite(label,1,1,yyout); break;}257 if (ch == EOF) {result = fwrite(label,1,1,yyout); break;} 257 258 if (IEQ('f')) { 258 259 label[2] = ch = fgetc(yyin); 259 if (ch == EOF) { fwrite(label,2,1,yyout); break;}260 if (ch == EOF) {result = fwrite(label,2,1,yyout); break;} 260 261 if (IEQ('i')) { 261 262 label[3] = ch = fgetc(yyin); 262 if (ch == EOF) { fwrite(label,3,1,yyout); break;}263 if (ch == EOF) {result = fwrite(label,3,1,yyout); break;} 263 264 if (IEQ('l')) { 264 265 label[4] = ch = fgetc(yyin); 265 if (ch == EOF) { fwrite(label,4,1,yyout); break;}266 if (ch == EOF) {result = fwrite(label,4,1,yyout); break;} 266 267 if (IEQ('e')) { 267 268 label[5] = ch = fgetc(yyin); 268 if (ch == EOF) { fwrite(label,5,1,yyout); break;}269 if (ch == EOF) {result = fwrite(label,5,1,yyout); break;} 269 270 if (ch == '_') { 270 271 label[6] = ch = fgetc(yyin); 271 if (ch == EOF) { fwrite(label,6,1,yyout); break;}272 if (ch == EOF) {result = fwrite(label,6,1,yyout); break;} 272 273 if (ch == '_') { 273 274 ch = fgetc(yyin); … … 278 279 (ch >= '\x7f' && ch <= '\xff') || 279 280 ch == '_') { 280 fwrite(label,7,1,yyout);281 result = fwrite(label,7,1,yyout); 281 282 } else { 282 283 fputs("eaccelerator_loader_file()",yyout); 283 284 } 284 285 } else { 285 fwrite(label,7,1,yyout);286 result = fwrite(label,7,1,yyout); 286 287 } 287 288 } else { 288 fwrite(label,6,1,yyout);289 result = fwrite(label,6,1,yyout); 289 290 } 290 291 } else { 291 fwrite(label,5,1,yyout);292 result = fwrite(label,5,1,yyout); 292 293 } 293 294 } else { 294 fwrite(label,4,1,yyout);295 result = fwrite(label,4,1,yyout); 295 296 } 296 297 } else { 297 fwrite(label,3,1,yyout);298 result = fwrite(label,3,1,yyout); 298 299 } 299 300 } else if (IEQ('l')) { 300 301 label[2] = ch = fgetc(yyin); 301 if (ch == EOF) { fwrite(label,2,1,yyout); break;}302 if (ch == EOF) {result = fwrite(label,2,1,yyout); break;} 302 303 if (IEQ('i')) { 303 304 label[3] = ch = fgetc(yyin); 304 if (ch == EOF) { fwrite(label,3,1,yyout); break;}305 if (ch == EOF) {result = fwrite(label,3,1,yyout); break;} 305 306 if (IEQ('n')) { 306 307 label[4] = ch = fgetc(yyin); 307 if (ch == EOF) { fwrite(label,4,1,yyout); break;}308 if (ch == EOF) {result = fwrite(label,4,1,yyout); break;} 308 309 if (IEQ('e')) { 309 310 label[5] = ch = fgetc(yyin); 310 if (ch == EOF) { fwrite(label,5,1,yyout); break;}311 if (ch == EOF) {result = fwrite(label,5,1,yyout); break;} 311 312 if (ch == '_') { 312 313 label[6] = ch = fgetc(yyin); 313 if (ch == EOF) { fwrite(label,6,1,yyout); break;}314 if (ch == EOF) {result = fwrite(label,6,1,yyout); break;} 314 315 if (ch == '_') { 315 316 ch = fgetc(yyin); … … 320 321 (ch >= '\x7f' && ch <= '\xff') || 321 322 ch == '_') { 322 fwrite(label,7,1,yyout);323 result = fwrite(label,7,1,yyout); 323 324 } else { 324 325 fputs("eaccelerator_loader_line()",yyout); 325 326 } 326 327 } else { 327 fwrite(label,7,1,yyout);328 result = fwrite(label,7,1,yyout); 328 329 } 329 330 } else { 330 fwrite(label,6,1,yyout);331 result = fwrite(label,6,1,yyout); 331 332 } 332 333 } else { 333 fwrite(label,5,1,yyout);334 result = fwrite(label,5,1,yyout); 334 335 } 335 336 } else { 336 fwrite(label,4,1,yyout);337 result = fwrite(label,4,1,yyout); 337 338 } 338 339 } else { 339 fwrite(label,3,1,yyout);340 result = fwrite(label,3,1,yyout); 340 341 } 341 342 } else { 342 fwrite(label,2,1,yyout);343 result = fwrite(label,2,1,yyout); 343 344 } 344 345 } else { 345 fwrite(label,1,1,yyout);346 result = fwrite(label,1,1,yyout); 346 347 } 347 348 allow = 0; … … 695 696 static void encode_class_entry(zend_class_entry* from); 696 697 698 /* not used 697 699 static void encode_class_entry_ptr(zend_class_entry** from) { 698 700 encode_class_entry(*from); 699 701 } 702 */ 700 703 #endif 701 704 … … 719 722 } 720 723 724 /* not used 721 725 #ifdef ZEND_ENGINE_2 722 726 #define encode_zval_hash_ex(from,p) encode_hash_ex(from, p, (encode_bucket_t)encode_zval_ptr) … … 745 749 } 746 750 #endif 751 */ 747 752 748 753 static void encode_op(zend_op_array* from, zend_op* opline, unsigned int ops) { … … 1183 1188 if (prefix != NULL) 1184 1189 { 1190 size_t result = 0; 1185 1191 prefix->type = IS_STRING; 1186 1192 prefix->value.str.len = pos; 1187 1193 prefix->value.str.val = emalloc(pos+1); 1188 1194 rewind(src_fp); 1189 fread(prefix->value.str.val, pos, 1, src_fp);1195 result = fread(prefix->value.str.val, pos, 1, src_fp); 1190 1196 prefix->value.str.val[prefix->value.str.len] = '\000'; 1191 1197 } … … 1204 1210 if (tmp_fp) 1205 1211 { 1212 size_t result = 0; 1206 1213 if (pre_content_len > 0) 1207 1214 { 1208 fwrite(pre_content, pre_content_len, 1, tmp_fp);1215 result = fwrite(pre_content, pre_content_len, 1, tmp_fp); 1209 1216 } 1210 1217 #ifndef WITHOUT_FILE_FILTER … … 1220 1227 if (post_content_len > 0) 1221 1228 { 1222 fwrite(post_content, post_content_len, 1, tmp_fp);1229 result = fwrite(post_content, post_content_len, 1, tmp_fp); 1223 1230 } 1224 1231 rewind(tmp_fp); -
eaccelerator/trunk/loader.c
r191 r201 213 213 } 214 214 215 #ifndef ZEND_ENGINE_2 215 216 static unsigned char* decode_pstr(char** p, unsigned int* l) { 216 217 unsigned char c = decode(p, l); … … 230 231 } 231 232 } 233 #endif 232 234 233 235 static double decode_double(char** p, unsigned int* l) { … … 251 253 252 254 #define decode_zval_hash(to, p, l) decode_hash(to, sizeof(zval*), (decode_bucket_t)decode_zval_ptr, p, l TSRMLS_CC) 253 #define decode_zval_hash_noref(to, p, l) decode_hash(to, sizeof(zval*), (decode_bucket_t)decode_zval_ptr_noref, p, l TSRMLS_CC)254 255 255 256 static HashTable* decode_hash(HashTable* to, int size, decode_bucket_t decode_bucket, char**p, unsigned int* l TSRMLS_DC); … … 316 317 } 317 318 319 #ifndef ZEND_ENGINE_2 320 #define decode_zval_hash_noref(to, p, l) decode_hash(to, sizeof(zval*), (decode_bucket_t)decode_zval_ptr_noref, p, l TSRMLS_CC) 318 321 static zval* decode_zval_ptr_noref(zval* to, char** p, unsigned int* l TSRMLS_DC) { 319 322 if (to == NULL) { … … 325 328 return to; 326 329 } 330 #endif 327 331 328 332 static void decode_znode(znode* to, unsigned int vars_count, char** p, unsigned int* l TSRMLS_DC) { … … 616 620 to->fn_flags = decode32(p, l); 617 621 scope_name = decode_lstr((unsigned int*)&scope_name_len, p, l); 618 if (to->scope == NULL && scope_name != NULL) { 619 if (zend_hash_find(CG(class_table), (void *)scope_name, 620 scope_name_len, (void **)&to->scope) == SUCCESS) { 621 to->scope = *(zend_class_entry**)to->scope; 622 } else { 623 to->scope = NULL; 624 } 625 } 622 if (to->scope == NULL && scope_name != NULL) { 623 union { 624 zend_class_entry *v; 625 void *ptr; 626 } scope; 627 scope.v = to->scope; 628 if (zend_hash_find(CG(class_table), (void *)scope_name, 629 scope_name_len, &scope.ptr) == SUCCESS) { 630 to->scope = *(zend_class_entry**)to->scope; 631 } else { 632 to->scope = NULL; 633 } 634 } 626 635 #endif 627 636 if (to->type == ZEND_INTERNAL_FUNCTION) { -
eaccelerator/trunk/mm.c
r197 r201 158 158 #undef MM_SHM_CAN_ATTACH 159 159 160 #if defined(MM_SEM_POSIX) || defined(MM_SEM_FCNTL) || defined(MM_SEM_FLOCK) || defined(MM_SEM_WIN32) || defined(MM_SHM_MMAP_POSIX) || defined(MM_SHM_MMAP_FILE) 160 161 static int strxcat(char* dst, const char* src, int size) { 161 162 int dst_len = strlen(dst); … … 170 171 } 171 172 } 173 #endif 172 174 173 175 #if defined(MM_SEM_SPINLOCK) … … 192 194 } mm_mutex; 193 195 196 /* not used 194 197 static int mm_attach_lock(const char* key, mm_mutex* lock) { 195 198 return 1; 196 199 } 200 */ 197 201 198 202 static int mm_init_lock(const char* key, mm_mutex* lock) { -
eaccelerator/trunk/optimize.c
r199 r201 1500 1500 (name_len == sizeof("false")-1 && strcmp(name,"false") == 0) || 1501 1501 (name_len == sizeof("true")-1 && strcmp(name,"true") == 0)) { 1502 zend_constant *c; 1502 union { 1503 zend_constant *v; 1504 void *ptr; 1505 } c; 1503 1506 int retval; 1504 1507 char *lookup_name = do_alloca(name_len+1); … … 1506 1509 lookup_name[name_len] = '\0'; 1507 1510 1508 if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) {1509 *result = c ;1511 if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, &c.ptr)==SUCCESS) { 1512 *result = c.v; 1510 1513 retval=1; 1511 1514 } else { 1512 1515 zend_str_tolower(lookup_name, name_len); 1513 1516 1514 if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, (void **) &c)==SUCCESS) {1515 if ((c ->flags & CONST_CS) && (memcmp(c->name, name, name_len)!=0)) {1517 if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1, &c.ptr)==SUCCESS) { 1518 if ((c.v->flags & CONST_CS) && (memcmp(c.v->name, name, name_len)!=0)) { 1516 1519 retval=0; 1517 1520 } else { 1518 *result = c ;1521 *result = c.v; 1519 1522 retval=1; 1520 1523 } … … 2544 2547 IS_DEFINED(op->op1)) { 2545 2548 zend_op *x = DEFINED_OP(op->op1); 2546 if ((x->opcode == ZEND_FETCH_W || x->opcode == ZEND_FETCH_RW) && 2547 x->op1.op_type == IS_CONST && 2548 x->op1.u.constant.type == IS_STRING) { 2549 if ((x->opcode == ZEND_FETCH_W || x->opcode == ZEND_FETCH_RW) && 2550 x->op1.op_type == IS_CONST && x->op1.u.constant.type == IS_STRING) { 2551 union { 2552 zend_op *v; 2553 void *ptr; 2554 } op_copy; 2549 2555 char *s = emalloc(x->op1.u.constant.value.str.len+2); 2556 op_copy.v = op; 2550 2557 memcpy(s,x->op1.u.constant.value.str.val,x->op1.u.constant.value.str.len); 2551 2558 s[x->op1.u.constant.value.str.len] = (char)FETCH_TYPE(x); 2552 2559 s[x->op1.u.constant.value.str.len+1] = '\0'; 2553 zend_hash_update(&assigns, 2554 s, x->op1.u.constant.value.str.len+2, 2555 (void**)&op, sizeof(void*), NULL); 2560 zend_hash_update(&assigns, s, x->op1.u.constant.value.str.len+2, &op_copy.ptr, 2561 sizeof(void*), NULL); 2556 2562 efree(s); 2557 2563 } 2558 2564 } 2559 } else if ((op->opcode == ZEND_FETCH_R || 2560 op->opcode == ZEND_FETCH_IS) && 2561 !global[VAR_NUM(op->result.u.var)] && 2562 op->op1.op_type == IS_CONST && 2563 op->op1.u.constant.type == IS_STRING) { 2564 zend_op *x; 2565 } else if ((op->opcode == ZEND_FETCH_R || op->opcode == ZEND_FETCH_IS) && 2566 !global[VAR_NUM(op->result.u.var)] && op->op1.op_type == IS_CONST && 2567 op->op1.u.constant.type == IS_STRING) { 2568 union { 2569 zend_op *v; 2570 void *ptr; 2571 } x; 2565 2572 char *s = emalloc(op->op1.u.constant.value.str.len+2); 2566 2573 memcpy(s,op->op1.u.constant.value.str.val,op->op1.u.constant.value.str.len); … … 2568 2575 s[op->op1.u.constant.value.str.len+1] = '\0'; 2569 2576 2570 if (zend_hash_find(&assigns, 2571 s, op->op1.u.constant.value.str.len+2, 2572 (void**)&x) == SUCCESS) { 2573 x = *(zend_op**)x; 2574 /* 2575 if (x->opcode == ZEND_ASSIGN && x->op2.op_type == IS_CONST) { 2576 zend_printf("possible const propogation in %s:%s (%s,%u:%u)<br>\n",op_array->filename, op_array->function_name, op->op1.u.constant.value.str.val, x-op_array->opcodes, op-op_array->opcodes); 2577 } 2578 */ 2579 memcpy(&x->result, &op->result, sizeof(op->result)); 2580 x->result.u.EA.type = 0; 2581 SET_DEFINED(x); 2582 zend_hash_del(&assigns, 2583 s, op->op1.u.constant.value.str.len+2); 2577 if (zend_hash_find(&assigns, s, op->op1.u.constant.value.str.len+2, 2578 &x.ptr) == SUCCESS) { 2579 x.v = *(zend_op**)x.v; 2580 memcpy(&x.v->result, &op->result, sizeof(op->result)); 2581 x.v->result.u.EA.type = 0; 2582 SET_DEFINED(x.v); 2583 zend_hash_del(&assigns, s, op->op1.u.constant.value.str.len+2); 2584 2584 STR_FREE(op->op1.u.constant.value.str.val); 2585 2585 SET_TO_NOP(op); … … 2587 2587 efree(s); 2588 2588 } else if (op->opcode == ZEND_FETCH_DIM_R && 2589 op->extended_value != ZEND_FETCH_ADD_LOCK &&2590 op->op1.op_type == IS_VAR &&2591 IS_DEFINED(op->op1)) {2589 op->extended_value != ZEND_FETCH_ADD_LOCK && 2590 op->op1.op_type == IS_VAR && 2591 IS_DEFINED(op->op1)) { 2592 2592 zend_op *x = DEFINED_OP(op->op1); 2593 2593 while ((x->opcode == ZEND_ASSIGN_REF || … … 2610 2610 x = DEFINED_OP(x->op1); 2611 2611 } 2612 if ((x->opcode == ZEND_FETCH_R || 2613 x->opcode == ZEND_FETCH_W || 2614 x->opcode == ZEND_FETCH_RW) && 2615 x->op1.op_type == IS_CONST && 2616 x->op1.u.constant.type == IS_STRING) { 2617 zend_op *y; 2612 if ((x->opcode == ZEND_FETCH_R || x->opcode == ZEND_FETCH_W || 2613 x->opcode == ZEND_FETCH_RW) && x->op1.op_type == IS_CONST && 2614 x->op1.u.constant.type == IS_STRING) { 2615 union { 2616 zend_op *v; 2617 void *ptr; 2618 } y; 2619 union { 2620 zend_op *v; 2621 void *ptr; 2622 } op_copy; 2618 2623 char *s = emalloc(x->op1.u.constant.value.str.len+2); 2624 op_copy.v = op; 2619 2625 memcpy(s,x->op1.u.constant.value.str.val,x->op1.u.constant.value.str.len); 2620 2626 s[x->op1.u.constant.value.str.len] = (char)FETCH_TYPE(x); 2621 2627 s[x->op1.u.constant.value.str.len+1] = '\0'; 2622 if (zend_hash_find(&fetch_dim, 2623 s, x->op1.u.constant.value.str.len+2, 2624 (void**)&y) == SUCCESS) { 2625 y = *(zend_op**)y; 2626 y->extended_value = ZEND_FETCH_ADD_LOCK; 2627 zend_hash_update(&fetch_dim, 2628 s, x->op1.u.constant.value.str.len+2, 2629 (void**)&op, sizeof(void*), NULL); 2628 if (zend_hash_find(&fetch_dim, s, x->op1.u.constant.value.str.len+2, 2629 &y.ptr) == SUCCESS) { 2630 y.v = *(zend_op**)y.v; 2631 y.v->extended_value = ZEND_FETCH_ADD_LOCK; 2632 zend_hash_update(&fetch_dim, s, x->op1.u.constant.value.str.len+2, 2633 &op_copy.ptr, sizeof(void*), NULL); 2630 2634 SET_UNDEFINED(x->result); 2631 2635 STR_FREE(x->op1.u.constant.value.str.val); 2632 2636 SET_TO_NOP(x); 2633 memcpy(&op->op1, &y->op1,sizeof(op->op1));2637 memcpy(&op->op1, &y.v->op1, sizeof(op->op1)); 2634 2638 } else { 2635 zend_hash_update(&fetch_dim, 2636 s, x->op1.u.constant.value.str.len+2, 2637 (void**)&op, sizeof(void*), NULL); 2639 zend_hash_update(&fetch_dim, s, x->op1.u.constant.value.str.len+2, 2640 &op_copy.ptr, sizeof(void*), NULL); 2638 2641 } 2639 2642 efree(s); … … 3171 3174 zend_uint i; 3172 3175 zend_uint n = 0; 3176 #ifndef ZEND_ENGINE_2 3173 3177 int uses_globals = 0; 3178 #endif 3174 3179 int* assigned = do_alloca(op_array->T * sizeof(int)); 3175 3180 char* reg_pool = do_alloca(op_array->T * sizeof(char));
Note: See TracChangeset
for help on using the changeset viewer.