emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 36de7bd: Define get_proc_addr in Cygwin-w32 build


From: Ken Brown
Subject: [Emacs-diffs] master 36de7bd: Define get_proc_addr in Cygwin-w32 build
Date: Mon, 20 Aug 2018 17:05:59 -0400 (EDT)

branch: master
commit 36de7bd7b0b9fcd038c440b4705e9186bfbaaa41
Author: Andy Moreton <address@hidden>
Commit: Ken Brown <address@hidden>

    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.
---
 src/decompress.c   |  1 +
 src/gnutls.c       |  1 +
 src/image.c        |  1 +
 src/json.c         |  1 +
 src/lcms.c         |  1 +
 src/w32.h          | 33 ---------------------------------
 src/w32common.h    | 30 ++++++++++++++++++++++++++++++
 src/w32font.c      |  1 +
 src/w32uniscribe.c |  1 +
 src/xml.c          |  1 +
 10 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/src/decompress.c b/src/decompress.c
index 9f7fbe4..2836338 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/>.  */
 
 #ifdef WINDOWSNT
 # include <windows.h>
+# include "w32common.h"
 # include "w32.h"
 
 DEF_DLL_FN (int, inflateInit2_,
diff --git a/src/gnutls.c b/src/gnutls.c
index 2d455ea..aa5c975 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/>.  */
 
 # ifdef WINDOWSNT
 #  include <windows.h>
+#  include "w32common.h"
 #  include "w32.h"
 # endif
 
diff --git a/src/image.c b/src/image.c
index 7866b9c..b9ff3f2 100644
--- a/src/image.c
+++ b/src/image.c
@@ -77,6 +77,7 @@ typedef struct x_bitmap_record Bitmap_Record;
 
 /* We need (or want) w32.h only when we're _not_ compiling for Cygwin.  */
 #ifdef WINDOWSNT
+# include "w32common.h"
 # include "w32.h"
 #endif
 
diff --git a/src/json.c b/src/json.c
index 4e413a2..4e46640 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/>.  */
 
 #ifdef WINDOWSNT
 # include <windows.h>
+# include "w32common.h"
 # include "w32.h"
 
 DEF_DLL_FN (void, json_set_alloc_funcs,
diff --git a/src/lcms.c b/src/lcms.c
index a3a9822..f37f843 100644
--- a/src/lcms.c
+++ b/src/lcms.c
@@ -34,6 +34,7 @@ typedef struct
 
 #ifdef WINDOWSNT
 # include <windows.h>
+# include "w32common.h"
 # include "w32.h"
 
 DEF_DLL_FN (cmsFloat64Number, cmsCIE2000DeltaE,
diff --git a/src/w32.h b/src/w32.h
index a053ee0..9c219cd 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -164,10 +164,6 @@ extern void reset_standard_handles (int in, int out,
 /* Return the string resource associated with KEY of type TYPE.  */
 extern LPBYTE w32_get_resource (const char * key, LPDWORD type);
 
-/* Load a function from a DLL.  Defined in this file.  */
-typedef void (* VOIDFNPTR) (void);
-INLINE VOIDFNPTR get_proc_addr (HINSTANCE handle, LPCSTR fname);
-
 extern void release_listen_threads (void);
 extern void init_ntproc (int);
 extern void term_ntproc (int);
@@ -245,33 +241,4 @@ extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p,
                                   const void* buf, size_t sz);
 #endif /* HAVE_GNUTLS */
 
-
-
-/* Load a function address from a DLL. Cast the result via "VOIDFNPTR"
-   to pacify -Wcast-function-type in GCC 8.1.  */
-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 /* EMACS_W32_H */
diff --git a/src/w32common.h b/src/w32common.h
index af548dd..4981bdf 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 */
diff --git a/src/w32font.c b/src/w32font.c
index f613061..798869b 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/>.  */
 #include "coding.h"    /* for ENCODE_SYSTEM, DECODE_SYSTEM */
 #include "w32font.h"
 #ifdef WINDOWSNT
+#include "w32common.h"
 #include "w32.h"
 #endif
 
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c
index 54f1616..29c9c7a 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/>.  */
 #include "composite.h"
 #include "font.h"
 #include "w32font.h"
+#include "w32common.h"
 
 struct uniscribe_font_info
 {
diff --git a/src/xml.c b/src/xml.c
index 5f3ccc8..e85891d 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/>.  */
 #ifdef WINDOWSNT
 
 # include <windows.h>
+# include "w32common.h"
 # include "w32.h"
 
 DEF_DLL_FN (htmlDocPtr, htmlReadMemory,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]