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