summaryrefslogtreecommitdiff
path: root/miniperlmain.c
Commit message (Collapse)AuthorAgeFilesLines
* perl.c - move PL_restartop assert out of perl_run()Yves Orton2022-11-301-1/+22
| | | | | | | | | | | | | | | | | | | | | | | In dd66b1d793 we added an assert to perl_run() that PL_restartop should never be true when perl_run() is called after perl_parse(). Looked at from the point of the internals, which calls perl_parse() and perl_run() exactly once, this made sense. It turns out however that there is at least one XS module out there that expects to be able to set PL_restartop and then call perl_run(). If that works out for them then we shouldn't block it, as we aren't really trying to say "perl_run() should never be called with PL_restartop set" (at least this assert wasn't trying to say that really), we are trying to assert "between the top level transition from perl_parse() to perl_run() we shouldnt leak any PL_restartop". One could argue the assert maybe should go at the end of perl_parse(), but I chose to put it in Miniperl.pm and thus into perlmain.c and miniperlmain.c as I am not certain that perl_parse() should never be called with PL_restartop set already, and putting it in the main code really does more closely reflect the intent of this assert anyway. This was reported as Blead Breaks CPAN Github Issue #20557.
* make PERL_USE_SAFE_PUTENV the default and the only optionTomasz Konojacki2022-05-291-16/+0
| | | | | | | Now environ isn't owned by Perl and calling setenv/putenv in XS code will no longer result in memory corruption. Fixes #19399
* Remove PERL_GLOBAL_STRUCTDagfinn Ilmari Mannsåker2020-07-201-31/+0
| | | | | | | | This was originally added for MinGW, which no longer needs it, and only still used by Symbian, which is now removed. This also leaves perlapi.[ch] empty, but we keep the header for CPAN backwards compatibility.
* get MakeMaker to play under PERL_GLOBAL_STRUCTDavid Mitchell2019-02-191-1/+6
| | | | | | | | | | | | | Under PERL_GLOBAL_STRUCT (well, actually I've only tried under PERL_GLOBAL_STRUCT_PRIVATE), cpan/ExtUtils-MakeMaker/t/03-xsstatic.t was failing some tests. This was because it was creating a statically-linked perl binary, but wasn't compiling perlmain.c with -DPERL_CORE. Usually this doesn't matter, but under PERL_GLOBAL_STRUCT it needed a definition of aTHX which it was pulling from XSUB.h rather than perl.h, causing a SEGV. Until a proper fix makes it way into MakeMaker, explicitly define PERL_CORE in perlmain.c
* fix up faulty perl embeddingsZefram2017-12-211-2/+1
| | | | | | | | | | | | Some platform-specific embeddings of perl were misusing the return values from perl_parse() and perl_run(), in some cases causing failure due to exit(0) combined with the recent changes in commit 0301e899536a22752f40481d8a1d141b7a7dda82. Commit d4a50999a5525c2681d59cae5fcd94f94ff897fd partially fixed a Windows embedding. More fully fix that, along with NetWare and OS/2. Even in embeddings with correct logic, stop using a variable named "exitstatus" to hold the result of perl_parse() or perl_run(), to avoid misleading people who copy the code.
* better document Miniperl.pm, (mini)perlmain.cDavid Mitchell2016-06-171-3/+10
| | | | | | | | ExtUtils::Miniperl is used to generate both miniperlmain.c and perlmain.c, but in different ways (via regen and via make respectively). Update the pod in Miniperl.pm to explain this more clearly, and imporve the header comment it emits in miniperlmain.c and perlmain.c.
* Tru64: introduce PERL_SYS_FPU_INIT, use it.Jarkko Hietaniemi2014-09-261-0/+2
| | | | | | | In Tru64 the cc -ieee enables the IEEE math but disables traps. We need to reenable the "invalid" trap because otherwise generation of NaN values leaves the IEEE fp flags in bad state, leaving any further fp ops behaving strangely (Inf + 1 resulting in zero, for example).
* Some low-hanging -Wunreachable-code fruits.Jarkko Hietaniemi2014-06-151-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | - after return/croak/die/exit, return/break are pointless (break is not a terminator/separator, it's a goto) - after goto, another goto (!) is pointless - in some cases (usually function ends) introduce explicit NOT_REACHED to make the noreturn nature clearer (do not do this everywhere, though, since that would mean adding NOT_REACHED after every croak) - for the added NOT_REACHED also add /* NOTREACHED */ since NOT_REACHED is for gcc (and VC), while the comment is for linters - declaring variables in switch blocks is just too fragile: it kind of works for narrowing the scope (which is nice), but breaks the moment there are initializations for the variables (the initializations will be skipped since the flow will bypass the start of the block); in some easy cases simply hoist the declarations out of the block and move them earlier Note 1: Since after this patch the core is not yet -Wunreachable-code clean, not enabling that via cflags.SH, one needs to -Accflags=... it. Note 2: At least with the older gcc 4.4.7 there are far too many "unreachable code" warnings, which seem to go away with gcc 4.8, maybe better flow control analysis. Therefore, the warning should eventually be enabled only for modernish gccs (what about clang and Intel cc?)
* Revert "Some low-hanging -Wunreachable-code fruits."Jarkko Hietaniemi2014-06-131-0/+1
| | | | | | | This reverts commit 8c2b19724d117cecfa186d044abdbf766372c679. I don't understand - smoke-me came back happy with three separate reports... oh well, some other time.
* Some low-hanging -Wunreachable-code fruits.Jarkko Hietaniemi2014-06-131-1/+0
| | | | | | | | | | | | | | | | | | - after croak/die/exit (or return), break (or return!) are pointless (break is not a terminator/separator, it's a promise of a jump) - after goto, another goto (!) is pointless - in some cases (usually function ends) introduce explicit NOT_REACHED to make the noreturn nature clearer (do not do this everywhere, though, since that would mean adding NOT_REACHED after every croak) - for the added NOT_REACHED also add /* NOTREACHED */ since NOT_REACHED is for gcc (and VC), while the comment is for linters - declaring variables in switch blocks is just too fragile: it kind of works for narrowing the scope (which is nice), but breaks the moment there are initializations for the variables (they will be skipped!); in some easy cases simply hoist the declarations out of the block and move them earlier There are still a few places left.
* my_plvarsp nulling and PERL_GLOBAL_STRUCT_PRIVATEDavid Mitchell2014-04-241-1/+7
| | | | | | | | | | | | | | | | | | | With PERL_GLOBAL_STRUCT_PRIVATE, all "global" vars are in a malloc()d structure pointed to by the static var my_plvarsp. At exit, this struct is freed and my_plvarsp is set to NULL. My previous commit c1181d2b skipped the free if PL_veto_cleanup is set (as it would be if other threads are still running for example), but still left my_plvarsp getting set to NULL. Thus other threads could still deref a null pointer if they accessed a "global" var just as the main thread was exiting. This commit makes the veto skip the NULLing in addition to the freeing. This commit is quite late into the code freeze, but it's a follow-up to the earlier attempt to get smokes not to fail, and all the affected code is within #ifdef PERL_GLOBAL_STRUCT_PRIVATE, so it shouldn't affect mainstream builds at all. (Famous last words.)
* For -DPERL_GLOBAL_STRUCT, eliminate local variable plvarsp in main().Nicholas Clark2013-07-121-4/+3
|
* Fix SEGVs and test failures for -DPERL_GLOBAL_STRUCT_PRIVATENicholas Clark2013-07-121-0/+6
| | | | | | | | | | | | | With PERL_GLOBAL_STRUCT_PRIVATE "global" variables are in a structure in malloc()ed memory, not in global static variables or a global static structure. Hence no global variables are implicitly initialised to zero. * PL_curinterp and PL_op_sequence need initialising to NULL * The global structure is free()d before handlers registered with atexit() run, so be defensive about this. * Some C code checks SvOK(PL_sv_placeholder) so ensure that its SvFLAGS() are 0. * Zero PL_hash_seed
* Refactor ExtUtils::Miniperl to use ExtUtils::Embed.Nicholas Clark2013-07-091-2/+1
| | | | | | | | There is now only one copy of Perl code to generate the C for an xsinit() function. This also eliminates ExtUtils::Miniperl::canon(), which was not exported, and is no longer needed.
* Move the "editor block" from miniperlmain.c to ExtUtils::MiniperlNicholas Clark2013-07-071-9/+7
| | | | | | | As miniperlmain.c is now generated by ExtUtils::Miniperl (and not the other way round), there's no reason to have an editor block in the generated file, as it's not intended to be edited. Instead, add the "generated from" and read-only headers to miniperlmain.c
* Clean up ExtUtils::MiniperlNicholas Clark2013-07-071-1/+1
| | | | | | | | | Give it a $VERSION. Bring the joy of strict (and warnings) to it. Inline the C code into writemain() instead of using $head, $tail and a regex to split the $tail into $tail1, $tail2 and $tail3. Tweak the NAME section so that ABSTRACT_FROM parses it. Document the updated functionality of writemain().
* Invert the build logic for miniperlmain.c and ExtUtils::MiniperlNicholas Clark2013-07-071-2/+2
| | | | | | | | | | | | | Now ExtUtils::Miniperl has the master version of {mini,}perlmain.c and is checked into the repository. miniperlmain.c is now generated by a script in regen/ which uses ExtUtils::Miniperl. Tweak ExtUtils::Miniperl::writemain() to take an optional first argument, a reference to a file handle. This permits the regen script to use the regen_lib.pl functions for file opening/closing/renaming and TAP generation. For now check in ExtUtils::Miniperl minimally modified from the version generated by the former minimod.pl. The next commit will tidy it up.
* release the global struct *after* we've finished using itTony Cook2013-01-251-2/+2
|
* Remove dead code related to the Atari ST port of perl 4.0 patchlevel 19Nicholas Clark2012-07-281-6/+0
| | | | | The subdirectory containing the port specific files was purged when 5.000 was released, but changes made to other files were not removed.
* do not try to restore state of pseudosignal zeroChip Salzenberg2012-06-221-1/+1
|
* update the editor hints for spaces, not tabsRicardo Signes2012-05-291-2/+2
| | | | | This updates the editor hints in our files for Emacs and vim to request that tabs be inserted as spaces.
* Change PL_use_safe_putenv from int to bool.Nicholas Clark2011-06-121-1/+1
| | | | | It is only ever checked for truth/falsehood, and all assignments to it (in core and on CPAN) are either 0 or 1.
* Microperl doesn't do signal handlers, ifdef some handling codeDavid Leadbeater2011-03-281-0/+2
|
* [perl #81500] Make compilation work when NO_ENV_ARRAY_IN_MAIN is definedDavid Leadbeater2011-01-021-1/+3
| | | | | | This is only normally defined if OEMVS is defined; the commit that added it (2f3efc97) claims z/OS support. I guess no-one has tried this for awhile as dd374669 broke this in 2005.
* Remove the port to MiNT. It's a dead platform that hasn't had any love ↵Jesse Vincent2009-08-031-1/+1
| | | | since 5.005
* main: Unregister signal handler before destroying my_perlJohn Wright2009-06-071-1/+8
| | | | | | | | If the signal handler runs after perl_destruct() has been called, it will get an invalid (or NULL) my_perl when it asks for the thread-specific interpreter struct. This patch resets the signal handler for any signal previously handled by PL_csighandlerp to SIG_DFL before calling perl_destruct().
* PATCH: Large omnibus patch to clean up the JRRT quotesTom Christiansen2008-11-021-1/+5
| | | | | | Message-ID: <25940.1225611819@chthon> Date: Sun, 02 Nov 2008 01:43:39 -0600 p4raw-id: //depot/perl@34698
* Fix up copyright years for files modified in 2007.Nicholas Clark2007-11-071-1/+1
| | | p4raw-id: //depot/perl@32237
* Update copyright years in .c filesRafael Garcia-Suarez2007-01-051-1/+1
| | | p4raw-id: //depot/perl@29696
* z/OS: non-CPAN ext and lib + main() without the third arg + Stephen ↵Jarkko Hietaniemi2006-07-131-1/+11
| | | | | | | McCamant's comment Message-ID: <44B67921.6090901@iki.fi> p4raw-id: //depot/perl@28567
* PERL_TRACK_MEMPOOL cripples environment after exit()Marcus Holland-Moritz2006-02-271-1/+14
| | | | | Message-ID: <20060226204721.00be2bff@r2d2> p4raw-id: //depot/perl@27343
* unused context warningsAndy Lester2006-02-241-0/+1
| | | | | Message-ID: <20060221062711.GA16160@petdance.com> p4raw-id: //depot/perl@27300
* Include vim/emacs modelines in generated files to open themRafael Garcia-Suarez2005-05-111-2/+2
| | | | | | in read-only mode. Make vi modelines compatible with non-vim vi versions. p4raw-id: //depot/perl@24445
* Add editor boilerplates to all C filesRafael Garcia-Suarez2005-05-101-0/+10
| | | | | (except the generated ones) p4raw-id: //depot/perl@24440
* Symbian port of PerlJarkko Hietaniemi2005-04-211-12/+20
| | | | | Message-ID: <B356D8F434D20B40A8CEDAEC305A1F2453D653@esebe105.NOE.Nokia.com> p4raw-id: //depot/perl@24271
* Update copyrights.Rafael Garcia-Suarez2005-03-301-1/+1
| | | p4raw-id: //depot/perl@24106
* Consting fiveAndy Lester2005-03-251-0/+1
| | | | | | | | Message-ID: <20050325231409.GB17660@petdance.com> [with modification - the extra argument to incpush was supposed to be being used] p4raw-id: //depot/perl@24081
* Update copyright years.Nicholas Clark2005-01-041-2/+2
| | | p4raw-id: //depot/perl@23746
* SuSE's perl safe_putenf diffMichael Schroeder2004-11-171-0/+3
| | | | | | | | | Message-ID: <20041111145443.GA1854@immd4.informatik.uni-erlangen.de> slightly reworked to make the PL_use_safe_putenv variable fit in the current framework. This patch turns on the use of safe putenv for any application that embeds a perl interpreter. p4raw-id: //depot/perl@23507
* more typo fixes for change 3176 (comments at top of .c files)Dave Mitchell2004-08-031-2/+2
| | | p4raw-id: //depot/perl@23187
* Add comment to top of reentr.c and fix typos in other filesDave Mitchell2004-08-011-2/+2
| | | p4raw-id: //depot/perl@23180
* Add comment to the top of most .c files explaining their purposeDave Mitchell2004-07-311-0/+9
| | | p4raw-id: //depot/perl@23176
* Move the PL_earlytaint initialization to the PERL_SYS_INIT()Jarkko Hietaniemi2003-06-291-3/+0
| | | | | as per suggestion from Sarathy. p4raw-id: //depot/perl@19878
* Introduce (global) variable PL_earlytaint whichJarkko Hietaniemi2003-06-271-0/+3
| | | | | | | is set very early in main(), before perl_parse() has been called and PL_tainting (or PL_taint_warn) might have been set. p4raw-id: //depot/perl@19863
* Fix up Larry's copyright statements to my best knowledge.Jarkko Hietaniemi2003-04-161-1/+2
| | | | | | | (Lots of Perl 5 source code archaeology was involved.) Larry didn't make strangled noises when I showed him the patch, either :-) p4raw-id: //depot/perl@19242
* Reverse copyright update (#18801) for files not changed in 2003.Hugo van der Sanden2003-03-021-1/+1
| | | p4raw-id: //depot/perl@18807
* Update all copyrights to 2003, from JarkkoHugo van der Sanden2003-03-021-1/+1
| | | p4raw-id: //depot/perl@18801
* Happy chainsaw stories; The removal of the 5005 threadsH.Merijn Brand2002-10-191-1/+1
| | | | | Still imcomplete. Configure will follow p4raw-id: //depot/perl@18030
* Sprinkle some copyrights (use the oldest timestamp toJarkko Hietaniemi2002-01-241-0/+9
| | | | | | be found in the repository, which is most often not right, but at least consistent) p4raw-id: //depot/perl@14400
* Oh, bother. In Tru64 cc -std1 was looking rather niceJarkko Hietaniemi2001-10-171-13/+2
| | | | | | | | | | in speed (upto 20% speedup in certain operations) but meanwhile regexps and arithmetics got slower (5-10%) (according to perlbench average speedup is negligible, and within measuring flutter, 1%). Therefore retracting all the changes aimed at getting -std1 to compile cleanly: #12475, #12476, #12479, #12480, #12481, #12482, #12483, #12484. p4raw-id: //depot/perl@12485