winutils.h revision b7fa8b09631f67d6557bf8e404a967dccaa4283b
#ifndef __WINUTILS_H_
# define __WINUTILS_H_
# ifdef RT_OS_WINDOWS
# include <WinSock2.h>
# include <ws2tcpip.h>
# include <mswsock.h>
# include <Windows.h>
/**
* of hton-family functions in LWIP and windock's headers.
*/
# ifndef PF_LOCAL
# endif
# ifdef DEBUG
AssertMsgFailed((__VA_ARGS__)); \
}while(0)
#else
DPRINTF0((__VA_ARGS__)); \
ExitProcess(code); \
}while(0)
#endif
# define __func__ __FUNCTION__
# define __attribute__(x) /* IGNORE */
# define SOCKERRNO() (WSAGetLastError())
/**
* "Windows Sockets Error Codes" obtained with WSAGetLastError().
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx
*/
# define EMSGSIZE WSAEMSGSIZE
# define ENETDOWN WSAENETDOWN
# define ENETUNREACH WSAENETUNREACH
# define EHOSTDOWN WSAEHOSTDOWN
# define EHOSTUNREACH WSAEHOSTUNREACH
/**
* parameters to shutdown (2) with Winsock2
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms740481(v=vs.85).aspx
*/
# define SHUT_RD SD_RECEIVE
#if _WIN32_WINNT < 0x0600
/* otherwise defined the other way around in ws2def.h */
#define cmsghdr _WSACMSGHDR
#define CMSG_DATA WSA_CMSG_DATA
#define CMSG_LEN WSA_CMSG_LEN
#define CMSG_SPACE WSA_CMSG_SPACE
#define CMSG_FIRSTHDR WSA_CMSG_FIRSTHDR
#define CMSG_NXTHDR WSA_CMSG_NXTHDR
#endif /* _WIN32_WINNT < 0x0600 - provide unglified CMSG names */
# else /* !RT_OS_WINDOWS */
# define SOCKET int
# define INVALID_SOCKET (-1)
# define SOCKET_ERROR (-1)
# define closesocket(s) close(s)
# endif
#endif