On 22.04.2025 14:16, Martin Storsjö wrote:
On Fri, 11 Apr 2025, Jacek Caban wrote:

Instead of for specific architectures. Fixes setjmp on ARM64EC.
---
mingw-w64-headers/crt/setjmp.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mingw-w64-headers/crt/setjmp.h b/mingw-w64-headers/crt/setjmp.h
index 2dc7d8739..f5208a0dc 100644
--- a/mingw-w64-headers/crt/setjmp.h
+++ b/mingw-w64-headers/crt/setjmp.h
@@ -230,7 +230,7 @@ void * __cdecl __attribute__ ((__nothrow__)) mingw_getsp (void);   int __cdecl __attribute__ ((__nothrow__,__returns_twice__)) __mingw_setjmp(jmp_buf _Buf);   __MINGW_ATTRIB_NORETURN __attribute__ ((__nothrow__)) void __mingw_longjmp(jmp_buf _Buf,int _Value);
#  elif defined(__SEH__) && !defined(__USE_MINGW_SETJMP_NON_SEH)
-#    if defined(__aarch64__) || defined(_ARM64_) || defined(__arm__) || defined(_ARM_)
+#    if __has_builtin(__builtin_sponentry)
#      define setjmp(BUF) _setjmp((BUF), __builtin_sponentry())
#    elif (__MINGW_GCC_VERSION < 40702) && !defined(__clang__)
#      define setjmp(BUF) _setjmp((BUF), mingw_getsp())
--
2.49.0


I guess this is ok, assuming that regular x86_64 doesn't expose __builtin_sponentry(), and/or that the value returned from it also is suitable there too?


__x86_64__ doesn't expose it. See also [1] for how Wine handles it (which was my inspiration).


The conditional a couple lines above this is quite messy as well, I wonder if there's something we could do to simplify it a little? We do want to keep allow users to set __USE_MINGW_SETJMP_NON_SEH, but the other concerns checked in it might not be very relevant any longer. Or would this be simpler if we'd just reorder this to come after the main __SEH__ case?


Yes, we could at least reorder things to reduce indention a bit, I will look at it. I think we should be fine dropping missing __SEH__ case. A quick grep in GCC git suggests that __builtin_sponentry is still not supported there, so I guess the WIP GCC support still uses that fallback?


Thanks,

Jacek


[1] https://gitlab.winehq.org/wine/wine/-/blob/ba6adef9bfc209f1247ba88acec64b58d97100c3/include/msvcrt/setjmp.h#L170



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to