Re: [Mingw-w64-public] [PATCH] headers: Use the msvcrt/ucrt setjmp functions on ARM64 is SEH is available

2019-05-09 Thread Jacek Caban

On 5/7/19 9:41 AM, Martin Storsjö wrote:

This requires using a new builtin intrinsic __builtin_sponentry(),
which was added in Clang 9.

Signed-off-by: Martin Storsjö 
---
The new intrinsic was added yesterday. After some time we could remove
the fallback setjmp/longjmp for ARM64, assuming that all users of
this arch have a new enough Clang with SEH enabled by default.
---



The patch looks good to me.


Thanks,

Jacek



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


[Mingw-w64-public] [PATCH] headers: Use the msvcrt/ucrt setjmp functions on ARM64 is SEH is available

2019-05-07 Thread Martin Storsjö
This requires using a new builtin intrinsic __builtin_sponentry(),
which was added in Clang 9.

Signed-off-by: Martin Storsjö 
---
The new intrinsic was added yesterday. After some time we could remove
the fallback setjmp/longjmp for ARM64, assuming that all users of
this arch have a new enough Clang with SEH enabled by default.
---
 mingw-w64-headers/crt/setjmp.h | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-headers/crt/setjmp.h b/mingw-w64-headers/crt/setjmp.h
index f66ea7177..83147d0b5 100644
--- a/mingw-w64-headers/crt/setjmp.h
+++ b/mingw-w64-headers/crt/setjmp.h
@@ -204,6 +204,11 @@ _CRTIMP __MINGW_ATTRIB_NORETURN __attribute__ 
((__nothrow__)) void __cdecl longj
 
 void * __cdecl __attribute__ ((__nothrow__)) mingw_getsp (void);
 
+#pragma push_macro("__has_builtin")
+#ifndef __has_builtin
+  #define __has_builtin(x) 0
+#endif
+
 #if !defined(USE_NO_MINGW_SETJMP_TWO_ARGS)
 #  ifdef _UCRT
 #ifdef _WIN64
@@ -211,17 +216,22 @@ void * __cdecl __attribute__ ((__nothrow__)) mingw_getsp 
(void);
 #else
 #  define _setjmp __intrinsic_setjmp
 #endif
+#  elif defined(__aarch64__)
+ // ARM64 msvcrt.dll lacks _setjmp, only has _setjmpex.
+#define _setjmp _setjmpex
 #  endif
 #  ifndef _INC_SETJMPEX
 #if defined(_X86_) || defined(__i386__)
 #  define setjmp(BUF) _setjmp3((BUF), NULL)
-#elif defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || 
defined(__aarch64__)
+#elif defined(_ARM_) || defined(__arm__) || ((defined(_ARM64_) || 
defined(__aarch64__)) && (!defined(__SEH__) || 
!__has_builtin(__builtin_sponentry)))
 #  define setjmp(BUF) __mingw_setjmp((BUF))
 #  define longjmp __mingw_longjmp
   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__)
-# if (__MINGW_GCC_VERSION < 40702)
+# if defined(__aarch64__) || defined(_ARM64_)
+#  define setjmp(BUF) _setjmp((BUF), __builtin_sponentry ())
+# elif (__MINGW_GCC_VERSION < 40702)
 #  define setjmp(BUF) _setjmp((BUF), mingw_getsp())
 # else
 #  define setjmp(BUF) _setjmp((BUF), __builtin_frame_address (0))
@@ -257,6 +267,8 @@ void * __cdecl __attribute__ ((__nothrow__)) mingw_getsp 
(void);
   int __cdecl __attribute__ ((__nothrow__,__returns_twice__)) setjmp(jmp_buf 
_Buf);
 #endif
 
+#pragma pop_macro("__has_builtin")
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.17.1



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