summaryrefslogtreecommitdiff
path: root/inline.h
Commit message (Collapse)AuthorAgeFilesLines
* Evaluate arg once in all forms of SvTRUEKarl Williamson2020-12-061-1/+50
| | | | 5.32 did this for one form; now all do.
* Slience compiler warnings for NV, [IU]V compareKarl Williamson2020-11-221-1/+1
| | | | | | | | | | | | | | These were occurring on FreeBSD smokes. warning: implicit conversion from 'IV' (aka 'long') to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion] 9223372036854775807 is IV_MAX. What needed to be done here was to use the NV containing IV_MAX+1, a value that already exists in perl.h In other instances, simply casting to an NV before doing the comparison with the NV was what was needed. This fixes #18328
* Move regcurly to regcomp.c (from inline.h)Karl Williamson2020-11-181-30/+0
| | | | | | This function is called only at compile time; experience has shown that compile-time operations are not time-critical. And future commits will lengthen it, making it not practically inlinable anyway.
* autodoc.pl: Enhance apidoc_section featureKarl Williamson2020-11-061-7/+7
| | | | | | | | | | | This feature allows documentation destined for perlapi or perlintern to be split into sections of related functions, no matter where the documentation source is. Prior to this commit the line had to contain the exact text of the title of the section. Now it can be a $variable name that autodoc.pl expands to the title. It still has to be an exact match for the variable in autodoc, but now, the expanded text can be changed in autodoc alone, without other files needing to be updated at the same time.
* Document CvGVKarl Williamson2020-09-281-0/+7
|
* Clarify branch prediction in SvTRUEKarl Williamson2020-09-051-1/+1
|
* Reorganize perlapiKarl Williamson2020-09-041-2/+5
| | | | | This uses a new organization of sections that I came up with. I asked for comments on p5p, but there were none.
* Change some =head1 to apidoc_section linesKarl Williamson2020-09-041-1/+1
| | | | | apidoc_section is slightly favored over head1, as it is known only to autodoc, and can't be confused with real pod.
* S_lossless_NV_to_IV(): skip Perl_isnanDavid Mitchell2020-08-271-4/+6
| | | | | | | | | | | | | | | | | | | This inline function was added by v5.31.0-27-g3a019afd6f to consolidate similar code in several places, like pp_add(). It also avoided undefined behaviour, as seen by ASan, by no longer unconditionally trying to cast an NV to IV - ASan would complain when nv was -Inf for example. However that commit introduced a performance regression into common numeric operators like pp_and(). This commit partially claws back performance by skipping the initial test of 'skip if Nan' which called Perl_isnan(). Instead, except on systems where NAN_COMPARE_BROKEN is true, it relies on NaN being compared to anything always being false, and simply rearranges existing conditions nv < IV_MIN etc to be nv >= IV_MIN so that any NaN comparison will trigger a false return. This claws back about half the performance loss. The rest seems unavoidable, since the two range tests for IV_MIN..IV_MAX are an unavoidable part of avoiding undefined behaviour.
* sort { return foo() } ...David Mitchell2020-08-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | GH #18081 A sub call via return in a sort block was called in void rather than scalar context, causing the comparison result to be discarded. This because when a sort block is called it is not a real function call, even though a sort block can be returned from. Instead, a CXt_NULL is pushed on the context stack. Because this isn't a sub-ish context type (unlike CXt_SUB, CXt_EVAL etc) there is no 'caller sub' on the context stack to be found to retrieve the caller's context (i.e. cx->cx_gimme). This commit fixes it by special-casing Perl_gimme_V(). Ideally at some future point, a new context type, CXt_SORT, should be added. This would be used instead of CXt_NULL when a sort BLOCK is called. Like other sub-ish context types, it would have an old_cxsubix field and PL_curstackinfo->si_cxsubix would point to it. This would eliminate needing special-case handling in places like Perl_gimme_V().
* Add av_count()Karl Williamson2020-08-191-4/+12
| | | | | | | | | This returns the number of elements in an array in a clearly named function. av_top_index(), av_tindex() are clearly named, but are less than ideal, and came about because no one back then thought of this one, until now Paul Evans did.
* Remove use of dVAR in coreDagfinn Ilmari Mannsåker2020-07-201-1/+0
| | | | | It only does anything under PERL_GLOBAL_STRUCT, which is gone. Keep the dNOOP defintion for CPAN back-compat
* Fix a bunch of repeated-word typosDagfinn Ilmari Mannsåker2020-05-221-2/+2
| | | | | Mostly in comments and docs, but some in diagnostic messages and one case of 'or die die'.
* Revert "croak_memory_wrap is an inline function."Karl Williamson2020-03-111-11/+0
| | | | | | | This reverts commit 6c714a09cc08600278e72aea1fcdf83576d061b4. croak_memory_wrap is designed to save a few bytes of memory, and was never intended to be inlined. This commit moves it to util.c where the other croak functions are.
* Add thread safety to some environment accessesKarl Williamson2020-03-111-0/+53
| | | | | | | | | | | | | | | | | | The previous commit added a mutex specifically for protecting against simultaneous accesses of the environment. This commit changes the normal getenv, putenv, and clearenv functions to use it, to avoid races. This makes the code simpler in places where we've gotten burned and added stuff to avoid races. Other places where we haven't known we were getting burned could have existed until now. Now that comes automatically, and we can remove the special cases we earlier stumbled over. getenv() returns a pointer to static memory, which can be overwritten at any moment from another thread, or even another getenv from the same thread. This commit changes the accesses to be under control of a mutex, and in the case of getenv, a mortalized copy is created so that there is no possible race.
* Inline the SvGETMAGIC call directly rather than via the macroPaul "LeoNerd" Evans2020-03-011-1/+2
|
* SvTRUE might need to take aTHXPaul "LeoNerd" Evans2020-03-011-2/+4
|
* Initial experiment at moving SvTRUE into a static inline macroPaul "LeoNerd" Evans2020-03-011-0/+5
|
* Change return type of regcurly to boolKarl Williamson2020-01-231-1/+1
| | | | This internal function is more properly bool, not I32.
* Remove dquote_inline.hKarl Williamson2020-01-231-0/+30
| | | | | The remaining function in this file is moved to inline.h, just to not have an extra file lying around with hardly anything in it.
* Rewrite and inline my_strnlen()Karl Williamson2020-01-131-0/+30
| | | | | | | This commit changes this function to use memchr() instead of looping byte-by-byte through the string. And it inlines it into 3 lines of code. This should give comparable performance to a native libc strnlen().
* The VC6 Chainsaw MassacreSteve Hay2019-10-171-18/+1
| | | | | Remove MS Visual C++ 6.0 support as agreed in the thread starting here: https://www.nntp.perl.org/group/perl.perl5.porters/2019/07/msg255625.html
* Move http:// URLs to https:// URLs in source codeMax Maischein2019-10-111-6/+6
| | | | | | This commit moves more URLs from http to https. This time it affects some source code, that's why it is not bunched up with the commits affecting pod/*
* Un-revert "[MERGE] add+use si_cxsubix field"David Mitchell2019-09-231-0/+26
| | | | | | | | original merge commit: v5.31.3-198-gd2cd363728 reverted by: v5.31.4-0-g20ef288c53 The commit following this commit fixes the breakage, which that means the revert can be undone.
* Revert "[MERGE] add+use PL_curstackinfo->si_cxsubix field"v5.31.4Max Maischein2019-09-201-26/+0
| | | | | | | | | | | | This reverts commit d2cd363728088adada85312725ac9d96c29659be, reversing changes made to 068b48acd4bdf9e7c69b87f4ba838bdff035053c. This change breaks installing Test::Deep: ... not ok 37 - Test 'isa eq' completed ok 38 - Test 'isa eq' no premature diagnostication ...
* Perl_gimme_V(): assume caller always provides cxtDavid Mitchell2019-09-191-5/+2
| | | | | So we don't need to check whether (cxstack[cxix].blk_gimme & G_WANT), just use it. Replace the check with an assertion.
* add Perl_gimme_V() static inline fn for GIMME_VDavid Mitchell2019-09-191-0/+20
| | | | | | This function makes use of PL_curstackinfo->si_cxsubix to avoid the overhead of a call to block_gimme() when the context of the op is unknown.
* add PL_curstackinfo->si_cxsubix fieldDavid Mitchell2019-09-191-0/+9
| | | | | | | | | | | | | This tracks the most recent sub/eval/format context pushed onto the context stack. Then make dopopto_cursub use it. The previous value is saved in the cxt struct, and is restored whenever the context is popped. This adds a tiny overhead for every sub call, but speeds up other operations, such as determining the caller context when returning a value from a sub - this has to be dpne for every sub call where the last expression is context sensitive, so its often a win.
* perlapi: Improve description of is_safe_syscall()Karl Williamson2019-09-151-2/+6
| | | | Two parameters weren't described, nor the warnings category used.
* embed.fnc: Add p flag for is_utf8_non_invariant_string()Karl Williamson2019-09-151-1/+1
| | | | | This is because it has the X flag, which means the function is visible on ELF systems.
* Add embed.fnc entry for ReANYKarl Williamson2019-09-151-0/+3
| | | | This inline function should have an entry.
* Add Perl_ to SvAMAGIC _off,_on namesKarl Williamson2019-09-151-2/+6
| | | | These function names need a Perl_ prefix to avoid namespace pollution.
* Add embed.fnc entries for Cv inline fcnsKarl Williamson2019-09-151-1/+5
| | | | | | and change the name of one. CvDEPTH shouldn't have a trailing 'p' to indicate private memeber access. It may do so internally, but the name shouldn't indicate that.
* Fix up get_regex_charset_name()Karl Williamson2019-09-151-1/+7
| | | | | This inline function should not be visible outside certain core (and ext/re) functions. Make that happen.
* inline.h: Move some fcn '{' to column 1Karl Williamson2019-09-151-3/+6
| | | | | | Traditionally, functions in perl have been written so their initial '{' is in column 1 after the prototype. This makes grepping easier. This commit brings 3 functions in this file into conformance.
* Make PadnameIN_SCOPE() name begin with S_Karl Williamson2019-09-151-1/+3
| | | | All functions should have a prefix.
* Some SvREFCNT_foo are no longer macrosKarl Williamson2019-09-151-0/+5
| | | | but are inline functions. They should be listed in embed.fnc.
* Strip leading underscore _variant_byte_number()Karl Williamson2019-09-151-2/+2
| | | | Names with leading underscores are reserved for the C implementers.
* Change name of _utf8_to_uvchr_buf()Karl Williamson2019-09-151-2/+2
| | | | | A function name with a leading underscore is not legal in C. Instead add a suffix to differentiate this name from an otherwise identical one.
* Strip leading underscore from is_utf8_char_helper()Karl Williamson2019-09-151-2/+2
| | | | Leading underscored name are reserved for the C implementers
* inline.h: Change fcn name prefix from S_ to Perl_Karl Williamson2019-09-151-48/+48
| | | | | | | | | | | | | | | | This is being done only for those functions that don't have a guard preventing them from being seen outside of the Perl core. Talking to Tony Cook, we agreed that this was a good idea for two reasons: 1) The 'Perl_' prefix does not pollute XS caller's name space. The 'S_' one could be argued that it doesn't much either, but it does more so than 'Perl_', and the next reason is the clincher: 2) It allows us to change our minds about whether a function should be static inline or not, without affecting callers who use the Perl_ form, which they would be accustomed to anyway if they're using the full name form.
* embed.fnc: Change some 'x' marked fcns to 'C'Karl Williamson2019-09-151-4/+4
| | | | | | | The previous commit added the C flag, which is better to use in many instances than x. This commit changes the x entries in embed.fnc that I'm pretty sure would be better off being C, and removes some 'x' entries for internal only functions
* inline.h: Return proper value on EBCDICKarl Williamson2019-08-211-1/+1
| | | | | | | | The final step was missing in the conversion from UTF-EBCDIC to uv. This adds a macro call that expands to its argument on non-EBCDIC platforms, so this commit makes no changes to the compiled binary on those systems.
* Fix utf8_to_uvchr_buf to match docsKarl Williamson2019-08-191-1/+5
| | | | | | | | | | It did so already except when passed a zero length input on non-debugging builds. This caused test failures in Devel::PPPort, and commit 4a5ab54a18679ab24ca03190884d326c2ca85288 was used to customize that module in blead to get the tests to pass. This commit avoids the possibility of having to bump the version again, which is what that commit did.
* utf8_to_uvchr_buf() make behavior match docsKarl Williamson2019-07-011-0/+21
| | | | | | | | | | | For well formed input, there is no change. But for malformed it wasn't returning the documented length when warnings were enabled, and not always the documented value when they were disabled. This is implemented as an inline function, called from both the macro and the Perl_ form. Devel::PPPort has sufficient tests for this.
* Remove redundant info on =for apidoc linesKarl Williamson2019-05-301-3/+3
| | | | | | | | | This information is already in embed.fnc, and we know it compiles. Some of this information is now out-of-date. Get rid of it. There was one bit of information that was (apparently) wrong in embed.fnc. The apidoc line asked that there be no usage example generated for newXS. I added that flag to the embed.fnc entry.
* Create fcn for lossless conversion of NV to IVKarl Williamson2019-05-241-0/+34
| | | | | | | | Essentially the same code was being used in three places, and had undefined C behavior for some inputs. This consolidates the code into one inline function, and rewrites it to avoid undefined behavior.
* inline.h: Improve commentKarl Williamson2019-03-151-2/+2
|
* inline.h: Clarify commentKarl Williamson2018-12-051-4/+4
| | | | | This function works as well as possible on non-UTF-8 inputs. No need to list the UTF-8-only failures, since those aren't legal inputs.
* inline.h: Use 'do {} while' instead of 'while {}'Karl Williamson2018-08-201-2/+2
|