schedsvc: Print an error if the service couldn't start monitoring the tasks directory.
[wine.git] / dlls / msvcrt / cppexcept.h
blob2091889066d1ff62076bbd235370f67599df0936
1 /*
2 * msvcrt C++ exception handling
4 * Copyright 2002 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __MSVCRT_CPPEXCEPT_H
22 #define __MSVCRT_CPPEXCEPT_H
24 #define CXX_FRAME_MAGIC_VC6 0x19930520
25 #define CXX_FRAME_MAGIC_VC7 0x19930521
26 #define CXX_FRAME_MAGIC_VC8 0x19930522
27 #define CXX_EXCEPTION 0xe06d7363
29 #define FUNC_DESCR_SYNCHRONOUS 1 /* synchronous exceptions only (built with /EHs and /EHsc) */
31 typedef void (*vtable_ptr)(void);
33 /* type_info object, see cpp.c for implementation */
34 typedef struct __type_info
36 const vtable_ptr *vtable;
37 char *name; /* Unmangled name, allocated lazily */
38 char mangled[64]; /* Variable length, but we declare it large enough for static RTTI */
39 } type_info;
41 /* exception object */
42 typedef struct __exception
44 const vtable_ptr *vtable;
45 char *name; /* Name of this exception, always a new copy for each object */
46 BOOL do_free; /* Whether to free 'name' in our dtor */
47 } exception;
49 typedef void (*cxx_copy_ctor)(void);
51 /* offsets for computing the this pointer */
52 typedef struct
54 int this_offset; /* offset of base class this pointer from start of object */
55 int vbase_descr; /* offset of virtual base class descriptor */
56 int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */
57 } this_ptr_offsets;
59 /* complete information about a C++ type */
60 #ifndef __x86_64__
61 typedef struct __cxx_type_info
63 UINT flags; /* flags (see CLASS_* flags below) */
64 const type_info *type_info; /* C++ type info */
65 this_ptr_offsets offsets; /* offsets for computing the this pointer */
66 unsigned int size; /* object size */
67 cxx_copy_ctor copy_ctor; /* copy constructor */
68 } cxx_type_info;
69 #else
70 typedef struct __cxx_type_info
72 UINT flags;
73 unsigned int type_info;
74 this_ptr_offsets offsets;
75 unsigned int size;
76 unsigned int copy_ctor;
77 } cxx_type_info;
78 #endif
80 #define CLASS_IS_SIMPLE_TYPE 1
81 #define CLASS_HAS_VIRTUAL_BASE_CLASS 4
83 /* table of C++ types that apply for a given object */
84 #ifndef __x86_64__
85 typedef struct __cxx_type_info_table
87 UINT count; /* number of types */
88 const cxx_type_info *info[3]; /* variable length, we declare it large enough for static RTTI */
89 } cxx_type_info_table;
90 #else
91 typedef struct __cxx_type_info_table
93 UINT count;
94 unsigned int info[3];
95 } cxx_type_info_table;
96 #endif
98 struct __cxx_exception_frame;
99 struct __cxx_function_descr;
101 typedef DWORD (*cxx_exc_custom_handler)( PEXCEPTION_RECORD, struct __cxx_exception_frame*,
102 PCONTEXT, EXCEPTION_REGISTRATION_RECORD**,
103 const struct __cxx_function_descr*, int nested_trylevel,
104 EXCEPTION_REGISTRATION_RECORD *nested_frame, DWORD unknown3 );
106 /* type information for an exception object */
107 #ifndef __x86_64__
108 typedef struct __cxx_exception_type
110 UINT flags; /* TYPE_FLAG flags */
111 void (*destructor)(void);/* exception object destructor */
112 cxx_exc_custom_handler custom_handler; /* custom handler for this exception */
113 const cxx_type_info_table *type_info_table; /* list of types for this exception object */
114 } cxx_exception_type;
115 #else
116 typedef struct
118 UINT flags;
119 unsigned int destructor;
120 unsigned int custom_handler;
121 unsigned int type_info_table;
122 } cxx_exception_type;
123 #endif
125 void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
126 int CDECL _XcptFilter(NTSTATUS, PEXCEPTION_POINTERS);
128 static inline const char *dbgstr_type_info( const type_info *info )
130 if (!info) return "{}";
131 return wine_dbg_sprintf( "{vtable=%p name=%s (%s)}",
132 info->vtable, info->mangled, info->name ? info->name : "" );
135 /* compute the this pointer for a base class of a given type */
136 static inline void *get_this_pointer( const this_ptr_offsets *off, void *object )
138 if (!object) return NULL;
140 if (off->vbase_descr >= 0)
142 int *offset_ptr;
144 /* move this ptr to vbase descriptor */
145 object = (char *)object + off->vbase_descr;
146 /* and fetch additional offset from vbase descriptor */
147 offset_ptr = (int *)(*(char **)object + off->vbase_offset);
148 object = (char *)object + *offset_ptr;
151 object = (char *)object + off->this_offset;
152 return object;
155 #ifndef __x86_64__
156 #define DEFINE_EXCEPTION_TYPE_INFO(type, base_no, cl1, cl2) \
158 static const cxx_type_info type ## _cxx_type_info = { \
159 0, \
160 & type ##_type_info, \
161 { 0, -1, 0 }, \
162 sizeof(type), \
163 (cxx_copy_ctor)THISCALL(MSVCRT_ ## type ##_copy_ctor) \
164 }; \
166 static const cxx_type_info_table type ## _type_info_table = { \
167 base_no+1, \
169 & type ## _cxx_type_info, \
170 cl1, \
171 cl2 \
173 }; \
175 static const cxx_exception_type type ## _exception_type = { \
176 0, \
177 (cxx_copy_ctor)THISCALL(MSVCRT_ ## type ## _dtor), \
178 NULL, \
179 & type ## _type_info_table \
182 #else
184 #define DEFINE_EXCEPTION_TYPE_INFO(type, base_no, cl1, cl2) \
186 static cxx_type_info type ## _cxx_type_info = { \
187 0, \
188 0xdeadbeef, \
189 { 0, -1, 0 }, \
190 sizeof(type), \
191 0xdeadbeef \
192 }; \
194 static cxx_type_info_table type ## _type_info_table = { \
195 base_no+1, \
197 0xdeadbeef, \
198 0xdeadbeef, \
199 0xdeadbeef \
201 }; \
203 static cxx_exception_type type ##_exception_type = { \
204 0, \
205 0xdeadbeef, \
206 0, \
207 0xdeadbeef \
208 }; \
210 static void init_ ## type ## _cxx(char *base) \
212 type ## _cxx_type_info.type_info = (char *)&type ## _type_info - base; \
213 type ## _cxx_type_info.copy_ctor = (char *)MSVCRT_ ## type ## _copy_ctor - base; \
214 type ## _type_info_table.info[0] = (char *)&type ## _cxx_type_info - base; \
215 type ## _type_info_table.info[1] = (char *)cl1 - base; \
216 type ## _type_info_table.info[2] = (char *)cl2 - base; \
217 type ## _exception_type.destructor = (char *)MSVCRT_ ## type ## _dtor - base; \
218 type ## _exception_type.type_info_table = (char *)&type ## _type_info_table - base; \
220 #endif
222 #endif /* __MSVCRT_CPPEXCEPT_H */