The #19842 is no more needed thanks to #19876,
[p5sagit/p5-mst-13.2.git] / miniperlmain.c
1 /*    miniperlmain.c
2  *
3  *    Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002,
4  *    by Larry Wall and others
5  *
6  *    You may distribute under the terms of either the GNU General Public
7  *    License or the Artistic License, as specified in the README file.
8  *
9  */
10
11 /*
12  * "The Road goes ever on and on, down from the door where it began."
13  */
14
15 #ifdef OEMVS
16 #ifdef MYMALLOC
17 /* sbrk is limited to first heap segement so make it big */
18 #pragma runopts(HEAP(8M,500K,ANYWHERE,KEEP,8K,4K) STACK(,,ANY,) ALL31(ON))
19 #else
20 #pragma runopts(HEAP(2M,500K,ANYWHERE,KEEP,8K,4K) STACK(,,ANY,) ALL31(ON))
21 #endif
22 #endif
23
24
25 #include "EXTERN.h"
26 #define PERL_IN_MINIPERLMAIN_C
27 #include "perl.h"
28
29 static void xs_init (pTHX);
30 static PerlInterpreter *my_perl;
31
32 #if defined (__MINT__) || defined (atarist)
33 /* The Atari operating system doesn't have a dynamic stack.  The
34    stack size is determined from this value.  */
35 long _stksize = 64 * 1024;
36 #endif
37
38 int
39 main(int argc, char **argv, char **env)
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     /* To be used instead PL_taining before perl_parse() */
60     PL_earlytaint = doing_taint(argc, argv, env);
61
62     PERL_SYS_INIT3(&argc,&argv,&env);
63
64 #if defined(USE_ITHREADS)
65     /* XXX Ideally, this should really be happening in perl_alloc() or
66      * perl_construct() to keep libperl.a transparently fork()-safe.
67      * It is currently done here only because Apache/mod_perl have
68      * problems due to lack of a call to cancel pthread_atfork()
69      * handlers when shared objects that contain the handlers may
70      * be dlclose()d.  This forces applications that embed perl to
71      * call PTHREAD_ATFORK() explicitly, but if and only if it hasn't
72      * been called at least once before in the current process.
73      * --GSAR 2001-07-20 */
74     PTHREAD_ATFORK(Perl_atfork_lock,
75                    Perl_atfork_unlock,
76                    Perl_atfork_unlock);
77 #endif
78
79     if (!PL_do_undump) {
80         my_perl = perl_alloc();
81         if (!my_perl)
82             exit(1);
83         perl_construct(my_perl);
84         PL_perl_destruct_level = 0;
85     }
86     PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
87     exitstatus = perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
88     if (!exitstatus)
89         perl_run(my_perl);
90       
91     exitstatus = perl_destruct(my_perl);
92
93     perl_free(my_perl);
94
95     PERL_SYS_TERM();
96
97     exit(exitstatus);
98     return exitstatus;
99 }
100
101 /* Register any extra external extensions */
102
103 /* Do not delete this line--writemain depends on it */
104
105 static void
106 xs_init(pTHX)
107 {
108     dXSUB_SYS;
109 }