po: Update German translation.
[wine.git] / dlls / msvcrt / except_arm.c
blob29ddb7b1b958b36e8e171f75255826e712931104
1 /*
2 * msvcrt C++ exception handling
4 * Copyright 2011 Alexandre Julliard
5 * Copyright 2013 André Hentschel
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.
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.
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
22 #include "config.h"
23 #include "wine/port.h"
25 #ifdef __arm__
27 #include <stdarg.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);
43 struct _DISPATCHER_CONTEXT;
45 typedef LONG (WINAPI *PC_LANGUAGE_EXCEPTION_HANDLER)(EXCEPTION_POINTERS *ptrs, DWORD frame);
46 typedef EXCEPTION_DISPOSITION (WINAPI *PEXCEPTION_ROUTINE)(EXCEPTION_RECORD *rec, DWORD frame,
47 CONTEXT *context,
48 struct _DISPATCHER_CONTEXT *dispatch);
50 typedef struct _DISPATCHER_CONTEXT
52 DWORD ControlPc;
53 DWORD ImageBase;
54 PRUNTIME_FUNCTION FunctionEntry;
55 DWORD EstablisherFrame;
56 DWORD TargetPc;
57 PCONTEXT ContextRecord;
58 PEXCEPTION_ROUTINE LanguageHandler;
59 PVOID HandlerData;
60 PUNWIND_HISTORY_TABLE HistoryTable;
61 DWORD ScopeIndex;
62 BOOLEAN ControlPcIsUnwound;
63 PBYTE NonVolatileRegisters;
64 DWORD VirtualVfpHead;
65 } DISPATCHER_CONTEXT;
67 /*********************************************************************
68 * __CxxExceptionFilter (MSVCRT.@)
70 int CDECL __CxxExceptionFilter( PEXCEPTION_POINTERS ptrs,
71 const type_info *ti, int flags, void **copy )
73 FIXME( "%p %p %x %p: not implemented\n", ptrs, ti, flags, copy );
74 return EXCEPTION_CONTINUE_SEARCH;
77 /*********************************************************************
78 * __CxxFrameHandler (MSVCRT.@)
80 EXCEPTION_DISPOSITION CDECL __CxxFrameHandler(EXCEPTION_RECORD *rec, DWORD frame, CONTEXT *context,
81 DISPATCHER_CONTEXT *dispatch)
83 FIXME("%p %x %p %p: not implemented\n", rec, frame, context, dispatch);
84 return ExceptionContinueSearch;
88 /*********************************************************************
89 * __CppXcptFilter (MSVCRT.@)
91 int CDECL __CppXcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
93 /* only filter c++ exceptions */
94 if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH;
95 return _XcptFilter(ex, ptr);
99 /*********************************************************************
100 * __CxxDetectRethrow (MSVCRT.@)
102 BOOL CDECL __CxxDetectRethrow(PEXCEPTION_POINTERS ptrs)
104 PEXCEPTION_RECORD rec;
106 if (!ptrs)
107 return FALSE;
109 rec = ptrs->ExceptionRecord;
111 if (rec->ExceptionCode == CXX_EXCEPTION &&
112 rec->NumberParameters == 3 &&
113 rec->ExceptionInformation[0] == CXX_FRAME_MAGIC_VC6 &&
114 rec->ExceptionInformation[2])
116 ptrs->ExceptionRecord = msvcrt_get_thread_data()->exc_record;
117 return TRUE;
119 return (msvcrt_get_thread_data()->exc_record == rec);
123 /*********************************************************************
124 * __CxxQueryExceptionSize (MSVCRT.@)
126 unsigned int CDECL __CxxQueryExceptionSize(void)
128 return sizeof(cxx_exception_type);
132 /*******************************************************************
133 * _setjmp (MSVCRT.@)
135 __ASM_GLOBAL_FUNC(MSVCRT__setjmp,
136 "mov r1, #0\n\t" /* frame */
137 "b " __ASM_NAME("MSVCRT__setjmpex"));
139 /*******************************************************************
140 * _setjmpex (MSVCRT.@)
142 __ASM_GLOBAL_FUNC(MSVCRT__setjmpex,
143 "str r1, [r0]\n\t" /* jmp_buf->Frame */
144 "str r4, [r0, #0x4]\n\t" /* jmp_buf->R4 */
145 "str r5, [r0, #0x8]\n\t" /* jmp_buf->R5 */
146 "str r6, [r0, #0xc]\n\t" /* jmp_buf->R6 */
147 "str r7, [r0, #0x10]\n\t" /* jmp_buf->R7 */
148 "str r8, [r0, #0x14]\n\t" /* jmp_buf->R8 */
149 "str r9, [r0, #0x18]\n\t" /* jmp_buf->R9 */
150 "str r10, [r0, #0x1c]\n\t" /* jmp_buf->R10 */
151 "str r11, [r0, #0x20]\n\t" /* jmp_buf->R11 */
152 "str sp, [r0, #0x24]\n\t" /* jmp_buf->Sp */
153 "str lr, [r0, #0x28]\n\t" /* jmp_buf->Pc */
154 /* FIXME: Save floating point data */
155 "mov r0, #0\n\t"
156 "bx lr");
159 extern void DECLSPEC_NORETURN CDECL longjmp_set_regs(struct MSVCRT___JUMP_BUFFER *jmp, int retval);
160 __ASM_GLOBAL_FUNC(longjmp_set_regs,
161 "ldr r4, [r0, #0x4]\n\t" /* jmp_buf->R4 */
162 "ldr r5, [r0, #0x8]\n\t" /* jmp_buf->R5 */
163 "ldr r6, [r0, #0xc]\n\t" /* jmp_buf->R6 */
164 "ldr r7, [r0, #0x10]\n\t" /* jmp_buf->R7 */
165 "ldr r8, [r0, #0x14]\n\t" /* jmp_buf->R8 */
166 "ldr r9, [r0, #0x18]\n\t" /* jmp_buf->R9 */
167 "ldr r10, [r0, #0x1c]\n\t" /* jmp_buf->R10 */
168 "ldr r11, [r0, #0x20]\n\t" /* jmp_buf->R11 */
169 "ldr sp, [r0, #0x24]\n\t" /* jmp_buf->Sp */
170 "ldr r2, [r0, #0x28]\n\t" /* jmp_buf->Pc */
171 /* FIXME: Restore floating point data */
172 "mov r0, r1\n\t" /* retval */
173 "bx r2");
175 /*******************************************************************
176 * longjmp (MSVCRT.@)
178 void __cdecl MSVCRT_longjmp(struct MSVCRT___JUMP_BUFFER *jmp, int retval)
180 EXCEPTION_RECORD rec;
182 if (!retval) retval = 1;
183 if (jmp->Frame)
185 rec.ExceptionCode = STATUS_LONGJUMP;
186 rec.ExceptionFlags = 0;
187 rec.ExceptionRecord = NULL;
188 rec.ExceptionAddress = NULL;
189 rec.NumberParameters = 1;
190 rec.ExceptionInformation[0] = (DWORD_PTR)jmp;
191 RtlUnwind((void *)jmp->Frame, (void *)jmp->Pc, &rec, IntToPtr(retval));
193 longjmp_set_regs(jmp, retval);
196 /*********************************************************************
197 * _fpieee_flt (MSVCRT.@)
199 int __cdecl _fpieee_flt(ULONG exception_code, EXCEPTION_POINTERS *ep,
200 int (__cdecl *handler)(_FPIEEE_RECORD*))
202 FIXME("(%x %p %p)\n", exception_code, ep, handler);
203 return EXCEPTION_CONTINUE_SEARCH;
206 #endif /* __arm__ */