|
6 | 6 | #include <windows.h> |
7 | 7 | #endif |
8 | 8 |
|
| 9 | +#include "compat/win32/lazyload.h" |
| 10 | + |
9 | 11 | static inline int file_attr_to_st_mode (DWORD attr, DWORD tag) |
10 | 12 | { |
11 | 13 | int fMode = S_IREAD; |
@@ -40,42 +42,4 @@ static inline int get_file_attr(const char *fname, WIN32_FILE_ATTRIBUTE_DATA *fd |
40 | 42 | } |
41 | 43 | } |
42 | 44 |
|
43 | | -/* simplify loading of DLL functions */ |
44 | | - |
45 | | -struct proc_addr { |
46 | | - const char *const dll; |
47 | | - const char *const function; |
48 | | - FARPROC pfunction; |
49 | | - unsigned initialized : 1; |
50 | | -}; |
51 | | - |
52 | | -/* Declares a function to be loaded dynamically from a DLL. */ |
53 | | -#define DECLARE_PROC_ADDR(dll, rettype, function, ...) \ |
54 | | - static struct proc_addr proc_addr_##function = \ |
55 | | - { #dll, #function, NULL, 0 }; \ |
56 | | - static rettype (WINAPI *function)(__VA_ARGS__) |
57 | | - |
58 | | -/* |
59 | | - * Loads a function from a DLL (once-only). |
60 | | - * Returns non-NULL function pointer on success. |
61 | | - * Returns NULL + errno == ENOSYS on failure. |
62 | | - */ |
63 | | -#define INIT_PROC_ADDR(function) (function = get_proc_addr(&proc_addr_##function)) |
64 | | - |
65 | | -static inline void *get_proc_addr(struct proc_addr *proc) |
66 | | -{ |
67 | | - /* only do this once */ |
68 | | - if (!proc->initialized) { |
69 | | - HANDLE hnd; |
70 | | - proc->initialized = 1; |
71 | | - hnd = LoadLibraryA(proc->dll); |
72 | | - if (hnd) |
73 | | - proc->pfunction = GetProcAddress(hnd, proc->function); |
74 | | - } |
75 | | - /* set ENOSYS if DLL or function was not found */ |
76 | | - if (!proc->pfunction) |
77 | | - errno = ENOSYS; |
78 | | - return proc->pfunction; |
79 | | -} |
80 | | - |
81 | 45 | #endif |
0 commit comments