From d88a993a1767205552130883bdc72e2c6271993a Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 29 Mar 2019 12:58:27 +0100 Subject: [PATCH 1/3] mingw: allow compiling with GCC 8 and DEVELOPER=1 The return type of the `GetProcAddress()` function is `FARPROC` which evaluates to `long long int (*)()`, i.e. it cannot be cast to the correct function signature by GCC 8. To work around that, we first cast to `void *` and go on with our merry lives. Signed-off-by: Johannes Schindelin --- compat/poll/poll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/poll/poll.c b/compat/poll/poll.c index b622982b534eea..16a6ccc4619f27 100644 --- a/compat/poll/poll.c +++ b/compat/poll/poll.c @@ -149,7 +149,7 @@ win32_compute_revents (HANDLE h, int *p_sought) case FILE_TYPE_PIPE: if (!once_only) { - NtQueryInformationFile = (PNtQueryInformationFile) + NtQueryInformationFile = (PNtQueryInformationFile)(void *) GetProcAddress (GetModuleHandleA ("ntdll.dll"), "NtQueryInformationFile"); once_only = TRUE; From f882f5d93f861a1bc61c4635f9dc92bd36c7dbf8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 29 Mar 2019 14:17:03 +0100 Subject: [PATCH 2/3] kwset: allow building with GCC 8 The kwset functionality makes use of the obstack code, which expects to be handed a function that can allocate large chunks of data. It expects that function to accept a `size` parameter of type `long`. This upsets GCC 8 on Windows, because `long` does not have the same bit size as `size_t` there. Now, the proper thing to do would be to switch to `size_t`. But this would make us deviate from the "upstream" code even further, making it hard to synchronize with newer versions, and also it would be quite involved because that `long` type is so invasive in that code. Let's punt, and instead provide a super small wrapper around `xmalloc()`. Signed-off-by: Johannes Schindelin --- kwset.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kwset.c b/kwset.c index 4fb6455acaf129..efc2ff41bc361a 100644 --- a/kwset.c +++ b/kwset.c @@ -38,7 +38,13 @@ #include "compat/obstack.h" #define NCHAR (UCHAR_MAX + 1) -#define obstack_chunk_alloc xmalloc +/* adapter for `xmalloc()`, which takes `size_t`, not `long` */ +static void *obstack_chunk_alloc(long size) +{ + if (size < 0) + BUG("Cannot allocate a negative amount: %ld", size); + return xmalloc(size); +} #define obstack_chunk_free free #define U(c) ((unsigned char) (c)) From 77f869808cccbad16705b14920a714e67c5c3011 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 3 Apr 2019 12:47:39 +0200 Subject: [PATCH 3/3] fixup! mingw: kill child processes in a gentler way This is needed to make things compile with GCC 8.x and later. Signed-off-by: Johannes Schindelin --- compat/win32/exit-process.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/win32/exit-process.h b/compat/win32/exit-process.h index 88e3bbc83c499e..5aacf3715005e5 100644 --- a/compat/win32/exit-process.h +++ b/compat/win32/exit-process.h @@ -130,7 +130,7 @@ static int exit_process(HANDLE process, int exit_code) HINSTANCE kernel32 = GetModuleHandleA("kernel32"); if (!kernel32) die("BUG: cannot find kernel32"); - exit_process_address = (LPTHREAD_START_ROUTINE) + exit_process_address = (LPTHREAD_START_ROUTINE)(void *) GetProcAddress(kernel32, "ExitProcess"); initialized = 1; }