aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Moreton2018-08-20 17:00:27 -0400
committerKen Brown2018-08-20 17:04:24 -0400
commit36de7bd7b0b9fcd038c440b4705e9186bfbaaa41 (patch)
treec3c72a209b8ed2c3ab1efe6d702f1742d2833010 /src
parent21397837eaf0801e7b1cd4155a811a939a7667de (diff)
downloademacs-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.c1
-rw-r--r--src/gnutls.c1
-rw-r--r--src/image.c1
-rw-r--r--src/json.c1
-rw-r--r--src/lcms.c1
-rw-r--r--src/w32.h33
-rw-r--r--src/w32common.h30
-rw-r--r--src/w32font.c1
-rw-r--r--src/w32uniscribe.c1
-rw-r--r--src/xml.c1
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
35DEF_DLL_FN (int, inflateInit2_, 36DEF_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
39DEF_DLL_FN (void, json_set_alloc_funcs, 40DEF_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
39DEF_DLL_FN (cmsFloat64Number, cmsCIE2000DeltaE, 40DEF_DLL_FN (cmsFloat64Number, cmsCIE2000DeltaE,
diff --git a/src/w32.h b/src/w32.h
index a053ee0fc4b..9c219cdda62 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -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. */
165extern LPBYTE w32_get_resource (const char * key, LPDWORD type); 165extern LPBYTE w32_get_resource (const char * key, LPDWORD type);
166 166
167/* Load a function from a DLL. Defined in this file. */
168typedef void (* VOIDFNPTR) (void);
169INLINE VOIDFNPTR get_proc_addr (HINSTANCE handle, LPCSTR fname);
170
171extern void release_listen_threads (void); 167extern void release_listen_threads (void);
172extern void init_ntproc (int); 168extern void init_ntproc (int);
173extern void term_ntproc (int); 169extern 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. */
252INLINE VOIDFNPTR
253get_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. */
51extern void cache_system_info (void); 51extern void cache_system_info (void);
52 52
53typedef 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. */
58INLINE VOIDFNPTR
59get_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
40struct uniscribe_font_info 41struct uniscribe_font_info
41{ 42{
diff --git a/src/xml.c b/src/xml.c
index 5f3ccc85c86..e85891d2a29 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -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
36DEF_DLL_FN (htmlDocPtr, htmlReadMemory, 37DEF_DLL_FN (htmlDocPtr, htmlReadMemory,