secur32: Remove some unused variables.
[wine] / dlls / msvcp90 / msvcp90.h
1 /*
2  * Copyright 2010 Piotr Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "stdlib.h"
20 #include "windef.h"
21
22 typedef unsigned char MSVCP_bool;
23 typedef SIZE_T MSVCP_size_t;
24 typedef SIZE_T streamoff;
25 typedef SIZE_T streamsize;
26
27 void __cdecl _invalid_parameter(const wchar_t*, const wchar_t*,
28         const wchar_t*, unsigned int, uintptr_t);
29
30 extern void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
31 extern void (__cdecl *MSVCRT_operator_delete)(void*);
32 extern void* (__cdecl *MSVCRT_set_new_handler)(void*);
33
34 /* Copied from dlls/msvcrt/cpp.c */
35 #ifdef __i386__  /* thiscall functions are i386-specific */
36
37 #define THISCALL(func) __thiscall_ ## func
38 #define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
39 #define __thiscall __stdcall
40 #define DEFINE_THISCALL_WRAPPER(func,args) \
41     extern void THISCALL(func)(void); \
42     __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
43                       "popl %eax\n\t" \
44                       "pushl %ecx\n\t" \
45                       "pushl %eax\n\t" \
46                       "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
47 #else /* __i386__ */
48
49 #define THISCALL(func) func
50 #define THISCALL_NAME(func) __ASM_NAME(#func)
51 #define __thiscall __cdecl
52 #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
53
54 #endif /* __i386__ */
55
56 #ifdef _WIN64
57
58 #define VTABLE_ADD_FUNC(name) "\t.quad " THISCALL_NAME(name) "\n"
59
60 #define __ASM_VTABLE(name,funcs) \
61     __asm__(".data\n" \
62             "\t.align 8\n" \
63             "\t.quad " __ASM_NAME(#name "_rtti") "\n" \
64             "\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
65             __ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
66             "\t.quad " THISCALL_NAME(MSVCP_ ## name ## _vector_dtor) "\n" \
67             funcs "\n\t.text")
68
69 #else
70
71 #define VTABLE_ADD_FUNC(name) "\t.long " THISCALL_NAME(name) "\n"
72
73 #define __ASM_VTABLE(name,funcs) \
74     __asm__(".data\n" \
75             "\t.align 4\n" \
76             "\t.long " __ASM_NAME(#name "_rtti") "\n" \
77             "\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
78             __ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
79             "\t.long " THISCALL_NAME(MSVCP_ ## name ## _vector_dtor) "\n" \
80             funcs "\n\t.text")
81
82 #endif /* _WIN64 */
83
84 #define DEFINE_RTTI_DATA(name, off, base_classes, cl1, cl2, cl3, mangled_name) \
85 static const type_info name ## _type_info = { \
86     &MSVCP_type_info_vtable, \
87     NULL, \
88     mangled_name \
89 }; \
90 \
91 static const rtti_base_descriptor name ## _rtti_base_descriptor = { \
92     &name ##_type_info, \
93     base_classes, \
94     { 0, -1, 0}, \
95     64 \
96 }; \
97 \
98 static const rtti_base_array name ## _rtti_base_array = { \
99     { \
100         &name ## _rtti_base_descriptor, \
101         cl1, \
102         cl2, \
103         cl3 \
104     } \
105 }; \
106 \
107 static const rtti_object_hierarchy name ## _hierarchy = { \
108     0, \
109     0, \
110     base_classes+1, \
111     &name ## _rtti_base_array \
112 }; \
113 \
114 const rtti_object_locator name ## _rtti = { \
115     0, \
116     off, \
117     0, \
118     &name ## _type_info, \
119     &name ## _hierarchy \
120 }
121
122 #ifdef __i386__
123
124 #define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (WINAPI*)type)&vtbl_wrapper_##off)args
125
126 extern void *vtbl_wrapper_0;
127 extern void *vtbl_wrapper_4;
128 extern void *vtbl_wrapper_8;
129 extern void *vtbl_wrapper_12;
130 extern void *vtbl_wrapper_16;
131 extern void *vtbl_wrapper_20;
132 extern void *vtbl_wrapper_24;
133 extern void *vtbl_wrapper_28;
134 extern void *vtbl_wrapper_32;
135 extern void *vtbl_wrapper_36;
136 extern void *vtbl_wrapper_40;
137 extern void *vtbl_wrapper_44;
138 extern void *vtbl_wrapper_48;
139 extern void *vtbl_wrapper_52;
140 extern void *vtbl_wrapper_56;
141 extern void *vtbl_wrapper_60;
142
143 #else
144
145 #define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (__cdecl***)type)this)[0][off/4]args
146
147 #endif
148
149 /* exception object */
150 typedef void (*vtable_ptr)(void);
151 typedef struct __exception
152 {
153     const vtable_ptr *vtable;
154     char             *name;    /* Name of this exception, always a new copy for each object */
155     int               do_free; /* Whether to free 'name' in our dtor */
156 } exception;
157
158 /* Internal: throws selected exception */
159 typedef enum __exception_type {
160     EXCEPTION_RERAISE,
161     EXCEPTION,
162     EXCEPTION_BAD_ALLOC,
163     EXCEPTION_LOGIC_ERROR,
164     EXCEPTION_LENGTH_ERROR,
165     EXCEPTION_OUT_OF_RANGE,
166     EXCEPTION_INVALID_ARGUMENT,
167     EXCEPTION_RUNTIME_ERROR,
168     EXCEPTION_FAILURE,
169 } exception_type;
170 void throw_exception(exception_type, const char *);
171
172 /* rtti */
173 typedef struct __type_info
174 {
175     const vtable_ptr *vtable;
176     char              *name;         /* Unmangled name, allocated lazily */
177     char               mangled[128]; /* Variable length, but we declare it large enough for static RTTI */
178 } type_info;
179
180 extern const vtable_ptr MSVCP_type_info_vtable;
181
182 /* offsets for computing the this pointer */
183 typedef struct
184 {
185     int         this_offset;   /* offset of base class this pointer from start of object */
186     int         vbase_descr;   /* offset of virtual base class descriptor */
187     int         vbase_offset;  /* offset of this pointer offset in virtual base class descriptor */
188 } this_ptr_offsets;
189
190 typedef struct _rtti_base_descriptor
191 {
192     const type_info *type_descriptor;
193     int num_base_classes;
194     this_ptr_offsets offsets;    /* offsets for computing the this pointer */
195     unsigned int attributes;
196 } rtti_base_descriptor;
197
198 typedef struct _rtti_base_array
199 {
200     const rtti_base_descriptor *bases[4]; /* First element is the class itself */
201 } rtti_base_array;
202
203 typedef struct _rtti_object_hierarchy
204 {
205     unsigned int signature;
206     unsigned int attributes;
207     int array_len; /* Size of the array pointed to by 'base_classes' */
208     const rtti_base_array *base_classes;
209 } rtti_object_hierarchy;
210
211 typedef struct _rtti_object_locator
212 {
213     unsigned int signature;
214     int base_class_offset;
215     unsigned int flags;
216     const type_info *type_descriptor;
217     const rtti_object_hierarchy *type_hierarchy;
218 } rtti_object_locator;
219
220 /* basic_string<char, char_traits<char>, allocator<char>> */
221 #define BUF_SIZE_CHAR 16
222 typedef struct _basic_string_char
223 {
224     void *allocator;
225     union {
226         char buf[BUF_SIZE_CHAR];
227         char *ptr;
228     } data;
229     MSVCP_size_t size;
230     MSVCP_size_t res;
231 } basic_string_char;
232
233 basic_string_char* __stdcall MSVCP_basic_string_char_ctor_cstr(basic_string_char*, const char*);
234 basic_string_char* __stdcall MSVCP_basic_string_char_copy_ctor(basic_string_char*, const basic_string_char*);
235 void __stdcall MSVCP_basic_string_char_dtor(basic_string_char*);
236 const char* __stdcall MSVCP_basic_string_char_c_str(const basic_string_char*);
237
238 #define BUF_SIZE_WCHAR 8
239 typedef struct _basic_string_wchar
240 {
241     void *allocator;
242     union {
243         wchar_t buf[BUF_SIZE_WCHAR];
244         wchar_t *ptr;
245     } data;
246     MSVCP_size_t size;
247     MSVCP_size_t res;
248 } basic_string_wchar;
249
250 basic_string_wchar* __stdcall MSVCP_basic_string_wchar_ctor_cstr(basic_string_wchar*, const wchar_t*);
251
252 char* __stdcall MSVCP_allocator_char_allocate(void*, MSVCP_size_t);
253 void __stdcall MSVCP_allocator_char_deallocate(void*, char*, MSVCP_size_t);
254 MSVCP_size_t __stdcall MSVCP_allocator_char_max_size(void*);
255 wchar_t* __stdcall MSVCP_allocator_wchar_allocate(void*, MSVCP_size_t);
256 void __stdcall MSVCP_allocator_wchar_deallocate(void*, wchar_t*, MSVCP_size_t);
257 MSVCP_size_t __stdcall MSVCP_allocator_wchar_max_size(void*);
258
259 /* class locale */
260 typedef struct
261 {
262     struct _locale__Locimp *ptr;
263 } locale;
264
265 locale* __thiscall locale_ctor(locale*);
266 locale* __thiscall locale_copy_ctor(locale*, const locale*);
267 locale* __thiscall locale_operator_assign(locale*, const locale*);
268 void __thiscall locale_dtor(locale*);
269
270 /* class _Lockit */
271 typedef struct {
272     int locktype;
273 } _Lockit;
274
275 #define _LOCK_LOCALE 0
276 #define _LOCK_MALLOC 1
277 #define _LOCK_STREAM 2
278 #define _LOCK_DEBUG 3
279 #define _MAX_LOCK 4
280
281 void init_lockit(void);
282 void free_lockit(void);
283 _Lockit* __thiscall _Lockit_ctor_locktype(_Lockit*, int);
284 void __thiscall _Lockit_dtor(_Lockit*);
285
286 /* class mutex */
287 typedef struct {
288         void *mutex;
289 } mutex;
290
291 mutex* __thiscall mutex_ctor(mutex*);
292 void __thiscall mutex_dtor(mutex*);
293 void __thiscall mutex_lock(mutex*);
294 void __thiscall mutex_unlock(mutex*);