msi: Check transform validation flags.
[wine/multimedia.git] / dlls / msvcrt / cxx.h
blobe649f0317de442cfa28ae7c99660b7a2b087daa1
1 /*
2 * Copyright 2012 Piotr Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifdef __i386__ /* thiscall functions are i386-specific */
21 #define THISCALL(func) __thiscall_ ## func
22 #define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
23 #define __thiscall __stdcall
24 #define DEFINE_THISCALL_WRAPPER(func,args) \
25 extern void THISCALL(func)(void); \
26 __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
27 "popl %eax\n\t" \
28 "pushl %ecx\n\t" \
29 "pushl %eax\n\t" \
30 "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
31 #else /* __i386__ */
33 #define THISCALL(func) func
34 #define THISCALL_NAME(func) __ASM_NAME(#func)
35 #define __thiscall __cdecl
36 #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
38 #endif /* __i386__ */
40 #ifdef _WIN64
42 #define VTABLE_ADD_FUNC(name) "\t.quad " THISCALL_NAME(name) "\n"
44 #define __ASM_VTABLE(name,funcs) \
45 __asm__(".data\n" \
46 "\t.align 8\n" \
47 "\t.quad " __ASM_NAME(#name "_rtti") "\n" \
48 "\t.globl " __ASM_NAME("MSVCRT_" #name "_vtable") "\n" \
49 __ASM_NAME("MSVCRT_" #name "_vtable") ":\n" \
50 funcs "\n\t.text")
52 #else
54 #define VTABLE_ADD_FUNC(name) "\t.long " THISCALL_NAME(name) "\n"
56 #define __ASM_VTABLE(name,funcs) \
57 __asm__(".data\n" \
58 "\t.align 4\n" \
59 "\t.long " __ASM_NAME(#name "_rtti") "\n" \
60 "\t.globl " __ASM_NAME("MSVCRT_" #name "_vtable") "\n" \
61 __ASM_NAME("MSVCRT_" #name "_vtable") ":\n" \
62 funcs "\n\t.text")
64 #endif /* _WIN64 */
66 #ifndef __x86_64__
68 #define DEFINE_RTTI_DATA(name, off, base_classes_no, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
69 static const type_info name ## _type_info = { \
70 &MSVCRT_type_info_vtable, \
71 NULL, \
72 mangled_name \
73 }; \
75 static const rtti_base_descriptor name ## _rtti_base_descriptor = { \
76 &name ##_type_info, \
77 base_classes_no, \
78 { 0, -1, 0}, \
79 64 \
80 }; \
82 static const rtti_base_array name ## _rtti_base_array = { \
83 { \
84 &name ## _rtti_base_descriptor, \
85 cl1, \
86 cl2, \
87 cl3, \
88 cl4, \
89 cl5, \
90 cl6, \
91 cl7, \
92 cl8, \
93 cl9, \
94 } \
95 }; \
97 static const rtti_object_hierarchy name ## _hierarchy = { \
98 0, \
99 0, \
100 base_classes_no+1, \
101 &name ## _rtti_base_array \
102 }; \
104 const rtti_object_locator name ## _rtti = { \
105 0, \
106 off, \
107 0, \
108 &name ## _type_info, \
109 &name ## _hierarchy \
112 #else
114 #define DEFINE_RTTI_DATA(name, off, base_classes_no, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
115 static const type_info name ## _type_info = { \
116 &MSVCRT_type_info_vtable, \
117 NULL, \
118 mangled_name \
119 }; \
121 static rtti_base_descriptor name ## _rtti_base_descriptor = { \
122 0xdeadbeef, \
123 base_classes_no, \
124 { 0, -1, 0}, \
125 64 \
126 }; \
128 static rtti_base_array name ## _rtti_base_array = { \
130 0xdeadbeef, \
131 0xdeadbeef, \
132 0xdeadbeef, \
133 0xdeadbeef, \
134 0xdeadbeef, \
135 0xdeadbeef, \
136 0xdeadbeef, \
137 0xdeadbeef, \
138 0xdeadbeef, \
139 0xdeadbeef, \
141 }; \
143 static rtti_object_hierarchy name ## _hierarchy = { \
144 0, \
145 0, \
146 base_classes_no+1, \
147 0xdeadbeef \
148 }; \
150 rtti_object_locator name ## _rtti = { \
151 1, \
152 off, \
153 0, \
154 0xdeadbeef, \
155 0xdeadbeef, \
156 0xdeadbeef \
159 static void init_ ## name ## _rtti(char *base) \
161 name ## _rtti_base_descriptor.type_descriptor = (char*)&name ## _type_info - base; \
162 name ## _rtti_base_array.bases[0] = (char*)&name ## _rtti_base_descriptor - base; \
163 name ## _rtti_base_array.bases[1] = (char*)cl1 - base; \
164 name ## _rtti_base_array.bases[2] = (char*)cl2 - base; \
165 name ## _rtti_base_array.bases[3] = (char*)cl3 - base; \
166 name ## _rtti_base_array.bases[4] = (char*)cl4 - base; \
167 name ## _rtti_base_array.bases[5] = (char*)cl5 - base; \
168 name ## _rtti_base_array.bases[6] = (char*)cl6 - base; \
169 name ## _rtti_base_array.bases[7] = (char*)cl7 - base; \
170 name ## _rtti_base_array.bases[8] = (char*)cl8 - base; \
171 name ## _rtti_base_array.bases[9] = (char*)cl9 - base; \
172 name ## _hierarchy.base_classes = (char*)&name ## _rtti_base_array - base; \
173 name ## _rtti.type_descriptor = (char*)&name ## _type_info - base; \
174 name ## _rtti.type_hierarchy = (char*)&name ## _hierarchy - base; \
175 name ## _rtti.object_locator = (char*)&name ## _rtti - base; \
178 #endif
180 #define DEFINE_RTTI_DATA0(name, off, mangled_name) \
181 DEFINE_RTTI_DATA(name, off, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
182 #define DEFINE_RTTI_DATA1(name, off, cl1, mangled_name) \
183 DEFINE_RTTI_DATA(name, off, 1, cl1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
184 #define DEFINE_RTTI_DATA2(name, off, cl1, cl2, mangled_name) \
185 DEFINE_RTTI_DATA(name, off, 2, cl1, cl2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
186 #define DEFINE_RTTI_DATA3(name, off, cl1, cl2, cl3, mangled_name) \
187 DEFINE_RTTI_DATA(name, off, 3, cl1, cl2, cl3, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
188 #define DEFINE_RTTI_DATA4(name, off, cl1, cl2, cl3, cl4, mangled_name) \
189 DEFINE_RTTI_DATA(name, off, 4, cl1, cl2, cl3, cl4, NULL, NULL, NULL, NULL, NULL, mangled_name)
190 #define DEFINE_RTTI_DATA8(name, off, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, mangled_name) \
191 DEFINE_RTTI_DATA(name, off, 8, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, NULL, mangled_name)
192 #define DEFINE_RTTI_DATA9(name, off, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
193 DEFINE_RTTI_DATA(name, off, 9, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name)
195 #ifndef __x86_64__
197 typedef struct _rtti_base_descriptor
199 const type_info *type_descriptor;
200 int num_base_classes;
201 this_ptr_offsets offsets; /* offsets for computing the this pointer */
202 unsigned int attributes;
203 } rtti_base_descriptor;
205 typedef struct _rtti_base_array
207 const rtti_base_descriptor *bases[10]; /* First element is the class itself */
208 } rtti_base_array;
210 typedef struct _rtti_object_hierarchy
212 unsigned int signature;
213 unsigned int attributes;
214 int array_len; /* Size of the array pointed to by 'base_classes' */
215 const rtti_base_array *base_classes;
216 } rtti_object_hierarchy;
218 typedef struct _rtti_object_locator
220 unsigned int signature;
221 int base_class_offset;
222 unsigned int flags;
223 const type_info *type_descriptor;
224 const rtti_object_hierarchy *type_hierarchy;
225 } rtti_object_locator;
227 #else
229 typedef struct
231 unsigned int type_descriptor;
232 int num_base_classes;
233 this_ptr_offsets offsets; /* offsets for computing the this pointer */
234 unsigned int attributes;
235 } rtti_base_descriptor;
237 typedef struct
239 unsigned int bases[10]; /* First element is the class itself */
240 } rtti_base_array;
242 typedef struct
244 unsigned int signature;
245 unsigned int attributes;
246 int array_len; /* Size of the array pointed to by 'base_classes' */
247 unsigned int base_classes;
248 } rtti_object_hierarchy;
250 typedef struct
252 unsigned int signature;
253 int base_class_offset;
254 unsigned int flags;
255 unsigned int type_descriptor;
256 unsigned int type_hierarchy;
257 unsigned int object_locator;
258 } rtti_object_locator;
260 #endif