In perl.git, the branch smoke-me/steveh/errno has been updated <http://perl5.git.perl.org/perl.git/commitdiff/7c2af0af4d368d6278ec98e0a708faba40231f20?hp=057c4aa90ceecf1f56cc4690e7c38043e4153920>
- Log ----------------------------------------------------------------- commit 7c2af0af4d368d6278ec98e0a708faba40231f20 Author: Steve Hay <[email protected]> Date: Fri Sep 6 22:14:33 2013 +0100 Fix Windows build for compilers other than VC10+ The new errno2.h only ensures that those new Exxx constants which are required by convert_wsa_error_to_errno() have definitions; the other new Exxx constants will remain undefined on compilers other than VC10+, so we must take care not to use them unless we know they are defined. ----------------------------------------------------------------------- Summary of changes: win32/include/sys/errno2.h | 9 +++++++++ win32/win32.c | 4 +++- win32/win32sck.c | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/win32/include/sys/errno2.h b/win32/include/sys/errno2.h index b4749a3..c2d46fb 100644 --- a/win32/include/sys/errno2.h +++ b/win32/include/sys/errno2.h @@ -156,4 +156,13 @@ /* EPROVIDERFAILEDINIT is not an errno.h value at all */ /* EREFUSED is not an errno.h value at all */ +/* Set a flag indicating whether <errno.h> has the POSIX supplement (the first + * constant in which is EADDRINUSE). If so then we won't have just defined it as + * WSAEADDRINUSE above. + */ +#undef ERRNO_HAS_POSIX_SUPPLEMENT +#if EADDRINUSE != WSAEADDRINUSE +# define ERRNO_HAS_POSIX_SUPPLEMENT +#endif + #endif /* _INC_SYS_ERRNO2 */ diff --git a/win32/win32.c b/win32/win32.c index 3802a54..9f996d6 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2586,7 +2586,9 @@ win32_feof(FILE *fp) return (feof(fp)); } +#ifdef ERRNO_HAS_POSIX_SUPPLEMENT extern int convert_errno_to_wsa_error(int err); /* in win32sck.c */ +#endif /* * Since the errors returned by the socket error function @@ -2607,7 +2609,7 @@ win32_strerror(int e) dTHXa(NULL); if (e < 0) e = GetLastError(); -#if EADDRINUSE != WSAEADDRINUSE +#ifdef ERRNO_HAS_POSIX_SUPPLEMENT /* VC10+ define a "POSIX supplement" of errno values ranging from * EADDRINUSE (100) to EWOULDBLOCK (140), but sys_nerr is still 43 and * strerror() returns "Unknown error" for them. We must therefore still diff --git a/win32/win32sck.c b/win32/win32sck.c index f065be8..508cc0a 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -185,11 +185,13 @@ convert_wsa_error_to_errno(int wsaerr) return 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>; * we just use ERROR_INVALID_FUNCTION for those that are missing but do not - * really expect to encounter them anyway. + * really expect to encounter them anyway in the context in which this function + * is called. * Other Exxx values (err < sys_nerr) are returned unchanged. */ int @@ -282,6 +284,7 @@ convert_errno_to_wsa_error(int err) return err; } +#endif /* ERRNO_HAS_POSIX_SUPPLEMENT */ static int get_last_socket_error(void) -- Perl5 Master Repository
