Thanks! Do you also need to add the prototype of __fastfail to intrin.h? Also, 
there is a TODO comment in winnt.h about __fastfail, which I guess should be 
made obsolete by this patch, is this right?

On 22/9/2022 0:01, Martin Storsjö wrote:
> Signed-off-by: Martin Storsjö <mar...@martin.st>
> ---
>  mingw-w64-headers/crt/_mingw.h.in | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
>
> diff --git a/mingw-w64-headers/crt/_mingw.h.in 
> b/mingw-w64-headers/crt/_mingw.h.in
> index 0ef7ae6ea..087fce88d 100644
> --- a/mingw-w64-headers/crt/_mingw.h.in
> +++ b/mingw-w64-headers/crt/_mingw.h.in
> @@ -577,6 +577,7 @@ extern "C" {
>  
>  
>  #ifdef __MINGW_INTRIN_INLINE
> +
>  #ifdef __has_builtin
>  #define __MINGW_DEBUGBREAK_IMPL !__has_builtin(__debugbreak)
>  #else
> @@ -596,8 +597,32 @@ __MINGW_INTRIN_INLINE void __cdecl __debugbreak(void)
>    __asm__ __volatile__("unimplemented");
>  #endif
>  }
> +#endif /* __MINGW_DEBUGBREAK_IMPL == 1 */
> +
> +#ifdef __has_builtin
> +#define __MINGW_FASTFAIL_IMPL !__has_builtin(__fastfail)
> +#else
> +#define __MINGW_FASTFAIL_IMPL 1
>  #endif
> +#if __MINGW_FASTFAIL_IMPL == 1
> +void __cdecl __MINGW_ATTRIB_NORETURN __fastfail(unsigned int code);
> +__MINGW_INTRIN_INLINE void __cdecl __MINGW_ATTRIB_NORETURN 
> __fastfail(unsigned int code)
> +{
> +#if defined(__i386__) || defined(__x86_64__)
> +  __asm__ __volatile__("int {$}0x29"::"c"(code));
> +#elif defined(__arm__)
> +  register unsigned int r0 __asm__("r0") = code;
> +  __asm__ __volatile__("udf #0xfb"::"r"(r0));
> +#elif defined(__aarch64__)
> +  register unsigned int w0 __asm__("w0") = code;
> +  __asm__ __volatile__("brk #0xf003"::"r"(w0));
> +#else
> +  __asm__ __volatile__("unimplemented");
>  #endif
> +}
> +#endif /* __MINGW_FASTFAIL_IMPL == 1 */
> +
> +#endif /* defined(__MINGW_INTRIN_INLINE) */
>  
>  /* mingw-w64 specific functions: */
>  const char *__mingw_get_crt_info (void);


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

Reply via email to