5 #if UTL_HOST_OS == UTL_OS_MINGW 11 #define WINAPI __stdcall 12 #define CreateEvent CreateEventA 13 #define CreateMutex CreateMutexA 14 #define CreateProcess CreateProcessA 15 #define CreateSemaphore CreateSemaphoreA 16 #define GetEnvironmentVariable GetEnvironmentVariableA 17 #define SetEnvironmentVariable SetEnvironmentVariableA 21 #if UTL_HOST_WORDSIZE == 64 22 #define InterlockedIncrement _InterlockedIncrement 23 #define InterlockedDecrement _InterlockedDecrement 24 #define InterlockedCompareExchange _InterlockedCompareExchange 36 #define INFINITE 0xffffffffU 37 #define MAKEWORD(a, b) ((WORD)(((BYTE)(a)) | (((WORD)((BYTE)(b))) << 8))) 43 typedef unsigned char BYTE;
46 typedef DWORD(WINAPI* LPTHREAD_START_ROUTINE)(
void*);
50 #if UTL_HOST_WORDSIZE == 64 51 typedef unsigned __int64 UINT_PTR;
52 typedef unsigned __int64 ULONG_PTR;
54 typedef unsigned int UINT_PTR;
55 typedef unsigned long ULONG_PTR;
60 typedef struct _FILETIME
68 typedef struct _CRITICAL_SECTION
80 typedef struct _STARTUPINFO
92 DWORD dwFillAttribute;
104 typedef struct _PROCESS_INFORMATION
110 } PROCESS_INFORMATION;
115 int WINAPI CloseHandle(HANDLE);
116 HANDLE WINAPI CreateEventA(
void*, BOOL, BOOL,
void*);
117 HANDLE WINAPI CreateMutexA(
void*, BOOL,
void*);
118 BOOL WINAPI CreateProcessA(
void*,
128 HANDLE WINAPI CreateSemaphoreA(
void*,
long,
long,
void*);
129 HANDLE WINAPI CreateThread(
void*,
131 LPTHREAD_START_ROUTINE,
135 void WINAPI DeleteCriticalSection(CRITICAL_SECTION*);
136 void WINAPI EnterCriticalSection(CRITICAL_SECTION*);
137 HANDLE WINAPI GetCurrentThread();
138 DWORD WINAPI GetCurrentThreadId();
139 DWORD WINAPI GetEnvironmentVariableA(
void*,
void*, DWORD);
140 BOOL WINAPI GetExitCodeProcess(HANDLE, DWORD*);
141 BOOL WINAPI GetExitCodeThread(HANDLE, DWORD*);
142 DWORD WINAPI GetLastError();
143 BOOL WINAPI GetProcessTimes(HANDLE, FILETIME*, FILETIME*, FILETIME*, FILETIME*);
144 void WINAPI InitializeCriticalSection(CRITICAL_SECTION*);
145 long WINAPI InterlockedIncrement(
long volatile* val);
146 long WINAPI InterlockedDecrement(
long volatile* val);
147 long WINAPI InterlockedCompareExchange(
long volatile* dest,
long exchange,
long comparand);
148 void WINAPI LeaveCriticalSection(CRITICAL_SECTION*);
149 BOOL WINAPI ReleaseMutex(HANDLE);
150 HANDLE WINAPI ReleaseSemaphore(HANDLE,
long,
void*);
151 BOOL WINAPI ResetEvent(HANDLE);
152 BOOL WINAPI SetEnvironmentVariableA(
void*,
void*);
153 BOOL WINAPI SetEvent(HANDLE);
154 void WINAPI Sleep(DWORD);
155 DWORD WINAPI SignalObjectAndWait(HANDLE, HANDLE, DWORD, BOOL);
156 DWORD WINAPI TlsAlloc();
157 BOOL WINAPI TlsFree(DWORD);
158 void* WINAPI TlsGetValue(DWORD);
159 BOOL WINAPI TlsSetValue(DWORD,
void*);
160 DWORD WINAPI WaitForSingleObject(HANDLE, DWORD);
167 typedef int socklen_t;
168 typedef UINT_PTR SOCKET;
172 #define h_errno WSAGetLastError() 173 #define s_addr S_un.S_addr 177 #define FD_SETSIZE 64U 178 #define INVALID_SOCKET (SOCKET)(~0) 179 #define SOCK_STREAM 1 180 #define SOCKET_ERROR (-1) 181 #define SO_REUSEADDR 4 182 #define SO_KEEPALIVE 8 183 #define SO_LINGER 128 184 #define SO_ERROR 0x1007 185 #define SOL_SOCKET 0xffff 186 #define TCP_NODELAY 0x0001 187 #define WSABASEERR 10000 188 #define WSADESCRIPTION_LEN 256 189 #define WSAEADDRINUSE (WSABASEERR + 48) 190 #define WSAEADDRNOTAVAIL (WSABASEERR + 49) 191 #define WSAENETUNREACH (WSABASEERR + 51) 192 #define WSAECONNRESET (WSABASEERR + 54) 193 #define WSAECONNREFUSED (WSABASEERR + 61) 194 #define WSAEHOSTUNREACH (WSABASEERR + 65) 195 #define WSAHOST_NOT_FOUND (WSABASEERR + 1001) 196 #define WSATRY_AGAIN (WSABASEERR + 1002) 197 #define WSANO_RECOVERY (WSABASEERR + 1003) 198 #define WSANO_DATA (WSABASEERR + 1004) 199 #define WSASYS_STATUS_LEN 128 206 SOCKET fd_array[FD_SETSIZE];
218 #define h_addr h_addr_list[0] 253 struct in_addr sin_addr;
267 struct sockaddr* ai_addr;
268 struct addrinfo* ai_next;
281 struct sockaddr_storage
295 char szDescription[WSADESCRIPTION_LEN + 1];
296 char szSystemStatus[WSASYS_STATUS_LEN + 1];
305 #define FD_CLR(fd, set) \ 309 for (__i = 0; __i < ((fd_set*)(set))->fd_count; __i++) \ 311 if (((fd_set*)(set))->fd_array[__i] == ((SOCKET)fd)) \ 313 while (__i < ((fd_set*)(set))->fd_count - 1) \ 315 ((fd_set*)(set))->fd_array[__i] = ((fd_set*)(set))->fd_array[__i + 1]; \ 318 ((fd_set*)(set))->fd_count--; \ 327 #define FD_SET(fd, set) \ 331 for (__i = 0; __i < ((fd_set*)(set))->fd_count; __i++) \ 333 if (((fd_set*)(set))->fd_array[__i] == ((SOCKET)fd)) \ 338 if (__i == ((fd_set*)(set))->fd_count) \ 340 if (((fd_set*)(set))->fd_count < FD_SETSIZE) \ 342 ((fd_set*)(set))->fd_array[__i] = ((SOCKET)fd); \ 343 ((fd_set*)(set))->fd_count++; \ 351 #define FD_ZERO(set) (((fd_set*)(set))->fd_count = 0) 356 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set)) 361 SOCKET WINAPI accept(SOCKET,
struct sockaddr*,
int*);
362 int WINAPI bind(SOCKET,
const struct sockaddr*,
int);
363 int WINAPI closesocket(SOCKET);
364 int WINAPI connect(SOCKET,
const struct sockaddr*,
int);
365 int WINAPI getaddrinfo(
const char*,
const char*,
const struct addrinfo*,
struct addrinfo**);
366 hostent* WINAPI gethostbyaddr(
const char*,
int,
int);
367 hostent* WINAPI gethostbyname(
const char*);
368 int WINAPI gethostname(
char*,
int);
369 int WINAPI getsockopt(SOCKET,
int,
int,
char*,
int*);
370 int WINAPI setsockopt(SOCKET,
int,
int,
const char*,
int);
371 WORD WINAPI htons(WORD);
372 WORD WINAPI ntohs(WORD);
373 int WINAPI listen(SOCKET,
int);
374 int WINAPI recv(SOCKET,
char*,
int,
int);
375 SOCKET WINAPI socket(
int,
int,
int);
376 int WINAPI select(
int, fd_set*, fd_set*, fd_set*,
const struct timeval*);
377 int WINAPI send(SOCKET,
const char*,
int,
int);
378 int WINAPI WSACleanup();
379 int WINAPI WSAGetLastError();
380 int WINAPI WSAStartup(WORD, WSADATA*);
381 int WINAPI __WSAFDIsSet(SOCKET, fd_set*);
unsigned char byte_t
Unsigned character.
long int64_t
Signed 64-bit integer.
unsigned int uint_t
Unsigned integer.
unsigned short ushort_t
Unsigned short integer.
unsigned long ulong_t
Unsigned long integer.