/* 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 */
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
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
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
return err;
}
+#endif /* ERRNO_HAS_POSIX_SUPPLEMENT */
static int
get_last_socket_error(void)