summaryrefslogtreecommitdiff
path: root/ext/POSIX/POSIX.xs
Commit message (Collapse)AuthorAgeFilesLines
* avoid truncating time values when long is smaller than time_tTony Cook2012-01-181-2/+2
| | | | | | | | | long is only 32-bits on x64 Win32, but time_t is 64-bits. This was warning: POSIX.xs(1777) : warning C4244: 'initializing' : conversion from 'time_t' to 'const long', possible loss of data The check against (time_t)-1 is the approved check from ANSI C 89 and 99.
* Provide the correct POSIX return value for POSIX::dup2() on Win32.Nicholas Clark2011-12-301-0/+11
| | | | | | | | | | Microsoft, in their wisdom, chose to ignore the POSIX spec when implementing their dup2(), and have theirs return 0 on success, instead of the file descriptor. It seems that no other vendor is this, um, "special", so code the exception directly, as we don't run Configure on Win32, so there's little point probing for this. This resolves RT #98912.
* Convert POSIX::sleep to an XS wrapper for PerlProc_sleep().Nicholas Clark2011-12-301-0/+8
| | | | | | | | Previously it was a Perl wrapper for CORE::sleep, converting CORE::sleep's return value of elapsed time slept into the POSIX return value of seconds remaining. However, that approach could sometimes return a negative result if CORE::sleep had slept for more than a second longer than the requested time.
* Signal handlers must run before sigsuspend returnsLeon Timmermans2011-12-291-0/+4
| | | | | | | | | | The whole point of sigsuspend and pause is to wait until a signal has arrived, and then return *after* it has been triggered. Currently delayed/"safe" signals prevent that from happening, which might cause race conditions. This patch prevents that (as far as possible) by running the signal handlers ASAP.
* avoid double defining the POSIX::TCSANOW constant subTony Cook2011-11-281-2/+6
| | | | | | | | | On Win32 which has no native TCSANOW definition this would produce: Constant subroutine TCSANOW redefined at ../lib/POSIX.pm line -1. because the macro wasn't defined when building the unknown symbols table but was defined when building the defined symbols table.
* Change POSIX::Termios::setattr() to default to TCASNOW, not 0.Nicholas Clark2011-09-131-1/+8
| | | | | | | | 0 isn't valid on all operating systems. TCASNOW has the value 0 on most operating systems, but on Solaris (at least) TCASNOW, TCSADRAIN and TCSAFLUSH have the same values as the equivalent ioctls, TCSETS, TCSETSW and TCSETSF. Solaris faults 0, setting errno to EINVAL. This isn't useful as a default behaviour.
* Remove unneeded fallback definitions of dNOOP, dVAR etc from POSIX.xsNicholas Clark2011-09-131-20/+0
| | | | | | As POSIX.xs is not dual life, we can always rely on these macros being defined for us in perl.h. (And these days, dual life XS code should let Devel::PPPort take care of this sort of thing.)
* Merge the implementations of POSIX::{asctime,mktime} using ALIAS.Nicholas Clark2011-09-131-34/+18
| | | | | | This shares identical code marshaling 6 to 9 input arguments into a struct tm. However, as the return types differ we have to explicitly code pushing the return value onto perl's stack.
* Merge the implementations of POSIX::{access,mkfifo} using ALIAS.Nicholas Clark2011-09-131-7/+8
|
* Merge the implementations of POSIX::{close,dup,tcdrain} using ALIAS.Nicholas Clark2011-09-131-8/+8
| | | | On this platform, this reduces the shared object size by about .5K.
* Merge the implementations of 11 is*() functions in POSIX using XSANY.Nicholas Clark2011-09-131-154/+74
| | | | | | | is{alnum,alpha,cntrl,digit,graph,lower,print,punct,space,upper,xdigit} have identical structures, so replace them with one body to marshal arguments between Perl and C, calling the C library is*() function via a function pointer stored in the CV's XSANY.
* Merge the implementations of 10 maths functions in POSIX using ALIAS.Nicholas Clark2011-09-131-36/+44
| | | | | | 10 functions take a single NV argument and return an NV result. Merging them reduces the shared object size by over 2K on this platform. (Argument marshalling code in XS is not free.)
* Change POSIX::localeconv() to a table-driven implementation.Nicholas Clark2011-09-131-63/+58
| | | | | | This removes a lot of copy-paste code. [with a tweak by Ilmari that removed residual duplication]
* Merge the implementations of 2 sets of POSIX functions.Nicholas Clark2011-09-131-15/+14
| | | | | | Using ALIAS to merge POSIX::sig{pending,suspend} and POSIX::tc{flow,flush,sendbreak} reduces the size of POSIX.so by about 2K on this platform.
* Merge the implementations of 4 sets of POSIX::Termios methods.Nicholas Clark2011-09-131-87/+53
| | | | | | Using ALIAS to merge cfget[io]speed(), get[cloi]flag(), cfset[io]speed() and set[cloi]flag() reduces the size of POSIX.so by almost 2K on this platform.
* Merge the implementations of 2 pairs of POSIX::SigSet methods.Nicholas Clark2011-09-131-11/+14
| | | | | | Using ALIAS to merge addset() with delset() and emptyset() with fillset() reduces the shared object size, by removing duplicate marshaling code for arguments and return values. On this platform the saving is over .5K
* Store sigset_t used by POSIX::SigSet directly in the object SV.Nicholas Clark2011-09-131-22/+15
| | | | | | | | | | | | | | Previously POSIX::SigSet was using the PTROBJ typemap to store a pointer to a dynamically-allocated sigset_t as an IV (blessed into the class) This requires an explicit DESTROY to free the dynamic allocation, but fails badly if any POSIX::SigSet objects exist at ithread clone time, as the dynamic allocation is not duplicated in the new thread. (DESTROY is called in both threads, free-from-wrong pool or other jollity occurs.) Removing dynamic allocation removes the need for a DESTROY method. This change is analogous to the previous change in POSIX::Termios, and is made for the same reason.
* In POSIX.xs, extract allocate_struct() from POSIX::Termios::new().Nicholas Clark2011-09-131-7/+13
| | | | | The same code will be needed for POSIX::SigSet::new(), so share it as a small static function.
* Store struct termios used by POSIX::Termios directly in the object SV.Nicholas Clark2011-09-131-15/+13
| | | | | | | | | | | | | | | | | Previously POSIX::Termios was using the PTROBJ typemap to store a pointer to a dynamically-allocated struct termios as an IV (blessed into the class). This requires an explicit DESTROY to free the dynamic allocation, but fails badly if any POSIX::Termios objects exist at ithread clone time, as the dynamic allocation is not duplicated in the new thread. (DESTROY is called in both threads, free-from-wrong pool or other jollity occurs.) Removing dynamic allocation removes the need for a DESTROY method. This introduces a new OPAQUEPTROBJ typemap, but currently doesn't use the OUTPUT section, as that copies an existing structure, whereas POSIX::Termios->new() only needs to zero-allocate the right space. Assuming that this typemap should be of general applicability, it should be moved to the main typemap file.
* The Borland Chainsaw MassacreSteve Hay2011-09-101-3/+0
| | | | | Remove support for the Borland C++ compiler on Win32, as agreed here: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2011-09/msg00034.html
* Redefine errno values for Visual Studio 2010Steve Hay2011-03-191-81/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Perl traditionally stores WinSock error codes (values above 10000) in errno, with corresponding support for $! to stringify them properly. In Visual Studio 2010 (and presumably newer Windows SDKs) Microsoft has started to define additional errno constants in errno.h (values between 100 and 200) with conflicting names (e.g. EWOULDBLOCK). There are 2 ways to deal with this situation: 1) Redefine the errno.h constants back to the winsock values for the Errno and POSIX modules. 2) Translate the winsock error codes to the new errno constants in the socket implementation in win32/win32sck.c. Solution 1) has the advantage that any existing Perl code that has numeric error codes hard-coded in it will continue to work. Solution 2) has the advantage that XS code using external libaries can set errno to the new constants, and they will be handled consistently in the Perl core. It will however need additional support for other compilers and runtime libraries that don't support these new error codes. This commit implements solution 1). Blame attribution: the commit message is from Jan Dubois, the actual patch was created by Steve Hay. Signed-off-by: Jan Dubois <jand@activestate.com>
* Fix typos (spelling errors) in ext/*.Peter J. Acklam) (via RT2011-01-071-1/+1
| | | | | | | | | # New Ticket Created by (Peter J. Acklam) # Please include the string: [perl #81882] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81882 > Signed-off-by: Abigail <abigail@abigail.be>
* fix various compiler warnings from XS codeZefram2010-12-111-19/+19
| | | | | | | | | | | Trivial changes to fix warnings of types * unclear precedence * assignment as conditional * signed/unsigned mixing * unused parameter/variable * value computed not used * wrong argument type for a printf format * variable may be used uninitialised (due to unhandled switch case)
* rt77432: sigaction would crash/assert with a replaced %SIGTony Cook2010-08-311-1/+1
|
* fix logic for a workaround in POSIX.xsStepan Kasal2009-11-231-2/+2
| | | | | | | | There is the assignment "RETVAL = 0" to silence the compiler in case it incorrectly reports return of an undefined value. This assignment should be present whenever *any* of the symbols is not defined. But the code was written so that the assignment was compiled only when *none* of the symbols was defined.
* Add missing LEAVE to POSIX.xs sigactionGerard Goossen2009-11-121-2/+6
|
* Map winsock error codes to POSIX errno valuesJan Dubois2009-11-111-0/+123
|
* Replace sv_2mortal(newSVpvn(...)) with newSVpvn_flags(..., SVs_TEMP)Nicholas Clark2009-10-151-8/+8
|
* Use newSVpvn(), newSVpvs() and gv_fetchpvs(), the later with proper arguments.Nicholas Clark2009-10-151-3/+3
| | | | Brought to you by the Campaign for the Elimination of strlen().
* In strftime(), save a malloc()/free() by using sv_usepvn_flags().Nicholas Clark2009-10-151-2/+6
|
* POSIX::strftime() should be able to handle Unicode characters in the formatNicholas Clark2009-10-151-3/+3
| | | | | | | | string. (Restore the intent of 9e8c01f558a03902ff2f54935fd7e6dcc7ec656c, but with non- buggy tests. Improve the implementation so that it doesn't always upgrade the format string to UTF-8.)
* Hmmm... this may be a heisenbug. Works on some terminals but notSteve Peters2009-10-151-3/+3
| | | | | | others. This reverts commit 9e8c01f558a03902ff2f54935fd7e6dcc7ec656c.
* POSIX::strftime() should be able to handle Unicode characters in theSteve Peters2009-10-151-3/+3
| | | | format string the same as ASCII ones.
* Fix compiler warning when cuserid is absent and sizeof(int) != sizeof(pointer)Tim Jenness2009-07-081-4/+9
| | | | | | | | | | | | | | | | | | | The attached patch fixes a compilation warning from POSIX.xs when cuserid is missing and ints and pointers have different size. eg on Mac OSX when using 64-bit mode. gcc-4.2 -c -fno-common -DPERL_DARWIN -no-cpp-precomp -arch x86_64 -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include -O3 -g -DVERSION=\"1.17\" -DXS_VERSION=\"1.17\" "-I../.." POSIX.c POSIX.c: In function 'XS_POSIX_cuserid': POSIX.c:4096: warning: cast to pointer from integer of different size Running Mkbootstrap for POSIX () chmod 644 POSIX.bs rm -f ../../lib/auto/POSIX/POSIX.bundle Also relevant for 5.10.1. Signed-off-by: H.Merijn Brand <h.m.brand@xs4all.nl>
* Fix POSIX::tzset() as per Time::Piece::_tzset().Steve Hay2009-05-061-0/+112
| | | | | | | Jan Dubois suggested POSIX::tzset() should be fixed too, but there is no way to share the code since Time-Piece is dual-lived and POSIX is not. Therefore, the code is simply duplicated with appropriate comments to prompt keeping the two in sync.
* Remove all #ifdef MACOS_TRADITIONAL code in core and non-dual-life XS code.Nicholas Clark2009-04-271-16/+8
| | | | | | | | (MacOS support was removed from MakeMaker in 6.22, and merged to blead on 15th December 2004 with 5dca256ec738057dc331fb644a93eca44ad5fa14. After this point MacOS wouldn't even have been able to build the perl binary, because it would not have been able to build DynaLoader. If anyone wishes to resurrect MacOS, start by reversing this commit and the relevant part of that commit.)
* Adjustments to POSIX for the Haiku portIngo Weinhold2009-01-051-7/+17
| | | | | | | | | Message-Id: <20081029022544.413.1@knochen-vm.localdomain> I re-introduced the use of the WMUNGE() macro, which was (accidentally?) removed after 5.10.0. The macro is still a hack. As my added comment explains the use of the OS's W*() macros in this context is simply not correct and should probably better be fixed.
* Add conditional code to initialise RETVAL, to avoid compiler warnings.Nicholas Clark2008-05-311-0/+5
| | | | | (There was never an error, as croak() was called before the return). p4raw-id: //depot/perl@33956
* My recent changes to POSIX.xs forgot that WEXITSTATUS etc may not evenNicholas Clark2008-05-251-0/+24
| | | | | | | be defined. This fix changes the error message from "Your vendor has not defined POSIX macro %s, used" to "POSIX::%s not implemented on this architecture", which I assume is not going to break anything. p4raw-id: //depot/perl@33936
* Replaced the WEXITSTATUS, WIFEXITED, WIFSIGNALED, WIFSTOPPED, WSTOPSIGNicholas Clark2008-05-211-20/+31
| | | | | | | | and WTERMSIG wrappers with one wrapper using the XS "ALIAS" feature. This gets the shared object size back below the size before the removal of int_macro_int. It looks like there are other space savings to be made this way. p4raw-id: //depot/perl@33897
* Eliminate POSIX::int_macro_int, and all the complex AUTOLOAD fandangoNicholas Clark2008-05-211-151/+23
| | | | | | | | that creates closures round it. Instead, wrap WEXITSTATUS, WIFEXITED, WIFSIGNALED, WIFSTOPPED, WSTOPSIG and WTERMSIG directly with XS. The shared library is slightly larger, but dynamic memory usage savings beat this, even within one thread of one process. Simpler code too. p4raw-id: //depot/perl@33896
* Remove POSIX's internal implementation of S_ISBLK, S_ISCHR, S_ISDIR,Nicholas Clark2008-05-151-70/+8
| | | | | | | S_ISFIFO and S_ISREG, and pull them in from Fcntl. Spotted as a result of bug #54186, but there has been a redefined subroutine warning for ages if you elected to import all of POSIX and Fcntl's exports. p4raw-id: //depot/perl@33826
* From: "Robin Barker" <Robin.Barker@npl.co.uk>Robin Barker2008-01-111-2/+2
| | | | | | | Message-ID: <46A0F33545E63740BC7563DE59CA9C6D0939C3@exchsvr2.npl.ad.local> More consting. p4raw-id: //depot/perl@32947
* ext/ constingRobin Barker2007-12-221-2/+2
| | | | | | | From: "Robin Barker" <Robin.Barker@npl.co.uk> Message-ID: <46A0F33545E63740BC7563DE59CA9C6D09399D@exchsvr2.npl.ad.local> Date: Sat, 22 Dec 2007 00:39:47 -0000 p4raw-id: //depot/perl@32703
* Fix POSIX::setlocale(): the CRT function returns a pointer to aSteve Hay2007-06-271-3/+12
| | | | | | | | buffer that may be overwritten by subsequent calls to the CRT function, so we must make a safe copy of that buffer for our own use. This fixes lib/locale.t on Win32 with the Borland compiler, but presumably could affect other compilers too. p4raw-id: //depot/perl@31482
* Cast needed to get POSIX compiling with g++ on FreeBSD.Nicholas Clark2007-04-101-1/+1
| | | p4raw-id: //depot/perl@30898
* Make the isdst argument to asctime and mktime default to -1Rafael Garcia-Suarez2007-03-151-2/+2
| | | | | instead of 0, as suggested by Mike Schilli. p4raw-id: //depot/perl@30590
* Silence VC++ 8 warnings about "possible loss of data"Steve Hay2006-11-281-1/+1
| | | p4raw-id: //depot/perl@29408
* Additional changes to get C++ a little closer to a clean compileSteve Peters2006-08-161-1/+1
| | | | | of Perl. p4raw-id: //depot/perl@28729
* Two signed array indicies that Coverity spots should be unsigned.Nicholas Clark2006-05-091-2/+2
| | | p4raw-id: //depot/perl@28142