Show
Ignore:
Timestamp:
06/19/08 18:01:31 (7 months ago)
Author:
bart
Message:

Remove support for all php versions older than php 5.1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • eaccelerator/trunk/ea_restore.c

    r331 r344  
    3636#include "zend_API.h" 
    3737#include "zend_extensions.h" 
    38 #ifdef ZEND_ENGINE_2_1 
    3938#include "zend_vm.h" 
    40 #endif 
    4139 
    4240#ifndef INCOMPLETE_CLASS 
     
    5250#endif 
    5351 
    54 #ifdef ZEND_ENGINE_2 
    5552/* pointer to the properties_info hashtable destructor */ 
    5653dtor_func_t properties_info_dtor = NULL; 
     
    7269    zend_hash_destroy(&dummy_class_entry.constants_table); 
    7370    zend_hash_destroy(&dummy_class_entry.properties_info); 
    74 #  ifdef ZEND_ENGINE_2_1 
    7571    zend_hash_destroy(&dummy_class_entry.default_static_members); 
    76 #  endif 
    77 #  if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_1) 
    78     zend_hash_destroy(dummy_class_entry.static_members); 
    79         FREE_HASHTABLE(dummy_class_entry.static_members); 
    80 #  endif 
    8172    return property_dtor; 
    8273} 
    83 #endif 
    8474 
    8575/******************************************************************************/ 
     
    9282    fixup_hash(base, from, (fixup_bucket_t)fixup_zval TSRMLS_CC) 
    9383 
    94 #ifdef ZEND_ENGINE_2 
    9584static void fixup_property_info(char *base, zend_property_info * from TSRMLS_DC) 
    9685{ 
    9786    FIXUP(base, from->name); 
    98 #ifdef ZEND_ENGINE_2_1 
    9987    FIXUP(base, from->doc_comment); 
    100 #endif 
    101 
    102 #endif 
     88
    10389 
    10490static void fixup_hash(char *base, HashTable * source, 
     
    165151    zend_op *end; 
    166152 
    167 #ifdef ZEND_ENGINE_2 
    168153    if (from->num_args > 0) { 
    169154        zend_uint i; 
     
    174159        } 
    175160    } 
    176 #else 
    177     FIXUP(base, from->arg_types); 
    178 #endif 
    179161    FIXUP(base, from->function_name); 
    180 #ifdef ZEND_ENGINE_2 
    181162    FIXUP(base, from->scope_name); 
    182 #endif 
    183163    if (from->type == ZEND_INTERNAL_FUNCTION) { 
    184164        return; 
     
    200180            if (opline->op2.op_type == IS_CONST) 
    201181                fixup_zval(base, &opline->op2.u.constant TSRMLS_CC); 
    202 #ifdef ZEND_ENGINE_2 
    203182            switch (opline->opcode) { 
    204183            case ZEND_JMP: 
     
    212191                break; 
    213192            } 
    214 #  ifdef ZEND_ENGINE_2_1 
    215193            ZEND_VM_SET_OPCODE_HANDLER(opline); 
    216 #  elif defined(ZEND_ENGINE_2) 
    217             opline->handler = zend_opcode_handlers[opline->opcode]; 
    218 #  else 
    219             opline->handler = get_opcode_handler(opline->opcode TSRMLS_CC); 
    220 #  endif 
    221  
    222 #endif 
    223194        } 
    224195        EAG(compress) = 1; 
    225196    } 
    226197    FIXUP(base, from->brk_cont_array); 
    227 #ifdef ZEND_ENGINE_2 
    228198    FIXUP(base, from->try_catch_array); 
    229 #endif 
    230199    if (from->static_variables != NULL) { 
    231200        FIXUP(base, from->static_variables); 
    232201        fixup_zval_hash(base, from->static_variables); 
    233202    } 
    234 #ifdef ZEND_ENGINE_2_1 
    235203    if (from->vars != NULL) { 
    236204        int i; 
     
    240208        } 
    241209    } 
    242 #endif 
    243210    FIXUP(base, from->filename); 
    244211#ifdef INCLUDE_DOC_COMMENTS 
    245 #ifdef ZEND_ENGINE_2 
    246212    FIXUP(base, from->doc_comment); 
    247 #endif 
    248213#endif 
    249214} 
     
    253218    FIXUP(base, from->name); 
    254219    FIXUP(base, from->parent); 
    255 #ifdef ZEND_ENGINE_2 
    256220    FIXUP(base, from->filename); 
    257221    fixup_zval_hash(base, &from->constants_table); 
     
    259223    fixup_hash(base, &from->properties_info, 
    260224               (fixup_bucket_t) fixup_property_info TSRMLS_CC); 
    261 #  ifdef ZEND_ENGINE_2_1 
    262225    fixup_zval_hash(base, &from->default_static_members); 
    263226    if (from->static_members != NULL) { 
     
    267230        } 
    268231    } 
    269 #  else 
    270     if (from->static_members != NULL) { 
    271         FIXUP(base, from->static_members); 
    272         fixup_zval_hash(base, from->static_members); 
    273     } 
    274 #  endif 
    275 #else 
    276     fixup_zval_hash(base, &from->default_properties); 
    277 #endif 
    278232    fixup_hash(base, &from->function_table,(fixup_bucket_t) fixup_op_array TSRMLS_CC); 
    279233} 
     
    433387        void *ptr; 
    434388    } function; 
    435 #ifdef ZEND_ENGINE_2 
    436389    int fname_len = 0; 
    437390    char *fname_lc = NULL; 
    438 #endif 
    439391 
    440392    DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 
     
    458410    } 
    459411    to->type = from->type; 
    460 #ifdef ZEND_ENGINE_2 
    461412    to->num_args = from->num_args; 
    462413    to->required_num_args = from->required_num_args; 
    463414    to->arg_info = from->arg_info; 
    464415    to->pass_rest_by_reference = from->pass_rest_by_reference; 
    465 #else 
    466     to->arg_types = from->arg_types; 
    467 #endif 
    468416    to->function_name = from->function_name; 
    469417 
    470 #ifdef ZEND_ENGINE_2 
    471418    if (to->function_name) { 
    472419        fname_len = strlen(to->function_name); 
     
    538485    DBG(ea_debug_printf, (EA_DEBUG, "[%d]                   %s's scope is '%s'\n", getpid(),  
    539486            from->function_name ? from->function_name : "(top)", to->scope ? to->scope->name : "NULL")); 
    540 #endif 
    541487    if (from->type == ZEND_INTERNAL_FUNCTION) { 
    542488        zend_class_entry *class_entry = EAG(class_entry); 
     
    551497        if (class_entry != NULL && class_entry->parent != NULL &&  
    552498                zend_hash_find(&class_entry->parent->function_table, 
    553 #ifdef ZEND_ENGINE_2 
    554499                fname_lc, fname_len + 1, 
    555 #else 
    556                 to->function_name, strlen(to->function_name) + 1, 
    557 #endif 
    558500                &function.ptr) == SUCCESS && function.v->type == ZEND_INTERNAL_FUNCTION) { 
    559501            DBG(ea_debug_pad, (EA_DEBUG TSRMLS_CC)); 
     
    567509            DBG(ea_debug_printf, (EA_DEBUG, "[%d]                                       can't find\n", getpid())); 
    568510        }        
    569 #ifdef ZEND_ENGINE_2 
    570511        /* hrak: slight memleak here. dont forget to free the lowercase function name! */ 
    571512        if (fname_lc != NULL) { 
     
    576517        /* this gets set by zend_do_inheritance */ 
    577518        to->prototype = NULL; 
    578 #endif 
    579519        return to; 
    580520    } 
    581 #ifdef ZEND_ENGINE_2 
    582521    /* hrak: slight memleak here. dont forget to free the lowercase function name! */ 
    583522    if (fname_lc != NULL) { 
    584523        efree(fname_lc); 
    585524    } 
    586 #endif 
    587525    to->opcodes = from->opcodes; 
    588526    to->last = to->size = from->last; 
     
    599537    to->filename = from->filename; 
    600538 
    601 #ifdef ZEND_ENGINE_2 
    602539    to->try_catch_array = from->try_catch_array; 
    603540    to->last_try_catch = from->last_try_catch; 
     
    613550    to->doc_comment = NULL; 
    614551#endif 
    615 #else 
    616     to->uses_globals = from->uses_globals; 
    617 #endif 
    618552    if (from->static_variables) { 
    619553        to->static_variables = restore_zval_hash(NULL, from->static_variables); 
    620554        to->static_variables->pDestructor = ZVAL_PTR_DTOR; 
    621 #ifndef ZEND_ENGINE_2 
    622555        if (EAG(class_entry) != NULL) { 
    623556            Bucket *p = to->static_variables->pListHead; 
     
    627560            } 
    628561        } 
    629 #endif 
    630     } 
    631  
    632 #ifdef ZEND_ENGINE_2_1 
     562    } 
     563 
    633564    to->vars             = from->vars; 
    634565    to->last_var         = from->last_var; 
    635566    to->size_var         = 0; 
    636 #endif 
    637567 
    638568    /* disable deletion in destroy_op_array */ 
     
    648578} 
    649579 
    650 #ifdef ZEND_ENGINE_2 
    651580static zend_property_info *restore_property_info(zend_property_info * 
    652581                                                 from TSRMLS_DC) 
     
    656585    to->name = emalloc(from->name_length + 1); 
    657586    memcpy(to->name, from->name, from->name_length + 1); 
    658 #  ifdef ZEND_ENGINE_2_1 
    659 #    ifdef INCLUDE_DOC_COMMENTS 
     587#ifdef INCLUDE_DOC_COMMENTS 
    660588    if (from->doc_comment != NULL) { 
    661589        to->doc_comment = emalloc(from->doc_comment_len + 1); 
    662590        memcpy(to->doc_comment, from->doc_comment, from->doc_comment_len + 1); 
    663591    } 
    664 #    else 
    665     to->doc_comment_len = 0; 
    666     to->doc_comment = NULL; 
    667 #    endif 
    668 #    ifdef ZEND_ENGINE_2_2 
     592# ifdef ZEND_ENGINE_2_2 
    669593    to->ce = EAG(class_entry); 
    670 #    endif 
    671 #  endif 
     594# endif 
     595#endif 
    672596    return to; 
    673597} 
    674 #endif 
    675598 
    676599/* restore the parent class with the given name for the given class */ 
    677600static void restore_class_parent(char *parent, int len, zend_class_entry * to TSRMLS_DC) 
    678601{ 
    679 #ifdef ZEND_ENGINE_2 
    680602    zend_class_entry** parent_ptr = NULL; 
    681603    if (zend_lookup_class(parent, len, &parent_ptr TSRMLS_CC) != SUCCESS) 
    682 #else 
    683     char *name_lc = estrndup(parent, len); 
    684     zend_str_tolower(name_lc, len); 
    685     if (zend_hash_find(CG(class_table), (void *) name_lc, len + 1, (void **) &to->parent) != SUCCESS) 
    686 #endif 
    687604    { 
    688605        ea_debug_error("[%d] EACCELERATOR can't restore parent class \"%s\" of class \"%s\"\n", getpid(), (char *) parent, to->name); 
     
    690607    } else { 
    691608        /* parent found */ 
    692 #ifdef ZEND_ENGINE_2 
    693609        to->parent = *parent_ptr; 
    694 #endif 
    695610        DBG(ea_debug_printf, (EA_DEBUG, "restore_class_parent: found parent %s..\n", to->parent->name)); 
    696611        DBG(ea_debug_printf, (EA_DEBUG, "restore_class_parent: parent type=%d child type=%d\n", to->parent->type, to->type)); 
    697612    } 
    698 #ifndef ZEND_ENGINE_2 
    699     efree(name_lc); 
    700 #endif 
    701 
    702  
    703 #ifdef ZEND_ENGINE_2 
     613
     614 
    704615static void restore_class_methods(zend_class_entry * to TSRMLS_DC) 
    705616{ 
     
    738649                     memcmp(fname_lc, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)) == 0) 
    739650                to->__set = f; 
    740 #  ifdef ZEND_ENGINE_2_1 
    741651            else if (fname_len == sizeof(ZEND_UNSET_FUNC_NAME) - 1 && 
    742652                    memcmp(fname_lc, ZEND_UNSET_FUNC_NAME, sizeof(ZEND_UNSET_FUNC_NAME)) == 0) 
     
    745655                    memcmp(fname_lc, ZEND_ISSET_FUNC_NAME, sizeof(ZEND_ISSET_FUNC_NAME)) == 0) 
    746656                to->__isset = f; 
    747 #  endif 
    748657            else if (fname_len == sizeof(ZEND_CALL_FUNC_NAME) - 1 && 
    749658                     memcmp(fname_lc, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)) == 0) 
     
    766675    efree(cname_lc); 
    767676} 
    768 #endif 
    769677 
    770678static zend_class_entry *restore_class_entry(zend_class_entry * to, ea_class_entry * from TSRMLS_DC) 
     
    792700    EAG(class_entry) = to; 
    793701 
    794 #ifdef ZEND_ENGINE_2 
    795702    to->ce_flags = from->ce_flags; 
    796703    to->num_interfaces = from->num_interfaces; 
     
    828735    to->properties_info.pDestructor = properties_info_dtor; 
    829736 
    830 #  ifdef ZEND_ENGINE_2_1 
    831737    /* restore default_static_members */ 
    832738    restore_zval_hash(&to->default_static_members, &from->default_static_members); 
     
    840746        to->static_members = &(to->default_static_members); 
    841747    } 
    842 #  else 
    843     if (from->static_members != NULL) { 
    844         ALLOC_HASHTABLE(to->static_members); 
    845         restore_zval_hash(to->static_members, from->static_members); 
    846         to->static_members->pDestructor = ZVAL_PTR_DTOR; 
    847     } 
    848 #  endif 
    849 #else 
    850     to->refcount = emalloc(sizeof(*to->refcount)); 
    851     *to->refcount = 1; 
    852  
    853     restore_zval_hash(&to->default_properties, &from->default_properties); 
    854     to->default_properties.pDestructor = ZVAL_PTR_DTOR; 
    855     /* Clearing references */ 
    856     { 
    857         Bucket *p = to->default_properties.pListHead; 
    858         while (p != NULL) { 
    859             ((zval *) (p->pDataPtr))->refcount = 1; 
    860             p = p->pListNext; 
    861         } 
    862     } 
    863 #endif 
    864748 
    865749    if (from->parent != NULL) { 
     
    874758    to->function_table.pDestructor = ZEND_FUNCTION_DTOR; 
    875759 
    876 #ifdef ZEND_ENGINE_2 
    877760    restore_class_methods(to TSRMLS_CC); 
    878 #endif 
    879761 
    880762    if (to->parent) { 
    881 #ifdef ZEND_ENGINE_2 
    882763        zend_do_inheritance(to, to->parent TSRMLS_CC); 
    883 #else 
    884         zend_do_inheritance(to, to->parent); 
    885 #endif 
    886764    } 
    887765    EAG(class_entry) = old; 
     
    904782            CG(in_compilation) = 1; 
    905783            CG(compiled_filename) = EAG(mem); 
    906 #ifdef ZEND_ENGINE_2 
    907784            CG(zend_lineno) = op_array.line_start; 
    908 #else 
    909             CG(zend_lineno) = op_array.opcodes[0].lineno; 
    910 #endif 
    911785            zend_error(E_ERROR, "Cannot redeclare %s()", p->htabkey); 
    912786        } 
     
    919793void restore_class(ea_fc_entry * p TSRMLS_DC) 
    920794{ 
    921 #ifdef ZEND_ENGINE_2 
    922795    zend_class_entry *ce; 
    923 #else 
    924     zend_class_entry ce; 
    925 #endif 
    926796 
    927797    if ((p->htabkey[0] == '\000') && zend_hash_exists(CG(class_table), p->htabkey, p->htablen)) { 
    928798        return; 
    929799    } 
    930 #ifdef ZEND_ENGINE_2 
    931800    ce = restore_class_entry(NULL, (ea_class_entry *) p->fc TSRMLS_CC); 
    932801    if (ce != NULL) 
    933 #else 
    934     if (restore_class_entry(&ce, (ea_class_entry *) p->fc TSRMLS_CC) != NULL) 
    935 #endif 
    936802    { 
    937 #ifdef ZEND_ENGINE_2 
    938803        if (zend_hash_add(CG(class_table), p->htabkey, p->htablen, &ce, sizeof(zend_class_entry *), NULL) == FAILURE) 
    939 #else 
    940         if (zend_hash_add(CG(class_table), p->htabkey, p->htablen, &ce, sizeof(zend_class_entry), NULL) == FAILURE) 
    941 #endif 
    942804        { 
    943805            CG(in_compilation) = 1; 
    944806            CG(compiled_filename) = EAG(mem); 
    945 #ifdef ZEND_ENGINE_2 
    946807            CG(zend_lineno) = ce->line_start; 
    947 #else 
    948             CG(zend_lineno) = 0; 
    949 #endif 
    950808            zend_error(E_ERROR, "Cannot redeclare class %s", p->htabkey); 
    951809        }