diff options
| author | Andy Moreton | 2018-08-20 17:00:27 -0400 |
|---|---|---|
| committer | Ken Brown | 2018-08-20 17:04:24 -0400 |
| commit | 36de7bd7b0b9fcd038c440b4705e9186bfbaaa41 (patch) | |
| tree | c3c72a209b8ed2c3ab1efe6d702f1742d2833010 /src | |
| parent | 21397837eaf0801e7b1cd4155a811a939a7667de (diff) | |
| download | emacs-36de7bd7b0b9fcd038c440b4705e9186bfbaaa41.tar.gz 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')
| -rw-r--r-- | src/decompress.c | 1 | ||||
| -rw-r--r-- | src/gnutls.c | 1 | ||||
| -rw-r--r-- | src/image.c | 1 | ||||
| -rw-r--r-- | src/json.c | 1 | ||||
| -rw-r--r-- | src/lcms.c | 1 | ||||
| -rw-r--r-- | src/w32.h | 33 | ||||
| -rw-r--r-- | src/w32common.h | 30 | ||||
| -rw-r--r-- | src/w32font.c | 1 | ||||
| -rw-r--r-- | src/w32uniscribe.c | 1 | ||||
| -rw-r--r-- | src/xml.c | 1 |
10 files changed, 38 insertions, 33 deletions
diff --git a/src/decompress.c b/src/decompress.c index 9f7fbe41952..28363382168 100644 --- a/src/decompress.c +++ b/src/decompress.c | |||
| @@ -30,6 +30,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 30 | 30 | ||
| 31 | #ifdef WINDOWSNT | 31 | #ifdef WINDOWSNT |
| 32 | # include <windows.h> | 32 | # include <windows.h> |
| 33 | # include "w32common.h" | ||
| 33 | # include "w32.h" | 34 | # include "w32.h" |
| 34 | 35 | ||
| 35 | DEF_DLL_FN (int, inflateInit2_, | 36 | DEF_DLL_FN (int, inflateInit2_, |
diff --git a/src/gnutls.c b/src/gnutls.c index 2d455ea1ba1..aa5c97532f0 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -58,6 +58,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 58 | 58 | ||
| 59 | # ifdef WINDOWSNT | 59 | # ifdef WINDOWSNT |
| 60 | # include <windows.h> | 60 | # include <windows.h> |
| 61 | # include "w32common.h" | ||
| 61 | # include "w32.h" | 62 | # include "w32.h" |
| 62 | # endif | 63 | # endif |
| 63 | 64 | ||
diff --git a/src/image.c b/src/image.c index 7866b9cc463..b9ff3f25c43 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -77,6 +77,7 @@ typedef struct x_bitmap_record Bitmap_Record; | |||
| 77 | 77 | ||
| 78 | /* We need (or want) w32.h only when we're _not_ compiling for Cygwin. */ | 78 | /* We need (or want) w32.h only when we're _not_ compiling for Cygwin. */ |
| 79 | #ifdef WINDOWSNT | 79 | #ifdef WINDOWSNT |
| 80 | # include "w32common.h" | ||
| 80 | # include "w32.h" | 81 | # include "w32.h" |
| 81 | #endif | 82 | #endif |
| 82 | 83 | ||
diff --git a/src/json.c b/src/json.c index 4e413a2bd51..4e46640a0c6 100644 --- a/src/json.c +++ b/src/json.c | |||
| @@ -34,6 +34,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 34 | 34 | ||
| 35 | #ifdef WINDOWSNT | 35 | #ifdef WINDOWSNT |
| 36 | # include <windows.h> | 36 | # include <windows.h> |
| 37 | # include "w32common.h" | ||
| 37 | # include "w32.h" | 38 | # include "w32.h" |
| 38 | 39 | ||
| 39 | DEF_DLL_FN (void, json_set_alloc_funcs, | 40 | DEF_DLL_FN (void, json_set_alloc_funcs, |
diff --git a/src/lcms.c b/src/lcms.c index a3a98223060..f37f843e500 100644 --- a/src/lcms.c +++ b/src/lcms.c | |||
| @@ -34,6 +34,7 @@ typedef struct | |||
| 34 | 34 | ||
| 35 | #ifdef WINDOWSNT | 35 | #ifdef WINDOWSNT |
| 36 | # include <windows.h> | 36 | # include <windows.h> |
| 37 | # include "w32common.h" | ||
| 37 | # include "w32.h" | 38 | # include "w32.h" |
| 38 | 39 | ||
| 39 | DEF_DLL_FN (cmsFloat64Number, cmsCIE2000DeltaE, | 40 | DEF_DLL_FN (cmsFloat64Number, cmsCIE2000DeltaE, |
| @@ -164,10 +164,6 @@ extern void reset_standard_handles (int in, int out, | |||
| 164 | /* Return the string resource associated with KEY of type TYPE. */ | 164 | /* Return the string resource associated with KEY of type TYPE. */ |
| 165 | extern LPBYTE w32_get_resource (const char * key, LPDWORD type); | 165 | extern LPBYTE w32_get_resource (const char * key, LPDWORD type); |
| 166 | 166 | ||
| 167 | /* Load a function from a DLL. Defined in this file. */ | ||
| 168 | typedef void (* VOIDFNPTR) (void); | ||
| 169 | INLINE VOIDFNPTR get_proc_addr (HINSTANCE handle, LPCSTR fname); | ||
| 170 | |||
| 171 | extern void release_listen_threads (void); | 167 | extern void release_listen_threads (void); |
| 172 | extern void init_ntproc (int); | 168 | extern void init_ntproc (int); |
| 173 | extern void term_ntproc (int); | 169 | extern void term_ntproc (int); |
| @@ -245,33 +241,4 @@ extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p, | |||
| 245 | const void* buf, size_t sz); | 241 | const void* buf, size_t sz); |
| 246 | #endif /* HAVE_GNUTLS */ | 242 | #endif /* HAVE_GNUTLS */ |
| 247 | 243 | ||
| 248 | |||
| 249 | |||
| 250 | /* Load a function address from a DLL. Cast the result via "VOIDFNPTR" | ||
| 251 | to pacify -Wcast-function-type in GCC 8.1. */ | ||
| 252 | INLINE VOIDFNPTR | ||
| 253 | get_proc_addr (HINSTANCE handle, LPCSTR fname) | ||
| 254 | { | ||
| 255 | return (VOIDFNPTR) GetProcAddress (handle, fname); | ||
| 256 | } | ||
| 257 | |||
| 258 | /* Define a function that will be loaded from a DLL. The variable | ||
| 259 | arguments should contain the argument list for the function, and | ||
| 260 | optionally be followed by function attributes. For example: | ||
| 261 | DEF_DLL_FN (void, png_longjmp, (png_structp, int) PNG_NORETURN); | ||
| 262 | */ | ||
| 263 | #define DEF_DLL_FN(type, func, ...) \ | ||
| 264 | typedef type (CDECL *W32_PFN_##func) __VA_ARGS__; \ | ||
| 265 | static W32_PFN_##func fn_##func | ||
| 266 | |||
| 267 | /* Load a function from the DLL. */ | ||
| 268 | #define LOAD_DLL_FN(lib, func) \ | ||
| 269 | do \ | ||
| 270 | { \ | ||
| 271 | fn_##func = (W32_PFN_##func) get_proc_addr (lib, #func); \ | ||
| 272 | if (!fn_##func) \ | ||
| 273 | return false; \ | ||
| 274 | } \ | ||
| 275 | while (false) | ||
| 276 | |||
| 277 | #endif /* EMACS_W32_H */ | 244 | #endif /* EMACS_W32_H */ |
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; | |||
| 50 | /* Cache system info, e.g., the NT page size. */ | 50 | /* Cache system info, e.g., the NT page size. */ |
| 51 | extern void cache_system_info (void); | 51 | extern void cache_system_info (void); |
| 52 | 52 | ||
| 53 | typedef void (* VOIDFNPTR) (void); | ||
| 54 | |||
| 55 | /* Load a function address from a DLL. Cast the result via VOIDFNPTR | ||
| 56 | to pacify -Wcast-function-type in GCC 8.1. The return value must | ||
| 57 | be cast to the correct function pointer type. */ | ||
| 58 | INLINE VOIDFNPTR | ||
| 59 | get_proc_addr (HINSTANCE handle, LPCSTR fname) | ||
| 60 | { | ||
| 61 | return (VOIDFNPTR) GetProcAddress (handle, fname); | ||
| 62 | } | ||
| 63 | |||
| 64 | /* Define a function that will be loaded from a DLL. The variable | ||
| 65 | arguments should contain the argument list for the function, and | ||
| 66 | optionally be followed by function attributes. For example: | ||
| 67 | DEF_DLL_FN (void, png_longjmp, (png_structp, int) PNG_NORETURN); | ||
| 68 | */ | ||
| 69 | #define DEF_DLL_FN(type, func, ...) \ | ||
| 70 | typedef type (CDECL *W32_PFN_##func) __VA_ARGS__; \ | ||
| 71 | static W32_PFN_##func fn_##func | ||
| 72 | |||
| 73 | /* Load a function from the DLL. */ | ||
| 74 | #define LOAD_DLL_FN(lib, func) \ | ||
| 75 | do \ | ||
| 76 | { \ | ||
| 77 | fn_##func = (W32_PFN_##func) get_proc_addr (lib, #func); \ | ||
| 78 | if (!fn_##func) \ | ||
| 79 | return false; \ | ||
| 80 | } \ | ||
| 81 | while (false) | ||
| 82 | |||
| 53 | #endif /* W32COMMON_H */ | 83 | #endif /* W32COMMON_H */ |
diff --git a/src/w32font.c b/src/w32font.c index f6130618323..798869b5caf 100644 --- a/src/w32font.c +++ b/src/w32font.c | |||
| @@ -29,6 +29,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 29 | #include "coding.h" /* for ENCODE_SYSTEM, DECODE_SYSTEM */ | 29 | #include "coding.h" /* for ENCODE_SYSTEM, DECODE_SYSTEM */ |
| 30 | #include "w32font.h" | 30 | #include "w32font.h" |
| 31 | #ifdef WINDOWSNT | 31 | #ifdef WINDOWSNT |
| 32 | #include "w32common.h" | ||
| 32 | #include "w32.h" | 33 | #include "w32.h" |
| 33 | #endif | 34 | #endif |
| 34 | 35 | ||
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c index 54f161690b7..29c9c7a0bd1 100644 --- a/src/w32uniscribe.c +++ b/src/w32uniscribe.c | |||
| @@ -36,6 +36,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 36 | #include "composite.h" | 36 | #include "composite.h" |
| 37 | #include "font.h" | 37 | #include "font.h" |
| 38 | #include "w32font.h" | 38 | #include "w32font.h" |
| 39 | #include "w32common.h" | ||
| 39 | 40 | ||
| 40 | struct uniscribe_font_info | 41 | struct uniscribe_font_info |
| 41 | { | 42 | { |
| @@ -31,6 +31,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 31 | #ifdef WINDOWSNT | 31 | #ifdef WINDOWSNT |
| 32 | 32 | ||
| 33 | # include <windows.h> | 33 | # include <windows.h> |
| 34 | # include "w32common.h" | ||
| 34 | # include "w32.h" | 35 | # include "w32.h" |
| 35 | 36 | ||
| 36 | DEF_DLL_FN (htmlDocPtr, htmlReadMemory, | 37 | DEF_DLL_FN (htmlDocPtr, htmlReadMemory, |