2 * Copyright 2010 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
22 typedef unsigned char MSVCP_bool;
23 typedef int MSVCP_long;
24 typedef SIZE_T MSVCP_size_t;
26 void __cdecl _invalid_parameter(const wchar_t*, const wchar_t*,
27 const wchar_t*, unsigned int, uintptr_t);
29 extern void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
30 extern void (__cdecl *MSVCRT_operator_delete)(void*);
32 /* Copied from dlls/msvcrt/cpp.c */
33 #ifdef __i386__ /* thiscall functions are i386-specific */
35 #define THISCALL(func) __thiscall_ ## func
36 #define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
37 #define __thiscall __stdcall
38 #define DEFINE_THISCALL_WRAPPER(func,args) \
39 extern void THISCALL(func)(void); \
40 __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
44 "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
46 #define DEFINE_THISCALL_WRAPPER_RETPTR(func,args) \
47 extern void THISCALL(func)(void); \
48 __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
54 "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
57 #define THISCALL(func) func
58 #define THISCALL_NAME(func) __ASM_NAME(#func)
59 #define __thiscall __cdecl
60 #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
61 #define DEFINE_THISCALL_WRAPPER_RETPTR(func,args) /* nothing */
67 #define __ASM_VTABLE(name,funcs) \
70 "\t.quad " __ASM_NAME(#name "_rtti") "\n" \
71 "\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
72 __ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
73 "\t.quad " THISCALL_NAME(MSVCP_ ## name ## _vector_dtor) "\n" \
78 #define __ASM_VTABLE(name,funcs) \
81 "\t.long " __ASM_NAME(#name "_rtti") "\n" \
82 "\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
83 __ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
84 "\t.long " THISCALL_NAME(MSVCP_ ## name ## _vector_dtor) "\n" \
89 /* exception object */
90 typedef void (*vtable_ptr)(void);
91 typedef struct __exception
93 const vtable_ptr *vtable;
94 char *name; /* Name of this exception, always a new copy for each object */
95 int do_free; /* Whether to free 'name' in our dtor */
98 /* Internal: throws selected exception */
99 typedef enum __exception_type {
102 EXCEPTION_LOGIC_ERROR,
103 EXCEPTION_LENGTH_ERROR,
104 EXCEPTION_OUT_OF_RANGE,
105 EXCEPTION_INVALID_ARGUMENT
107 void throw_exception(exception_type, const char *);
108 void set_exception_vtable(void);
111 typedef struct __type_info
113 const vtable_ptr *vtable;
114 char *name; /* Unmangled name, allocated lazily */
115 char mangled[64]; /* Variable length, but we declare it large enough for static RTTI */
118 /* offsets for computing the this pointer */
121 int this_offset; /* offset of base class this pointer from start of object */
122 int vbase_descr; /* offset of virtual base class descriptor */
123 int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */
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[3]; /* 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;
156 /* basic_string<char, char_traits<char>, allocator<char>> */
157 #define BUF_SIZE_CHAR 16
158 typedef struct _basic_string_char
162 char buf[BUF_SIZE_CHAR];
169 basic_string_char* __stdcall MSVCP_basic_string_char_ctor_cstr(basic_string_char*, const char*);
170 basic_string_char* __stdcall MSVCP_basic_string_char_copy_ctor(basic_string_char*, const basic_string_char*);
171 void __stdcall MSVCP_basic_string_char_dtor(basic_string_char*);
172 const char* __stdcall MSVCP_basic_string_char_c_str(basic_string_char*);
174 #define BUF_SIZE_WCHAR 8
175 typedef struct _basic_string_wchar
179 wchar_t buf[BUF_SIZE_WCHAR];
184 } basic_string_wchar;
186 char* __stdcall MSVCP_allocator_char_allocate(void*, MSVCP_size_t);
187 void __stdcall MSVCP_allocator_char_deallocate(void*, char*, MSVCP_size_t);
188 wchar_t* __stdcall MSVCP_allocator_wchar_allocate(void*, MSVCP_size_t);
189 void __stdcall MSVCP_allocator_wchar_deallocate(void*, wchar_t*, MSVCP_size_t);
194 struct locale__Locimp *ptr;
202 void init_lockit(void);
203 void free_lockit(void);