summaryrefslogtreecommitdiff
path: root/ext/Errno
diff options
context:
space:
mode:
authorSteve Hay <steve.m.hay@googlemail.com>2011-03-18 17:04:35 -0700
committerJan Dubois <jand@activestate.com>2011-03-19 10:15:52 -0700
commitb59e75b34cef3fedd214c9b6ee744146cf8b3308 (patch)
tree5fcfe739490cbba81cc4335ecef60f8400d70e62 /ext/Errno
parent41ef34de832ea2283fbc3b35c6da583d89497204 (diff)
downloadperl-b59e75b34cef3fedd214c9b6ee744146cf8b3308.tar.gz
Redefine errno values for Visual Studio 2010
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>
Diffstat (limited to 'ext/Errno')
-rw-r--r--ext/Errno/Errno_pm.PL3
1 files changed, 3 insertions, 0 deletions
diff --git a/ext/Errno/Errno_pm.PL b/ext/Errno/Errno_pm.PL
index c38f309c54..56bc815002 100644
--- a/ext/Errno/Errno_pm.PL
+++ b/ext/Errno/Errno_pm.PL
@@ -229,6 +229,9 @@ sub write_errno_pm {
if ($IsMSWin32) {
print CPPI "#include <winsock.h>\n";
foreach $err (keys %wsa) {
+ print CPPI "#if defined($err) && $err >= 100\n";
+ print CPPI "#undef $err\n";
+ print CPPI "#endif\n";
print CPPI "#ifndef $err\n";
print CPPI "#define $err WSA$err\n";
print CPPI "#endif\n";