34faed695cc8b1037b22b7de5a98e990c325ebde
[p5sagit/p5-mst-13.2.git] / miniperlmain.c
1 /*
2  * "The Road goes ever on and on, down from the door where it began."
3  */
4
5 #ifdef OEMVS
6 #ifdef MYMALLOC
7 /* sbrk is limited to first heap segement so make it big */
8 #pragma runopts(HEAP(8M,500K,ANYWHERE,KEEP,8K,4K) STACK(,,ANY,) ALL31(ON))
9 #else
10 #pragma runopts(HEAP(2M,500K,ANYWHERE,KEEP,8K,4K) STACK(,,ANY,) ALL31(ON))
11 #endif
12 #endif
13
14
15 #include "EXTERN.h"
16 #define PERL_IN_MINIPERLMAIN_C
17 #include "perl.h"
18
19 static void xs_init (pTHX);
20 static PerlInterpreter *my_perl;
21
22 #if defined (__MINT__) || defined (atarist)
23 /* The Atari operating system doesn't have a dynamic stack.  The
24    stack size is determined from this value.  */
25 long _stksize = 64 * 1024;
26 #endif
27
28 /* If the compiler is in such a strict mood that it doesn't
29  * even like the third argument of main(). */
30 #if (defined(__DECC) && defined(__STDC__) && __STDC__ == 1)
31 #   define STRICT_ANSI_DISLIKES_ENVP
32 #endif
33
34 int
35 main(int argc, char **argv
36 #ifndef STRICT_ANSI_DISLIKES_ENVP
37      , char **envp
38 #endif
39      )
40 {
41     int exitstatus;
42
43 #ifdef PERL_GLOBAL_STRUCT
44 #define PERLVAR(var,type) /**/
45 #define PERLVARA(var,type) /**/
46 #define PERLVARI(var,type,init) PL_Vars.var = init;
47 #define PERLVARIC(var,type,init) PL_Vars.var = init;
48 #include "perlvars.h"
49 #undef PERLVAR
50 #undef PERLVARA
51 #undef PERLVARI
52 #undef PERLVARIC
53 #endif
54
55     /* if user wants control of gprof profiling off by default */
56     /* noop unless Configure is given -Accflags=-DPERL_GPROF_CONTROL */
57     PERL_GPROF_MONCONTROL(0);
58
59     /* The default PERL_SYS_INIT3 ignores envp but e.g. OS/2 uses it. */
60     PERL_SYS_INIT3(&argc,&argv,&envp);
61
62 #if defined(USE_5005THREADS) || defined(USE_ITHREADS)
63     /* XXX Ideally, this should really be happening in perl_alloc() or
64      * perl_construct() to keep libperl.a transparently fork()-safe.
65      * It is currently done here only because Apache/mod_perl have
66      * problems due to lack of a call to cancel pthread_atfork()
67      * handlers when shared objects that contain the handlers may
68      * be dlclose()d.  This forces applications that embed perl to
69      * call PTHREAD_ATFORK() explicitly, but if and only if it hasn't
70      * been called at least once before in the current process.
71      * --GSAR 2001-07-20 */
72     PTHREAD_ATFORK(Perl_atfork_lock,
73                    Perl_atfork_unlock,
74                    Perl_atfork_unlock);
75 #endif
76
77     if (!PL_do_undump) {
78         my_perl = perl_alloc();
79         if (!my_perl)
80             exit(1);
81         perl_construct(my_perl);
82         PL_perl_destruct_level = 0;
83     }
84     PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
85     exitstatus = perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
86     if (!exitstatus)
87         perl_run(my_perl);
88       
89     exitstatus = perl_destruct(my_perl);
90
91     perl_free(my_perl);
92
93     PERL_SYS_TERM();
94
95     exit(exitstatus);
96     return exitstatus;
97 }
98
99 /* Register any extra external extensions */
100
101 /* Do not delete this line--writemain depends on it */
102
103 static void
104 xs_init(pTHX)
105 {
106     dXSUB_SYS;
107 }