X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/148f39b7de6eae9ddd59e0b0aff691d6abea7aca..0fbfbb97fd8bda2b2f51041f575b8e41691c21f0:/perl.c diff --git a/perl.c b/perl.c index 012d94f..eb875fc 100644 --- a/perl.c +++ b/perl.c @@ -325,7 +325,6 @@ perl_construct(pTHXx) PL_stashcache = newHV(); PL_patchlevel = newSVpvs("v" PERL_VERSION_STRING); - PL_apiversion = newSVpvs("v" PERL_API_VERSION_STRING); #ifdef HAS_MMAP if (!PL_mmap_page_size) { @@ -546,7 +545,12 @@ perl_destruct(pTHXx) { const char * const s = PerlEnv_getenv("PERL_DESTRUCT_LEVEL"); if (s) { - const int i = atoi(s); + int i; + if (strEQ(s, "-1")) { /* Special case: modperl folklore. */ + i = -1; + } else { + i = grok_atou(s, NULL); + } #ifdef DEBUGGING if (destruct_level < i) destruct_level = i; #endif @@ -901,7 +905,6 @@ perl_destruct(pTHXx) Safefree(PL_inplace); PL_inplace = NULL; SvREFCNT_dec(PL_patchlevel); - SvREFCNT_dec(PL_apiversion); if (PL_e_script) { SvREFCNT_dec(PL_e_script); @@ -963,6 +966,9 @@ perl_destruct(pTHXx) PL_DBsingle = NULL; PL_DBtrace = NULL; PL_DBsignal = NULL; + PL_DBsingle_iv = 0; + PL_DBtrace_iv = 0; + PL_DBsignal_iv = 0; PL_DBcv = NULL; PL_dbargs = NULL; PL_debstash = NULL; @@ -1029,6 +1035,7 @@ perl_destruct(pTHXx) SvREFCNT_dec(PL_utf8_foldable); SvREFCNT_dec(PL_utf8_foldclosures); SvREFCNT_dec(PL_AboveLatin1); + SvREFCNT_dec(PL_InBitmap); SvREFCNT_dec(PL_UpperLatin1); SvREFCNT_dec(PL_Latin1); SvREFCNT_dec(PL_NonL1NonFinalFold); @@ -1042,6 +1049,7 @@ perl_destruct(pTHXx) PL_utf8_idcont = NULL; PL_utf8_foldclosures = NULL; PL_AboveLatin1 = NULL; + PL_InBitmap = NULL; PL_HasMultiCharFold = NULL; PL_Latin1 = NULL; PL_NonL1NonFinalFold = NULL; @@ -1356,8 +1364,11 @@ perl_free(pTHXx) "free this thread's memory\n"); PL_debug &= ~ DEBUG_m_FLAG; } - while(aTHXx->Imemory_debug_header.next != &(aTHXx->Imemory_debug_header)) - safesysfree(PERL_MEMORY_DEBUG_HEADER_SIZE + (char *)(aTHXx->Imemory_debug_header.next)); + while(aTHXx->Imemory_debug_header.next != &(aTHXx->Imemory_debug_header)){ + char * next = (char *)(aTHXx->Imemory_debug_header.next); + Malloc_t ptr = PERL_MEMORY_DEBUG_HEADER_SIZE + next; + safesysfree(ptr); + } PL_debug = old_debug; } } @@ -1415,7 +1426,6 @@ perl_fini(void) void Perl_call_atexit(pTHX_ ATEXIT_t fn, void *ptr) { - dVAR; Renew(PL_exitlist, PL_exitlistlen+1, PerlExitListEntry); PL_exitlist[PL_exitlistlen].fn = fn; PL_exitlist[PL_exitlistlen].ptr = ptr; @@ -1452,7 +1462,7 @@ perl_parse(pTHXx_ XSINIT_t xsinit, int argc, char **argv, char **env) { const char * const s = PerlEnv_getenv("PERL_HASH_SEED_DEBUG"); - if (s && (atoi(s) == 1)) { + if (s && (grok_atou(s, NULL) == 1)) { unsigned char *seed= PERL_HASH_SEED; unsigned char *seed_end= PERL_HASH_SEED + PERL_HASH_SEED_BYTES; PerlIO_printf(Perl_debug_log, "HASH_FUNCTION = %s HASH_SEED = 0x", PERL_HASH_FUNC); @@ -2066,9 +2076,10 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) it should be reported immediately as a build failure. */ (void)Perl_av_create_and_unshift_one(aTHX_ &PL_preambleav, Perl_newSVpvf(aTHX_ - "BEGIN { do {local $!; -f q%c%"SVf"/buildcustomize.pl%c} and do q%c%"SVf"/buildcustomize.pl%c || die $@ }", - 0, SVfARG(*inc0), 0, - 0, SVfARG(*inc0), 0)); + "BEGIN { my $f = q%c%s%"SVf"/buildcustomize.pl%c; " + "do {local $!; -f $f }" + " and do $f || die $@ || qq '$f: $!' }", + 0, (TAINTING_get ? "./" : ""), SVfARG(*inc0), 0)); } # else /* SITELIB_EXP is a function call on Win32. */ @@ -2152,7 +2163,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) PL_main_cv = PL_compcv = MUTABLE_CV(newSV_type(SVt_PVCV)); CvUNIQUE_on(PL_compcv); - CvPADLIST(PL_compcv) = pad_new(0); + CvPADLIST_set(PL_compcv, pad_new(0)); PL_isarev = newHV(); @@ -2286,8 +2297,8 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) #ifdef MYMALLOC { const char *s; - if ((s=PerlEnv_getenv("PERL_DEBUG_MSTATS")) && atoi(s) >= 2) - dump_mstats("after compilation:"); + if ((s=PerlEnv_getenv("PERL_DEBUG_MSTATS")) && grok_atou(s, NULL) >= 2) + dump_mstats("after compilation:"); } #endif @@ -2308,7 +2319,6 @@ Tells a Perl interpreter to run. See L. int perl_run(pTHXx) { - dVAR; I32 oldscope; int ret = 0; dJMPENV; @@ -2366,7 +2376,6 @@ perl_run(pTHXx) STATIC void S_run_body(pTHX_ I32 oldscope) { - dVAR; DEBUG_r(PerlIO_printf(Perl_debug_log, "%s $` $& $' support (0x%x).\n", PL_sawampersand ? "Enabling" : "Omitting", (unsigned int)(PL_sawampersand))); @@ -2384,7 +2393,7 @@ S_run_body(pTHX_ I32 oldscope) my_exit(0); } if (PERLDB_SINGLE && PL_DBsingle) - sv_setiv(PL_DBsingle, 1); + PL_DBsingle_iv = 1; if (PL_initav) { PERL_SET_PHASE(PERL_PHASE_INIT); call_list(oldscope, PL_initav); @@ -2411,8 +2420,7 @@ S_run_body(pTHX_ I32 oldscope) CALLRUNOPS(aTHX); } my_exit(0); - /* NOTREACHED */ - assert(0); + assert(0); /* NOTREACHED */ } /* @@ -2567,7 +2575,6 @@ Perl_call_argv(pTHX_ const char *sub_name, I32 flags, char **argv) /* See G_* flags in cop.h */ /* null terminated arg list */ { - dVAR; dSP; PERL_ARGS_ASSERT_CALL_ARGV; @@ -2643,8 +2650,7 @@ Perl_call_sv(pTHX_ SV *sv, VOL I32 flags) { dVAR; dSP; LOGOP myop; /* fake syntax tree node */ - UNOP method_unop; - SVOP method_svop; + METHOP method_op; I32 oldmark; VOL I32 retval = 0; I32 oldscope; @@ -2688,23 +2694,19 @@ Perl_call_sv(pTHX_ SV *sv, VOL I32 flags) myop.op_private |= OPpENTERSUB_DB; if (flags & (G_METHOD|G_METHOD_NAMED)) { + Zero(&method_op, 1, METHOP); + method_op.op_next = (OP*)&myop; + PL_op = (OP*)&method_op; if ( flags & G_METHOD_NAMED ) { - Zero(&method_svop, 1, SVOP); - method_svop.op_next = (OP*)&myop; - method_svop.op_ppaddr = PL_ppaddr[OP_METHOD_NAMED]; - method_svop.op_type = OP_METHOD_NAMED; - method_svop.op_sv = sv; - PL_op = (OP*)&method_svop; + method_op.op_ppaddr = PL_ppaddr[OP_METHOD_NAMED]; + method_op.op_type = OP_METHOD_NAMED; + method_op.op_u.op_meth_sv = sv; } else { - Zero(&method_unop, 1, UNOP); - method_unop.op_next = (OP*)&myop; - method_unop.op_ppaddr = PL_ppaddr[OP_METHOD]; - method_unop.op_type = OP_METHOD; - PL_op = (OP*)&method_unop; + method_op.op_ppaddr = PL_ppaddr[OP_METHOD]; + method_op.op_type = OP_METHOD; } myop.op_ppaddr = PL_ppaddr[OP_ENTERSUB]; myop.op_type = OP_ENTERSUB; - } if (!(flags & G_EVAL)) { @@ -2739,8 +2741,7 @@ Perl_call_sv(pTHX_ SV *sv, VOL I32 flags) FREETMPS; JMPENV_POP; my_exit_jump(); - /* NOTREACHED */ - assert(0); + assert(0); /* NOTREACHED */ case 3: if (PL_restartop) { PL_restartjmpenv = NULL; @@ -2849,8 +2850,7 @@ Perl_eval_sv(pTHX_ SV *sv, I32 flags) FREETMPS; JMPENV_POP; my_exit_jump(); - /* NOTREACHED */ - assert(0); + assert(0); /* NOTREACHED */ case 3: if (PL_restartop) { PL_restartjmpenv = NULL; @@ -2883,7 +2883,7 @@ Perl_eval_sv(pTHX_ SV *sv, I32 flags) /* =for apidoc p||eval_pv -Tells Perl to C the given string and return an SV* result. +Tells Perl to C the given string in scalar context and return an SV* result. =cut */ @@ -2891,7 +2891,6 @@ Tells Perl to C the given string and return an SV* result. SV* Perl_eval_pv(pTHX_ const char *p, I32 croak_on_error) { - dVAR; SV* sv = newSVpv(p, 0); PERL_ARGS_ASSERT_EVAL_PV; @@ -2932,7 +2931,6 @@ implemented that way; consider using load_module instead. void Perl_require_pv(pTHX_ const char *pv) { - dVAR; dSP; SV* sv; @@ -3051,7 +3049,10 @@ Perl_get_debug_opts(pTHX_ const char **s, bool givehelp) } } else if (isDIGIT(**s)) { - i = atoi(*s); + const char* e; + i = grok_atou(*s, &e); + if (e) + *s = e; for (; isWORDCHAR(**s); (*s)++) ; } else if (givehelp) { @@ -3534,7 +3535,6 @@ Internet, point your browser at http://www.perl.org/, the Perl Home Page.\n\n"); void Perl_my_unexec(pTHX) { - PERL_UNUSED_CONTEXT; #ifdef UNEXEC SV * prog = newSVpv(BIN_EXP, 0); SV * file = newSVpv(PL_origfilename, 0); @@ -3548,10 +3548,11 @@ Perl_my_unexec(pTHX) /* unexec prints msg to stderr in case of failure */ PerlProc_exit(status); #else + PERL_UNUSED_CONTEXT; # ifdef VMS lib$signal(SS$_DEBUG); /* ssdef.h #included from vmsish.h */ # elif defined(WIN32) || defined(__CYGWIN__) - Perl_croak(aTHX_ "dump is not supported"); + Perl_croak_nocontext("dump is not supported"); # else ABORT(); /* for use with undump */ # endif @@ -3562,7 +3563,6 @@ Perl_my_unexec(pTHX) STATIC void S_init_interp(pTHX) { - dVAR; #ifdef MULTIPLICITY # define PERLVAR(prefix,var,type) # define PERLVARA(prefix,var,n,type) @@ -3595,7 +3595,6 @@ S_init_interp(pTHX) STATIC void S_init_main_stash(pTHX) { - dVAR; GV *gv; PL_curstash = PL_defstash = (HV *)SvREFCNT_inc_simple_NN(newHV()); @@ -3647,7 +3646,6 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, bool *suidscript) { int fdscript = -1; PerlIO *rsfp = NULL; - dVAR; Stat_t tmpstatbuf; int fd; @@ -3662,9 +3660,9 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, bool *suidscript) if (strnEQ(scriptname, "/dev/fd/", 8) && isDIGIT(scriptname[8]) ) { const char *s = scriptname + 8; - fdscript = atoi(s); - while (isDIGIT(*s)) - s++; + const char* e; + fdscript = grok_atou(s, &e); + s = e; if (*s) { /* PSz 18 Feb 04 * Tell apart "normal" usage of fdscript, e.g. @@ -3824,7 +3822,6 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n"); STATIC void S_find_beginning(pTHX_ SV* linestr_sv, PerlIO *rsfp) { - dVAR; const char *s; const char *s2; @@ -3857,12 +3854,13 @@ S_init_ids(pTHX) /* no need to do anything here any more if we don't * do tainting. */ #ifndef NO_TAINT_SUPPORT - dVAR; const Uid_t my_uid = PerlProc_getuid(); const Uid_t my_euid = PerlProc_geteuid(); const Gid_t my_gid = PerlProc_getgid(); const Gid_t my_egid = PerlProc_getegid(); + PERL_UNUSED_CONTEXT; + /* Should not happen: */ CHECK_MALLOC_TAINT(my_uid && (my_euid != my_uid || my_egid != my_gid)); TAINTING_set( TAINTING_get | (my_uid && (my_euid != my_uid || my_egid != my_gid)) ); @@ -3910,7 +3908,7 @@ Perl_doing_taint(int argc, char *argv[], char *envp[]) * if -T are the first chars together; otherwise one gets * "Too late" message. */ if ( argc > 1 && argv[1][0] == '-' - && (argv[1][1] == 't' || argv[1][1] == 'T') ) + && isALPHA_FOLD_EQ(argv[1][1], 't')) return 1; return 0; } @@ -3922,10 +3920,10 @@ Perl_doing_taint(int argc, char *argv[], char *envp[]) STATIC void S_forbid_setid(pTHX_ const char flag, const bool suidscript) /* g */ { - dVAR; char string[3] = "-x"; const char *message = "program input from stdin"; + PERL_UNUSED_CONTEXT; if (flag) { string[1] = flag; message = string; @@ -3962,8 +3960,8 @@ Perl_init_dbargs(pTHX) void Perl_init_debugger(pTHX) { - dVAR; HV * const ostash = PL_curstash; + MAGIC *mg; PL_curstash = (HV *)SvREFCNT_inc_simple(PL_debstash); @@ -3980,12 +3978,24 @@ Perl_init_debugger(pTHX) PL_DBsingle = GvSV((gv_fetchpvs("DB::single", GV_ADDMULTI, SVt_PV))); if (!SvIOK(PL_DBsingle)) sv_setiv(PL_DBsingle, 0); + mg = sv_magicext(PL_DBsingle, NULL, PERL_MAGIC_debugvar, &PL_vtbl_debugvar, 0, 0); + mg->mg_private = DBVARMG_SINGLE; + SvSETMAGIC(PL_DBsingle); + PL_DBtrace = GvSV((gv_fetchpvs("DB::trace", GV_ADDMULTI, SVt_PV))); if (!SvIOK(PL_DBtrace)) sv_setiv(PL_DBtrace, 0); + mg = sv_magicext(PL_DBtrace, NULL, PERL_MAGIC_debugvar, &PL_vtbl_debugvar, 0, 0); + mg->mg_private = DBVARMG_TRACE; + SvSETMAGIC(PL_DBtrace); + PL_DBsignal = GvSV((gv_fetchpvs("DB::signal", GV_ADDMULTI, SVt_PV))); if (!SvIOK(PL_DBsignal)) sv_setiv(PL_DBsignal, 0); + mg = sv_magicext(PL_DBsignal, NULL, PERL_MAGIC_debugvar, &PL_vtbl_debugvar, 0, 0); + mg->mg_private = DBVARMG_SIGNAL; + SvSETMAGIC(PL_DBsignal); + SvREFCNT_dec(PL_curstash); PL_curstash = ostash; } @@ -4001,7 +4011,6 @@ Perl_init_debugger(pTHX) void Perl_init_stacks(pTHX) { - dVAR; /* start with 128-item stack and 8K cxstack */ PL_curstackinfo = new_stackinfo(REASONABLE(128), REASONABLE(8192/sizeof(PERL_CONTEXT) - 1)); @@ -4041,7 +4050,6 @@ Perl_init_stacks(pTHX) STATIC void S_nuke_stacks(pTHX) { - dVAR; while (PL_curstackinfo->si_next) PL_curstackinfo = PL_curstackinfo->si_next; while (PL_curstackinfo) { @@ -4097,7 +4105,6 @@ Perl_populate_isa(pTHX_ const char *name, STRLEN len, ...) STATIC void S_init_predump_symbols(pTHX) { - dVAR; GV *tmpgv; IO *io; @@ -4158,8 +4165,6 @@ S_init_predump_symbols(pTHX) void Perl_init_argv_symbols(pTHX_ int argc, char **argv) { - dVAR; - PERL_ARGS_ASSERT_INIT_ARGV_SYMBOLS; argc--,argv++; /* skip name of script */ @@ -4206,7 +4211,9 @@ Perl_init_argv_symbols(pTHX_ int argc, char **argv) STATIC void S_init_postdump_symbols(pTHX_ int argc, char **argv, char **env) { +#ifdef USE_ITHREADS dVAR; +#endif GV* tmpgv; PERL_ARGS_ASSERT_INIT_POSTDUMP_SYMBOLS; @@ -4283,7 +4290,6 @@ S_init_postdump_symbols(pTHX_ int argc, char **argv, char **env) STATIC void S_init_perllib(pTHX) { - dVAR; #ifndef VMS const char *perl5lib = NULL; #endif @@ -4489,7 +4495,6 @@ S_init_perllib(pTHX) STATIC SV * S_incpush_if_exists(pTHX_ AV *const av, SV *dir, SV *const stem) { - dVAR; Stat_t tmpstatbuf; PERL_ARGS_ASSERT_INCPUSH_IF_EXISTS; @@ -4644,7 +4649,6 @@ S_mayberelocate(pTHX_ const char *const dir, STRLEN len, U32 flags) STATIC void S_incpush(pTHX_ const char *const dir, STRLEN len, U32 flags) { - dVAR; #ifndef PERL_IS_MINIPERL const U8 using_sub_dirs = (U8)flags & (INCPUSH_ADD_VERSIONED_SUB_DIRS @@ -4803,7 +4807,6 @@ S_incpush_use_sep(pTHX_ const char *p, STRLEN len, U32 flags) void Perl_call_list(pTHX_ I32 oldscope, AV *paramList) { - dVAR; SV *atsv; volatile const line_t oldline = PL_curcop ? CopLINE(PL_curcop) : 0; CV *cv; @@ -4868,8 +4871,7 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList) CopLINE_set(PL_curcop, oldline); JMPENV_POP; my_exit_jump(); - /* NOTREACHED */ - assert(0); + assert(0); /* NOTREACHED */ case 3: if (PL_restartop) { PL_curcop = &PL_compiling; @@ -4887,7 +4889,6 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList) void Perl_my_exit(pTHX_ U32 status) { - dVAR; if (PL_exit_flags & PERL_EXIT_ABORT) { abort(); } @@ -4913,7 +4914,6 @@ Perl_my_exit(pTHX_ U32 status) void Perl_my_failure_exit(pTHX) { - dVAR; #ifdef VMS /* We have been called to fall on our sword. The desired exit code * should be already set in STATUS_UNIX, but could be shifted over @@ -5007,8 +5007,6 @@ Perl_my_failure_exit(pTHX) STATIC void S_my_exit_jump(pTHX) { - dVAR; - if (PL_e_script) { SvREFCNT_dec(PL_e_script); PL_e_script = NULL; @@ -5024,7 +5022,6 @@ S_my_exit_jump(pTHX) static I32 read_e_script(pTHX_ int idx, SV *buf_sv, int maxlen) { - dVAR; const char * const p = SvPVX_const(PL_e_script); const char *nl = strchr(p, '\n'); @@ -5041,6 +5038,15 @@ read_e_script(pTHX_ int idx, SV *buf_sv, int maxlen) return 1; } +/* removes boilerplate code at the end of each boot_Module xsub */ +void +Perl_xs_boot_epilog(pTHX_ const U32 ax) +{ + if (PL_unitcheckav) + call_list(PL_scopestack_ix, PL_unitcheckav); + XSRETURN_YES; +} + /* * Local variables: * c-indentation-style: bsd