pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:1567:    } \    n = MINIMUM(n*2+1,MAXVARS(NUMTYPE)); \    } while (m + cnt > n); \    m = n; \    tmp = mexec_realloc(state->new_program->NAME, sizeof(TYPE) * m); \    if(!tmp) Pike_fatal("Out of memory.\n"); \    PIKE_CONCAT(RELOCATE_,NAME)(state->new_program, tmp); \    state->malloc_size_program->PIKE_CONCAT(num_,NAME)=m; \    state->new_program->NAME=tmp; \    } \ -  MEMCPY(state->new_program->NAME + \ +  memcpy(state->new_program->NAME + \    state->new_program->PIKE_CONCAT(num_,NAME), \    ARG, sizeof(TYPE) * cnt); \    state->new_program->PIKE_CONCAT(num_,NAME) += cnt; \   } \   void PIKE_CONCAT(add_to_,NAME) (ARGTYPE ARG) { \    PIKE_CONCAT(low_add_to_,NAME) ( Pike_compiler, ARG ); \   }   #else /* !PIKE_USE_MACHINE_CODE */   #define BAR(NUMTYPE,TYPE,ARGTYPE,NAME) \    FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \
pike.git/src/program.c:1599:    } \    n = MINIMUM(n*2+1,MAXVARS(NUMTYPE)); \    } while (m + cnt > n); \    m = n; \    tmp = realloc(state->new_program->NAME, sizeof(TYPE) * m); \    if(!tmp) Pike_fatal("Out of memory.\n"); \    PIKE_CONCAT(RELOCATE_,NAME)(state->new_program, tmp); \    state->malloc_size_program->PIKE_CONCAT(num_,NAME)=m; \    state->new_program->NAME=tmp; \    } \ -  MEMCPY(state->new_program->NAME + \ +  memcpy(state->new_program->NAME + \    state->new_program->PIKE_CONCAT(num_,NAME), \    ARG, sizeof(TYPE) * cnt); \    state->new_program->PIKE_CONCAT(num_,NAME) += cnt; \   }   #endif /* PIKE_USE_MACHINE_CODE */      /* Funny guys use the uppermost value for nonexistant variables and    the like. Hence -2 and not -1. Y2K. */   #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \   void PIKE_CONCAT(low_add_to_,NAME) (struct program_state *state, \
pike.git/src/program.c:2368:    size=0;      #ifdef PIKE_USE_MACHINE_CODE    /* As above. */   #define BAR(NUMTYPE,TYPE,ARGTYPE,NAME)   #endif /* PIKE_USE_MACHINE_CODE */      #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \    size=DO_ALIGN(size, ALIGNOF(TYPE)); \    if (p->PIKE_CONCAT (num_, NAME)) \ -  MEMCPY(data+size,p->NAME,p->PIKE_CONCAT(num_,NAME)*sizeof(p->NAME[0])); \ +  memcpy(data+size,p->NAME,p->PIKE_CONCAT(num_,NAME)*sizeof(p->NAME[0])); \    PIKE_CONCAT(RELOCATE_,NAME)(p, (TYPE *)(data+size)); \    dmfree(p->NAME); \    p->NAME=(TYPE *)(data+size); \    size+=p->PIKE_CONCAT(num_,NAME)*sizeof(p->NAME[0]);   #include "program_areas.h"       p->total_size=size + sizeof(struct program);       p->flags |= PROGRAM_OPTIMIZED;    make_program_executable(p);
pike.git/src/program.c:2412: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG   struct pike_string *find_program_name(struct program *p, INT_TYPE *line)   {    INT_TYPE l;    if(!line) line=&l;      #ifdef DEBUG_MALLOC    {    char *tmp=dmalloc_find_name(p);    if (tmp) { -  char *p = STRCHR (tmp, ':'); +  char *p = strchr (tmp, ':');    if (p) {    char *pp; -  while ((pp = STRCHR (p + 1, ':'))) p = pp; +  while ((pp = strchr (p + 1, ':'))) p = pp;    *line = atoi (p + 1);    return make_shared_binary_string (tmp, p - tmp);    }    else {    *line=0;    return make_shared_string(tmp);    }    }    }   #endif
pike.git/src/program.c:2853:    }    }    dmalloc_set_mmap_template(Pike_compiler->new_program, m);    }   #endif   }      struct program *low_allocate_program(void)   {    struct program *p=alloc_program(); -  MEMSET(p, 0, sizeof(struct program)); +  memset(p, 0, sizeof(struct program));    p->flags|=PROGRAM_VIRGIN;    p->alignment_needed=1;       GC_ALLOC(p);    p->id=++current_program_id;    INIT_PIKE_MEMOBJ(p, T_PROGRAM);       DOUBLELINK(first_program, p);    ACCURATE_GETTIMEOFDAY(& p->timestamp);    return p;
pike.git/src/program.c:2959:    yyerror("Pass2: Program already done");    }       Pike_compiler->malloc_size_program = ALLOC_STRUCT(program);    Pike_compiler->fake_object=alloc_object();      #ifdef PIKE_DEBUG    Pike_compiler->fake_object->storage=(char *)malloc(256 * sizeof(struct svalue));    if (Pike_compiler->fake_object->storage) {    /* Stipple to find illegal accesses */ -  MEMSET(Pike_compiler->fake_object->storage,0x55,256*sizeof(struct svalue)); +  memset(Pike_compiler->fake_object->storage,0x55,256*sizeof(struct svalue));    PIKE_MEM_WO_RANGE (Pike_compiler->fake_object->storage,    256 * sizeof (struct svalue));    }   #else    Pike_compiler->fake_object->storage=(char *)malloc(sizeof(struct parent_info));   #endif    if (!Pike_compiler->fake_object->storage) {    yyerror("Out of memory when allocating object storage.");    }    /* Can't use GC_ALLOC on fake objects, but still it's good to know
pike.git/src/program.c:3022: Inside #if defined(PROGRAM_BUILD_DEBUG)
   print_svalue (stderr, --Pike_sp);    putc ('\n', stderr);    }    else    fprintf (stderr, "%.*sstarting program %d (pass=%d)\n",    c->compilation_depth, "",    Pike_compiler->new_program->id, Pike_compiler->compiler_pass);   #endif       if (c->compilation_depth >= 1) { -  if(TEST_COMPAT(7,2) || (c->lex.pragmas & ID_SAVE_PARENT)) +  if(c->lex.pragmas & ID_SAVE_PARENT)    {    p->flags |= PROGRAM_USES_PARENT; -  }else if (!(c->lex.pragmas & ID_DONT_SAVE_PARENT)) { +  } else if (!(c->lex.pragmas & ID_DONT_SAVE_PARENT)) {    struct pike_string *tmp=findstring("__pragma_save_parent__");    if(tmp)    {    struct node_s *n=find_module_identifier(tmp, 0);    if(n)    {    int do_save_parent = !node_is_false(n); /* Default to true. */    free_node(n);    if (do_save_parent) p->flags |= PROGRAM_USES_PARENT;    }
pike.git/src/program.c:5835:       debug_add_to_identifiers(dummy);       if(n != -1)    {    int overridden;       if(IDENTIFIERP(n)->id_flags & ID_FINAL)    my_yyerror("Illegal to redefine 'final' identifier %S", name);    -  if(!TEST_COMPAT(7,2) && -  IDENTIFIER_IS_VARIABLE(ID_FROM_INT(Pike_compiler->new_program, +  if(IDENTIFIER_IS_VARIABLE(ID_FROM_INT(Pike_compiler->new_program,    n)->identifier_flags))    {    my_yyerror("Illegal to redefine variable %S as constant.", name);    }       /* not inherited */    if(Pike_compiler->new_program->identifier_references[n].inherit_offset == 0)    {    my_yyerror("Identifier %S defined twice.", name);    return n;
pike.git/src/program.c:6895: Inside #if 0
   id = ID_FROM_INT(p, i);    if (IDENTIFIER_IS_PIKE_FUNCTION(id->identifier_flags) &&    (id->func.offset == -1)) {    /* Function prototype. */    return -1;    }   #endif /* 0 */    return i;   }    - PMOD_EXPORT int find_lfun_fatal(struct program *p, ptrdiff_t lfun) + PMOD_EXPORT int find_lfun_fatal(struct program *UNUSED(p), ptrdiff_t lfun)   {    Pike_fatal("Invalid lfun number: %d\n", lfun);    return -1;   }      int lfun_lookup_id(struct pike_string *lfun_name)   {    struct svalue *id = low_mapping_string_lookup(lfun_ids, lfun_name);    if (!id) return -1;    if (TYPEOF(*id) == T_INT) return id->u.integer;
pike.git/src/program.c:7696:       else{    char *buffer;    if (malloced)    buffer = malloc (len + 1);    else {    buffer = buf;    if (len > NELEM (buf) - 1)    len = NELEM (buf) - 1;    } -  MEMCPY (buffer, file, len); +  memcpy (buffer, file, len);    buffer[len] = 0;    return buffer;    }   }      /* Same as low_get_program_line but returns a plain char *. It's    * malloced if the malloced flag is set, otherwise it's a pointer to a    * static buffer which might be clobbered by later calls.    *    * This function is useful when the shared string table has been freed
pike.git/src/program.c:9309:   }      static void compilation_event_handler(int e)   {    struct compilation *c = THIS_COMPILATION;       switch (e) {    case PROG_EVENT_INIT:    CDFPRINTF((stderr, "th(%ld) compilation: INIT(%p).\n",    (long) th_self(), c)); -  MEMSET(c, 0, sizeof(*c)); +  memset(c, 0, sizeof(*c));    c->supporter.self = Pike_fp->current_object; /* NOTE: Not ref-counted! */    c->compilation_inherit =    Pike_fp->context - Pike_fp->current_object->prog->inherits;    initialize_buf(&c->used_modules);    SET_SVAL(c->default_module, T_MAPPING, 0, mapping, get_builtin_constants());    add_ref(c->default_module.u.mapping);    c->major = -1;    c->minor = -1;    c->lex.current_line = 1;    c->lex.current_file = make_shared_string("-");
pike.git/src/program.c:11701:         /* returns 1 if a implements b */   static int low_implements(struct program *a, struct program *b)   {    DECLARE_CYCLIC();    int e;    int ret = 1;    struct pike_string *s=findstring("__INIT");    -  if (BEGIN_CYCLIC(a, b)) return 1; /* Tentatively ok, */ +  if (BEGIN_CYCLIC(a, b)) { +  END_CYCLIC(); +  return 1; /* Tentatively ok, */ +  }    SET_CYCLIC_RET(1);       for(e=0;e<b->num_identifier_references;e++)    {    struct identifier *bid;    int i;    if (b->identifier_references[e].id_flags & (ID_PROTECTED|ID_HIDDEN|ID_VARIANT))    continue; /* Skip protected & hidden */    bid = ID_FROM_INT(b,e);    if(s == bid->name) continue; /* Skip __INIT */
pike.git/src/program.c:11784:   }      /* Returns 1 if a is compatible with b */   static int low_is_compatible(struct program *a, struct program *b)   {    DECLARE_CYCLIC();    int e;    int ret = 1;    struct pike_string *s=findstring("__INIT");    -  if (BEGIN_CYCLIC(a, b)) return 1; +  if (BEGIN_CYCLIC(a, b)) { +  END_CYCLIC(); +  return 1; +  }    SET_CYCLIC_RET(1);       /* Optimize the loop somewhat */    if (a->num_identifier_references < b->num_identifier_references) {    struct program *tmp = a;    a = b;    b = tmp;    }       for(e=0;e<b->num_identifier_references;e++)
pike.git/src/program.c:12180: Inside #if defined(PIKE_DEBUG)
     #ifdef PIKE_DEBUG    if (loc.inherit->prog != expected) {    Pike_fatal("Failed to find expected parent storage.\n");    }   #endif       return loc.o->storage + loc.inherit->storage_offset;   }    - PMOD_EXPORT void *get_inherited_storage(int inh, struct program *expected) + PMOD_EXPORT void *get_inherited_storage(int inh, +  struct program *DEBUGUSED(expected))   {    struct inherit *i = Pike_fp->context + inh;      #ifdef PIKE_DEBUG    struct program *p = Pike_fp->current_program;    if (i >= (p->inherits + p->num_inherits)) {    Pike_fatal("Inherit out of range!\n");    }    if (i->prog != expected) {    Pike_fatal("Unexpected program at inherit #%d!\n", inh);
pike.git/src/program.c:12215:    "change_compiler_compatibility");    pop_stack();   }      #ifdef PIKE_USE_MACHINE_CODE      #ifdef HAVE_SYS_MMAN_H   #include <sys/mman.h>   #endif    + #if defined(HAVE_SYNC_INSTRUCTION_MEMORY) || defined(FLUSH_INSTRUCTION_CACHE) || !defined(USE_MY_MEXEC_ALLOC)   void make_area_executable (char *start, size_t len)   {   #ifndef USE_MY_MEXEC_ALLOC    {    /* Perform page alignment. */    void *addr = (void *)(((size_t)start) & ~(page_size-1));    size_t l = ((start + len) - ((char *)addr) +    (page_size - 1)) & ~(page_size-1);       if (mprotect(addr, l, PROT_EXEC | PROT_READ | PROT_WRITE) < 0) {
pike.git/src/program.c:12239: Inside #if undefined(USE_MY_MEXEC_ALLOC)
   }    }   #endif /* !USE_MY_MEXEC_ALLOC */      #ifdef HAVE_SYNC_INSTRUCTION_MEMORY    sync_instruction_memory(start, len);   #elif defined(FLUSH_INSTRUCTION_CACHE)    FLUSH_INSTRUCTION_CACHE(start, len);   #endif /* HAVE_SYNC_INSTRUCTION_MEMORY || FLUSH_INSTRUCTION_CACHE */   } + #else + void make_area_executable (char *UNUSED(start), size_t UNUSED(len)) + { + } + #endif      void make_program_executable(struct program *p)   {    if (!p->num_program) return;    if ((p->event_handler == compat_event_handler) &&    ((p->num_program * sizeof(p->program[0]) <=    (NUM_PROG_EVENTS * sizeof(p->event_handler))))) {    /* Only event handlers. */    return;    }       make_area_executable ((char *) p->program,    p->num_program * sizeof (p->program[0]));   }   #endif