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