Skip to content

Commit

Permalink
Merge pull request #3626 from dscho/windows-dynload-fix
Browse files Browse the repository at this point in the history
Fix custom date formats in i686 builds
  • Loading branch information
dscho committed Jan 12, 2022
2 parents 6161615 + 37eac0d commit b1e0460
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
6 changes: 4 additions & 2 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "win32/fscache.h"
#include "../attr.h"
#include "../string-list.h"
#define SECURITY_WIN32
#include <sspi.h>

#define HCAST(type, handle) ((type)(intptr_t)handle)

Expand Down Expand Up @@ -1214,7 +1216,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))
Expand Down Expand Up @@ -2675,7 +2677,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;
Expand Down
2 changes: 1 addition & 1 deletion compat/win32/flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ int win32_fsync_no_flush(int fd)

#define FLUSH_FLAGS_FILE_DATA_ONLY 1

DECLARE_PROC_ADDR(ntdll.dll, NTSTATUS, NtFlushBuffersFileEx,
DECLARE_PROC_ADDR(ntdll.dll, NTSTATUS, NTAPI, NtFlushBuffersFileEx,
HANDLE FileHandle, ULONG Flags, PVOID Parameters, ULONG ParameterSize,
PIO_STATUS_BLOCK IoStatusBlock);

Expand Down
6 changes: 3 additions & 3 deletions compat/win32/lazyload.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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

/*
Expand Down
4 changes: 2 additions & 2 deletions compat/win32/trace2_win32_process_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions compat/winansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion t/helper/test-drop-caches.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#if defined(GIT_WINDOWS_NATIVE)
#include "lazyload.h"
#include <winnt.h>

static int cmd_sync(void)
{
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit b1e0460

Please sign in to comment.