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, \
30 "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
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 */
42 #define VTABLE_ADD_FUNC(name) "\t.quad " THISCALL_NAME(name) "\n"
44 #define __ASM_VTABLE(name,funcs) \
47 "\t.quad " __ASM_NAME(#name "_rtti") "\n" \
48 "\t.globl " __ASM_NAME("MSVCRT_" #name "_vtable") "\n" \
49 __ASM_NAME("MSVCRT_" #name "_vtable") ":\n" \
54 #define VTABLE_ADD_FUNC(name) "\t.long " THISCALL_NAME(name) "\n"
56 #define __ASM_VTABLE(name,funcs) \
59 "\t.long " __ASM_NAME(#name "_rtti") "\n" \
60 "\t.globl " __ASM_NAME("MSVCRT_" #name "_vtable") "\n" \
61 __ASM_NAME("MSVCRT_" #name "_vtable") ":\n" \
66 #define DEFINE_RTTI_DATA(name, off, base_classes, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
67 static const type_info name ## _type_info = { \
68 &MSVCRT_type_info_vtable, \
73 static const rtti_base_descriptor name ## _rtti_base_descriptor = { \
80 static const rtti_base_array name ## _rtti_base_array = { \
82 &name ## _rtti_base_descriptor, \
95 static const rtti_object_hierarchy name ## _hierarchy = { \
99 &name ## _rtti_base_array \
102 const rtti_object_locator name ## _rtti = { \
106 &name ## _type_info, \
107 &name ## _hierarchy \
110 #define DEFINE_RTTI_DATA0(name, off, mangled_name) \
111 DEFINE_RTTI_DATA(name, off, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
112 #define DEFINE_RTTI_DATA1(name, off, cl1, mangled_name) \
113 DEFINE_RTTI_DATA(name, off, 1, cl1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
114 #define DEFINE_RTTI_DATA2(name, off, cl1, cl2, mangled_name) \
115 DEFINE_RTTI_DATA(name, off, 2, cl1, cl2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
116 #define DEFINE_RTTI_DATA3(name, off, cl1, cl2, cl3, mangled_name) \
117 DEFINE_RTTI_DATA(name, off, 3, cl1, cl2, cl3, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
118 #define DEFINE_RTTI_DATA4(name, off, cl1, cl2, cl3, cl4, mangled_name) \
119 DEFINE_RTTI_DATA(name, off, 4, cl1, cl2, cl3, cl4, NULL, NULL, NULL, NULL, NULL, mangled_name)
120 #define DEFINE_RTTI_DATA8(name, off, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, mangled_name) \
121 DEFINE_RTTI_DATA(name, off, 8, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, NULL, mangled_name)
122 #define DEFINE_RTTI_DATA9(name, off, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
123 DEFINE_RTTI_DATA(name, off, 9, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name)
126 typedef struct _rtti_base_descriptor
128 const type_info *type_descriptor;
129 int num_base_classes;
130 this_ptr_offsets offsets; /* offsets for computing the this pointer */
131 unsigned int attributes;
132 } rtti_base_descriptor;
134 typedef struct _rtti_base_array
136 const rtti_base_descriptor *bases[10]; /* First element is the class itself */
139 typedef struct _rtti_object_hierarchy
141 unsigned int signature;
142 unsigned int attributes;
143 int array_len; /* Size of the array pointed to by 'base_classes' */
144 const rtti_base_array *base_classes;
145 } rtti_object_hierarchy;
147 typedef struct _rtti_object_locator
149 unsigned int signature;
150 int base_class_offset;
152 const type_info *type_descriptor;
153 const rtti_object_hierarchy *type_hierarchy;
154 } rtti_object_locator;