1 /*-------------------------------------------------------------------------
4 * MinGW compatibility functions
6 * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
9 * $PostgreSQL: pgsql/src/backend/port/win32/mingwcompat.c,v 1.9 2010/02/09 19:55:14 mha Exp $
11 *-------------------------------------------------------------------------
16 #ifndef WIN32_ONLY_COMPILER
18 * MingW defines an extern to this struct, but the actual struct isn't present
19 * in any library. It's trivial enough that we can safely defined it
22 const struct in6_addr in6addr_any = {{{0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}}};
26 * This file contains loaders for functions that are missing in the MinGW
27 * import libraries. It's only for actual Win32 API functions, so they are
28 * all present in proper Win32 compilers.
30 static HMODULE kernel32 = NULL;
33 * Load DLL file just once regardless of how many functions
42 kernel32 = LoadLibraryEx("kernel32.dll", NULL, 0);
45 (errmsg_internal("could not load kernel32.dll: %d",
46 (int) GetLastError())));
51 * Replacement for RegisterWaitForSingleObject(), which lives in
55 BOOL (WINAPI * __RegisterWaitForSingleObject)
56 (PHANDLE, HANDLE, WAITORTIMERCALLBACK, PVOID, ULONG, ULONG);
57 static __RegisterWaitForSingleObject _RegisterWaitForSingleObject = NULL;
60 RegisterWaitForSingleObject(PHANDLE phNewWaitObject,
62 WAITORTIMERCALLBACK Callback,
67 if (_RegisterWaitForSingleObject == NULL)
71 _RegisterWaitForSingleObject = (__RegisterWaitForSingleObject)
72 GetProcAddress(kernel32, "RegisterWaitForSingleObject");
74 if (_RegisterWaitForSingleObject == NULL)
76 (errmsg_internal("could not locate RegisterWaitForSingleObject in kernel32.dll: %d",
77 (int) GetLastError())));
80 return (_RegisterWaitForSingleObject)
81 (phNewWaitObject, hObject, Callback, Context, dwMilliseconds, dwFlags);