summaryrefslogtreecommitdiff
path: root/util.c
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Don’t call save_re_context"David Mitchell2015-03-301-0/+1
| | | | | | This reverts commit d28a9254e445aee7212523d9a7ff62ae0a743fec. Turns out we need save_re_context() after all
* Replace common Emacs file-local variables with dir-localsDagfinn Ilmari Mannsåker2015-03-221-6/+0
| | | | | | | | | | | | | | | | An empty cpan/.dir-locals.el stops Emacs using the core defaults for code imported from CPAN. Committer's work: To keep t/porting/cmp_version.t and t/porting/utils.t happy, $VERSION needed to be incremented in many files, including throughout dist/PathTools. perldelta entry for module updates. Add two Emacs control files to MANIFEST; re-sort MANIFEST. For: RT #124119.
* don't test non-null argsDavid Mitchell2015-03-111-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For lots of core functions: if a function parameter has been declared NN in embed.fnc, don't test for nullness at the start of the function, i.e. eliminate code like if (!foo) ... On debugging builds the test is redundant, as the PERL_ARGS_ASSERT_FOO at the start of the function will already have croaked. On optimised builds, it will skip the check (and so be slightly faster), but if actually passed a null arg, will now crash with a null-deref SEGV rather than doing whatever the check used to do (e.g. croak, or silently return and let the caller's code logic to go awry). But hopefully this should never happen as such instances will already have been detected on debugging builds. It also has the advantage of shutting up recent clangs which spew forth lots of stuff like: sv.c:6308:10: warning: nonnull parameter 'bigstr' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion] if (!bigstr) The only exception was in dump.c, where rather than skipping the null test, I instead changed the function def in embed.fnc to allow a null arg, on the basis that dump functions are often used for debugging (where pointers may unexpectedly become NULL) and it's better there to display that this item is null than to SEGV. See the p5p thread starting at 20150224112829.GG28599@iabyn.com.
* [perl #123814] replace grok_atou with grok_atoUVHugo van der Sanden2015-03-091-21/+40
| | | | | | | | | | | | Some questions and loose ends: XXX gv.c:S_gv_magicalize - why are we using SSize_t for paren? XXX mg.c:Perl_magic_set - need appopriate error handling for $) XXX regcomp.c:S_reg - need to check if we do the right thing if parno was not grokked Perl_get_debug_opts should probably return something unsigned; not sure if that's something we can change.
* Consistently use NOT_REACHED; /* NOTREACHED */Jarkko Hietaniemi2015-03-041-1/+1
| | | | | | Both needed: the macro is for compilers, the comment for static checkers. (This doesn't address whether each spot is correct and necessary.)
* [perl #123554] fix threaded builds and prevent a warningTony Cook2015-02-101-8/+22
|
* [perl #123554] catch a couple of other size overflowsTony Cook2015-02-101-6/+9
| | | | | | Unfortunately, running out of memory in safesysmalloc() and safesysrealloc() doesn't produce a catchable croak(), so remove the test.
* Corrections to spelling and grammatical errors.Lajos Veres2015-01-281-2/+2
| | | | Extracted from patch submitted by Lajos Veres in RT #123693.
* Revert the support for new warning categories outside of "all"Ævar Arnfjörð Bjarmason2015-01-251-21/+6
| | | | | | | | | | | | | | | | | | | | | | | | This reverts & amends my v5.21.7-151-gea5519d and Karl Williamson's v5.21.7-183-g2f3cbe1, the latter was only need because of the former. I've also taken the opportunity to fix the long-standing trivial bug with misaligned code in warnings.{pm,h}. That was easier to commit along with this than to split it up from the other generated changes. Why revert this? See the "use warnings 'absolutely-all-almost';" thread on perl5-porters for the latest summary: http://www.nntp.perl.org/group/perl.perl5.porters/2015/01/msg225066.html Basically as I explained in v5.21.7-151-gea5519d the current design of the API makes it too contentious to freely add new warnings, but there's no consensus on how to solve that. I.e. whether we should just add them to "all", or do this change, or several other possible things outlined in that thread and elsewhere. Since the deadline for contentious changes for v5.22 is already past us I'm backing this out for now.
* [-Dusecbacktrace] Close the BFD descriptor.Jarkko Hietaniemi2015-01-071-0/+6
| | | | | Otherwise we leak several dozens of megabytes, if not more, for each Perl_dump_c_backtrace().
* Add support for new warning categories outside of "all"Ævar Arnfjörð Bjarmason2014-12-291-6/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When someone suggests a new warning on p5p it always often up being argued about on the basis that it'll break existing code, and that we shouldn't add warnings for possibly legitimate code just because it's unusual or odd. As I pointed out in a discussion about RT #121025 (see [1]) we only keep having this discussion because until now we've had no facility to add new warnings outside of the default set that'll be retroactively enabled for everything that does 'use warnings'. This patch introduces such a facility. As a proof of concept I'm adding a warning for something that was added as a warning in the past, but pulled out because it was deemed too controversial at the time: warning about the use of grep in void context. That warning was added back in v5.10.0-218-g74295f0 but quickly pulled out in v5.10.0-230-gf5df478. See [2] for the discussion about it at the time. Now if you do: use warnings; grep /42/, (1,2); You'll get no warnings as before, but if you do: use warnings qw(extra); # Or its sole subcategory: void_unusual grep /42/, (1,2); You'll get a warning about "Unusual use of grep in void context". To turn off this warning once you've turned it on it's *not* sufficient to do: no warnings; You need to do: no warnings qw(pedantic); Or: no warnings qw(everything); I'm willing to change that, but first we should ask ourselves whether this should continue to remain a symmetric operation: {use,no} warnings ['all']; There's more elaboration on how this works in the changes I'm making to the perldelta and the warnings documentation. But briefly this should be 100% backwards compatible, but allow us to have our cake and eat it too in the future by adding new warnings without imposing them on existing code written against older perl versions (unless that code explicitly requested to get new warnings as they upgrade perl). The patch to the warnings.pm documentation lays out a backwards compatibility policy for warnings, we promise that we'll continue the status quo with the "all" category, but for other categories (including future additions) we'll make such promises on a per-category basis. TODO: I wanted to come up with some more general facility for being able to add these new warnings without altering the behavior of the -w and -W switches. I.e. now we'll emit this, as intended: $ ./perl -Ilib -w -e 'grep /42/, (1,2)' $ ./perl -Ilib -W -e 'grep /42/, (1,2)' $ ./perl -Ilib -e 'use warnings; grep /42/, (1,2)' $ ./perl -Ilib -e 'use warnings "extra"; grep /42/, (1,2)' Unusual use of grep in void context at -e line 1. I.e. we don't want -w and -W to mean "use warnings 'everything'", it should continue to mean "use warnings 'all'". But due to how they're implemented I couldn't find an easy way to generalize this. Right now I'm just hardcoding an exception to the new warning category I've added outside "all" for these warnings. That should be followed-up with a more general solution, but for now if we only have a few of these catogeries we should be fine. This patch incorporates work from Andreas Guðmundsson <andreasg@nasarde.org> who picked up an earlier version of mine and figured out the change being made to mg.c here. That change removes an optimization in the ${^WARNING_BITS} magic which might make things a tad slower. 1. https://rt.perl.org/Ticket/Display.html?id=121025#txn-1276663 2. http://www.nntp.perl.org/group/perl.perl5.porters/2007/12/msg131922.html
* improve xs_handshake() diag messageDavid Mitchell2014-12-171-2/+2
| | | | | | | | | | | | | | | The important part of the error message is that the binaries are mismatched; the details of the handshake keys are an implementation detail. Or to put it another way, when someone mixes up their paths, getting something like Fcntl.c: Invalid handshake key got 0xcf80000 needed 0xd700000, binaries are mismatched Is a bit scary and confusing. This is hopefully (slightly) less scary: Fcntl.c: loadable library and perl binaries are mismatched (got handshake key 0xcf80000, needed 0xd700000)
* xs_handshake(() clean up desciptionDavid Mitchell2014-12-171-22/+37
| | | | | | Clean up the description of this function; in particular, say at the top what the function is for; fix typos; and generally improve the readability of the text.
* make xs_version_bootcheck a static func since not used as export anymoreDaniel Dragan2014-12-081-3/+3
| | | | | | | | Since commit db6e00bd00 the function has not been used by XS modules. Now remove it from export table since it has never been public API (the macro is), and it saves its symbol name string name, symbol table pointer, and allows for inlining and/or random calling convention optimization by the CC.
* Change OP_SIBLING to OpSIBLINGFather Chrysostomos2014-12-071-2/+2
| | | | | | | | | to match the existing convention (OpREFCNT, OpSLAB). Dave Mitchell asked me to wait until after his multideref work was merged. Unfortunately, there are now CPAN modules using OP_SIBLING.
* 1 exit path for returning ptr in Perl_safesysmalloc and Perl_safesysreallocDaniel Dragan2014-12-051-72/+68
| | | | | | | commit 6edcbed640 goto-ed around an initialization and was partially reverted in commit c62df97fd6 . This patch restores the intention of commit 6edcbed640 by having only 1 exit path that will be returning a pointer (and not croaking).
* make more use of NOT_REACHEDLukas Mai2014-11-291-8/+8
| | | | In particular, remove all instances of 'assert(0);'.
* Try making gcc happy about casting U32 to void*.Jarkko Hietaniemi2014-11-181-2/+2
| | | | | util.c: In function ‘I32 Perl_xs_handshake(U32, void*, const char*, ...)’: util.c:5389:39: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
* readd noreturn and silence "noreturn that returns" warning on MSVCDaniel Dragan2014-11-151-17/+30
| | | | | | | | | | | | | | | | | | Based on commit 73758d77 (by me), in commit 117af67d629 more things got noreturn removed on MSVC. See also ML post "(Hugmeir) Re: [perl.git] branch blead, updated. v5.21.0-377-gdc3bf40" This caused a measurable increase in machine code size in 117af67d629 . In commit 73758d77 , the reason there was no increase is Perl_magic_regdatum_set is called only through a magic vtable. Optimizing this to noreturn is forbidden unless the struct member type specifies it (and it obviously doesn't, since this is the magic vtable). The other not-noreturn on MSVC function, Perl_screaminstr, has no core usage (its only reference is in the export table) or CPAN grep usage so therefore it is being removed. It was made fatal in commit 9e3f0d16db . before .text section of perl521.dll on VC 2003 32b, 0xc66a3 bytes, after 0xc6453
* Revert the ‘return’ part of 6edcbed6Father Chrysostomos2014-11-151-16/+7
| | | | | The gotos were jumping over initializations, causing C+++threads+debugging to fail.
* make debugging easier in memory allocator code in perl.c and util.cDaniel Dragan2014-11-151-13/+24
| | | | | | | | | | -show intermediate values to make C debugging easier -Perl_safesysfree overwrote var where with a different value, this caused alot of confusion for me of trying to hunt for a pointer from a stack trace with conditional breakpoints, so don't change var where in an unoptimized build -in Perl_safesysrealloc and Perl_safesysmalloc provide 1 exit path, so the returned value is easily seen and BPed on unoptimized builds
* add filename handling to xs handshakeDaniel Dragan2014-11-131-23/+35
| | | | | | | | | | | | | | | | | | | | | - this improves the error message on ABI incompatibility, per [perl #123136] - reduce the number of gv_fetchfile calls in newXS over registering many XSUBs - "v" was not stripped from PERL_API_VERSION_STRING since string "vX.XX.X\0", a typical version number is 8 bytes long, and aligned to 4/8 by most compilers in an image. A double digit maint release is extremely unlikely. - newXS_deffile saves on machine code in bootstrap functions by not passing arg filename - move newXS to where the rest of the newXS*()s live - move the "no address" panic closer to the start to get it out of the way sooner flow wise (it nothing to do with var gv or cv) - move CvANON_on to not check var name twice - change die message to use %p, more efficient on 32 ptr/64 IV platforms see ML post "about commit "util.c: fix comiler warnings"" - vars cv/xs_spp (stack pointer pointer)/xs_interp exist for inspection by a C debugger in an unoptimized build
* util.c: fix comiler warningsDavid Mitchell2014-11-091-7/+9
| | | | | A recent commit gave some warnings about format types, and assignments without extra parens within an if condition.
* add xs_handshake APIDaniel Dragan2014-11-071-13/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This API elevates the amount of ABI compatibility protection between XS modules and the interp. It also makes each boot XSUB smaller in machine code by removing function calls and factoring out code into the new Perl_xs_handshake and Perl_xs_epilog functions. sv.c : - revise padlist duping code to reduce code bloat/asserts on DEBUGGING ext/DynaLoader/dlutils.c : - disable version checking so interp startup is faster, ABI mismatches are impossible because DynaLoader is never available as a shared library ext/XS-APItest/XSUB-redefined-macros.xs : - "" means dont check the version, so switch to " " to make the test in xsub_h.t pass, see ML thread "XS_APIVERSION_BOOTCHECK and XS_VERSION is CPP defined but "", mow what?" ext/re/re.xs : - disable API version checking until #123007 is resolved ParseXS/Utilities.pm : 109-standard_XS_defs.t : - remove context from S_croak_xs_usage similar to core commit cb077ed296 . CvGV doesn't need a context until 5.21.4 and commit ae77754ae2 and by then core's croak_xs_uage API has been long available and this backport doesn't need to account for newer perls - fix test where lack of having PERL_IMPLICIT_CONTEXT caused it to fail
* simplify Perl_xs_apiversion_bootcheckDaniel Dragan2014-11-061-24/+6
| | | | | | | We control both strings. Perl API versions are not old decimal or alphas versions. Maints dont increase Perl API ver. Just do a memcmp. Faster and less machine code. Before 0xA6 bytes of machine code on VC 2003 32b, after 0x35. This patch is related to [perl #123136].
* [perl #121159] use the updated win32_popenlist() even with USE_IMP_SYSTony Cook2014-10-231-1/+3
|
* treat fatal warnings after syntax errors as syntax errorsLukas Mai2014-10-151-2/+7
|
* quadmath NV formatted I/O.Jarkko Hietaniemi2014-09-191-3/+160
|
* Fix $DB::sub in DB::goto for lexical subsFather Chrysostomos2014-09-161-2/+2
| | | | | | | | | | | | | | | | | | | | | $ PERL5DB='sub DB::DB{}' ./perl -Ilib -XMfeature=:all -de ' state sub f{}; sub DB::goto { warn $DB::sub } $^P|=0x80; sub {goto &f}->()' main::f at -e line 1. There should not be a package name. Lexical subs should be treated like anonymous subs here; $DB::sub should contain a reference. This bug was introduced recently, in ae77754ae. Before that the output was: CODE(0x7fdbf102de58) at -e line 1. Though before 9d8e4b9b3 it was: Segmentation fault: 11
* sv_cathekFather Chrysostomos2014-09-151-4/+1
| | | | | This macro, intended for internal use, simplifies the code in a couple of places.
* Don’t call save_re_contextFather Chrysostomos2014-09-121-1/+0
| | | | It is an empty function.
* Fix crash with lex subs under -dFather Chrysostomos2014-08-281-2/+2
|
* Only use setenv() on Solaris if it is available.Andy Dougherty2014-07-251-1/+5
| | | | | | | | This is a followup to 07ad9e0e19891ec129e1a78e40a66ca19b51302d. util.c:Perl_my_setenv() unconditionally used setenv() if #defined(__sun). Solaris 8 had neither setenv() nor unsetenv(), so it failed. Configure does not currently check for setenv(), but the check for unsetenv() is sufficient here since Solaris 9 and later have both.
* use setenv() on SolarisVladimir Marek2014-07-231-1/+1
|
* Use grok_atou instead of atoi.Jarkko Hietaniemi2014-07-221-9/+15
| | | | | Remaining atoi() uses include at least: ext/DynaLoader/dl_aix.xs, os2/os2.c, vms/vms.c
* util.c: Add commentKarl Williamson2014-07-121-0/+3
|
* wrap op_sibling field access in OP_SIBLING* macrosDavid Mitchell2014-07-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Remove (almost all) direct access to the op_sibling field of OP structs, and use these three new macros instead: OP_SIBLING(o); OP_HAS_SIBLING(o); OP_SIBLING_set(o, new_value); OP_HAS_SIBLING is intended to be a slightly more efficient version of OP_SIBLING when only boolean context is needed. For now these three macros are just defined in the obvious way: #define OP_SIBLING(o) (0 + (o)->op_sibling) #define OP_HAS_SIBLING(o) (cBOOL((o)->op_sibling)) #define OP_SIBLING_set(o, sib) ((o)->op_sibling = (sib)) but abstracting them out will allow us shortly to make the last pointer in an op_sibling chain point back to the parent rather than being null, with a new flag indicating whether this is the last op. Perl_ck_fun() still has a couple of direct uses of op_sibling, since it takes the field's address, which is not covered by these macros.
* Remove or downgrade unnecessary dVAR.Jarkko Hietaniemi2014-06-251-29/+23
| | | | | | | | You need to configure with g++ *and* -Accflags=-DPERL_GLOBAL_STRUCT or -Accflags=-DPERL_GLOBAL_STRUCT_PRIVATE to see any difference. (g++ does not do the "post-annotation" form of "unused".) The version code has some of these issues, reported upstream.
* Unused contexts found under PERL_GLOBAL_STRUCT.Jarkko Hietaniemi2014-06-241-1/+4
|
* PERL_UNUSED_CONTEXT -> remove interp context where possibleDaniel Dragan2014-06-241-6/+3
| | | | | | | | | | | | | | | | | | | | | Removing context params will save machine code in the callers of these functions, and 1 ptr of stack space. Some of these funcs are heavily used as mg_find*. The contexts can always be readded in the future the same way they were removed. This patch inspired by commit dc3bf40570. Also remove PERL_UNUSED_CONTEXT when its not needed. See removal candidate rejection rational in [perl #122106]. -Perl_hv_backreferences_p uses context in S_hv_auxinit commit 96a5add60f was wrong -Perl_whichsig_sv and Perl_whichsig_pv wrongly used PERL_UNUSED_CONTEXT from inception in commit 84c7b88cca -in authors opinion cast_* shouldn't be public API, no CPAN grep usage, can't be static and/or inline optimized since it is exported -Perl_my_unexec move to block where it is needed, make Win32 block, context free, for inlining likelyhood, private api and only 2 callers in core -Perl_my_dirfd make all blocks context free, then change proto -Perl_bytes_cmp_utf8 wrongly used PERL_UNUSED_CONTEXT from inception in commit fed3ba5d6b
* If we do not have vsnprintf, the len is unused.Jarkko Hietaniemi2014-06-221-1/+6
|
* g++ -DPERL_GLOBAL_STRUCT_PRIVATE died on this.Jarkko Hietaniemi2014-06-211-1/+1
|
* Revert "/* NOTREACHED */ belongs *before* the unreachable."Jarkko Hietaniemi2014-06-191-10/+5
| | | | | | This reverts commit 148f39b7de6eae9ddd59e0b0aff691d6abea7aca. (Still needs more work, but wanted to see how well this passed with Jenkins.)
* /* NOTREACHED */ belongs *before* the unreachable.Jarkko Hietaniemi2014-06-191-5/+10
| | | | | | Definitely not *after* it. It marks the start of the unreachable, not the first unrechable line. And if they are in that order, it looks better to linebreak after the lint hint.
* Silence several -Wunused-parameter warnings about my_perlBrian Fraser2014-06-131-0/+8
| | | | | | | | This meant sprinkling some PERL_UNUSED_CONTEXT invocations, as well as stopping some functions from getting my_perl in the first place; all of the functions in the latter category are internal (S_ prefix and s or i in embed.fnc), so this should be both safe and economical.
* Added several missing PERL_UNUSED_RESULT()Brian Fraser2014-06-131-2/+2
|
* Mark several functions with __attribute__noreturn__Brian Fraser2014-06-131-4/+4
| | | | | Namely, die_nocontext, die, die_sv, and screaminstr. They all croak and never return, so let's mark them as non-returning.
* Adding missing SVfARG() invocationsBrian Fraser2014-06-131-7/+8
| | | | This silences a chunk of warnings under -Wformat
* Adding missing HEKfARG() invocationsBrian Fraser2014-06-131-1/+1
| | | | This silences a chunk of warnings under -Wformat
* C backtrace tweaks.Jarkko Hietaniemi2014-06-111-7/+27
| | | | | | | | | Rename the environment variable that triggers the backtrace before warns and croaks as PERL_USE_C_BACKTRACE_ON_ERROR (and correspondingly, the define as USE_C_BACKTRACE_ON_ERROR). Pod cleanups and updates, and move the needed #includes from perl.h to util.c since that's the only place where they are needed.