From 746e8e250b265c40d9706f26560e02e8623f123f Mon Sep 17 00:00:00 2001
From: Lars Kanis <lars@greiz-reinsdorf.de>
Date: Fri, 31 Jan 2025 21:58:00 +0100
Subject: [PATCH] Use workaround of __builtin_setjmp only on MINGW on MSVCRT

Because it is not present on ARM64 on Windows and not necessary on any UCRT based toolchain.
---
 src/include/c.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/include/c.h b/src/include/c.h
index a14c631516..33792c860c 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -1312,19 +1312,19 @@ extern int	fdatasync(int fildes);
 /*
  * When there is no sigsetjmp, its functionality is provided by plain
  * setjmp.  We now support the case only on Windows.  However, it seems
- * that MinGW-64 has some longstanding issues in its setjmp support,
- * so on that toolchain we cheat and use gcc's builtins.
+ * that MinGW-64 on x86_64 has some longstanding issues in its setjmp
+ * support, so on that toolchain we cheat and use gcc's builtins.
  */
 #ifdef WIN32
-#ifdef __MINGW64__
+#if defined(__MINGW64__) && !defined(_UCRT)
 typedef intptr_t sigjmp_buf[5];
 #define sigsetjmp(x,y) __builtin_setjmp(x)
 #define siglongjmp __builtin_longjmp
-#else							/* !__MINGW64__ */
+#else							/* !defined(__MINGW64__) || defined(_UCRT) */
 #define sigjmp_buf jmp_buf
 #define sigsetjmp(x,y) setjmp(x)
 #define siglongjmp longjmp
-#endif							/* __MINGW64__ */
+#endif							/* defined(__MINGW64__) && !defined(_UCRT) */
 #endif							/* WIN32 */
 
 /* /port compatibility functions */
-- 
2.43.0

