summaryrefslogtreecommitdiff
path: root/perlapi.h
Commit message (Collapse)AuthorAgeFilesLines
* Correct typos as per GH 20435James E Keenan2022-12-291-1/+1
| | | | | | | | | | | | | | | | | | | In GH 20435 many typos in our C code were corrected. However, this pull request was not applied to blead and developed merge conflicts. I extracted diffs for the individual modified files and applied them with 'git apply', excepting four files where patch conflicts were reported. Those files were: handy.h locale.c regcomp.c toke.c We can handle these in a subsequent commit. Also, had to run these two programs to keep 'make test_porting' happy: $ ./perl -Ilib regen/uconfig_h.pl $ ./perl -Ilib regen/regcomp.pl regnodes.h
* Remove PERL_GLOBAL_STRUCTDagfinn Ilmari Mannsåker2020-07-201-213/+7
| | | | | | | | 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.
* Make PL_utf8_foldclosures interpreter levelKarl Williamson2020-06-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | This resolves #17774. This ticket is because the fixes in GH #17154 failed to get every case, leaving this one outlier to be fixed by this commit. The text in https://github.com/Perl/perl5/issues/17154 gives extensive details as to the problem. But briefly, in an attempt to speed up interpreter cloning, I moved certain SVs from interpreter level to global level in e80a0113c4a8036dfb22aec44d0a9feb65d36fed (v5.27.11, March 2018). This was doable, we thought, because the content of these SVs is constant throughout the life of the program, so no need to copy them when cloning a new interpreter or thread. However when an interpreter exits, all its SVs get cleaned up, which caused these to become garbage in applications where another interpreter remains running. This circumstance is rare enough that the bug wasn't reported until September 2019, #17154. I made an initial attempt to fix the problem, and closed that ticket, but I overlooked one of the variables, which was reported in #17774, which this commit addresses. Effectively the behavior is reverted to the way it was before e80a0113c4a8036dfb22aec44d0a9feb65d36fed.
* Add mutex for accessing ENVKarl Williamson2020-03-111-0/+2
|
* Revert "Move PL_check to the interp vars to fix threading issues"Tony Cook2019-12-161-0/+2
| | | | | and the associated commits, at least until a way to make wrap_op_checker() work is available.
* Move PL_check to the interp vars to fix threading issuesStefan Seifert2019-12-121-2/+0
| | | | Fixes issue #14816
* Move regex global variables to interpreter levelKarl Williamson2019-11-261-62/+0
| | | | | | | | | | | | | | | | | | | | | | | This is part of fixing gh #17154 This scenario from the ticket (https://github.com/Perl/perl5/issues/17154#issuecomment-558877358) shows why this fix is necessary: main interpreter initializes PL_AboveLatin1 to an SV it owns loads threads::lite and creates a new thread/interpreter which initializes PL_AboveLatin1 to a SV owned by the new interpreter threads::lite child interpreter finishes, freeing all of its SVs, PL_AboveLatin1 is now invalid main interpreter uses a regexp that relies on PL_AboveLatin1, dies horribly. By making these interpreter level variables, this is avoided. There is extra copying, but it is just the SV headers, as the real data is kept as static C arrays.
* add explicit 1-arg and 3-arg sig handler functionsDavid Mitchell2019-11-181-0/+4
| | | | | | | Currently, whether the OS-level signal handler function is declared as 1-arg or 3-arg depends on the configuration. Add explicit versions of these functions, principally so that POSIX.xs can call which version of the handler it wants regardless of configuration: see next commit.
* Remove generation and use of NonFinalFold tableKarl Williamson2019-11-161-2/+0
| | | | | | With the revamping done in cc288b7a2732c37504039083ebb98241954636be, the table of Unicode case folds that are more than a single character is no longer used, so no need to generate it, or having it available.
* Add hook for Unicode private use overrideKarl Williamson2019-03-071-0/+2
| | | | | | | | | | I am starting to write a Unicode::Private_Use module which will allow one to specify the Unicode properties of private use code points, thus making them actually useful. This commit adds a hook to regcomp.c to accommodate this module. The changes are pretty minimal. This way we don't have to wait another release cycle to get it out there. I don't want to document this interface, until it's proven.
* fix thread issue with PERL_GLOBAL_STRUCTDavid Mitchell2019-02-191-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | The MY_CXT subsystem allows per-thread pseudo-static data storage. Part of the implementation for this involves each XS module being assigned a unique index in its my_cxt_index static var when first loaded. Because PERL_GLOBAL_STRUCT bans any static vars, under those builds there is instead a table which maps the MY_CXT_KEY identifying string to index. Unfortunately, this table was allocated per-interpreter rather than globally, meaning if multiple threads tried to load the same XS module, crashes could ensue. This manifested itself in failures in ext/XS-APItest/t/keyword_plugin_threads.t The fix is relatively straightforward: allocate PL_my_cxt_keys globally rather than per-interpreter. Also record the size of this struct in a new var, PL_my_cxt_keys_size, rather than doing double duty on PL_my_cxt_size.
* foo_cloexec() under PERL_GLOBAL_STRUCT_PRIVATEDavid Mitchell2019-02-191-0/+18
| | | | | | | | | | | | | | | | | | Fix the various Perl_PerlSock_dup2_cloexec() type functions so that t/porting/liberl.a passes under -DPERL_GLOBAL_STRUCT_PRIVATE builds. In these builds it is forbidden to have any static variables, but each of these functions (via convoluted macros) has a static var called 'strategy' which records, for each function, whether a run-time probe has been done to determine the best way of achieving close-exec functionality, and the result. Replace them all with 'global' vars: PL_strategy_dup2 etc. NB these vars aren't thread-safe but it doesn't really matter, as the worst that can happen is for a redundant probe or two to be done before a suitable "don't probe any more" value is written to the var and seen by all the threads.
* Add global hash to handle \p{user-defined}Karl Williamson2019-02-141-0/+4
| | | | | | | A global hash has to be specially handled. The keys can't be shared, and all the SVs stored into it must be in its thread. This commit adds the hash, and initialization, and macros for context change, but doesn't use them. The code to deal with this is entirely confined to regcomp.c.
* Add mutex for dealing with qr/\p{user-defined}/Karl Williamson2019-02-141-0/+2
| | | | This will be used in future commits
* regen/mk_invlists.pl: Create new inversion listKarl Williamson2019-02-051-0/+2
| | | | This will be used in a future commit.
* Change name of PL_NonL1NonFinalFoldKarl Williamson2018-12-251-2/+2
| | | | | The inversion list this refers to now includes the Latin 1 range, so the name was misleading.
* Change name of PL_utf8_foldable variableKarl Williamson2018-12-251-2/+2
| | | | | | This variable's name was out-of-date and misleading. It is the name of an inversion list that contains all the code points in the current version of Unicode that participate in any way in a /i type of fold.
* regen/mk_invlists.pl: Add new tableKarl Williamson2018-12-071-0/+2
| | | | | | | This table contains all the code points that are in any multi-character fold (not the folded-from character, but what that character folds to). It will be used in a future commit.
* Make global two interpreter variablesKarl Williamson2018-07-141-0/+4
| | | | | These variables are constant, once initialized, through the life of a program, so having them be per instance is a waste of time and space
* regcomp.c: SimplifyKarl Williamson2018-06-251-0/+2
| | | | | | | | | | | | Under /a pattern matching, the matches of the [:posix:] classes are restricted to the ASCII range. Previously, in a time/space trade-off that favored space, we created the list of matching characters at pattern compilation time by ANDing the full-range Posix class with the set of ASCII characters. But now, the tables for just the ASCII-range classes are generated anyway, so there's no need to do that compilation-time intersection. This slightly simplifies the code.
* Use compiled-in C structure for inverted case foldsKarl Williamson2018-03-311-0/+2
| | | | | | | | | | This commit changes to use the C data structures generated by the previous commit to compute what characters fold to a given one. This is used to find out what things should match under /i. This now avoids the expensive start up cost of switching to perl utf8_heavy.pl, loading a file from disk, and constructing a hash from it.
* Use charnames inversion listsKarl Williamson2018-03-311-0/+4
| | | | | | | | This commit makes the inversion lists for parsing character name global instead of interpreter level, so can be initialized once per process, and no copies are created upon new thread instantiation. More importantly, this is another instance where utf8_heavy.pl no longer needs to be loaded, and the definition files read from disk.
* Move case change invlists from interpreter to globalKarl Williamson2018-03-261-0/+10
| | | | | These are now constant through the life of the program, so don't need to be duplicated at each new thread instantiation.
* Make Unicode data structures globalKarl Williamson2018-03-141-0/+38
| | | | | | | | | | These structures are read-only, use const C strings, and are truly global, so no need to have them be interpreter level. This saves duplicating and freeing them as threads come and go. In doing this, I noticed that not every one was properly being copied/deallocated, so this fixes some potential unreported bugs, and leaks.
* Latch LC_NUMERIC during critical sectionsKarl Williamson2018-02-181-0/+2
| | | | | | | | | | | | | | It is possible for operations on threaded perls which don't 'use locale' to still change the locale. This happens when calling POSIX::localeconv() and I18N::Langinfo(), and in earlier perls, it can happen for other operations when perl has been initialized with the environment causing the various locale categories to not have a uniform locale. This commit causes the areas where the locale for this category should predictably be in one or the other state to be a critical section where another thread can't interrupt and change it. This is a separate mutex, so that only these particular operations will be held up.
* add wrap_keyword_plugin function (RT #132413)Lukas Mai2017-11-111-0/+2
|
* Restore "Add new hashing and "hash with state" infrastructure"Yves Orton2017-06-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit e6a172f358c0f48c4b744dbd5e9ef6ff0b4ff289, which was a revert of a3bf60fbb1f05cd2c69d4ff0a2ef99537afdaba7. Add new hashing and "hash with state" infrastructure This adds support for three new hash functions: StadtX, Zaphod32 and SBOX, and reworks some of our hash internals infrastructure to do so. SBOX is special in that it is designed to be used in conjuction with any other hash function for hashing short strings very efficiently and very securely. It features compile time options on how much memory and startup time are traded off to control the length of keys that SBOX hashes. This also adds support for caching the hash values of single byte characters which can be used in conjuction with any other hash, including SBOX, although SBOX itself is as fast as the lookup cache, so typically you wouldnt use both at the same time. This also *removes* support for Jenkins One-At-A-Time. It has served us well, but it's day is done. This patch adds three new files: zaphod32_hash.h, stadtx_hash.h, sbox32_hash.h
* Revert "Add new hashing and "hash with state" infrastructure"Yves Orton2017-04-231-4/+0
| | | | | | This reverts commit a3bf60fbb1f05cd2c69d4ff0a2ef99537afdaba7. Accidentally pushed work pending unfreeze.
* Add new hashing and "hash with state" infrastructureYves Orton2017-04-231-0/+4
| | | | | | | | | | | | | | | | | | | | | This adds support for three new hash functions: StadtX, Zaphod32 and SBOX, and reworks some of our hash internals infrastructure to do so. SBOX is special in that it is designed to be used in conjuction with any other hash function for hashing short strings very efficiently and very securely. It features compile time options on how much memory and startup time are traded off to control the length of keys that SBOX hashes. This also adds support for caching the hash values of single byte characters which can be used in conjuction with any other hash, including SBOX, although SBOX itself is as fast as the lookup cache, so typically you wouldnt use both at the same time. This also *removes* support for Jenkins One-At-A-Time. It has served us well, but it's day is done. This patch adds three new files: zaphod32_hash.h, stadtx_hash.h, sbox32_hash.h
* Make PERLLIB_SEP dynamic on VMS.Craig A. Berry2016-09-011-0/+2
| | | | | | | Because if we're running under a Unix shell, the path separator is likely to meet the expectations of Unix shell scripts better if it's the Unix ':' rather than the VMS '|'. There is no change when running under DCL.
* locale.c: Revamp my_strerror() for thread-safenessKarl Williamson2016-07-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is the first step in making locale handling thread-safe. [perl #127708] was solved for 5.24 by adding a mutex in this function. That bug was caused by the code changing the locale even if the calling program is not consciously using locales. Posix 2008 introduced thread-safe locale functions. This commit changes this function to use them if the perl is threaded and the platform has them available. This means that the mutex is avoided on modern platforms. It restructures the function to return a mortal copy of the error message. This is a step towards making the function completely thread safe. Right now, as documented, if you do 'use locale', locale handling isn't thread-safe. A global C locale object is created and used here if necessary. It is destroyed at the end of the program. Note that some platforms have a strerror_r(), which is automatically used instead of strerror() if available. It differs form straight strerror() by taking a buffer to place the returned string, so the return does not point to internal static storage. One could test for the existence of this and avoid the mortal copy.
* Add locale mutexKarl Williamson2016-04-091-0/+2
| | | | | This adds a new mutex for use in the next commit for use with locale handling.
* Static initialization using 1/0 or 0/0 not C89.Jarkko Hietaniemi2014-09-011-4/+0
|
* Do not use HUGE_VAL/VALL for NV_INF.Jarkko Hietaniemi2014-09-011-0/+4
| | | | | | | | Because some platforms (like HP-UX 10.*) have HUGE_VAL as DBL_MAX, which, while large, is not quite the infinity. So have infinity own our very own. Similarly for NV_NAN.
* Revert "[perl #119801] Stop @DB::dbline modifications from crashing"Father Chrysostomos2013-12-251-6/+0
| | | | | | This reverts commit c1cec775e9019cc8ae244d4db239a7ea5c0b343e. See ticket #120864.
* [perl #119801] Stop @DB::dbline modifications from crashingFather Chrysostomos2013-12-211-0/+6
| | | | | | | | | | | | | | | | | | | | | The cop address for each breakable line was being stored in the IVX slot of ${"_<$file"}[$line]. This value itself, writable from Perl space, was being used as the address of the op to be flagged, whenever a breakpoint was set. This meant writing to ${"_<$file"}[$line] and assigning a number (like 42) would cause perl to use 42 as an op address, and crash when trying to flag the op. Furthermore, since the array holding the lines could outlive the ops, setting a breakpoint on the op could write to freed memory or to an unrelated op (even a different type), potentially changing the beha- viour of unrelated code. This commit solves those pitfalls by moving breakpoints into a global breakpoint bitfield. Dbstate ops now have an extra field on the end holding a sequence number, representing which bit holds the breakpoint for that op.
* Hash Function Change - Murmur hash and true per process hash seedYves Orton2012-11-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch does the following: *) Introduces multiple new hash functions to choose from at build time. This includes Murmur-32, SDBM, DJB2, SipHash, SuperFast, and One-at-a-time. Currently this is handled by muning hv.h. Configure support hopefully to follow. *) Changes the default hash to Murmur hash which is faster than the old default One-at-a-time. *) Rips out the old HvREHASH mechanism and replaces it with a per-process random hash seed. *) Changes the old PL_hash_seed from an interpreter value to a global variable. This means it does not have to be copied during interpreter setup or cloning. *) Changes the format of the PERL_HASH_SEED variable to a hex string so that hash seeds longer than fit in an integer are possible. *) Changes the return of Hash::Util::hash_seed() from a number to a string. This is to accomodate hash functions which have more bits than can be fit in an integer. *) Adds new functions to Hash::Util to improve introspection of hashes -) hash_value() - returns an integer hash value for a given string. -) bucket_info() - returns basic hash bucket utilization info -) bucket_stats() - returns more hash bucket utilization info -) bucket_array() - which keys are in which buckets in a hash More details on the new hash functions can be found below: Murmur Hash: (v3) from google, see http://code.google.com/p/smhasher/wiki/MurmurHash3 Superfast Hash: From Paul Hsieh. http://www.azillionmonkeys.com/qed/hash.html DJB2: a hash function from Daniel Bernstein http://www.cse.yorku.ca/~oz/hash.html SDBM: a hash function sdbm. http://www.cse.yorku.ca/~oz/hash.html SipHash: by Jean-Philippe Aumasson and Daniel J. Bernstein. https://www.131002.net/siphash/ They have all be converted into Perl's ugly macro format. I have not done any rigorous testing to make sure this conversion is correct. They seem to function as expected however. All of them use the random hash seed. You can force the use of a given function by defining one of PERL_HASH_FUNC_MURMUR PERL_HASH_FUNC_SUPERFAST PERL_HASH_FUNC_DJB2 PERL_HASH_FUNC_SDBM PERL_HASH_FUNC_ONE_AT_A_TIME Setting the environment variable PERL_HASH_SEED_DEBUG to 1 will make perl output the current seed (changed to hex) and the hash function it has been built with. Setting the environment variable PERL_HASH_SEED to a hex value will cause that value to be used at the seed. Any missing bits of the seed will be set to 0. The bits are filled in from left to right, not the traditional right to left so setting it to FE results in a seed value of "FE000000" not "000000FE". Note that we do the hash seed initialization in perl_construct(). Doing it via perl_alloc() (via init_tls) causes problems under threaded builds as the buffers used for reentrant srand48 functions are not allocated. See also the p5p mail "Hash improvements blocker: portable random code that doesnt depend on a functional interpreter", Message-ID: <CANgJU+X+wNayjsNOpKRqYHnEy_+B9UH_2irRA5O3ZmcYGAAZFQ@mail.gmail.com>
* 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.
* Simplify embedvar.h, removing a level of macro indirection for PL_* variables.Nicholas Clark2011-08-111-9/+9
| | | | | | | 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.
* Move PL_runops_{std,dbg} to perl.h, and make them const.Nicholas Clark2011-06-121-4/+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-6/+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-2/+2
| | | | | 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-6/+0
| | | | | To get the initialisation to work, the location of #include patchlevel.h needs to be moved.
* Move PL_{No,Yes,hexdigit} from perlvars.h to perl.h, as all are const char[]Nicholas Clark2011-06-121-12/+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-2/+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-2/+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]
* 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)
* RT #76248: double-freed SV with nested sig-handlerDavid Mitchell2010-11-011-2/+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.
* embed.pl -> regen/embed.plFather Chrysostomos2010-10-131-2/+2
| | | | so newcomers can find it more easily