xref: /reactos/sdk/lib/crt/wine/except_arm.c (revision 3435c3b5)
1 /*
2  * msvcrt C++ exception handling
3  *
4  * Copyright 2011 Alexandre Julliard
5  * Copyright 2013 André Hentschel
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21 
22 #include "config.h"
23 #include "wine/port.h"
24 
25 #ifdef __arm__
26 
27 #include <stdarg.h>
28 
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"
38 
39 #include "cppexcept.h"
40 
41 WINE_DEFAULT_DEBUG_CHANNEL(seh);
42 
43 
44 /*********************************************************************
45  *		__CxxExceptionFilter (MSVCRT.@)
46  */
47 int CDECL __CxxExceptionFilter( PEXCEPTION_POINTERS ptrs,
48                                 const type_info *ti, int flags, void **copy )
49 {
50     FIXME( "%p %p %x %p: not implemented\n", ptrs, ti, flags, copy );
51     return EXCEPTION_CONTINUE_SEARCH;
52 }
53 
54 /*********************************************************************
55  *		__CxxFrameHandler (MSVCRT.@)
56  */
57 EXCEPTION_DISPOSITION CDECL __CxxFrameHandler(EXCEPTION_RECORD *rec, DWORD frame, CONTEXT *context,
58                                               DISPATCHER_CONTEXT *dispatch)
59 {
60     FIXME("%p %x %p %p: not implemented\n", rec, frame, context, dispatch);
61     return ExceptionContinueSearch;
62 }
63 
64 
65 /*********************************************************************
66  *		__CppXcptFilter (MSVCRT.@)
67  */
68 int CDECL __CppXcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
69 {
70     /* only filter c++ exceptions */
71     if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH;
72     return _XcptFilter(ex, ptr);
73 }
74 
75 
76 /*********************************************************************
77  *		__CxxDetectRethrow (MSVCRT.@)
78  */
79 BOOL CDECL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs)
80 {
81     PEXCEPTION_RECORD rec;
82 
83     if (!ptrs)
84         return FALSE;
85 
86     rec = ptrs->ExceptionRecord;
87 
88     if (rec->ExceptionCode == CXX_EXCEPTION &&
89         rec->NumberParameters == 3 &&
90         rec->ExceptionInformation[0] == CXX_FRAME_MAGIC_VC6 &&
91         rec->ExceptionInformation[2])
92     {
93         ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record;
94         return TRUE;
95     }
96     return (msvcrt_get_thread_data()->exc_record == rec);
97 }
98 
99 
100 /*********************************************************************
101  *		__CxxQueryExceptionSize (MSVCRT.@)
102  */
103 unsigned int CDECL __CxxQueryExceptionSize(void)
104 {
105     return sizeof(cxx_exception_type);
106 }
107 
108 
109 /*******************************************************************
110  *		_setjmp (MSVCRT.@)
111  */
112 __ASM_GLOBAL_FUNC(MSVCRT__setjmp,
113                   "mov r1, #0\n\t"  /* frame */
114                   "b " __ASM_NAME("__wine_setjmpex"));
115 
116 /*******************************************************************
117  *		longjmp (MSVCRT.@)
118  */
119 void __cdecl MSVCRT_longjmp(struct MSVCRT___JUMP_BUFFER *jmp, int retval)
120 {
121     EXCEPTION_RECORD rec;
122 
123     if (!retval) retval = 1;
124     if (jmp->Frame)
125     {
126         rec.ExceptionCode = STATUS_LONGJUMP;
127         rec.ExceptionFlags = 0;
128         rec.ExceptionRecord = NULL;
129         rec.ExceptionAddress = NULL;
130         rec.NumberParameters = 1;
131         rec.ExceptionInformation[0] = (DWORD_PTR)jmp;
132         RtlUnwind((void *)jmp->Frame, (void *)jmp->Pc, &rec, IntToPtr(retval));
133     }
134     __wine_longjmp( (__wine_jmp_buf *)jmp, retval );
135 }
136 
137 /*********************************************************************
138  *              _fpieee_flt (MSVCRT.@)
139  */
140 int __cdecl _fpieee_flt(ULONG exception_code, EXCEPTION_POINTERS *ep,
141         int (__cdecl *handler)(_FPIEEE_RECORD*))
142 {
143     FIXME("(%x %p %p)\n", exception_code, ep, handler);
144     return EXCEPTION_CONTINUE_SEARCH;
145 }
146 
147 #endif  /* __arm__ */
148