Merge branch 'js/win-lazyload-buildfix'

Compilation fix.

* js/win-lazyload-buildfix:
  Makefile: restrict -Wpedantic and -Wno-pedantic-ms-format better
  lazyload.h: use an even more generic function pointer than FARPROC
  lazyload.h: fix warnings about mismatching function pointer types
This commit is contained in:
Junio C Hamano 2021-10-11 10:21:47 -07:00
commit 4ae0bc75f9
3 changed files with 20 additions and 8 deletions

View File

@ -15,10 +15,12 @@
* source, target);
*/
typedef void (*FARVOIDPROC)(void);
struct proc_addr {
const char *const dll;
const char *const function;
FARPROC pfunction;
FARVOIDPROC pfunction;
unsigned initialized : 1;
};
@ -26,7 +28,8 @@ struct proc_addr {
#define DECLARE_PROC_ADDR(dll, rettype, function, ...) \
static struct proc_addr proc_addr_##function = \
{ #dll, #function, NULL, 0 }; \
static rettype (WINAPI *function)(__VA_ARGS__)
typedef rettype (WINAPI *proc_type_##function)(__VA_ARGS__); \
static proc_type_##function function
/*
* Loads a function from a DLL (once-only).
@ -35,9 +38,9 @@ struct proc_addr {
* This function is not thread-safe.
*/
#define INIT_PROC_ADDR(function) \
(function = get_proc_addr(&proc_addr_##function))
(function = (proc_type_##function)get_proc_addr(&proc_addr_##function))
static inline FARPROC get_proc_addr(struct proc_addr *proc)
static inline FARVOIDPROC get_proc_addr(struct proc_addr *proc)
{
/* only do this once */
if (!proc->initialized) {
@ -46,7 +49,8 @@ static inline FARPROC get_proc_addr(struct proc_addr *proc)
hnd = LoadLibraryExA(proc->dll, NULL,
LOAD_LIBRARY_SEARCH_SYSTEM32);
if (hnd)
proc->pfunction = GetProcAddress(hnd, proc->function);
proc->pfunction = (FARVOIDPROC)GetProcAddress(hnd,
proc->function);
}
/* set ENOSYS if DLL or function was not found */
if (!proc->pfunction)

View File

@ -6,13 +6,17 @@ ifeq ($(filter no-error,$(DEVOPTS)),)
DEVELOPER_CFLAGS += -Werror
SPARSE_FLAGS += -Wsparse-error
endif
DEVELOPER_CFLAGS += -Wall
ifeq ($(filter no-pedantic,$(DEVOPTS)),)
DEVELOPER_CFLAGS += -pedantic
ifneq (($or $(filter gcc5,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),)
DEVELOPER_CFLAGS += -Wpedantic
ifneq ($(filter gcc5,$(COMPILER_FEATURES)),)
ifneq ($(filter gcc10,$(COMPILER_FEATURES)),)
ifeq ($(uname_S),MINGW)
DEVELOPER_CFLAGS += -Wno-pedantic-ms-format
DEVELOPER_CFLAGS += -Wno-incompatible-pointer-types
endif
endif
endif
endif
DEVELOPER_CFLAGS += -Wdeclaration-after-statement

View File

@ -11,6 +11,10 @@ uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
ifneq ($(findstring MINGW,$(uname_S)),)
uname_S := MINGW
endif
ifdef MSVC
# avoid the MingW and Cygwin configuration sections
uname_S := Windows
@ -588,7 +592,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
SANE_TOOL_PATH = /usr/coreutils/bin:/usr/local/bin
SHELL_PATH = /usr/coreutils/bin/bash
endif
ifneq (,$(findstring MINGW,$(uname_S)))
ifeq ($(uname_S),MINGW)
pathsep = ;
HAVE_ALLOCA_H = YesPlease
NO_PREAD = YesPlease