This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Up the F::S subpackage versions; up the JPL JNI.pm version
[perl5.git] / miniperlmain.c
CommitLineData
d6376244
JH
1/* miniperlmain.c
2 *
4bb101f2
JH
3 * Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002,
4 * by Larry Wall and others
d6376244
JH
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
a0d0e21e
LW
11/*
12 * "The Road goes ever on and on, down from the door where it began."
13 */
14
60e4866f 15#ifdef OEMVS
9133bbab
NIS
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
60e4866f
LJ
22#endif
23
4633a7c4 24
ecfc5424 25#include "EXTERN.h"
864dbfa3 26#define PERL_IN_MINIPERLMAIN_C
2304df62
AD
27#include "perl.h"
28
864dbfa3 29static void xs_init (pTHX);
a0d0e21e
LW
30static PerlInterpreter *my_perl;
31
61ae2fbf
JH
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. */
35long _stksize = 64 * 1024;
36#endif
37
c07a80fd 38int
91487cfc 39main(int argc, char **argv, char **env)
2304df62
AD
40{
41 int exitstatus;
2304df62 42
22239a37
NIS
43#ifdef PERL_GLOBAL_STRUCT
44#define PERLVAR(var,type) /**/
51371543 45#define PERLVARA(var,type) /**/
533c011a
NIS
46#define PERLVARI(var,type,init) PL_Vars.var = init;
47#define PERLVARIC(var,type,init) PL_Vars.var = init;
22239a37
NIS
48#include "perlvars.h"
49#undef PERLVAR
51371543 50#undef PERLVARA
22239a37 51#undef PERLVARI
0f3f18a6 52#undef PERLVARIC
22239a37
NIS
53#endif
54
2c4f7f0e
DM
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
91487cfc 59 PERL_SYS_INIT3(&argc,&argv,&env);
4633a7c4 60
3db8f154 61#if defined(USE_ITHREADS)
52e18b1f
GS
62 /* XXX Ideally, this should really be happening in perl_alloc() or
63 * perl_construct() to keep libperl.a transparently fork()-safe.
64 * It is currently done here only because Apache/mod_perl have
65 * problems due to lack of a call to cancel pthread_atfork()
66 * handlers when shared objects that contain the handlers may
67 * be dlclose()d. This forces applications that embed perl to
68 * call PTHREAD_ATFORK() explicitly, but if and only if it hasn't
69 * been called at least once before in the current process.
70 * --GSAR 2001-07-20 */
98e467d9
DM
71 PTHREAD_ATFORK(Perl_atfork_lock,
72 Perl_atfork_unlock,
73 Perl_atfork_unlock);
74#endif
75
3280af22 76 if (!PL_do_undump) {
a0d0e21e
LW
77 my_perl = perl_alloc();
78 if (!my_perl)
79 exit(1);
642f9deb 80 perl_construct(my_perl);
3280af22 81 PL_perl_destruct_level = 0;
a0d0e21e 82 }
31d77e54 83 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
642f9deb 84 exitstatus = perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
8815fa0e 85 if (!exitstatus)
31d77e54 86 perl_run(my_perl);
8815fa0e
AB
87
88 exitstatus = perl_destruct(my_perl);
2304df62 89
642f9deb 90 perl_free(my_perl);
2304df62 91
a91be337 92 PERL_SYS_TERM();
93
642f9deb 94 exit(exitstatus);
4e35701f 95 return exitstatus;
2304df62
AD
96}
97
98/* Register any extra external extensions */
99
4633a7c4
LW
100/* Do not delete this line--writemain depends on it */
101
a0d0e21e 102static void
864dbfa3 103xs_init(pTHX)
2304df62 104{
642f9deb 105 dXSUB_SYS;
2304df62 106}