mfplat/sample: Refactor sample_CopyToBuffer().
[wine.git] / dlls / msvcrt / except_arm64.c
blobe750cb8857321d45e2ef55a9bf20904d59ea3a25
1 /*
2 * msvcrt C++ exception handling
4 * Copyright 2011 Alexandre Julliard
5 * Copyright 2013 André Hentschel
6 * Copyright 2017 Martin Storsjo
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #ifdef __aarch64__
25 #include <setjmp.h>
26 #include <stdarg.h>
27 #include <fpieee.h>
29 #include "ntstatus.h"
30 #define WIN32_NO_STATUS
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winternl.h"
34 #include "msvcrt.h"
35 #include "wine/exception.h"
36 #include "excpt.h"
37 #include "wine/debug.h"
39 #include "cppexcept.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(seh);
44 /*********************************************************************
45 * __CxxExceptionFilter (MSVCRT.@)
47 int CDECL __CxxExceptionFilter( PEXCEPTION_POINTERS ptrs,
48 const type_info *ti, int flags, void **copy )
50 FIXME( "%p %p %x %p: not implemented\n", ptrs, ti, flags, copy );
51 return EXCEPTION_CONTINUE_SEARCH;
54 /*********************************************************************
55 * __CxxFrameHandler (MSVCRT.@)
57 EXCEPTION_DISPOSITION CDECL __CxxFrameHandler(EXCEPTION_RECORD *rec, ULONG64 frame, CONTEXT *context,
58 DISPATCHER_CONTEXT *dispatch)
60 FIXME("%p %I64x %p %p: not implemented\n", rec, frame, context, dispatch);
61 return ExceptionContinueSearch;
65 /*********************************************************************
66 * __CppXcptFilter (MSVCRT.@)
68 int CDECL __CppXcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
70 /* only filter c++ exceptions */
71 if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH;
72 return _XcptFilter(ex, ptr);
76 /*********************************************************************
77 * __CxxDetectRethrow (MSVCRT.@)
79 BOOL CDECL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs)
81 PEXCEPTION_RECORD rec;
83 if (!ptrs)
84 return FALSE;
86 rec = ptrs->ExceptionRecord;
88 if (rec->ExceptionCode == CXX_EXCEPTION &&
89 rec->NumberParameters == 3 &&
90 rec->ExceptionInformation[0] == CXX_FRAME_MAGIC_VC6 &&
91 rec->ExceptionInformation[2])
93 ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record;
94 return TRUE;
96 return (msvcrt_get_thread_data()->exc_record == rec);
100 /*********************************************************************
101 * __CxxQueryExceptionSize (MSVCRT.@)
103 unsigned int CDECL __CxxQueryExceptionSize(void)
105 return sizeof(cxx_exception_type);
109 /*******************************************************************
110 * _setjmp (MSVCRT.@)
112 __ASM_GLOBAL_FUNC(MSVCRT__setjmp,
113 "b " __ASM_NAME("__wine_setjmpex"));
115 /*******************************************************************
116 * longjmp (MSVCRT.@)
118 void __cdecl MSVCRT_longjmp(_JUMP_BUFFER *jmp, int retval)
120 EXCEPTION_RECORD rec;
122 if (!retval) retval = 1;
123 if (jmp->Frame)
125 rec.ExceptionCode = STATUS_LONGJUMP;
126 rec.ExceptionFlags = 0;
127 rec.ExceptionRecord = NULL;
128 rec.ExceptionAddress = NULL;
129 rec.NumberParameters = 1;
130 rec.ExceptionInformation[0] = (DWORD_PTR)jmp;
131 RtlUnwind((void *)jmp->Frame, (void *)jmp->Lr, &rec, IntToPtr(retval));
133 __wine_longjmp( (__wine_jmp_buf *)jmp, retval );
136 /*********************************************************************
137 * _fpieee_flt (MSVCRT.@)
139 int __cdecl _fpieee_flt(__msvcrt_ulong exception_code, EXCEPTION_POINTERS *ep,
140 int (__cdecl *handler)(_FPIEEE_RECORD*))
142 FIXME("(%lx %p %p)\n", exception_code, ep, handler);
143 return EXCEPTION_CONTINUE_SEARCH;
146 #endif /* __aarch64__ */