line |
stmt |
bran |
cond |
sub |
time |
code |
1
|
|
|
|
|
|
/* miniperlmain.c |
2
|
|
|
|
|
|
* |
3
|
|
|
|
|
|
* Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, |
4
|
|
|
|
|
|
* 2004, 2005, 2006, 2007, 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 |
13
|
|
|
|
|
|
* Down from the door where it began. |
14
|
|
|
|
|
|
* |
15
|
|
|
|
|
|
* [Bilbo on p.35 of _The Lord of the Rings_, I/i: "A Long-Expected Party"] |
16
|
|
|
|
|
|
* [Frodo on p.73 of _The Lord of the Rings_, I/iii: "Three Is Company"] |
17
|
|
|
|
|
|
*/ |
18
|
|
|
|
|
|
|
19
|
|
|
|
|
|
/* This file contains the main() function for the perl interpreter. |
20
|
|
|
|
|
|
* Note that miniperlmain.c contains main() for the 'miniperl' binary, |
21
|
|
|
|
|
|
* while perlmain.c contains main() for the 'perl' binary. |
22
|
|
|
|
|
|
* |
23
|
|
|
|
|
|
* Miniperl is like perl except that it does not support dynamic loading, |
24
|
|
|
|
|
|
* and in fact is used to build the dynamic modules needed for the 'real' |
25
|
|
|
|
|
|
* perl executable. |
26
|
|
|
|
|
|
*/ |
27
|
|
|
|
|
|
|
28
|
|
|
|
|
|
#ifdef OEMVS |
29
|
|
|
|
|
|
#ifdef MYMALLOC |
30
|
|
|
|
|
|
/* sbrk is limited to first heap segment so make it big */ |
31
|
|
|
|
|
|
#pragma runopts(HEAP(8M,500K,ANYWHERE,KEEP,8K,4K) STACK(,,ANY,) ALL31(ON)) |
32
|
|
|
|
|
|
#else |
33
|
|
|
|
|
|
#pragma runopts(HEAP(2M,500K,ANYWHERE,KEEP,8K,4K) STACK(,,ANY,) ALL31(ON)) |
34
|
|
|
|
|
|
#endif |
35
|
|
|
|
|
|
#endif |
36
|
|
|
|
|
|
|
37
|
|
|
|
|
|
#define PERL_IN_MINIPERLMAIN_C |
38
|
|
|
|
|
|
#include "EXTERN.h" |
39
|
|
|
|
|
|
#include "perl.h" |
40
|
|
|
|
|
|
#include "XSUB.h" |
41
|
|
|
|
|
|
|
42
|
|
|
|
|
|
static void xs_init (pTHX); |
43
|
|
|
|
|
|
static PerlInterpreter *my_perl; |
44
|
|
|
|
|
|
|
45
|
|
|
|
|
|
#if defined(PERL_GLOBAL_STRUCT_PRIVATE) |
46
|
|
|
|
|
|
/* The static struct perl_vars* may seem counterproductive since the |
47
|
|
|
|
|
|
* whole idea PERL_GLOBAL_STRUCT_PRIVATE was to avoid statics, but note |
48
|
|
|
|
|
|
* that this static is not in the shared perl library, the globals PL_Vars |
49
|
|
|
|
|
|
* and PL_VarsPtr will stay away. */ |
50
|
|
|
|
|
|
static struct perl_vars* my_plvarsp; |
51
|
|
|
|
|
|
struct perl_vars* Perl_GetVarsPrivate(void) { return my_plvarsp; } |
52
|
|
|
|
|
|
#endif |
53
|
|
|
|
|
|
|
54
|
|
|
|
|
|
#ifdef NO_ENV_ARRAY_IN_MAIN |
55
|
|
|
|
|
|
extern char **environ; |
56
|
|
|
|
|
|
int |
57
|
|
|
|
|
|
main(int argc, char **argv) |
58
|
|
|
|
|
|
#else |
59
|
|
|
|
|
|
int |
60
|
20310
|
|
|
|
|
main(int argc, char **argv, char **env) |
61
|
|
|
|
|
|
#endif |
62
|
|
|
|
|
|
{ |
63
|
|
|
|
|
|
int exitstatus, i; |
64
|
|
|
|
|
|
#ifdef PERL_GLOBAL_STRUCT |
65
|
|
|
|
|
|
struct perl_vars *my_vars = init_global_struct(); |
66
|
|
|
|
|
|
# ifdef PERL_GLOBAL_STRUCT_PRIVATE |
67
|
|
|
|
|
|
my_plvarsp = my_vars; |
68
|
|
|
|
|
|
# endif |
69
|
|
|
|
|
|
#endif /* PERL_GLOBAL_STRUCT */ |
70
|
|
|
|
|
|
#ifndef NO_ENV_ARRAY_IN_MAIN |
71
|
|
|
|
|
|
PERL_UNUSED_ARG(env); |
72
|
|
|
|
|
|
#endif |
73
|
|
|
|
|
|
#ifndef PERL_USE_SAFE_PUTENV |
74
|
20310
|
|
|
|
|
PL_use_safe_putenv = FALSE; |
75
|
|
|
|
|
|
#endif /* PERL_USE_SAFE_PUTENV */ |
76
|
|
|
|
|
|
|
77
|
|
|
|
|
|
/* if user wants control of gprof profiling off by default */ |
78
|
|
|
|
|
|
/* noop unless Configure is given -Accflags=-DPERL_GPROF_CONTROL */ |
79
|
|
|
|
|
|
PERL_GPROF_MONCONTROL(0); |
80
|
|
|
|
|
|
|
81
|
|
|
|
|
|
#ifdef NO_ENV_ARRAY_IN_MAIN |
82
|
|
|
|
|
|
PERL_SYS_INIT3(&argc,&argv,&environ); |
83
|
|
|
|
|
|
#else |
84
|
20310
|
|
|
|
|
PERL_SYS_INIT3(&argc,&argv,&env); |
85
|
|
|
|
|
|
#endif |
86
|
|
|
|
|
|
|
87
|
|
|
|
|
|
#if defined(USE_ITHREADS) |
88
|
|
|
|
|
|
/* XXX Ideally, this should really be happening in perl_alloc() or |
89
|
|
|
|
|
|
* perl_construct() to keep libperl.a transparently fork()-safe. |
90
|
|
|
|
|
|
* It is currently done here only because Apache/mod_perl have |
91
|
|
|
|
|
|
* problems due to lack of a call to cancel pthread_atfork() |
92
|
|
|
|
|
|
* handlers when shared objects that contain the handlers may |
93
|
|
|
|
|
|
* be dlclose()d. This forces applications that embed perl to |
94
|
|
|
|
|
|
* call PTHREAD_ATFORK() explicitly, but if and only if it hasn't |
95
|
|
|
|
|
|
* been called at least once before in the current process. |
96
|
|
|
|
|
|
* --GSAR 2001-07-20 */ |
97
|
|
|
|
|
|
PTHREAD_ATFORK(Perl_atfork_lock, |
98
|
|
|
|
|
|
Perl_atfork_unlock, |
99
|
|
|
|
|
|
Perl_atfork_unlock); |
100
|
|
|
|
|
|
#endif |
101
|
|
|
|
|
|
|
102
|
20310
|
50
|
|
|
|
if (!PL_do_undump) { |
103
|
20310
|
|
|
|
|
my_perl = perl_alloc(); |
104
|
20310
|
50
|
|
|
|
if (!my_perl) |
105
|
0
|
|
|
|
|
exit(1); |
106
|
20310
|
|
|
|
|
perl_construct(my_perl); |
107
|
20310
|
|
|
|
|
PL_perl_destruct_level = 0; |
108
|
|
|
|
|
|
} |
109
|
20310
|
|
|
|
|
PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
110
|
20310
|
|
|
|
|
exitstatus = perl_parse(my_perl, xs_init, argc, argv, (char **)NULL); |
111
|
20310
|
100
|
|
|
|
if (!exitstatus) |
112
|
19941
|
|
|
|
|
perl_run(my_perl); |
113
|
|
|
|
|
|
|
114
|
|
|
|
|
|
#ifndef PERL_MICRO |
115
|
|
|
|
|
|
/* Unregister our signal handler before destroying my_perl */ |
116
|
1391415
|
100
|
|
|
|
for (i = 1; PL_sig_name[i]; i++) { |
117
|
1381080
|
100
|
|
|
|
if (rsignal_state(PL_sig_num[i]) == (Sighandler_t) PL_csighandlerp) { |
118
|
708
|
|
|
|
|
rsignal(PL_sig_num[i], (Sighandler_t) SIG_DFL); |
119
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
#endif |
122
|
|
|
|
|
|
|
123
|
20310
|
|
|
|
|
exitstatus = perl_destruct(my_perl); |
124
|
|
|
|
|
|
|
125
|
20306
|
|
|
|
|
perl_free(my_perl); |
126
|
|
|
|
|
|
|
127
|
|
|
|
|
|
#if defined(USE_ENVIRON_ARRAY) && defined(PERL_TRACK_MEMPOOL) && !defined(NO_ENV_ARRAY_IN_MAIN) |
128
|
|
|
|
|
|
/* |
129
|
|
|
|
|
|
* The old environment may have been freed by perl_free() |
130
|
|
|
|
|
|
* when PERL_TRACK_MEMPOOL is defined, but without having |
131
|
|
|
|
|
|
* been restored by perl_destruct() before (this is only |
132
|
|
|
|
|
|
* done if destruct_level > 0). |
133
|
|
|
|
|
|
* |
134
|
|
|
|
|
|
* It is important to have a valid environment for atexit() |
135
|
|
|
|
|
|
* routines that are eventually called. |
136
|
|
|
|
|
|
*/ |
137
|
|
|
|
|
|
environ = env; |
138
|
|
|
|
|
|
#endif |
139
|
|
|
|
|
|
|
140
|
20306
|
|
|
|
|
PERL_SYS_TERM(); |
141
|
|
|
|
|
|
|
142
|
|
|
|
|
|
#ifdef PERL_GLOBAL_STRUCT |
143
|
|
|
|
|
|
free_global_struct(my_vars); |
144
|
|
|
|
|
|
# ifdef PERL_GLOBAL_STRUCT_PRIVATE |
145
|
|
|
|
|
|
my_plvarsp = NULL; |
146
|
|
|
|
|
|
/* Remember, functions registered with atexit() can run after this point, |
147
|
|
|
|
|
|
and may access "global" variables, and hence end up calling |
148
|
|
|
|
|
|
Perl_GetVarsPrivate() */ |
149
|
|
|
|
|
|
#endif |
150
|
|
|
|
|
|
#endif /* PERL_GLOBAL_STRUCT */ |
151
|
|
|
|
|
|
|
152
|
20306
|
|
|
|
|
exit(exitstatus); |
153
|
|
|
|
|
|
return exitstatus; |
154
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
156
|
|
|
|
|
|
/* Register any extra external extensions */ |
157
|
|
|
|
|
|
|
158
|
|
|
|
|
|
EXTERN_C void boot_DynaLoader (pTHX_ CV* cv); |
159
|
|
|
|
|
|
|
160
|
|
|
|
|
|
static void |
161
|
20192
|
|
|
|
|
xs_init(pTHX) |
162
|
|
|
|
|
|
{ |
163
|
|
|
|
|
|
static const char file[] = __FILE__; |
164
|
|
|
|
|
|
dXSUB_SYS; |
165
|
|
|
|
|
|
PERL_UNUSED_CONTEXT; |
166
|
|
|
|
|
|
|
167
|
|
|
|
|
|
/* DynaLoader is a special case */ |
168
|
20192
|
|
|
|
|
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); |
169
|
20192
|
|
|
|
|
} |