From bc0a515998c4241998b75d26b9530de97b716d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 9 May 2026 15:42:46 +0800 Subject: [PATCH] Common (Windows): works around a compiler optimise bug --- src/common/windows/nt.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/windows/nt.h b/src/common/windows/nt.h index a8bf50839..2f476b8d6 100644 --- a/src/common/windows/nt.h +++ b/src/common/windows/nt.h @@ -602,7 +602,15 @@ typedef struct _KUSER_SHARED_DATA { // ... more fields follow, but we don't need them } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; -#define SharedUserData ((const KUSER_SHARED_DATA*) 0x7FFE0000UL) +#ifdef __aarch64__ + #define SharedUserData ({ \ + __auto_type shared_user_data = (const volatile KUSER_SHARED_DATA*) (uintptr_t) 0x7FFE0000UL; \ + __asm__("" : "+r"(shared_user_data)); /* https://github.com/lhmouse/mcfgthread/issues/330 */ \ + shared_user_data; \ + }) +#else + #define SharedUserData ((const volatile KUSER_SHARED_DATA*) (uintptr_t) 0x7FFE0000UL) +#endif static inline uint64_t ffKSystemTimeToUInt64(const volatile KSYSTEM_TIME* pTime) { #if _WIN64