summaryrefslogtreecommitdiff
path: root/embedvar.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove gete?[ug]id cachingÆvar Arnfjörð Bjarmason2012-02-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we cache the UID/GID and effective UID/GID similarly to how we used to cache getpid() before v5.14.0-251-g0e21945. Remove this magical behavior in favor of always calling getpid(), getgid() etc. This resolves RT #96208. A minimal testcase for this is the following by Leon Timmermans attached to RT #96208: eval { require 'syscall.ph'; 1 } or eval { require 'sys/syscall.ph'; 1 } or die $@; if (syscall(&SYS_setuid, $ARGV[0] + 0 || 1000) >= 0 or die "$!") { printf "\$< = %d, getuid = %d\n", $<, syscall(&SYS_getuid); } I.e. if we call the sete?[ug]id() functions unbeknownst to perl the $<, $>, $( and $) variables won't be updated. This results in the same sort of issues we had with $$ before v5.14.0-251-g0e21945, and getppid() before my v5.15.7-407-gd7c042c patch. I'm completely eliminating the PL_egid, PL_euid, PL_gid and PL_uid variables as part of this patch, this will break some CPAN modules, but it'll be really easy before the v5.16.0 final to reinstate them. I'd like to remove them to see what breaks, and how easy it is to fix it. These variables are not part of the public API, and the modules using them could either use the Perl_gete?[ug]id() functions or are working around the bug I'm fixing with this commit. The new PL_delaymagic_(egid|euid|gid|uid) variables I'm adding are *only* intended to be used internally in the interpreter to facilitate the delaymagic in Perl_pp_sassign. There's probably some way not to export these to programs that embed perl, but I haven't found out how to do that.
* perl #77654: quotemeta quotes non-ASCII consistentlyKarl Williamson2012-02-151-0/+1
| | | | | | | | | | As described in the pod changes in this commit, this changes quotemeta() to consistenly quote non-ASCII characters when used under unicode_strings. The behavior is changed for these and UTF-8 encoded strings to more closely align with Unicode's recommendations. The end result is that we *could* at some future point start using other characters as metacharacters than the 12 we do now.
* Further eliminate POSIX-emulation under LinuxThreadsÆvar Arnfjörð Bjarmason2012-02-151-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under POSIX threads the getpid() and getppid() functions return the same values across multiple threads, i.e. threads don't have their own PID's. This is not the case under the obsolete LinuxThreads where each thread has a different PID, so getpid() and getppid() will return different values across threads. Ever since the first perl 5.0 we've returned POSIX-consistent semantics for $$, until v5.14.0-251-g0e21945 when the getpid() cache was removed. In 5.8.1 Rafael added further explicit POSIX emulation in perl-5.8.0-133-g4d76a34 [1] by explicitly caching getppid(), so that multiple threads would always return the same value. I don't think all this effort to emulate POSIX sematics is worth it. I think $$ and getppid() are OS-level functions that should always return the same as their C equivalents. I shouldn't have to use a module like Linux::Pid to get the OS version of the return values. This is pretty much a complete non-issue in practice these days, LinuxThreads was a Linux 2.4 thread implementation that nobody maintains anymore[2], all modern Linux distros use NPTL threads which don't suffer from this discrepancy. Debian GNU/kFreeBSD does use LinuxThreads in the 6.0 release, but they too will be moving away from it in future releases, and really, nobody uses Debian GNU/kFreeBSD anyway. This caching makes it unnecessarily tedious to fork an embedded Perl interpreter. When someone that constructs an embedded perl interpreter and forks their application, the fork(2) system call isn't going to run Perl_pp_fork(), and thus the return value of $$ and getppid() doesn't reflect the current process. See [3] for a bug in uWSGI related to this, and Perl::AfterFork on the CPAN for XS code that you need to run after forking a PerlInterpreter unbeknownst to perl. We've already been failing the tests in t/op/getpid.t on these Linux systems that nobody apparently uses, the Debian GNU/kFreeBSD users did notice and filed #96270, this patch fixes that failure by changing the tests to test for different behavior under LinuxThreads, I've tested that this works on my Debian GNU/kFreeBSD 6.0.4 virtual machine. If this change is found to be unacceptable (i.e. we want to continue to emulate POSIX thread semantics for the sake of LinuxThreads) we also need to revert v5.14.0-251-g0e21945, because currently we're only emulating POSIX semantics for getppid(), not getpid(). But I don't think we should do that, both v5.14.0-251-g0e21945 and this commit are awesome. This commit includes a change to embedvar.h made by "make regen_headers". 1. http://www.nntp.perl.org/group/perl.perl5.porters/2002/08/msg64603.html 2. http://pauillac.inria.fr/~xleroy/linuxthreads/ 3. http://projects.unbit.it/uwsgi/ticket/85
* intrpvar.h: Rmv no longer used PL_ variableKarl Williamson2012-02-111-1/+0
| | | | | Commit 24caacbccae7b938deecdcc3f13dd66c9c6a684e removed all uses of this variable, but failed to remove it.
* regcomp.c: /[[:lower:]]/i should match the same as /\p{Lower}/iKarl Williamson2012-02-111-0/+1
| | | | | | Same for [[:upper:]] and \p{Upper}. These were matching instead all of [[:alpha:]] or \p{Alpha}. What /\p{Lower}/i and /\p{Upper}/i match instead is \p{Cased}, and so that is what these should match.
* add wrap_op_checker() API functionZefram2012-02-111-0/+2
| | | | | This function provides a convenient and thread-safe way for modules to hook op checking.
* Add compile-time inversion lists for POSIX classesKarl Williamson2012-02-091-0/+29
| | | | | | | | | | | | | | These will be used in regcomp.c to replace the existing bit-wise handling of these, enabling subsequent optimizations. These are compiled-in, and hence affect the memory footprint of every program, including those that don't use Unicode. The lists that aren't tiny are therefore currently restricted to only the Latin1 range; anything needed beyond that will have to be read in at execution time, just as before. The design allows for easy conversion from Latin1 to use the full Unicode range, should it be deemed desirable for some or all of these.
* regcomp.c: Use compile-time invlistsKarl Williamson2012-02-091-0/+3
| | | | | | This creates three simple compile-time inversion lists from the data that has been generated in a previous commit, and uses two of them. Three PL_ variables are used to store them.
* Fix CORE::globFather Chrysostomos2011-10-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This commit makes CORE::glob bypassing glob overrides. A side effect of the fix is that, with the default glob implementa- tion, undefining *CORE::GLOBAL::glob no longer results in an ‘unde- fined subroutine’ error. Another side effect is that compilation of a glob op no longer assumes that the loading of File::Glob will create the *CORE::GLOB::glob type- glob. ‘++$INC{"File/Glob.pm"}; sub File::Glob::csh_glob; eval '<*>';’ used to crash. This is accomplished using a mechanism similar to lock() and threads::shared. There is a new PL_globhook interpreter varia- ble that pp_glob calls when there is no override present. Thus, File::Glob (which is supposed to be transparent, as it *is* the built-in implementation) no longer interferes with the user mechanism for overriding glob. This removes one tier from the five or so hacks that constitute glob’s implementation, and which work together to make it one of the buggiest and most inconsistent areas of Perl.
* utf8.c: Add function to retrieve new _Perl_IDStart propKarl Williamson2011-10-011-0/+1
|
* Don't use swash to find cntrlsKarl Williamson2011-10-011-1/+0
| | | | | | | | | Unicode stability policy guarantees that no code points will ever be added to the control characters beyond those already in it. All such characters are in the Latin1 range, and so the Perl core already knows which ones those are, and so there is no need to go out to disk and create a swash for these.
* No need for swashes for properties that are ASCII-onlyKarl Williamson2011-10-011-3/+0
| | | | | | These three properties are restricted to being true only for ASCII characters. That information is compiled into Perl, so no need to create swashes for them.
* No need for swashes for computing if ASCIIKarl Williamson2011-10-011-1/+0
| | | | | This information is trivially computed via the macro, no need to go out to disk and store a swash for this.
* Simplify embedvar.h, removing a level of macro indirection for PL_* variables.Nicholas Clark2011-08-111-369/+0
| | | | | | | For the default (non-multiplicity) configuration, PERLVAR*() macros now directly expand their arguments to tokens such as C<PL_defgv>, instead of expanding to C<PL_Idefgv>. This removes over 350 lines from F<embedvar.h>, which defined macros to map from C<PL_Idefgv> to C<PL_defgv> and so forth.
* Store C<study>'s data in in mg_ptr instead of interpreter variables.Nicholas Clark2011-07-011-6/+0
| | | | | This allows more than one C<study> to be active at the same time. It eliminates PL_screamfirst, PL_lastscream, PL_maxscream.
* Merge PL_scream{first,next} into one allocated buffer.Nicholas Clark2011-07-011-2/+0
| | | | | Effectively, PL_screamnext is now PL_screamfirst + 256. The actual interpreter variable PL_screamnext is eliminated.
* Move PL_runops_{std,dbg} to perl.h, and make them const.Nicholas Clark2011-06-121-6/+0
| | | | | They exist solely to ensure that Perl_runops_standard and Perl_runops_debug are linked in - nothing assigns to either variable, and nothing reads them.
* Move PL_global_struct_size, PL_interp_size{,_5_16_0} to perl.hNicholas Clark2011-06-121-9/+0
| | | | Make them const U16 - they should have been const from the start.
* In perlvar.h, move the always-present globals above those conditionally compiledNicholas Clark2011-06-121-3/+3
| | | | | Rename PL_interp_size_5_10_0 to PL_interp_size_5_16_0, as it is only intended to track interpreter size within (forwards) binary compatible maintenance branches.
* Move PL_{revision,version,subversion} to perl.h, making them const U8.Nicholas Clark2011-06-121-9/+0
| | | | | To get the initialisation to work, the location of #include patchlevel.h needs to be moved.
* Move PL_sh_path to perl.h (except for OS/2), as it's const char[]Nicholas Clark2011-06-121-0/+4
| | | | | | | | On OS/2, keep it in perlvars.h, as it's not const there. makedef.pl doesn't pay attention to C pre-processor symbols, so it will always see the declaration in perlvars.h, and add the symbol to the linker file, so no need to mention sh_path in globvar.sym. Add special case logic in regen/embed.pl to make the embedvar.h macros for PL_sh_path defined only on OS/2.
* Move PL_{No,Yes,hexdigit} from perlvars.h to perl.h, as all are const char[]Nicholas Clark2011-06-121-9/+0
| | | | | | | | | | | They were converted in perl.h from const char[] to #define in 31fb120917c4f65d, then re-instated as const char[], but in perlvars.h, in 3fe35a814d0a98f4. There's no need for compile-time constants to jump through the hoops of perlvars.h, even for Symbian, as the various "EXTCONST" variables already in perl.h demonstrate. These were the only 3 users of the the PERLVARISC macro, so eliminate that, and all related code.
* Eliminate PL_patleave, unused since perl 5.0 alpha 2.Nicholas Clark2011-06-121-3/+0
| | | | | | | patleave was added in perl 3.0 patch #35 patch #29 -- 395c379347344a50, used in scanpat(). scanpat() was refactored and renamed to scan_pat() in 5.0 alpha 2, "commented" out with the C pre-processor in 5.000, and removed in 5.001.
* Restore building with -DPERL_GLOBAL_STRUCT, broken since 4dc941f7cb795735.Nicholas Clark2011-05-221-3/+0
| | | | | | | | | As PL_charclass is a constant, it doesn't need to be accessed via the global struct. It should be exported via globvar.sym, not PERLVARA() in perlvars.h [With a PERVARA() it all compiles perfectly, once C<dVAR>s are added where now needed, but the build loops forever because the (real) charclass array is never initialised]
* handy.h: isIDFIRST_utf8() changed to use XIDStartKarl Williamson2011-02-171-0/+4
| | | | | | | | | | Previously this used a home-grown definition of an identifier start, stemming from a bug in some early Unicode versions. This led to some problems, fixed by #74022. But the home-grown solution did not track Unicode, and allowed for characters, like marks, to begin words when they shouldn't. This change brings this macro into compliance with Unicode going-forward.
* Add PL_foldable - a list of chars that participate in foldsKarl Williamson2011-02-021-0/+2
|
* Move all the generated file header printing into read_only_top()Nicholas Clark2011-01-231-4/+4
| | | | | | | | | Previously all the scripts in regen/ had code to generate header comments (buffer-read-only, "do not edit this file", and optionally regeneration script, regeneration data, copyright years and filename). This change results in some minor reformatting of header blocks, and standardises the copyright line as "Larry Wall and others".
* Generate pp_* prototypes in pp_proto.h, and remove pp.symNicholas Clark2011-01-091-1/+1
| | | | | | | | | | | Eliminate the #define pp_foo Perl_pp_foo(pTHX) macros, and update the 13 locations that relied on them. regen/opcode.pl now generates prototypes for the PP functions directly, into pp_proto.h. It no longer writes pp.sym, and regen/embed.pl no longer reads this, removing the only ordering dependency in the regen scripts. opcode.pl is now responsible for prototypes for pp_* functions. (embed.pl remains responsible for ck_* functions, reading from regen/opcodes)
* Improve custom OP support.Ben Morrow2010-11-141-0/+2
| | | | | | | | | | | | | | | | | Change the custom op registrations from two separate hashes to one hash holding structure pointers, and add API functions to register ops and look them up. This will make it easier to add new properties of custom ops in the future. Copy entries across from the old hashes where necessary, to preserve compatibility. Add two new properties, in addition to the already-existing 'name' and 'description': 'class' and 'peep'. 'class' is one of the OA_*OP constants, and allows B and other introspection mechanisms to work with custom ops that aren't BASEOPs. 'peep' is a pointer to a function that will be called for ops of this type from Perl_rpeep. Adjust B.xs to take account of the new properties, and also to give custom ops their registered name rather than simply 'custom'.
* Eliminate PL_dirtyFlorian Ragwitz2010-11-141-2/+0
| | | | | It now only exists as a compatibility macro for extensions that want to introspect it.
* Add ${^GLOBAL_PHASE}Florian Ragwitz2010-11-141-0/+2
| | | | This exposes the current top-level interpreter phase to perl space.
* regexec.c: Don't give up on fold matching earlyKarl Williamson2010-11-071-0/+2
| | | | | | | | | | | | | | | | | | | | As noted in the comments of the code, "a" =~ /[A]/i doesn't work currently (except that regcomp.c knows about the ASCII characters and corrects for it, but not always, for example in cases like "a" =~ /\p{Upper}/i. This patch catches all those). It works by computing a list of all characters that (singly) fold to another one, and then checking each of those. The maximum length of the list is 3 in the current Unicode standard. I believe that a better long-term solution is to do this at compile rather than execution time, by generating a closure of everything matched. But this can't be done now because the data structure would need to be extensively revamped to list all non-byte characters, and user-defined \p{} matches are not known at compile-time. And it doesn't handle the multi-char folds. There is a separate ticket for those.
* RT #76248: double-freed SV with nested sig-handlerDavid Mitchell2010-11-011-3/+0
| | | | | | | | | | | | | | | | | | | There was some buggy code in Perl_sighandler() related to getting an SV with the signal name to pass to the perl-level handler function. ` Basically: on threaded builds, a sig handler that died leaked PL_psig_name[sig]; on unthreaded builds, in a recursive handler that died, PL_sig_sv was prematurely freed. PL_sig_sv was originally just a file static var that was not recursion-save anyway, and got promoted to perlvars.h when it should instead have been done away with. So I've got rid of it now, and rationalised the code, which fixed the two issues listed above. Also added an assert which makes the dodgy manual popping of the save stack slightly less dodgy.
* replace PL_doextract with better kinds of variableZefram2010-10-211-2/+0
| | | | | | | | PL_doextract had two unrelated jobs, neither best served by an interpreter global variable. The first was to track the -x command-line switch. That is replaced with a local variable in S_parse_body(). The second was to track whether the lexer is in the middle of a =pod section. That is replaced with an element in PL_parser.
* embed.pl -> regen/embed.plFather Chrysostomos2010-10-131-2/+2
| | | | so newcomers can find it more easily
* make PL_charclass available to modules under Win32Tony Cook2010-09-261-0/+3
|
* Remove offer_nice_chunk(), PL_nice_chunk and PL_nice_chunk_size.Nicholas Clark2010-09-081-4/+0
| | | | | | | | | | | | | | | | | | These provided a non-public API for the hash and array code to donate free memory direct to the SV head allocation routines, instead of returning it to the malloc system with free(). I assume that on some older mallocs this could offer significant benefits. However, my benchmarking on a modern malloc couldn't detect any significant effect (positive or negative) on removing the code. Its (continued) presence, however, has downsides a: slightly more code complexity b: slightly larger interpreter structure c: in the steady state, if net creation of SVs is zero, 1 chunk of allocated but unused memory will exist (per thread) So I think it best to remove it.
* make recursive part of peephole optimiser hookableZefram2010-08-261-0/+2
| | | | | | | | New variable PL_rpeepp makes it possible for extensions to hook the per-op-chain part of the peephole optimiser (which recurses into side chains). The existing variable PL_peepp still allows hooking the per-sub part of the peephole optimiser, maintaining perfect backward compatibility.
* Check API compatibility when loading xs modulesFlorian Ragwitz2010-07-261-0/+2
| | | | | | | | | | | | | This adds PL_apiversion, allowing the API version of a running interpreter to be introspected. It is used in the new XS_APIVERSION_BOOTCHECK macro, which is added to the _boot function of every XS module, to compare it against the API version the module has been compiled against. If the versions do not match, an exception is thrown. This doesn't fully prevent binary incompatible extensions to be loaded. It merely compares PERL_API_* between compile- and runtime, and does not attempt to solve the problem of identifying binary incompatible perls with the same API version (i.e. the same perl version configured with and without DEBUGGING).
* Get rid of PERL_POLLUTEJan Dubois2010-07-211-33/+0
| | | | | | | | | | | PERL_POLLUTE was added (but undefined by default) in 5.6 to optionally expose older 5.005 symbols for backwards compatibility. It's use was always discouraged, and MakeMaker contains a more specific escape hatch: perl Makefile.PL POLLUTE=1 This can be used for modules that have not been upgraded to 5.6 naming conventions (and really should be completely obsolete by now).
* Generic hooks into Perl_block_{start,end}.Ben Morrow2010-07-121-0/+2
| | | | | | | | | | These take the form of a vtable pushed onto the new PL_blockhooks array. This could probably do with a API around it later. Separate pre_end and post_end hooks are needed to capture globals before the stack is unwound (like needblockscope in the existing code). The intention is that once a vtable is installed it never gets removed, so where necessary extensions using this will need to use a hinthv element to determine whether to do anything or not.
* add PL_signalhook to hook into signal dispatchDavid Mitchell2010-06-041-0/+2
| | | | | This is initially intended for threads::shared and shouldn't (yet) be considered part of the public API.
* unwinding target nominated by separate globalZefram2010-04-251-0/+2
| | | | | | | | When unwinding due to die, the new global PL_restartjmpenv points to the JMP_ENV at which longjmping should stop and control should be transferred to PL_restartop. This replaces the previous use of cxstack[cxstack_ix+1].blk_eval.cur_top_env, located in a nominally-discarded context frame.
* qr/\X/ expansionKarl Williamson2009-12-051-0/+20
|
* Add ENTER_with_name and LEAVE_with_name to automaticly check for matching ↵Gerard Goossen2009-11-121-0/+2
| | | | ENTER/LEAVE when debugging is enabled
* regen generated files changed by the previous patch - facility to plug in ↵Jesse Vincent2009-11-051-0/+3
| | | | syntax triggered by keywords
* somewhat fix failing regex tests. but break lots of other stuff at the same timeYves Orton2009-10-191-0/+6
|
* Remove obsolete interpreter variable PL_utf8_alnumcRafael Garcia-Suarez2009-09-131-2/+0
|
* Add a pluggable hook in op_free()Vincent Pit2009-07-081-0/+2
|
* Remove binary compatibility scaffolding for the change to PL_bitcount.Nicholas Clark2009-05-201-1/+0
|