diff options
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinError.c | 33 | ||||
-rw-r--r-- | win/tclWinPort.h | 42 | ||||
-rw-r--r-- | win/tclWinSerial.c | 2 | ||||
-rw-r--r-- | win/tclWinSock.c | 6 |
4 files changed, 49 insertions, 34 deletions
diff --git a/win/tclWinError.c b/win/tclWinError.c index 4fee02b..1b59dbe 100644 --- a/win/tclWinError.c +++ b/win/tclWinError.c @@ -12,11 +12,19 @@ #include "tclInt.h" +#ifndef WSAEWOULDBLOCK +# define WSAEWOULDBLOCK 10035L +#endif + +#ifndef __WIN32__ +# define DWORD unsigned int +#endif + /* * The following table contains the mapping from Win32 errors to errno errors. */ -static char errorTable[] = { +static const unsigned char errorTable[] = { 0, EINVAL, /* ERROR_INVALID_FUNCTION 1 */ ENOENT, /* ERROR_FILE_NOT_FOUND 2 */ @@ -284,18 +292,16 @@ static char errorTable[] = { EINVAL, /* 264 */ EINVAL, /* 265 */ EINVAL, /* 266 */ - ENOTDIR, /* ERROR_DIRECTORY 267 */ + ENOTDIR /* ERROR_DIRECTORY 267 */ }; -static const unsigned int tableLen = sizeof(errorTable); - /* * The following table contains the mapping from WinSock errors to * errno errors. */ -static int wsaErrorTable[] = { - EWOULDBLOCK, /* WSAEWOULDBLOCK */ +static const unsigned char wsaErrorTable[] = { + EAGAIN, /* WSAEWOULDBLOCK */ EINPROGRESS, /* WSAEINPROGRESS */ EALREADY, /* WSAEALREADY */ ENOTSOCK, /* WSAENOTSOCK */ @@ -331,7 +337,7 @@ static int wsaErrorTable[] = { EUSERS, /* WSAEUSERS */ EDQUOT, /* WSAEDQUOT */ ESTALE, /* WSAESTALE */ - EREMOTE, /* WSAEREMOTE */ + EREMOTE /* WSAEREMOTE */ }; /* @@ -352,9 +358,9 @@ static int wsaErrorTable[] = { void TclWinConvertError( - unsigned long errCode) /* Win32 error code. */ + DWORD errCode) /* Win32 error code. */ { - if (errCode >= tableLen) { + if (errCode >= sizeof(errorTable)/sizeof(errorTable[0])) { Tcl_SetErrno(EINVAL); } else { Tcl_SetErrno(errorTable[errCode]); @@ -379,12 +385,13 @@ TclWinConvertError( void TclWinConvertWSAError( - unsigned long errCode) /* Win32 error code. */ + DWORD errCode) /* Win32 error code. */ { - if ((errCode >= WSAEWOULDBLOCK) && (errCode <= WSAEREMOTE)) { - Tcl_SetErrno(wsaErrorTable[errCode - WSAEWOULDBLOCK]); - } else { + errCode -= WSAEWOULDBLOCK; + if (errCode >= sizeof(wsaErrorTable)/sizeof(wsaErrorTable[0])) { Tcl_SetErrno(EINVAL); + } else { + Tcl_SetErrno(wsaErrorTable[errCode]); } } diff --git a/win/tclWinPort.h b/win/tclWinPort.h index e3c5a49..db46a4a 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -226,9 +226,9 @@ typedef DWORD_PTR * PDWORD_PTR; #ifndef EOTHER # define EOTHER 131 /* Other error */ #endif -/* workaround for mingw-w64 bug 3407992 */ -#undef EOVERFLOW -#define EOVERFLOW 132 /* File too big */ +#ifndef EOVERFLOW +# define EOVERFLOW 132 /* File too big */ +#endif #ifndef EOWNERDEAD # define EOWNERDEAD 133 /* Owner dead */ #endif @@ -255,20 +255,28 @@ typedef DWORD_PTR * PDWORD_PTR; #endif -#undef ESOCKTNOSUPPORT -#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT /* Socket type not supported */ -#undef ESHUTDOWN -#define ESHUTDOWN WSAESHUTDOWN /* Can't send after socket shutdown */ -#undef ETOOMANYREFS -#define ETOOMANYREFS WSAETOOMANYREFS /* Too many references: can't splice */ -#undef EHOSTDOWN -#define EHOSTDOWN WSAEHOSTDOWN /* Host is down */ -#undef EUSERS -#define EUSERS WSAEUSERS /* Too many users (for UFS) */ -#undef EDQUOT -#define EDQUOT WSAEDQUOT /* Disc quota exceeded */ -#undef ESTALE -#define ESTALE WSAESTALE /* Stale NFS file handle */ +/* Visual Studio doesn't have these, so just choose some high numbers */ +#ifndef ESOCKTNOSUPPORT +# define ESOCKTNOSUPPORT 240 /* Socket type not supported */ +#endif +#ifndef ESHUTDOWN +# define ESHUTDOWN 241 /* Can't send after socket shutdown */ +#endif +#ifndef ETOOMANYREFS +# define ETOOMANYREFS 242 /* Too many references: can't splice */ +#endif +#ifndef EHOSTDOWN +# define EHOSTDOWN 243 /* Host is down */ +#endif +#ifndef EUSERS +# define EUSERS 244 /* Too many users (for UFS) */ +#endif +#ifndef EDQUOT +# define EDQUOT 245 /* Disc quota exceeded */ +#endif +#ifndef ESTALE +# define ESTALE 246 /* Stale NFS file handle */ +#endif /* * Signals not known to the standard ANSI signal.h. These are used diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index 0941d4a..58a9eb4 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -1036,7 +1036,7 @@ SerialOutputProc( * the channel is in non-blocking mode. */ - errno = EWOULDBLOCK; + errno = EAGAIN; goto error1; } diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 0c1a270..60cc313 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -1195,7 +1195,7 @@ CreateSocket( if (connect(sock, addrPtr->ai_addr, addrPtr->ai_addrlen) == SOCKET_ERROR) { TclWinConvertWSAError((DWORD) WSAGetLastError()); - if (Tcl_GetErrno() != EWOULDBLOCK) { + if (Tcl_GetErrno() != EAGAIN) { goto looperror; } @@ -1389,7 +1389,7 @@ WaitForSocketEvent( } else if (infoPtr->readyEvents & events) { break; } else if (infoPtr->flags & SOCKET_ASYNC) { - *errorCodePtr = EWOULDBLOCK; + *errorCodePtr = EAGAIN; result = 0; break; } @@ -1913,7 +1913,7 @@ TcpOutputProc( if (error == WSAEWOULDBLOCK) { infoPtr->readyEvents &= ~(FD_WRITE); if (infoPtr->flags & SOCKET_ASYNC) { - *errorCodePtr = EWOULDBLOCK; + *errorCodePtr = EAGAIN; bytesWritten = -1; break; } |