summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-01-12 23:11:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-01-12 23:11:41 (GMT)
commita4510f8106a65f42d4ecbe9b826f16e4ff9df6db (patch)
tree2c46633005363bc26b15aefd8648d052a2c97478
parentcde28af37b19e07139ebb6a355d742e763b7a235 (diff)
parent4a9b204920152c668228a9d43a63be39b0c32f45 (diff)
downloadgit-a4510f8106a65f42d4ecbe9b826f16e4ff9df6db.zip
git-a4510f8106a65f42d4ecbe9b826f16e4ff9df6db.tar.gz
git-a4510f8106a65f42d4ecbe9b826f16e4ff9df6db.tar.bz2
Merge branch 'ma/windows-dynload-fix'
Fix calling dynamically loaded functions on Windows. * ma/windows-dynload-fix: lazyload: use correct calling conventions
-rw-r--r--compat/mingw.c6
-rw-r--r--compat/win32/lazyload.h6
-rw-r--r--compat/win32/trace2_win32_process_info.c4
-rw-r--r--compat/winansi.c5
-rw-r--r--t/helper/test-drop-caches.c4
5 files changed, 15 insertions, 10 deletions
diff --git a/compat/mingw.c b/compat/mingw.c
index e14f2d5..640dcb1 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -8,6 +8,8 @@
#include "win32/lazyload.h"
#include "../config.h"
#include "dir.h"
+#define SECURITY_WIN32
+#include <sspi.h>
#define HCAST(type, handle) ((type)(intptr_t)handle)
@@ -1008,7 +1010,7 @@ size_t mingw_strftime(char *s, size_t max,
/* a pointer to the original strftime in case we can't find the UCRT version */
static size_t (*fallback)(char *, size_t, const char *, const struct tm *) = strftime;
size_t ret;
- DECLARE_PROC_ADDR(ucrtbase.dll, size_t, strftime, char *, size_t,
+ DECLARE_PROC_ADDR(ucrtbase.dll, size_t, __cdecl, strftime, char *, size_t,
const char *, const struct tm *);
if (INIT_PROC_ADDR(strftime))
@@ -2185,7 +2187,7 @@ enum EXTENDED_NAME_FORMAT {
static char *get_extended_user_info(enum EXTENDED_NAME_FORMAT type)
{
- DECLARE_PROC_ADDR(secur32.dll, BOOL, GetUserNameExW,
+ DECLARE_PROC_ADDR(secur32.dll, BOOL, SEC_ENTRY, GetUserNameExW,
enum EXTENDED_NAME_FORMAT, LPCWSTR, PULONG);
static wchar_t wbuffer[1024];
DWORD len;
diff --git a/compat/win32/lazyload.h b/compat/win32/lazyload.h
index 2b36371..f2bb96c 100644
--- a/compat/win32/lazyload.h
+++ b/compat/win32/lazyload.h
@@ -4,7 +4,7 @@
/*
* A pair of macros to simplify loading of DLL functions. Example:
*
- * DECLARE_PROC_ADDR(kernel32.dll, BOOL, CreateHardLinkW,
+ * DECLARE_PROC_ADDR(kernel32.dll, BOOL, WINAPI, CreateHardLinkW,
* LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
*
* if (!INIT_PROC_ADDR(CreateHardLinkW))
@@ -25,10 +25,10 @@ struct proc_addr {
};
/* Declares a function to be loaded dynamically from a DLL. */
-#define DECLARE_PROC_ADDR(dll, rettype, function, ...) \
+#define DECLARE_PROC_ADDR(dll, rettype, convention, function, ...) \
static struct proc_addr proc_addr_##function = \
{ #dll, #function, NULL, 0 }; \
- typedef rettype (WINAPI *proc_type_##function)(__VA_ARGS__); \
+ typedef rettype (convention *proc_type_##function)(__VA_ARGS__); \
static proc_type_##function function
/*
diff --git a/compat/win32/trace2_win32_process_info.c b/compat/win32/trace2_win32_process_info.c
index 8ccbd1c..a53fd92 100644
--- a/compat/win32/trace2_win32_process_info.c
+++ b/compat/win32/trace2_win32_process_info.c
@@ -143,8 +143,8 @@ static void get_is_being_debugged(void)
*/
static void get_peak_memory_info(void)
{
- DECLARE_PROC_ADDR(psapi.dll, BOOL, GetProcessMemoryInfo, HANDLE,
- PPROCESS_MEMORY_COUNTERS, DWORD);
+ DECLARE_PROC_ADDR(psapi.dll, BOOL, WINAPI, GetProcessMemoryInfo,
+ HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD);
if (INIT_PROC_ADDR(GetProcessMemoryInfo)) {
PROCESS_MEMORY_COUNTERS pmc;
diff --git a/compat/winansi.c b/compat/winansi.c
index c27b20a..4fceecf 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -45,8 +45,9 @@ typedef struct _CONSOLE_FONT_INFOEX {
static void warn_if_raster_font(void)
{
DWORD fontFamily = 0;
- DECLARE_PROC_ADDR(kernel32.dll, BOOL, GetCurrentConsoleFontEx,
- HANDLE, BOOL, PCONSOLE_FONT_INFOEX);
+ DECLARE_PROC_ADDR(kernel32.dll, BOOL, WINAPI,
+ GetCurrentConsoleFontEx, HANDLE, BOOL,
+ PCONSOLE_FONT_INFOEX);
/* don't bother if output was ascii only */
if (!non_ascii_used)
diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c
index 7b42784..e37396d 100644
--- a/t/helper/test-drop-caches.c
+++ b/t/helper/test-drop-caches.c
@@ -3,6 +3,7 @@
#if defined(GIT_WINDOWS_NATIVE)
#include "lazyload.h"
+#include <winnt.h>
static int cmd_sync(void)
{
@@ -86,7 +87,8 @@ static int cmd_dropcaches(void)
{
HANDLE hProcess = GetCurrentProcess();
HANDLE hToken;
- DECLARE_PROC_ADDR(ntdll.dll, DWORD, NtSetSystemInformation, INT, PVOID, ULONG);
+ DECLARE_PROC_ADDR(ntdll.dll, DWORD, NTAPI, NtSetSystemInformation, INT, PVOID,
+ ULONG);
SYSTEM_MEMORY_LIST_COMMAND command;
int status;