[io-layer] Extract error (#4279)
[mono.git] / mono / utils / w32api.h
1
2 #ifndef __MONO_UTILS_W32API_H__
3 #define __MONO_UTILS_W32API_H__
4
5 #include <glib.h>
6
7 G_BEGIN_DECLS
8
9 #ifndef HOST_WIN32
10
11 #define WAIT_FAILED        ((gint) 0xFFFFFFFF)
12 #define WAIT_OBJECT_0      ((gint) 0x00000000)
13 #define WAIT_ABANDONED_0   ((gint) 0x00000080)
14 #define WAIT_TIMEOUT       ((gint) 0x00000102)
15 #define WAIT_IO_COMPLETION ((gint) 0x000000C0)
16
17 #define WINAPI
18
19 typedef guint32 DWORD;
20 typedef gboolean BOOL;
21 typedef gint32 LONG;
22 typedef guint32 ULONG;
23 typedef guint UINT;
24
25 typedef gpointer HANDLE;
26 typedef gpointer HMODULE;
27
28 #else
29
30 #define __USE_W32_SOCKETS
31 #include <winsock2.h>
32 #include <windows.h>
33 #include <winbase.h>
34 /* The mingw version says: /usr/i686-pc-mingw32/sys-root/mingw/include/ws2tcpip.h:38:2: error: #error "ws2tcpip.h is not compatible with winsock.h. Include winsock2.h instead." */
35 #ifdef _MSC_VER
36 #include <ws2tcpip.h>
37 #endif
38 #include <psapi.h>
39
40 /* Workaround for missing WSAPOLLFD typedef in mingw's winsock2.h
41  * that is required for mswsock.h below. Remove once
42  * http://sourceforge.net/p/mingw/bugs/1980/ is fixed. */
43 #if defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION == 4
44 typedef struct pollfd {
45         SOCKET fd;
46         short  events;
47         short  revents;
48 } WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
49 #endif
50
51 #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
52 #include <mswsock.h>
53 #endif
54
55 #endif /* HOST_WIN32 */
56
57 G_END_DECLS
58
59 #endif /* __MONO_UTILS_W32API_H__ */