1 #ifndef _INC_SYS_ERRNO2
2 #define _INC_SYS_ERRNO2
3 
4 /* Too late to include winsock2.h if winsock.h has already been loaded */
5 #ifndef _WINSOCKAPI_
6 #  include <winsock2.h>
7 #endif
8 
9 /* Ensure all the Exxx constants required by convert_wsa_error_to_errno() in
10  * win32/win32sck.c are defined. Many are defined in <errno.h> already (more so
11  * in VC++ 2010 and above and some MinGW/gcc-4.8 and above, which have an extra
12  * "POSIX supplement") so, for the sake of compatibility with third-party code
13  * linked into XS modules, we must be careful not to redefine them; for the
14  * remainder we define our own values, namely the corresponding WSAExxx values.
15  *
16  * These definitions are also used as a supplement to the use of <errno.h> in
17  * the Errno and POSIX modules, both of which may be used to test the value of
18  * $!, which may have these values assigned to it (via code in win32/win32sck.c
19  * and the $! case in Perl_magic_set()). It also provides numerous otherwise
20  * missing values in the (hard-coded) list of Exxx constants exported by POSIX.
21  * Finally, three of the non-standard errno.h values (actually all now in the
22  * POSIX supplement in VC10+ and some MinGW/gcc-4.8+) are used in the perl core.
23  *
24  * This list is in the same order as that in convert_wsa_error_to_errno(). A
25  * handful of WSAExxx constants used by that function have no corresponding Exxx
26  * constant in any errno.h so there is no point in making up values for them;
27  * they are just returned unchanged by that function so we do not need to worry
28  * about them here.
29  */
30 
31 /* EINTR is a standard errno.h value */
32 /* EBADF is a standard errno.h value */
33 /* EACCES is a standard errno.h value */
34 /* EFAULT is a standard errno.h value */
35 /* EINVAL is a standard errno.h value */
36 /* EMFILE is a standard errno.h value */
37 
38 #ifndef EWOULDBLOCK		/* New in VC10 */
39 #  define EWOULDBLOCK		WSAEWOULDBLOCK
40 #endif
41 #ifndef EINPROGRESS		/* New in VC10 */
42 #  define EINPROGRESS		WSAEINPROGRESS
43 #endif
44 #ifndef EALREADY		/* New in VC10 */
45 #  define EALREADY		WSAEALREADY
46 #endif
47 #ifndef ENOTSOCK		/* New in VC10 and needed in doio.c */
48 #  define ENOTSOCK		WSAENOTSOCK
49 #endif
50 #ifndef EDESTADDRREQ		/* New in VC10 */
51 #  define EDESTADDRREQ		WSAEDESTADDRREQ
52 #endif
53 #ifndef EMSGSIZE		/* New in VC10 */
54 #  define EMSGSIZE		WSAEMSGSIZE
55 #endif
56 #ifndef EPROTOTYPE		/* New in VC10 */
57 #  define EPROTOTYPE		WSAEPROTOTYPE
58 #endif
59 #ifndef ENOPROTOOPT		/* New in VC10 */
60 #  define ENOPROTOOPT		WSAENOPROTOOPT
61 #endif
62 #ifndef EPROTONOSUPPORT		/* New in VC10 */
63 #  define EPROTONOSUPPORT	WSAEPROTONOSUPPORT
64 #endif
65 #ifndef ESOCKTNOSUPPORT		/* Not in errno.h but wanted by POSIX.pm */
66 #  define ESOCKTNOSUPPORT	WSAESOCKTNOSUPPORT
67 #endif
68 #ifndef EOPNOTSUPP		/* New in VC10 */
69 #  define EOPNOTSUPP		WSAEOPNOTSUPP
70 #endif
71 #ifndef EPFNOSUPPORT		/* Not in errno.h but wanted by POSIX.pm */
72 #  define EPFNOSUPPORT		WSAEPFNOSUPPORT
73 #endif
74 #ifndef EAFNOSUPPORT		/* New in VC10 and needed in util.c */
75 #  define EAFNOSUPPORT		WSAEAFNOSUPPORT
76 #endif
77 #ifndef EADDRINUSE		/* New in VC10 */
78 #  define EADDRINUSE		WSAEADDRINUSE
79 #endif
80 #ifndef EADDRNOTAVAIL		/* New in VC10 */
81 #  define EADDRNOTAVAIL		WSAEADDRNOTAVAIL
82 #endif
83 #ifndef ENETDOWN		/* New in VC10 */
84 #  define ENETDOWN		WSAENETDOWN
85 #endif
86 #ifndef ENETUNREACH		/* New in VC10 */
87 #  define ENETUNREACH		WSAENETUNREACH
88 #endif
89 #ifndef ENETRESET		/* New in VC10 */
90 #  define ENETRESET		WSAENETRESET
91 #endif
92 #ifndef ECONNABORTED		/* New in VC10 and needed in util.c */
93 #  define ECONNABORTED		WSAECONNABORTED
94 #endif
95 #ifndef ECONNRESET		/* New in VC10 */
96 #  define ECONNRESET		WSAECONNRESET
97 #endif
98 #ifndef ENOBUFS			/* New in VC10 */
99 #  define ENOBUFS		WSAENOBUFS
100 #endif
101 #ifndef EISCONN			/* New in VC10 */
102 #  define EISCONN		WSAEISCONN
103 #endif
104 #ifndef ENOTCONN		/* New in VC10 */
105 #  define ENOTCONN		WSAENOTCONN
106 #endif
107 #ifndef ESHUTDOWN		/* Not in errno.h but wanted by POSIX.pm */
108 #  define ESHUTDOWN		WSAESHUTDOWN
109 #endif
110 #ifndef ETOOMANYREFS		/* Not in errno.h but wanted by POSIX.pm */
111 #  define ETOOMANYREFS		WSAETOOMANYREFS
112 #endif
113 #ifndef ETIMEDOUT		/* New in VC10 */
114 #  define ETIMEDOUT		WSAETIMEDOUT
115 #endif
116 #ifndef ECONNREFUSED		/* New in VC10 */
117 #  define ECONNREFUSED		WSAECONNREFUSED
118 #endif
119 #ifndef ELOOP			/* New in VC10 */
120 #  define ELOOP			WSAELOOP
121 #endif
122 
123 /* ENAMETOOLONG is a standard errno.h value */
124 
125 /* EHOSTDOWN is not in errno.h and despite being wanted by POSIX.pm we cannot
126  * provide any sane value since there is no WSAEHOSTDOWN */
127 
128 #ifndef EHOSTUNREACH		/* New in VC10 */
129 #  define EHOSTUNREACH		WSAEHOSTUNREACH
130 #endif
131 
132 /* ENOTEMPTY is a standard errno.h value */
133 
134 #ifndef EPROCLIM		/* Not in errno.h but wanted by POSIX.pm */
135 #  define EPROCLIM		WSAEPROCLIM
136 #endif
137 #ifndef EUSERS			/* Not in errno.h but wanted by POSIX.pm */
138 #  define EUSERS		WSAEUSERS
139 #endif
140 #ifndef EDQUOT			/* Not in errno.h but wanted by POSIX.pm */
141 #  define EDQUOT		WSAEDQUOT
142 #endif
143 #ifndef ESTALE			/* Not in errno.h but wanted by POSIX.pm */
144 #  define ESTALE		WSAESTALE
145 #endif
146 #ifndef EREMOTE			/* Not in errno.h but wanted by POSIX.pm */
147 #  define EREMOTE		WSAEREMOTE
148 #endif
149 
150 /* EDISCON is not an errno.h value at all */
151 /* ENOMORE is not an errno.h value at all */
152 
153 #ifndef ECANCELED		/* New in VC10 */
154 #  ifdef WSAECANCELLED		/* New in WinSock2 */
155 #    define ECANCELED		WSAECANCELLED
156 #  endif
157 #endif
158 
159 /* EINVALIDPROCTABLE is not an errno.h value at all */
160 /* EINVALIDPROVIDER is not an errno.h value at all */
161 /* EPROVIDERFAILEDINIT is not an errno.h value at all */
162 /* EREFUSED is not an errno.h value at all */
163 
164 /* Set a flag indicating whether <errno.h> has the POSIX supplement (the first
165  * constant in which is EADDRINUSE). If so then we won't have just defined it as
166  * WSAEADDRINUSE above.
167  */
168 #undef ERRNO_HAS_POSIX_SUPPLEMENT
169 #if EADDRINUSE != WSAEADDRINUSE
170 #  define ERRNO_HAS_POSIX_SUPPLEMENT
171 #endif
172 
173 #endif /* _INC_SYS_ERRNO2 */
174