summaryrefslogtreecommitdiff
path: root/pp_sys.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Reenable numeric first argument of system() on VMS.Craig A. Berry2018-01-011-1/+1
| | | | | | | This was broken in 64def2aeaeb63f92dadc6dfa334, and fixed for Win32 only in 8fe3452cc6ac7af8c08. But VMS also uses a numeric first argument to system() as a flag indicating spawn without waiting for completion.
* make PerlIO handle FD_CLOEXECZefram2017-12-221-6/+0
| | | | | | Move handling of close-on-exec flag for PerlIO handles into PerlIO itself. Where PerlIO opens new file descriptors, have them opened in O_CLOEXEC mode where possible.
* set FD_CLOEXEC atomically in easy casesZefram2017-12-221-34/+13
| | | | | | | In many places where a file descriptor is being opened, open it with FD_CLOEXEC already set if possible. This commit covers the easy cases, where the file descriptor arises without the use of PerlIO, pp_open, or my_popen.
* preserve numericness of system() args on Win32Zefram2017-12-221-4/+31
| | | | | | | | | | | On Windows there's a nasty variation in the meaning of arguments to Perl's system(), in which a numeric first argument isn't used as part of the command to run, but instead selects between two different operations to perform with the command (whether to wait for the command to complete or not). Therefore the reduction of argument scalars to their operative values in the parent process, which was added in commit 64def2aeaeb63f92dadc6dfa33486c1d7b311963, needs to preserve numericness of arguments on Windows. Fixes [perl #132633].
* semicolon-friendly diagnostic controlZefram2017-12-161-8/+8
| | | | | | New macros {GCC,CLANG}_DIAG_{IGNORE,RESTORE}_{DECL,STMT}, which take a following semicolon. It is necessary to use the _DECL or _STMT version as appropriate to the context. Fixes [perl #130726].
* perform system() arg processing before forkZefram2017-12-161-6/+10
| | | | | | | | | | A lot of things can happen when stringifying an argument list: side effects, warnings, exceptions. In the case of system(), these effects should happen in the context of the parent process. The stringification can also depend on which process it happens in, as in the case of $$, and in that case it should also happen in the parent process. Therefore reduce the argument scalars to strings first thing in pp_system. Fixes [perl #121105].
* make exec keep its argument list more reliablyZefram2017-12-141-2/+0
| | | | | | | | | | Bits of exec code were putting the constructed commands into globals PL_Argv and PL_Cmd, which could then be clobbered by reentrancy. These are only global in order to manage their freeing, but that's better managed by using the scope stack. So replace them with automatic variables, with ENTER/SAVEFREEPV/LEAVE to free the memory. Also copy the strings acquired from SVs, to avoid magic clobbering the buffers of SVs already read. Fixes [perl #129888].
* handle null op_next in stacked filetestsZefram2017-12-061-1/+1
| | | | | | | When a filetest op returns false, it skips past following ops that are stacked filetests. The code to do this was assuming that op_next would always be non-null, which is not always the case, for example in a sort comparator. Allow for it to be null. Fixes [perl #129347].
* revert changes to st_ino signedness handlingZefram2017-12-011-5/+4
| | | | | | | | | | | | | This reverts commits 8843856e9716655549cce789b3338e1d4c72fffb, 3676f9e77d46b61f4785aad171f02bed29df0c07, and 793c2ded15ca832d1df1fabbc3b2e7562a057697. As noted in the large comment above the relevant code, the probed ST_INO_SIGN is not reliable enough for its purpose, because Configure makes guesses. The actual compiler knows whether st_ino is signed, and is perfectly capable of optimising out the negative-handling code in the usual case that st_ino is unsigned, without any need for us to preprocess it away.
* More robust version of 793c2ded.Jarkko Hietaniemi2017-11-291-8/+5
| | | | | | In platforms with st.ino always positive, never even see the negative code. Coverity #169271.
* False false.Jarkko Hietaniemi2017-11-281-1/+1
| | | | (Solaris cc got angry.)
* STDCHAR * might not be char *.Jarkko Hietaniemi2017-11-281-1/+1
| | | | | And therefore one may not be able to subtract the pointers, for example in HP-UX.
* In some systems st.ino is never negative.Jarkko Hietaniemi2017-11-281-0/+4
| | | | (Like HP-UX.)
* pp_sys.c: Avoid reparsing stringKarl Williamson2017-11-241-2/+6
| | | | | | | By using is_utf8_invariant_string_loc() instead of plain is_utf8_invariant_string(), we can start parsing at the first variant (if any is found) instead of the previous behavior of starting again at the beginning of the string.
* correctly error on -k "nonexistent" on WindowsZefram2017-11-171-18/+0
| | | | | | | | | | The file test operators for Unix permission bits were returning a blanket false result on systems where the bit being tested for doesn't exist. That's a sensible way to treat a nonexistent bit when statting a file, but the false result was being returned without checking that the argument actually refers to a file. Remove the pre-stat checks for nonexistent bits, so that we get the correct errors for non-files. We still get a blanket false result for nonexistent bits on files.
* set $! when statting a closed filehandleZefram2017-11-151-9/+13
| | | | | | | When a stat fails because it's on a closed or otherwise invalid filehandle, $! was often not being set, depending on the operation and the nature of the invalidity. Consistently set it to EBADF. Fixes [perl #108288].