wined3d: Rename WineD3D_ChoosePixelFormat() to context_choose_pixel_format().
[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 int MSVCP_long;
24 typedef SIZE_T MSVCP_size_t;
25
26 void __cdecl _invalid_parameter(const wchar_t*, const wchar_t*,
27         const wchar_t*, unsigned int, uintptr_t);
28
29 extern void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
30 extern void (__cdecl *MSVCRT_operator_delete)(void*);
31
32 /* Copied from dlls/msvcrt/cpp.c */
33 #ifdef __i386__  /* thiscall functions are i386-specific */
34
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, \
41                       "popl %eax\n\t" \
42                       "pushl %ecx\n\t" \
43                       "pushl %eax\n\t" \
44                       "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
45
46 #define DEFINE_THISCALL_WRAPPER_RETPTR(func,args) \
47     extern void THISCALL(func)(void); \
48     __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
49                       "popl %eax\n\t" \
50                       "popl %edx\n\t" \
51                       "pushl %ecx\n\t" \
52                       "pushl %edx\n\t" \
53                       "pushl %eax\n\t" \
54                       "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
55 #else /* __i386__ */
56
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 */
62
63 #endif /* __i386__ */
64
65 #ifdef _WIN64
66
67 #define __ASM_VTABLE(name,funcs) \
68     __asm__(".data\n" \
69             "\t.align 8\n" \
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" \
74             funcs "\n\t.text");
75
76 #else
77
78 #define __ASM_VTABLE(name,funcs) \
79     __asm__(".data\n" \
80             "\t.align 4\n" \
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" \
85             funcs "\n\t.text");
86
87 #endif /* _WIN64 */
88
89 /* exception object */
90 typedef void (*vtable_ptr)(void);
91 typedef struct __exception
92 {
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 */
96 } exception;
97
98 /* Internal: throws selected exception */
99 typedef enum __exception_type {
100     EXCEPTION,
101     EXCEPTION_BAD_ALLOC,
102     EXCEPTION_LOGIC_ERROR,
103     EXCEPTION_LENGTH_ERROR,
104     EXCEPTION_OUT_OF_RANGE,
105     EXCEPTION_INVALID_ARGUMENT
106 } exception_type;
107 void throw_exception(exception_type, const char *);
108 void set_exception_vtable(void);
109
110 /* rtti */
111 typedef struct __type_info
112 {
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 */
116 } type_info;
117
118 /* offsets for computing the this pointer */
119 typedef struct
120 {
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 */
124 } this_ptr_offsets;
125
126 typedef struct _rtti_base_descriptor
127 {
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;
133
134 typedef struct _rtti_base_array
135 {
136     const rtti_base_descriptor *bases[3]; /* First element is the class itself */
137 } rtti_base_array;
138
139 typedef struct _rtti_object_hierarchy
140 {
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;
146
147 typedef struct _rtti_object_locator
148 {
149     unsigned int signature;
150     int base_class_offset;
151     unsigned int flags;
152     const type_info *type_descriptor;
153     const rtti_object_hierarchy *type_hierarchy;
154 } rtti_object_locator;
155
156 /* basic_string<char, char_traits<char>, allocator<char>> */
157 #define BUF_SIZE_CHAR 16
158 typedef struct _basic_string_char
159 {
160     void *allocator;
161     union {
162         char buf[BUF_SIZE_CHAR];
163         char *ptr;
164     } data;
165     MSVCP_size_t size;
166     MSVCP_size_t res;
167 } basic_string_char;
168
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*);
173
174 #define BUF_SIZE_WCHAR 8
175 typedef struct _basic_string_wchar
176 {
177     void *allocator;
178     union {
179         wchar_t buf[BUF_SIZE_WCHAR];
180         wchar_t *ptr;
181     } data;
182     MSVCP_size_t size;
183     MSVCP_size_t res;
184 } basic_string_wchar;
185
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);
190
191 /* class locale */
192 typedef struct
193 {
194     struct locale__Locimp *ptr;
195 } locale;
196
197 /* class _Lockit */
198 typedef struct {
199     int locktype;
200 } _Lockit;
201
202 void init_lockit(void);
203 void free_lockit(void);