Redefine errno values for Visual Studio 2010
authorSteve Hay <steve.m.hay@googlemail.com>
Sat, 19 Mar 2011 00:04:35 +0000 (17:04 -0700)
committerJan Dubois <jand@activestate.com>
Sat, 19 Mar 2011 17:15:52 +0000 (10:15 -0700)
commitb59e75b34cef3fedd214c9b6ee744146cf8b3308
tree5fcfe739490cbba81cc4335ecef60f8400d70e62
parent41ef34de832ea2283fbc3b35c6da583d89497204
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>
ext/Errno/Errno_pm.PL
ext/POSIX/POSIX.xs
win32/include/sys/socket.h
win32/win32.h