diff options
author | Steve Hay <steve.m.hay@googlemail.com> | 2013-09-07 21:53:35 +0100 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2013-09-16 15:37:36 +0100 |
commit | 4eaf3102d69324863df3d6e00970832384cdf452 (patch) | |
tree | a9b608feef6f22e15d613ab5160705e08afb2906 /win32/win32sck.c | |
parent | 7b9b1b4e943aea8e8d16d497f20e2d3366df5eae (diff) | |
download | perl-4eaf3102d69324863df3d6e00970832384cdf452.tar.gz |
Fix the #include of winsock2.h in win32/include/sys/errno2.h
For some reason (I didn't figure out why) cpan/Win32/Win32.xs did not
compile as of the previous commit, but in any case we cannot just blindly
include winsock2.h because (a) it is too late if winsock.h has already
been included and (b) early WinCE doesn't have it.
The definition of _WINSOCKAPI_ was also wrongly not updated to _WINSOCK2API_
but was mistaken in its comment "Don't drag in everything" anyway: it's
actually just an old-fashioned "include guard", not a means to include a
minimal API from the file. (The mistaken comment came from the original
ext/Errno/Errno_pm.PL before this round of $!-related changes. That file
also had a redundant "#include <winsock.h>" left in it which should have
been removed along with earlier work that removed the other one, so tidy
that up too.)
Steal a hopefully more correct incantation from win32/include/sys/socket.h
instead.
Now that we allow for the possibility of winsock.h being used again, we
must take care not to make use of WSAECANCELLED if it is not defined.
(That is the only WSAExxx constant which we use that was new in winsock2.h.)
Diffstat (limited to 'win32/win32sck.c')
-rw-r--r-- | win32/win32sck.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/win32/win32sck.c b/win32/win32sck.c index 508cc0a95f..5032cf01b1 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -170,8 +170,10 @@ convert_wsa_error_to_errno(int wsaerr) return WSAEDISCON; /* EDISCON is not defined */ case WSAENOMORE: return WSAENOMORE; /* ENOMORE is not defined */ - case WSAECANCELLED: +#ifdef WSAECANCELLED + case WSAECANCELLED: /* New in WinSock2 */ return ECANCELED; +#endif case WSAEINVALIDPROCTABLE: return WSAEINVALIDPROCTABLE; /* EINVALIDPROCTABLE is not defined */ case WSAEINVALIDPROVIDER: @@ -188,7 +190,7 @@ convert_wsa_error_to_errno(int wsaerr) #ifdef ERRNO_HAS_POSIX_SUPPLEMENT /* Translate Exxx values in the POSIX supplement range defined in VC++ 2010 and * above (EADDRINUSE <= err <= EWOULDBLOCK) to corresponding WSAExxx values. Not - * all such Exxx constants have corresponding WSAExxx constants in <winsock2.h>; + * all such Exxx constants have corresponding WSAExxx constants in <winsock*.h>; * we just use ERROR_INVALID_FUNCTION for those that are missing but do not * really expect to encounter them anyway in the context in which this function * is called. @@ -209,7 +211,11 @@ convert_errno_to_wsa_error(int err) case EBADMSG: return ERROR_INVALID_FUNCTION; case ECANCELED: - return WSAECANCELLED; +#ifdef WSAECANCELLED + return WSAECANCELLED; /* New in WinSock2 */ +#else + return ERROR_INVALID_FUNCTION; +#endif case ECONNABORTED: return WSAECONNABORTED; case ECONNREFUSED: |