summaryrefslogtreecommitdiff
path: root/src/w32.h
diff options
context:
space:
mode:
authorAndy Moreton <andrewjmoreton@gmail.com>2018-08-14 13:59:08 +0100
committerEli Zaretskii <eliz@gnu.org>2018-08-17 17:29:10 +0300
commitcc5325b0bea13bd93478fcee0b035877b3a72290 (patch)
treeac22ceea567bc70e836b61ade04de644473267cb /src/w32.h
parent58e5f10f884f70faea2dc577e890ccc9e8c5d0f5 (diff)
downloademacs-cc5325b0bea13bd93478fcee0b035877b3a72290.tar.gz
Pacify -Wcast-function-type warnings in GCC 8.1
* src/image.c: Move attributes into DEF_DLL_FN call. * src/dynlib.c (dynlib_addr): Use get_proc_addr. * src/w32.h: (get_proc_addr): New function. (LOAD_DLL_FN): Use it. (DEF_DLL_FN): Allow function attributes after argument list. Add function pointer type used by LOAD_DLL_FN. * src/w32.c (open_process_token, get_token_information) (lookup_account_sid, get_sid_sub_authority) (get_sid_sub_authority_count, get_security_info) (get_file_security, set_file_security) (set_named_security_info) (get_security_descriptor_owner, get_security_descriptor_group) (get_security_descriptor_dacl, is_valid_sid, equal_sid) (get_length_sid, copy_sid, get_native_system_info) (get_system_times, create_symbolic_link) (is_valid_security_descriptor, convert_sd_to_sddl) (convert_sddl_to_sd, get_adapters_info, reg_open_key_ex_w) (reg_query_value_ex_w, expand_environment_strings_w) (init_environment, create_toolhelp32_snapshot) (process32_first, process32_next, open_thread_token) (impersonate_self, revert_to_self, get_process_memory_info) (get_process_working_set_size, global_memory_status) (global_memory_status_ex, init_winsock) (maybe_load_unicows_dll, globals_of_w32): Use get_proc_addr. * src/w32fns.c (setup_w32_kbdhook, Ffile_system_info) (get_dll_version, w32_reset_stack_overflow_guard) (w32_backtrace, globals_of_w32fns): Use get_proc_addr. * src/w32font.c (get_outline_metrics_w, get_text_metrics_w) (get_glyph_outline_w, get_char_width_32_w): Use get_proc_addr. * src/w32heap.c (init_heap): Use get_proc_addr. * src/w32menu.c (globals_of_w32menu): Use get_proc_addr. * src/w32proc.c (init_timers, sys_kill, w32_compare_strings): Use get_proc_addr. * src/w32uniscribe.c (syms_of_w32uniscribe): Use get_proc_addr.
Diffstat (limited to 'src/w32.h')
-rw-r--r--src/w32.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/w32.h b/src/w32.h
index fe8689a07b4..a053ee0fc4b 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -164,6 +164,10 @@ 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);
@@ -241,14 +245,30 @@ 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 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 = (void *) GetProcAddress (lib, #func); \
+ fn_##func = (W32_PFN_##func) get_proc_addr (lib, #func); \
if (!fn_##func) \
return false; \
} \