pike.git / src / main.c

version» Context lines:

pike.git/src/main.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: main.c,v 1.126 2001/05/16 23:35:52 hubbe Exp $"); + RCSID("$Id: main.c,v 1.127 2001/05/31 12:27:30 grubba Exp $");   #include "fdlib.h"   #include "backend.h"   #include "module.h"   #include "object.h"   #include "language.h"   #include "lex.h"   #include "pike_types.h"   #include "builtin_functions.h"   #include "array.h"   #include "stralloc.h"
pike.git/src/main.c:50: Inside #if defined(HAVE_SYS_RESOURCE_H)
     #ifdef HAVE_SYS_RESOURCE_H   #include <sys/resource.h>   #endif      #ifdef TRY_USE_MMX   #include <mmx.h>   int try_use_mmx;   #endif    + /* Define this to trace the execution of main(). */ + /* #define TRACE_MAIN */    -  + #ifdef TRACE_MAIN + #define TRACE(X) fprintf X + #else /* !TRACE_MAIN */ + #define TRACE(X) + #endif /* TRACE_MAIN */ +    char *master_file;   char **ARGV;      PMOD_EXPORT int debug_options=0;   PMOD_EXPORT int runtime_options=0;   PMOD_EXPORT int d_flag=0;   PMOD_EXPORT int c_flag=0;   PMOD_EXPORT int t_flag=0;   PMOD_EXPORT int default_t_flag=0;   PMOD_EXPORT int a_flag=0;   PMOD_EXPORT int l_flag=0;   PMOD_EXPORT int p_flag=0; - #ifdef YYDEBUG + #if defined(YYDEBUG) || defined(PIKE_DEBUG)   extern int yydebug; - #endif /* YYDEBUG */ + #endif /* YYDEBUG || PIKE_DEBUG */   static long instructions_left;      #define MASTER_COOKIE "(#*&)@(*&$Master Cookie:"      #ifndef MAXPATHLEN   #define MAXPATHLEN 32768   #endif      char master_location[MAXPATHLEN * 2] = MASTER_COOKIE;   
pike.git/src/main.c:172:   int dbm_main(int argc, char **argv)   {    JMP_BUF back;    int e, num, do_backend;    char *p;    struct array *a;   #ifdef DECLARE_ENVIRON    extern char **environ;   #endif    +  TRACE((stderr, "dbm_main()\n")); +     /* Attempt to make sure stderr is unbuffered. */   #ifdef HAVE_SETVBUF    setvbuf(stderr, NULL, _IONBF, 0);   #else /* !HAVE_SETVBUF */   #ifdef HAVE_SETBUF    setbuf(stderr, NULL);   #endif /* HAVE_SETBUF */   #endif /* HAVE_SETVBUF */    -  +  TRACE((stderr, "Init CPU lib...\n")); +     init_pike_cpulib();      #ifdef TRY_USE_MMX -  +  TRACE((stderr, "Init MMX...\n")); +     try_use_mmx=mmx_ok();   #endif   #ifdef OWN_GETHRTIME   /* initialize our own gethrtime conversion /Mirar */ -  +  TRACE((stderr, "Init gethrtime...\n")); +     own_gethrtime_init();   #endif       ARGV=argv;    -  +  TRACE((stderr, "Main init...\n")); +     fd_init();    {    extern void init_mapping_blocks(void);    extern void init_callable_blocks(void);    extern void init_gc_frame_blocks(void);    extern void init_pike_frame_blocks(void);    extern void init_node_s_blocks(void);    extern void init_object_blocks(void);    extern void init_callback_blocks(void);   
pike.git/src/main.c:214:    init_callable_blocks();    init_gc_frame_blocks();    init_pike_frame_blocks();    init_node_s_blocks();    init_object_blocks();    init_callback_blocks();    init_rbtree();    }      #ifdef SHARED_NODES +  TRACE((stderr, "Init shared nodes...\n")); +     node_hash.table = malloc(sizeof(node *)*32831);    if (!node_hash.table) {    fatal("Out of memory!\n");    }    MEMSET(node_hash.table, 0, sizeof(node *)*32831);    node_hash.size = 32831;   #endif /* SHARED_NODES */      #ifdef HAVE_SETLOCALE   #ifdef LC_NUMERIC
pike.git/src/main.c:240: Inside #if defined(HAVE_SETLOCALE)
   setlocale(LC_TIME, "C");   #endif   #ifdef LC_COLLATE    setlocale(LC_COLLATE, "");   #endif   #ifdef LC_MESSAGES    setlocale(LC_MESSAGES, "");   #endif   #endif    +  TRACE((stderr, "Init master...\n")); +     master_file = 0;      #ifdef HAVE_GETENV    if(getenv("PIKE_MASTER"))    master_file = getenv("PIKE_MASTER");   #endif       if(master_location[CONSTANT_STRLEN(MASTER_COOKIE)])    master_file=master_location + CONSTANT_STRLEN(MASTER_COOKIE);   
pike.git/src/main.c:264:       if(!master_file)    {    sprintf(master_location,DEFAULT_MASTER,    PIKE_MAJOR_VERSION,    PIKE_MINOR_VERSION,    PIKE_BUILD_VERSION);    master_file=master_location;    }    +  TRACE((stderr, "Default master at \"%s\"...\n", master_file)); +     for(e=1; e<argc; e++)    { -  +  TRACE((stderr, "Parse argument %d:\"%s\"...\n", e, argv[e])); +     if(argv[e][0]=='-')    {    for(p=argv[e]+1; *p;)    {    switch(*p)    {    case 'D':    add_predefine(p+1);    p+=strlen(p);    break;
pike.git/src/main.c:369:    more_d_flags:    switch(p[1])    {    case '0': case '1': case '2': case '3': case '4':    case '5': case '6': case '7': case '8': case '9':    d_flag+=STRTOL(p+1,&p,10);    break;       case 'c':    p++; - #ifdef YYDEBUG + #if defined(YYDEBUG) || defined(PIKE_DEBUG)    yydebug++; - #endif /* YYDEBUG */ + #endif /* YYDEBUG || PIKE_DEBUG */    break;       case 's':    debug_options|=DEBUG_SIGNALS;    p++;    goto more_d_flags;       case 't':    debug_options|=NO_TAILRECURSION;    p++;
pike.git/src/main.c:462:    }    }else{    break;    }    }      #if !defined(RLIMIT_NOFILE) && defined(RLIMIT_OFILE)   #define RLIMIT_NOFILE RLIMIT_OFILE   #endif    +  TRACE((stderr, "Init C stack...\n")); +     Pike_interpreter.stack_top = (char *)&argv;       /* Adjust for anything already pushed on the stack.    * We align on a 64 KB boundary.    * Thus we at worst, lose 64 KB stack.    *    * We have to do it this way since some compilers don't like    * & and | on pointers, and casting to an integer type is    * too unsafe (consider 64-bit systems).    */
pike.git/src/main.c:598: Inside #if 0 and #if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
   lim.rlim_max=MAX_OPEN_FILEDESCRIPTORS;   #endif    tmp=MINIMUM(lim.rlim_max, MAX_OPEN_FILEDESCRIPTORS);    lim.rlim_cur=tmp;    setrlimit(RLIMIT_NOFILE, &lim);    }    }   #endif   #endif    +  TRACE((stderr, "Init time...\n")); +     GETTIMEOFDAY(&current_time);    -  +  TRACE((stderr, "Init interpreter...\n")); +     init_shared_string_table();    init_interpreter();    init_types();    init_cpp();    init_lex();    init_program();    init_object();    low_th_init();    -  +  TRACE((stderr, "Init modules...\n")); +     init_modules(); -  +  +  TRACE((stderr, "Init master...\n")); +     master();    call_callback(& post_master_callbacks, 0);    free_callback_list(& post_master_callbacks);    -  +  TRACE((stderr, "Call master->_main()...\n")); +     if(SETJMP(back))    {    if(throw_severity == THROW_EXIT)    {    num=throw_value.u.integer;    }else{    call_handle_error();    num=10;    }    }else{
pike.git/src/main.c:649:    ITEM(a)[num].type=T_STRING;    }    push_array(a);       apply(master(),"_main",2);    pop_stack();    num=0;    }    UNSETJMP(back);    +  TRACE((stderr, "Exit %s...\n", num)); +     pike_do_exit(num);    return num; /* avoid warning */   }      #undef ATTRIBUTE   #define ATTRIBUTE(X)      DECLSPEC(noreturn) void pike_do_exit(int num) ATTRIBUTE((noreturn))   {    call_callback(&exit_callbacks, (void *)0);