Skip to content

Instantly share code, notes, and snippets.

@andyvand
Last active May 24, 2025 10:46
Show Gist options
  • Select an option

  • Save andyvand/fe43d64240223d6b13274464886d824a to your computer and use it in GitHub Desktop.

Select an option

Save andyvand/fe43d64240223d6b13274464886d824a to your computer and use it in GitHub Desktop.
mingw-w64 winpthreads XP
diff -Nur mingw-w64-v12.0.0/mingw-w64-crt/Makefile.am mingw-w64-v12.0.0-XP/mingw-w64-crt/Makefile.am
--- mingw-w64-v12.0.0/mingw-w64-crt/Makefile.am 2024-05-22 09:07:14
+++ mingw-w64-v12.0.0-XP/mingw-w64-crt/Makefile.am 2025-05-22 18:55:51
@@ -20,7 +20,7 @@
endif
AM_CPPFLAGS=$(sysincludes)
-AM_CFLAGS=-pipe -std=gnu99 -D_CRTBLD -D_WIN32_WINNT=0x0f00 -D__MSVCRT_VERSION__=0x700 -D__USE_MINGW_ANSI_STDIO=0 @IMAGEBASE_CFLAGS@ @CFGUARD_CFLAGS@ @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@
+AM_CFLAGS=-pipe -std=gnu99 -D_CRTBLD -D_WIN32_WINNT=0x0501 -D__MSVCRT_VERSION__=0x700 -D__USE_MINGW_ANSI_STDIO=0 @IMAGEBASE_CFLAGS@ @CFGUARD_CFLAGS@ @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@
AM_CXXFLAGS=@ADD_C_CXX_WARNING_FLAGS@ @ADD_CXX_ONLY_WARNING_FLAGS@
CPPFLAGSARM32=-mfpu=vfpv3
CPPFLAGS32=-m32 -masm=att
diff -Nur mingw-w64-v12.0.0/mingw-w64-crt/Makefile.in mingw-w64-v12.0.0-XP/mingw-w64-crt/Makefile.in
--- mingw-w64-v12.0.0/mingw-w64-crt/Makefile.in 2024-05-22 09:07:14
+++ mingw-w64-v12.0.0-XP/mingw-w64-crt/Makefile.in 2025-05-22 18:55:21
@@ -10765,7 +10765,7 @@
@WITHSYSROOT_FALSE@withsys =
@WITHSYSROOT_TRUE@withsys = "--with-sysroot=@TARGET_SYSTEM_ROOT@"
AM_CPPFLAGS = $(sysincludes)
-AM_CFLAGS = -pipe -std=gnu99 -D_CRTBLD -D_WIN32_WINNT=0x0f00 -D__MSVCRT_VERSION__=0x700 -D__USE_MINGW_ANSI_STDIO=0 @IMAGEBASE_CFLAGS@ @CFGUARD_CFLAGS@ @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@
+AM_CFLAGS = -pipe -std=gnu99 -D_CRTBLD -D_WIN32_WINNT=0x0501 -D__MSVCRT_VERSION__=0x700 -D__USE_MINGW_ANSI_STDIO=0 @IMAGEBASE_CFLAGS@ @CFGUARD_CFLAGS@ @ADD_C_CXX_WARNING_FLAGS@ @ADD_C_ONLY_WARNING_FLAGS@
AM_CXXFLAGS = @ADD_C_CXX_WARNING_FLAGS@ @ADD_CXX_ONLY_WARNING_FLAGS@
CPPFLAGSARM32 = -mfpu=vfpv3
CPPFLAGS32 = -m32 -masm=att
diff -Nur mingw-w64-v12.0.0/mingw-w64-crt/misc/gettimeofday.c mingw-w64-v12.0.0-XP/mingw-w64-crt/misc/gettimeofday.c
--- mingw-w64-v12.0.0/mingw-w64-crt/misc/gettimeofday.c 2024-05-22 09:07:14
+++ mingw-w64-v12.0.0-XP/mingw-w64-crt/misc/gettimeofday.c 2025-05-22 18:48:59
@@ -45,17 +45,8 @@
static GetSystemTimeAsFileTime_t GetSystemTimeAsFileTime_p /* = 0 */;
/* Set function pointer during first call */
- GetSystemTimeAsFileTime_t get_time =
- __atomic_load_n (&GetSystemTimeAsFileTime_p, __ATOMIC_RELAXED);
- if (get_time == NULL) {
- /* Use GetSystemTimePreciseAsFileTime() if available (Windows 8 or later) */
- get_time = (GetSystemTimeAsFileTime_t)(intptr_t) GetProcAddress (
- GetModuleHandle ("kernel32.dll"),
- "GetSystemTimePreciseAsFileTime"); /* <1us precision on Windows 10 */
- if (get_time == NULL)
- get_time = GetSystemTimeAsFileTime; /* >15ms precision on Windows 10 */
- __atomic_store_n (&GetSystemTimeAsFileTime_p, get_time, __ATOMIC_RELAXED);
- }
+ GetSystemTimeAsFileTime_t get_time = GetSystemTimeAsFileTime; /* >15ms precision on Windows 10 */
+// __atomic_store_n (&GetSystemTimeAsFileTime_p, get_time, __ATOMIC_RELAXED);
get_time (&_now.ft); /* 100 nano-seconds since 1-1-1601 */
_now.ns100 -= FILETIME_1970; /* 100 nano-seconds since 1-1-1970 */
diff -Nur mingw-w64-v12.0.0/mingw-w64-libraries/winpthreads/src/misc.c mingw-w64-v12.0.0/mingw-w64-libraries/winpthreads_xp/src/misc.c
--- mingw-w64-v12.0.0/mingw-w64-libraries/winpthreads/src/misc.c 2024-05-22 09:07:14
+++ mingw-w64-v12.0.0/mingw-w64-libraries/winpthreads_xp/src/misc.c 2025-05-24 12:39:15
@@ -25,27 +25,13 @@
#include "misc.h"
void (WINAPI *_pthread_get_system_time_best_as_file_time) (LPFILETIME) = NULL;
-static ULONGLONG (WINAPI *_pthread_get_tick_count_64) (VOID);
#if defined(__GNUC__) || defined(__clang__)
__attribute__((constructor))
#endif
static void winpthreads_init(void)
{
- HMODULE mod = GetModuleHandleA("kernel32.dll");
- if (mod)
- {
- _pthread_get_tick_count_64 =
- (ULONGLONG (WINAPI *)(VOID))(void*) GetProcAddress(mod, "GetTickCount64");
-
- /* <1us precision on Windows 10 */
- _pthread_get_system_time_best_as_file_time =
- (void (WINAPI *)(LPFILETIME))(void*) GetProcAddress(mod, "GetSystemTimePreciseAsFileTime");
- }
-
- if (!_pthread_get_system_time_best_as_file_time)
- /* >15ms precision on Windows 10 */
- _pthread_get_system_time_best_as_file_time = GetSystemTimeAsFileTime;
+ _pthread_get_system_time_best_as_file_time = GetSystemTimeAsFileTime;
}
#if defined(_MSC_VER) && !defined(__clang__)
@@ -96,9 +82,6 @@
static unsigned long long
_pthread_get_tick_count (long long *frequency)
{
- if (_pthread_get_tick_count_64 != NULL)
- return _pthread_get_tick_count_64 ();
-
LARGE_INTEGER freq, timestamp;
if (*frequency == 0)
diff -Nur mingw-w64-v12.0.0/mingw-w64-headers/include/sdkddkver.h mingw-w64-v12.0.0-XP/mingw-w64-headers/include/sdkddkver.h
--- mingw-w64-v12.0.0/mingw-w64-headers/include/sdkddkver.h 2024-05-22 09:07:14
+++ mingw-w64-v12.0.0-XP/mingw-w64-headers/include/sdkddkver.h 2025-05-23 09:46:57
@@ -165,7 +165,7 @@
/* Select Default WIN32_WINNT Value */
#if !defined(_WIN32_WINNT) && !defined(_CHICAGO_)
-#define _WIN32_WINNT _WIN32_WINNT_WS03
+#define _WIN32_WINNT _WIN32_WINNT_WINXP
#endif
/* Choose NTDDI Version */
@@ -173,7 +173,7 @@
#ifdef _WIN32_WINNT
#define NTDDI_VERSION NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT)
#else
-#define NTDDI_VERSION NTDDI_WS03
+#define NTDDI_VERSION NTDDI_WINXP
#endif
#endif
@@ -204,7 +204,7 @@
#elif (_WIN32_WINNT <= _WIN32_WINNT_WIN8)
#define _WIN32_IE _WIN32_IE_WIN8
#else
-#define _WIN32_IE 0x0a00
+#define _WIN32_IE 0x0700
#endif
#else
#define _WIN32_IE 0x0700
diff -Nur mingw-w64-v12.0.0/mingw-w64-headers/include/winreg.h mingw-w64-v12.0.0-XP/mingw-w64-headers/include/winreg.h
--- mingw-w64-v12.0.0/mingw-w64-headers/include/winreg.h 2024-05-22 09:07:14
+++ mingw-w64-v12.0.0-XP/mingw-w64-headers/include/winreg.h 2025-05-23 09:44:02
@@ -14,7 +14,7 @@
#endif
#ifndef WINVER
-#define WINVER 0x0502
+#define WINVER 0x0501
#endif
#define RRF_RT_REG_NONE 0x00000001
diff -Nur mingw-w64-v12.0.0/mingw-w64-headers/include/winresrc.h mingw-w64-v12.0.0-XP/mingw-w64-headers/include/winresrc.h
--- mingw-w64-v12.0.0/mingw-w64-headers/include/winresrc.h 2024-05-22 09:07:14
+++ mingw-w64-v12.0.0-XP/mingw-w64-headers/include/winresrc.h 2025-05-23 09:45:01
@@ -7,7 +7,7 @@
#define _WINRESRC_
#ifndef WINVER
-#define WINVER 0x0502
+#define WINVER 0x0501
#endif
#ifndef _WIN32_IE
@@ -15,11 +15,11 @@
#endif
#ifndef _WIN32_WINDOWS
-#define _WIN32_WINDOWS 0x0502
+#define _WIN32_WINDOWS 0x0501
#endif
#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0502
+#define _WIN32_WINNT 0x0501
#endif
#include <winuser.rh>
--- mingw-w64-v12.0.0/mingw-w64-crt/libsrc/dloadhelper.c 2024-05-22 09:07:14
+++ mingw-w64-v12.0.0-XP/mingw-w64-crt/libsrc/dloadhelper.c 2025-05-23 10:02:16
@@ -9,6 +9,7 @@
#include <windows.h>
#include <delayloadhandler.h>
+#if _WIN32_WINNT >= 0x0602
/* XXX NTSTATUS is supposed to be a LONG, but there are a bunch of STATUS_
* constants in winnt.h defined as ((DWORD)0x...), including
* STATUS_DLL_NOT_FOUND which we need, so using DWORD here to silence a warning
@@ -60,3 +61,4 @@
else
return S_OK;
}
+#endif
diff -Nur mingw-w64-v12.0.0/mingw-w64-crt/lib-common/kernel32.def.in mingw-w64-v12.0.0-XP/mingw-w64-crt/lib-common/kernel32.def.in
--- mingw-w64-v12.0.0/mingw-w64-crt/lib-common/kernel32.def.in 2024-05-22 09:07:14
+++ mingw-w64-v12.0.0-XP/mingw-w64-crt/lib-common/kernel32.def.in 2025-05-23 10:16:46
@@ -826,7 +826,6 @@
GetThreadTimes
GetThreadUILanguage
GetTickCount
-GetTickCount64
GetTimeFormatA
GetTimeFormatAWorker
GetTimeFormatEx
diff -Nur mingw-w64-v12.0.0/mingw-w64-crt/lib-common/kernel32_onecore.def mingw-w64-v12.0.0-XP/mingw-w64-crt/lib-common/kernel32_onecore.def
--- mingw-w64-v12.0.0/mingw-w64-crt/lib-common/kernel32_onecore.def 2024-05-22 09:07:14
+++ mingw-w64-v12.0.0-XP/mingw-w64-crt/lib-common/kernel32_onecore.def 2025-05-23 10:17:14
@@ -630,7 +630,6 @@
GetThreadTimes
GetThreadUILanguage
GetTickCount
-GetTickCount64
GetTimeFormatA
GetTimeFormatEx
GetTimeFormatW
--- mingw-w64-v12.0.0/mingw-w64-crt/secapi/_controlfp_s.c 2024-05-22 09:07:14
+++ mingw-w64-v12.0.0-XP/mingw-w64-crt/secapi/_controlfp_s.c 2025-05-23 16:50:51
@@ -1,4 +1,4 @@
-#include <float.h>
+#include "../../mingw-w64-headers/crt/float.h"
#include <errno.h>
#include <windows.h>
#include <msvcrt.h>

Comments are disabled for this gist.