diff options
author | Andy Moreton <andrewjmoreton@gmail.com> | 2018-08-20 17:00:27 -0400 |
---|---|---|
committer | Ken Brown <kbrown@cornell.edu> | 2018-08-20 17:04:24 -0400 |
commit | 36de7bd7b0b9fcd038c440b4705e9186bfbaaa41 (patch) | |
tree | c3c72a209b8ed2c3ab1efe6d702f1742d2833010 /src/w32common.h | |
parent | 21397837eaf0801e7b1cd4155a811a939a7667de (diff) | |
download | emacs-36de7bd7b0b9fcd038c440b4705e9186bfbaaa41.tar.gz emacs-36de7bd7b0b9fcd038c440b4705e9186bfbaaa41.tar.bz2 emacs-36de7bd7b0b9fcd038c440b4705e9186bfbaaa41.zip |
Define get_proc_addr in Cygwin-w32 build
* src/w32common.h (get_proc_addr, DEF_DLL_FN, LOAD_DLL_FN): Move
definitions here from src/w32.h.
* src/decompress.c [WINDOWSNT]:
* src/gnutls.c [WINDOWSNT]:
* src/image.c [WINDOWSNT]:
* src/json.c [WINDOWSNT]:
* src/lcms.c [WINDOWSNT]:
* src/w32font.c [WINDOWSNT]:
* src/w32uniscribe.c:
* src/xml.c [WINDOWSNT]: Include w32common.h.
Diffstat (limited to 'src/w32common.h')
-rw-r--r-- | src/w32common.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/w32common.h b/src/w32common.h index af548dd8ea1..4981bdfd89a 100644 --- a/src/w32common.h +++ b/src/w32common.h @@ -50,4 +50,34 @@ extern int os_subtype; /* Cache system info, e.g., the NT page size. */ extern void cache_system_info (void); +typedef void (* VOIDFNPTR) (void); + +/* Load a function address from a DLL. Cast the result via VOIDFNPTR + to pacify -Wcast-function-type in GCC 8.1. The return value must + be cast to the correct function pointer type. */ +INLINE VOIDFNPTR +get_proc_addr (HINSTANCE handle, LPCSTR fname) +{ + return (VOIDFNPTR) GetProcAddress (handle, fname); +} + +/* Define a function that will be loaded from a DLL. The variable + arguments should contain the argument list for the function, and + optionally be followed by function attributes. For example: + DEF_DLL_FN (void, png_longjmp, (png_structp, int) PNG_NORETURN); + */ +#define DEF_DLL_FN(type, func, ...) \ + typedef type (CDECL *W32_PFN_##func) __VA_ARGS__; \ + static W32_PFN_##func fn_##func + +/* Load a function from the DLL. */ +#define LOAD_DLL_FN(lib, func) \ + do \ + { \ + fn_##func = (W32_PFN_##func) get_proc_addr (lib, #func); \ + if (!fn_##func) \ + return false; \ + } \ + while (false) + #endif /* W32COMMON_H */ |