summaryrefslogtreecommitdiff
path: root/src/w32.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-12-26 09:32:06 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2014-12-28 00:33:27 -0800
commite092accb6bb8aea08dab1796d707b3adce55a38c (patch)
treef3f2bad267ce9f3f2ec61441a03447027ae3a3ea /src/w32.h
parent1505643bb70ce66e86d6c72902fe7e9199e93606 (diff)
downloademacs-e092accb6bb8aea08dab1796d707b3adce55a38c.tar.gz
emacs-e092accb6bb8aea08dab1796d707b3adce55a38c.tar.bz2
emacs-e092accb6bb8aea08dab1796d707b3adce55a38c.zip
Wrap dll functions more simply
* decompress.c, gnutls.c, image.c, xml.c: If WINDOWSNT, use '#define FOO fn_FOO' to wrap dll functions, rather than the inverse when not WINDOWSNT. This isolates the fn_* business into the WINDOWSNT-specific section of the code, which makes it easier to maintain the generic code. * decompress.c (DEF_ZLIB_FN, LOAD_ZLIB_FN): * gnutls.c (DEF_GNUTLS_FN, LOAD_GNUTLS_FN): * image.c (DEF_IMGLIB_FN, LOAD_IMGLIB_FN): * xml.c (DEF_XML2_FN, LOAD_XML2_FN): Remove. All uses replaced by DEF_DLL_FN. * w32.h (DEF_DLL_FN, LOAD_DLL_FN): New macros.
Diffstat (limited to 'src/w32.h')
-rw-r--r--src/w32.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/w32.h b/src/w32.h
index e0aedcbffa2..18e12b2458c 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -225,4 +225,17 @@ extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p,
const void* buf, size_t sz);
#endif /* HAVE_GNUTLS */
+/* Definine a function that will be loaded from a DLL. */
+#define DEF_DLL_FN(type, func, args) static type (FAR CDECL *fn_##func) args
+
+/* Load a function from the DLL. */
+#define LOAD_DLL_FN(lib, func) \
+ do \
+ { \
+ fn_##func = (void *) GetProcAddress (lib, #func); \
+ if (!fn_##func) \
+ return false; \
+ } \
+ while (false)
+
#endif /* EMACS_W32_H */