summaryrefslogtreecommitdiff
path: root/pp_sys.c
Commit message (Collapse)AuthorAgeFilesLines
* Now that I_SYS_SYSCALL is defined, use itH.Merijn Brand2023-04-301-0/+4
|
* pp_sys.c - suppress warning about comparison to unsigned valueYves Orton2023-03-291-0/+6
|
* getsockopt: increase the buffer size for getsockopt()Tony Cook2023-03-231-3/+6
| | | | | | | | | | | | | | | | | | As suggested in the ticket, the buffer size is now 1024 by default, but this can be adjusted at perl build time with: -Accflags=-DPERL_GETSOCKOPT_SIZE=2048 or similarly with hints. I considered making this adjustable with a ${^...} variable, but that seemed excessive. I don't see a practical way to regression test this, TCP_INFO is non-portable. I did examine strace output for a one-liner that calls getsockopt() and the new buffer size was used. Fixes #19758
* fix check order for filetest overloadDavid Mitchell2023-02-281-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tryAMAGICftest_MG() macro was doing two checks: 1) seeing whether the filetest operator's arg (*PL_stack_sp) looks to have magic or be a reference, 2) and if the op has children (which will have pushed an arg, unlike (-X _), If both are true, then do full-on magic and/or overload processing. The problem with this is that it checks the arg *before* checking whether there's even an arg. Thus in the case of (-X _), it is actually examining a random SV on the stack (or in the case of nothing on the stack, examining the PL_sv_undef pointer always stored at PL_stack_base[0] as a guard.) It turns out this was harmless - the test for (1) will examine a random (but real) SV and get garbage results, but then the 2nd test will fail anyway, so overloading won't be called. So the fix is to swap the (1) and (2) test order. In addition, I changed the 'has an argument' test from OPf_KIDS to !OPf_REF. These should be mutually exclusive, but the OPf_REF flag formally indicates (-X _), i.e. that no arg has been pushed on the stack. Whether the op has children or not could potentially change in the future, independent of whether it's the (-X _) form. So overall this commit makes no visible functional difference, but may make the code more robust against future changes.
* Replace SvGROW with sv_grow_fresh in perl.c, pp_sys.c, toke.cRichard Leach2022-11-301-3/+2
| | | | | | | | | | | | | | Changed: * perl.c - Perl_moreswitches * pp_sys.c - pp_sysread * toke.c - Perl_scan_str In each of the above functions, one instance of SvGROW on a new SVt_PV can be swapped for the more efficient sv_grow_fresh. In two of the instances, the calls used to create the the SVt_PV have also been streamlined. There should not be any functional change as a result of this commit.
* only fully calculate the stash (effective) name where neededTony Cook2022-11-181-1/+1
| | | | | | | | | gcc 12 was complaining that evaluating (somehekptr)->hek_key was always true in many places where HvNAME() or HvENAME() was being called in boolean context. Add new macros to check whether the names should be available and use those instead.
* Add mutexes around calls in pp_sys.cKarl Williamson2022-09-291-2/+13
| | | | | | If there is no reentrant form of the function, these still won't be thread safe, but doing that is better done in reentr.c. It is on my TODO list.
* sv.c - add a _QUOTEDPREFIX version of SVf, UTF8f, and HEKf for use in error ↵Yves Orton2022-08-251-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | messages. These new formats are intended to be used in error messages where we want to show the contents of a string without any possible hidden characters not rendering in the error message, and where it would be unreasonable to show every character of the string if it is very long. A good example would be when we want to say that a class name is illegal. Consider: "Foo\0"->thing() should not throw an error message about "Foo" being missing, the fact there is a null in there should be visible to the developer. Similarly if we had ("x" x 1000_000)->thing() we also do not want to throw a 1MB error message as it is generally just unhelpful, a class name that long is almost certainly a mistake. Currently this patch restricts it to showing 256 characters, the first 128 followed by an ellipses followed by the last 128 characters, but the docs are such that we can change that if we wish, I suspect something like 100 would be more reasonable. You can override the define PERL_QUOTEDPREFIX_LEN to a longer value in Configure if you wish. Example usage: other= newSVpvs("Some\0::Thing\n"); sv_catpvf(msg_sv,"%" SVf_QUOTEDPREFIX, SVfARG(other)); Should append "Some\0::Thing\n" to the msg_sv. If it were very long it would have ellipses infixed. The class name "x" x 1_000_000 would show Can't locate object method "non_existent_method" via \ package "x[repeated 128 times]"..."x[repeated 128 times]" \ (perhaps you forgot to load \ "x[repeated 128 times]"..."x[repeated 128 times]"?) at -e line 1. (but obviously as one line with the literal text of the class instead of "[repeated 128 times]") This patch changes a variety of error messages that used to output the full string always. I haven't changed every place that this could happen yet, just the main ones related to method calls, subroutine names and the like.
* Add a new env var PERL_RAND_SEEDYves Orton2022-08-121-0/+17
| | | | | | | | | | | | | | | | | | | | | This env var can be used to trigger a repeatable run of a script which calls C<srand()> with no arguments, either explicitly or implicitly via use of C<rand()> prior to calling srand(). This is implemented in such a way that calling C<srand()> with no arguments in forks or subthreads (again explicitly or implicitly) will receive their own seed but the seeds they receive will be repeatable. This is intended for debugging and perl development performance testing, and for running the test suite consistently. It is documented that the exact seeds used to initialize the random state are unspecified, and that they may change between releases or even builds. The only guarantee provided is that the same perl executable will produce the same results twice all other things being equal. In practice and in core testing we do expect consistency, but adding the tightest set of restrictions on our commitments seemed sensible. The env var is ignored when perl is run setuid or setgid similarly to the C<PERL_INTERNAL_RAND_SEED> env var.
* Replace sv_2mortal(newSVhek( with newSVhek_mortalRichard Leach2022-08-051-1/+1
| | | | The new Perl_newSVhek_mortal function is slightly more efficient.
* Make 4-argument select() handle UTF8-flagged strings correctly.Felipe Gasper2022-07-191-1/+4
| | | | Issue #19882
* setsockopt: treat boolean values as numbersTAKAI Kousuke2022-07-111-1/+1
| | | | | | | Boolean values used to be treated as string, but this is not desirable. (thanks to @tonycoz) Also added tests for this.
* setsockopt: use SvPOK to determine whether OPTVAL is string or integerTAKAI Kousuke2022-07-111-1/+1
| | | | | | | | | | | | setsockopt (pp_ssockopt) used to treat its last argument (OPTVAL) as a packed string whenever it has string slot set (SvPOKp), but this would be confused if the argument is an integer but had cached stringified value. Now it will treat OPTVAL as a packed string only when it is originally created as a string, using Perl 5.36+'s new (internal) feature where POK flag indicates whether the SV started as a string. Will fix GH #18642.
* perlapi: Note PL_defoutgv is ref'd by setdefout()Karl Williamson2022-07-021-0/+4
|
* Convert '!!' to cBOOL()Karl Williamson2022-06-141-2/+4
| | | | | | | | | | | | I believe the '!!' is somewhat obscure; I for one didn't know about it for years of programming C, and it was buggy in one compiler, which is why cBOOL was created, I believe. And it is graphically dense, and generally harder to read than the cBOOL() construct. This commit dates from before we moved to C99 where we can simply cast to (bool), and cBOOL() has been rewritten to do that. But the vast majority of code uses cBOOL(), and this commit brings the remainder of the core .[ch] files into uniformity.
* Drop the unused hv argument from S_hv_free_ent_ret()Nicholas Clark2022-03-191-2/+2
| | | | | | | | | | | In turn, this means that the hv argument to Perl_hv_free_ent() and Perl_hv_delayfree_ent() is now clearly unused, so mark it as such. Both functions are deemed to be API, so unlike the static function S_hv_free_ent_ret we can't simply change their parameters. However, change all the internal callers to pass NULL instead of the hv, as this makes it obvious that the function does not read hv, and might cause the compiler to generate better code.
* add {} around the now two lines introduced by f7f919a0Tony Cook2021-12-071-1/+2
| | | | | | | | This turned out to be harmless, as sv_setpvn_fresh() does nothing when h_addr is NULL, but the call is also unnecessary when h_addr is NULL, and possibly confusing to future maintainers. CID 343917
* Misc microoptimizations when dealing with new SVsRichard Leach2021-12-041-3/+5
| | | | | | | | | | In a few places, SVs can be created more efficiently or new SVs can be assigned to more efficiently. Small changes included: * Use sv_setpvn_fresh instead of sv_setpvn * Use sv_mortalcopy_flags instead of sv_newmortal + sv_setsv_flags * newSVsv_flags instead of newSV + sv_setsv_flags * sv_newmortal instead of sv_2mortal(newSV(0)) * Remove a SvGROW(sv, 257) following a newSV(257)
* newSVpvn_flags().. is more efficient than sv_2mortal(newSVpvn(..))Richard Leach2021-11-291-1/+1
| | | | The same holds for newSVpvs* wrappers around newSVpvn* functions.
* newSVpvn_flags(x, .. ,SVs_TEMP) more efficient than sv_2mortal(newSVpv(x,0))Richard Leach2021-11-291-2/+6
|
* pp_system: safe to switch in sv_setpvn_fresh hereRichard Leach2021-11-011-1/+1
|
* Remove NetWare supportDagfinn Ilmari Mannsåker2021-10-081-4/+0
| | | | The build has been broken since 2009.
* Free tied hash iterator state immediately at the `untie` callNicholas Clark2021-09-221-0/+12
| | | | | | | | | Previously the state was only freed at the point when the hash was iterated again, or re-tied, or destroyed. This shouldn't make any difference to sane code, but the change can be detected with suitably pathological pure-Perl code, so someone might just (unwisely) be relying on this undocumented implementation detail.
* detect struct stat.st_dev's size and signedness, and return it safelyTony Cook2021-09-011-0/+31
| | | | | | | | | | | | | | On FreeBSD dev_t (and hence the st_dev member of struct stat) is an unsigned 64-bit integer, and the previous simple PUSHi() corrupted that. A previous version of this reflected the st_ino code and implemented our own number to string conversion, but a system with such a large st_dev should be assumed to have inttypes.h, and an intmax_t which is no smaller than st_dev. The st_ino code could probably be changed similarly, but 64-bit inode numbers are not a new thing, so it may be riskier.
* pp_tie should completely reset the underlying hash's iterator state.Nicholas Clark2021-08-251-0/+1
| | | | | | | | | Previously it would mangle it, resetting EITER but not RITER, meaning that after untie continuing iteration would be inconsistent - normally it would carry on exactly where it left off, but if iteration had been in the middle of a chain of HEs, it would skip the rest of the chain. Fixes GH #19077
* pp_tie should use HvEITER_get() instead of HvEITER().Nicholas Clark2021-08-241-1/+1
| | | | The former doesn't make a function call.
* fix magic and upgraded SV handling for setsockopt()'s OPTVALTony Cook2021-06-231-2/+3
| | | | | | | | The code here checked SV flags before fetching magic, potentially getting confused if magic fetched changed flags. This also fixes handling for upgraded SVs, but I'm not sure that can be tested sufficiently portably.
* Rename G_ARRAY to G_LIST; provide back-compat when not(PERL_CORE)Paul "LeoNerd" Evans2021-06-021-14/+14
|
* style: Detabify indentation of the C code maintained by the core.Michael G. Schwern2021-01-171-1993/+1993
| | | | | | | | | | | This just detabifies to get rid of the mixed tab/space indentation. Applying consistent indentation and dealing with other tabs are another issue. Done with `expand -i`. * vutil.* left alone, it's part of version. * Left regen managed files alone for now.
* Win32: implement symlink() and readlink()Tony Cook2020-12-011-3/+3
| | | | | | | | The API used requires Windows Vista or later. The API itself requires either elevated privileges or a sufficiently recent version of Windows 10 running in "Developer Mode", so some tests require updates.
* fetch magic on the first stacked filetest, not the lastTony Cook2020-11-111-1/+1
| | | | fixes #18293
* autodoc.pl: Enhance apidoc_section featureKarl Williamson2020-11-061-1/+1
| | | | | | | | | | | 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.
* Reorganize perlapiKarl Williamson2020-09-041-1/+1
| | | | | This uses a new organization of sections that I came up with. I asked for comments on p5p, but there were none.
* pp_sys.c: Convert to use av_count()Karl Williamson2020-08-191-1/+1
|
* Remove Symbian portDagfinn Ilmari Mannsåker2020-07-201-19/+5
| | | | | Also eliminate USE_HEAP_INSTEAD_OF_STACK and SETSOCKOPT_OPTION_VALUE_T, since Symbian was the only user of those.
* Fix a bunch of repeated-word typosDagfinn Ilmari Mannsåker2020-05-221-1/+1
| | | | | Mostly in comments and docs, but some in diagnostic messages and one case of 'or die die'.
* pp_sys.c: don't hardcode socket address buffer sizeTomasz Konojacki2020-05-191-2/+6
| | | | | | When it's possible, use sizeof(struct sockaddr_storage). fixes #17761
* Revert "pp_(get|set)priority: remove ancient glibc C++ workaround"Dagfinn Ilmari Mannsåker2020-02-121-2/+15
| | | | | | | | | It turns out that even though the headers correctly define the argument as `int` under C++, -Wc++-compat doesn't know this. Add a comment to stop others from falling into the same trap I did. This reverts commit 34d254cefc451e5ab438acf22a51d7b557c05a0e.
* pp_sys.c: add casts to silence Win32 build warningsYves Orton2020-02-081-5/+5
|
* pp_(get|set)priority: remove ancient glibc C++ workaroundDagfinn Ilmari Mannsåker2020-02-041-10/+2
| | | | | | | Glibc has enum typedefs for some arguments that are defined as `int` by the X/Open standard. This is fine in C, but until glibc 2.3 (released in 2002) this was also done for C++, which is not allowed.
* (perl #134291) propagate non-PVs in $@ in bare die()Tony Cook2019-07-221-1/+1
|
* pp_sys.c: fix the position of HAS_SETNETENT definementAlexandr Savca2019-07-091-1/+1
| | | | Else, DIE() will bever be executed.
* pp.c, pp_sys.c: Use DO_UTF8 instead of its expansionKarl Williamson2019-03-191-1/+1
| | | | We have a macro to hide the details of this; use it
* First "eof" should return trueHauke D2019-01-021-1/+1
| | | | | When no file has previously been opened, "eof" should return true. This behavior was broken by 32e653230c7ccc (see also [#60978]).
* Remove 1 comparison whose result is always the same.James E Keenan2018-11-251-2/+1
| | | | | | Per: https://lgtm.com/projects/g/Perl/perl5/alerts/?mode=tree&ruleFocus=2154840804 For: RT 133686 (partial)
* Cast away const from AIX' accessx() path argumentDagfinn Ilmari Mannsåker2018-10-231-2/+2
| | | | | | Unlike every other platform's access() or equivalent (and as required by POSIX), AIX doesn't declare the path argument to access() and accessx() as const char*, so cast the const away.
* (perl #125760) fatalize sysread/syswrite/recv/send on :utf8 handlesTony Cook2018-10-101-66/+14
| | | | | | | | | | | | | This includes removing the :utf8 logic from pp_syswrite. pp_sysread retains it, since it's also used for read(). Tests that are specifically testing the behaviour against :utf8 handles have been removed (eg in lib/open.t), several other tests that incidentally used those functions on :utf8 handles have been adapted to use :raw handles instead (eg. op/readline.t). Test lib/sigtrap.t fails if STDERR is :utf8, in code from the original 5.000 commit, which is intended to run in a signal handler
* pp_warn: use MEXTEND rather than EXTENDDavid Mitchell2018-01-311-1/+1
| | | | RT #132602
* Revert "Revert "make PerlIO handle FD_CLOEXEC""Zefram2018-01-181-6/+0
| | | | | | This reverts commit 523d71b314dc75bd212794cc8392eab8267ea744, reinstating commit 2cdf406af42834c46ef407517daab0734f7066fc. Reversion is not the way to address the porting problem that motivated that reversion.
* Revert "make PerlIO handle FD_CLOEXEC"Abigail2018-01-181-0/+6
| | | | | | | | | | | | | | | | | | | | | This reverts commit 2cdf406af42834c46ef407517daab0734f7066fc. The reason for the revert is that with this commit, perl fails to compile on darwin (or at least, one some versions of it): ./miniperl -Ilib make_ext.pl lib/auto/DB_File/DB_File.bundle MAKE="/Applications/Xcode.app/Contents/Developer/usr/bin/make" LIBPERL_A=libperl.a LINKTYPE=dynamic Parsing config.in... Looks Good. dyld: lazy symbol binding failed: Symbol not found: _mkostemp Referenced from: /private/tmp/perl/cpan/DB_File/../../miniperl Expected in: flat namespace dyld: Symbol not found: _mkostemp Referenced from: /private/tmp/perl/cpan/DB_File/../../miniperl Expected in: flat namespace Unsuccessful Makefile.PL(cpan/DB_File): code=5 at make_ext.pl line 518. make: *** [lib/auto/DB_File/DB_File.bundle] Error 2