Module: wine Branch: master Commit: 457a6fd4b468772d15d2abb80d4ead472944dab8 URL: https://gitlab.winehq.org/wine/wine/-/commit/457a6fd4b468772d15d2abb80d4ead4...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Dec 7 14:49:51 2023 +0100
msvcrt: Add a stub ARM64EC CPU backend.
---
dlls/crtdll/Makefile.in | 1 + dlls/msvcr100/Makefile.in | 1 + dlls/msvcr110/Makefile.in | 1 + dlls/msvcr120/Makefile.in | 1 + dlls/msvcr70/Makefile.in | 1 + dlls/msvcr71/Makefile.in | 1 + dlls/msvcr80/Makefile.in | 1 + dlls/msvcr90/Makefile.in | 1 + dlls/msvcrt/Makefile.in | 1 + dlls/msvcrt/except_arm64ec.c | 158 +++++++++++++++++++++++++++++++++++++++++++ dlls/msvcrt/except_x86_64.c | 2 +- dlls/msvcrtd/Makefile.in | 1 + dlls/ucrtbase/Makefile.in | 1 + 13 files changed, 170 insertions(+), 1 deletion(-)
diff --git a/dlls/crtdll/Makefile.in b/dlls/crtdll/Makefile.in index b2559f3b91e..40b12eba29a 100644 --- a/dlls/crtdll/Makefile.in +++ b/dlls/crtdll/Makefile.in @@ -15,6 +15,7 @@ SOURCES = \ except.c \ except_arm.c \ except_arm64.c \ + except_arm64ec.c \ except_i386.c \ except_x86_64.c \ exception_ptr.c \ diff --git a/dlls/msvcr100/Makefile.in b/dlls/msvcr100/Makefile.in index 71bd580a6e7..09939efe08f 100644 --- a/dlls/msvcr100/Makefile.in +++ b/dlls/msvcr100/Makefile.in @@ -17,6 +17,7 @@ SOURCES = \ except.c \ except_arm.c \ except_arm64.c \ + except_arm64ec.c \ except_i386.c \ except_x86_64.c \ exception_ptr.c \ diff --git a/dlls/msvcr110/Makefile.in b/dlls/msvcr110/Makefile.in index a397b04efa2..d3795cecd7c 100644 --- a/dlls/msvcr110/Makefile.in +++ b/dlls/msvcr110/Makefile.in @@ -17,6 +17,7 @@ SOURCES = \ except.c \ except_arm.c \ except_arm64.c \ + except_arm64ec.c \ except_i386.c \ except_x86_64.c \ exception_ptr.c \ diff --git a/dlls/msvcr120/Makefile.in b/dlls/msvcr120/Makefile.in index ea9df276926..5954973cfec 100644 --- a/dlls/msvcr120/Makefile.in +++ b/dlls/msvcr120/Makefile.in @@ -17,6 +17,7 @@ SOURCES = \ except.c \ except_arm.c \ except_arm64.c \ + except_arm64ec.c \ except_i386.c \ except_x86_64.c \ exception_ptr.c \ diff --git a/dlls/msvcr70/Makefile.in b/dlls/msvcr70/Makefile.in index a1d8bf0f001..7979542caa2 100644 --- a/dlls/msvcr70/Makefile.in +++ b/dlls/msvcr70/Makefile.in @@ -16,6 +16,7 @@ SOURCES = \ except.c \ except_arm.c \ except_arm64.c \ + except_arm64ec.c \ except_i386.c \ except_x86_64.c \ exception_ptr.c \ diff --git a/dlls/msvcr71/Makefile.in b/dlls/msvcr71/Makefile.in index 6da68524dc6..2dfa5478544 100644 --- a/dlls/msvcr71/Makefile.in +++ b/dlls/msvcr71/Makefile.in @@ -16,6 +16,7 @@ SOURCES = \ except.c \ except_arm.c \ except_arm64.c \ + except_arm64ec.c \ except_i386.c \ except_x86_64.c \ exception_ptr.c \ diff --git a/dlls/msvcr80/Makefile.in b/dlls/msvcr80/Makefile.in index c6d2bb884f3..1bbabee0dac 100644 --- a/dlls/msvcr80/Makefile.in +++ b/dlls/msvcr80/Makefile.in @@ -16,6 +16,7 @@ SOURCES = \ except.c \ except_arm.c \ except_arm64.c \ + except_arm64ec.c \ except_i386.c \ except_x86_64.c \ exception_ptr.c \ diff --git a/dlls/msvcr90/Makefile.in b/dlls/msvcr90/Makefile.in index f86dfa18105..fb6047297e7 100644 --- a/dlls/msvcr90/Makefile.in +++ b/dlls/msvcr90/Makefile.in @@ -16,6 +16,7 @@ SOURCES = \ except.c \ except_arm.c \ except_arm64.c \ + except_arm64ec.c \ except_i386.c \ except_x86_64.c \ exception_ptr.c \ diff --git a/dlls/msvcrt/Makefile.in b/dlls/msvcrt/Makefile.in index 7dd1f9ed1a8..aa068b62e51 100644 --- a/dlls/msvcrt/Makefile.in +++ b/dlls/msvcrt/Makefile.in @@ -21,6 +21,7 @@ SOURCES = \ except.c \ except_arm.c \ except_arm64.c \ + except_arm64ec.c \ except_i386.c \ except_x86_64.c \ exception_ptr.c \ diff --git a/dlls/msvcrt/except_arm64ec.c b/dlls/msvcrt/except_arm64ec.c new file mode 100644 index 00000000000..f098449892a --- /dev/null +++ b/dlls/msvcrt/except_arm64ec.c @@ -0,0 +1,158 @@ +/* + * msvcrt C++ exception handling + * + * Copyright 2011 Alexandre Julliard + * Copyright 2013 André Hentschel + * Copyright 2017 Martin Storsjo + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifdef __arm64ec__ + +#include <setjmp.h> +#include <stdarg.h> +#include <fpieee.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winternl.h" +#include "msvcrt.h" +#include "wine/exception.h" +#include "excpt.h" +#include "wine/debug.h" + +#include "cppexcept.h" + +WINE_DEFAULT_DEBUG_CHANNEL(seh); + +/********************************************************************* + * __CxxExceptionFilter (MSVCRT.@) + */ +int CDECL __CxxExceptionFilter( PEXCEPTION_POINTERS ptrs, + const type_info *ti, int flags, void **copy ) +{ + FIXME( "%p %p %x %p: not implemented\n", ptrs, ti, flags, copy ); + return EXCEPTION_CONTINUE_SEARCH; +} + +/********************************************************************* + * __CxxFrameHandler (MSVCRT.@) + */ +EXCEPTION_DISPOSITION CDECL __CxxFrameHandler( EXCEPTION_RECORD *rec, ULONG64 frame, CONTEXT *context, + DISPATCHER_CONTEXT *dispatch ) +{ + FIXME("%p %I64x %p %p: not implemented\n", rec, frame, context, dispatch); + return ExceptionContinueSearch; +} + + +/********************************************************************* + * __CppXcptFilter (MSVCRT.@) + */ +int CDECL __CppXcptFilter( NTSTATUS ex, PEXCEPTION_POINTERS ptr ) +{ + /* only filter c++ exceptions */ + if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH; + return _XcptFilter(ex, ptr); +} + + +/********************************************************************* + * __CxxDetectRethrow (MSVCRT.@) + */ +BOOL CDECL __CxxDetectRethrow( PEXCEPTION_POINTERS ptrs ) +{ + PEXCEPTION_RECORD rec; + + if (!ptrs) + return FALSE; + + rec = ptrs->ExceptionRecord; + + if (rec->ExceptionCode == CXX_EXCEPTION && + rec->NumberParameters == 3 && + rec->ExceptionInformation[0] == CXX_FRAME_MAGIC_VC6 && + rec->ExceptionInformation[2]) + { + ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record; + return TRUE; + } + return (msvcrt_get_thread_data()->exc_record == rec); +} + + +/********************************************************************* + * __CxxQueryExceptionSize (MSVCRT.@) + */ +unsigned int CDECL __CxxQueryExceptionSize(void) +{ + return sizeof(cxx_exception_type); +} + + +/******************************************************************* + * _setjmp (MSVCRT.@) + */ +int __attribute__((naked)) MSVCRT__setjmp( jmp_buf buf ) +{ + asm( "b " __ASM_NAME("__wine_setjmpex") ); +} + + +/******************************************************************* + * longjmp (MSVCRT.@) + */ +void __cdecl MSVCRT_longjmp( _JUMP_BUFFER *jmp, int retval ) +{ + EXCEPTION_RECORD rec; + + if (!retval) retval = 1; + if (jmp->Frame) + { + rec.ExceptionCode = STATUS_LONGJUMP; + rec.ExceptionFlags = 0; + rec.ExceptionRecord = NULL; + rec.ExceptionAddress = NULL; + rec.NumberParameters = 1; + rec.ExceptionInformation[0] = (DWORD_PTR)jmp; + RtlUnwind( (void *)jmp->Frame, (void *)jmp->Rip, &rec, IntToPtr(retval) ); + } + __wine_longjmp( (__wine_jmp_buf *)jmp, retval ); +} + +/********************************************************************* + * _fpieee_flt (MSVCRT.@) + */ +int __cdecl _fpieee_flt( __msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep, + int (__cdecl *handler)(_FPIEEE_RECORD*) ) +{ + FIXME("(%lx %p %p)\n", exception_code, ep, handler); + return EXCEPTION_CONTINUE_SEARCH; +} + +#if _MSVCR_VER>=110 && _MSVCR_VER<=120 +/********************************************************************* + * __crtCapturePreviousContext (MSVCR110.@) + */ +void __cdecl __crtCapturePreviousContext( CONTEXT *ctx ) +{ + FIXME("not implemented\n"); +} +#endif + +#endif /* __arm64ec__ */ diff --git a/dlls/msvcrt/except_x86_64.c b/dlls/msvcrt/except_x86_64.c index b07a7b83772..9b8db6d0d67 100644 --- a/dlls/msvcrt/except_x86_64.c +++ b/dlls/msvcrt/except_x86_64.c @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
-#ifdef __x86_64__ +#if defined(__x86_64__) && !defined(__arm64ec__)
#include <setjmp.h> #include <stdarg.h> diff --git a/dlls/msvcrtd/Makefile.in b/dlls/msvcrtd/Makefile.in index 8bfae2270f8..a06a244747e 100644 --- a/dlls/msvcrtd/Makefile.in +++ b/dlls/msvcrtd/Makefile.in @@ -17,6 +17,7 @@ SOURCES = \ except.c \ except_arm.c \ except_arm64.c \ + except_arm64ec.c \ except_i386.c \ except_x86_64.c \ exception_ptr.c \ diff --git a/dlls/ucrtbase/Makefile.in b/dlls/ucrtbase/Makefile.in index 433ca5d4b48..a3bb54750af 100644 --- a/dlls/ucrtbase/Makefile.in +++ b/dlls/ucrtbase/Makefile.in @@ -21,6 +21,7 @@ SOURCES = \ except.c \ except_arm.c \ except_arm64.c \ + except_arm64ec.c \ except_i386.c \ except_x86_64.c \ exception_ptr.c \