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
28 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(msvcp
);
31 struct __Container_proxy
;
34 struct __Container_proxy
*proxy
;
37 typedef struct __Iterator_base12
{
38 struct __Container_proxy
*proxy
;
39 struct __Iterator_base12
*next
;
42 typedef struct __Container_proxy
{
43 const _Container_base12
*cont
;
44 _Iterator_base12
*head
;
47 /* ??0_Mutex@std@@QAE@XZ */
48 /* ??0_Mutex@std@@QEAA@XZ */
49 DEFINE_THISCALL_WRAPPER(mutex_ctor
, 4)
50 mutex
* __thiscall
mutex_ctor(mutex
*this)
52 CRITICAL_SECTION
*cs
= MSVCRT_operator_new(sizeof(*cs
));
54 ERR("Out of memory\n");
55 throw_exception(EXCEPTION_BAD_ALLOC
, NULL
);
58 InitializeCriticalSection(cs
);
59 cs
->DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": _Mutex critical section");
64 /* ??1_Mutex@std@@QAE@XZ */
65 /* ??1_Mutex@std@@QEAA@XZ */
66 DEFINE_THISCALL_WRAPPER(mutex_dtor
, 4)
67 void __thiscall
mutex_dtor(mutex
*this)
69 ((CRITICAL_SECTION
*)this->mutex
)->DebugInfo
->Spare
[0] = 0;
70 DeleteCriticalSection(this->mutex
);
71 MSVCRT_operator_delete(this->mutex
);
74 /* ?_Lock@_Mutex@std@@QAEXXZ */
75 /* ?_Lock@_Mutex@std@@QEAAXXZ */
76 DEFINE_THISCALL_WRAPPER(mutex_lock
, 4)
77 void __thiscall
mutex_lock(mutex
*this)
79 EnterCriticalSection(this->mutex
);
82 /* ?_Unlock@_Mutex@std@@QAEXXZ */
83 /* ?_Unlock@_Mutex@std@@QEAAXXZ */
84 DEFINE_THISCALL_WRAPPER(mutex_unlock
, 4)
85 void __thiscall
mutex_unlock(mutex
*this)
87 LeaveCriticalSection(this->mutex
);
90 /* ?_Mutex_Lock@_Mutex@std@@CAXPAV12@@Z */
91 /* ?_Mutex_Lock@_Mutex@std@@CAXPEAV12@@Z */
92 void CDECL
mutex_mutex_lock(mutex
*m
)
97 /* ?_Mutex_Unlock@_Mutex@std@@CAXPAV12@@Z */
98 /* ?_Mutex_Unlock@_Mutex@std@@CAXPEAV12@@Z */
99 void CDECL
mutex_mutex_unlock(mutex
*m
)
104 /* ?_Mutex_ctor@_Mutex@std@@CAXPAV12@@Z */
105 /* ?_Mutex_ctor@_Mutex@std@@CAXPEAV12@@Z */
106 void CDECL
mutex_mutex_ctor(mutex
*m
)
111 /* ?_Mutex_dtor@_Mutex@std@@CAXPAV12@@Z */
112 /* ?_Mutex_dtor@_Mutex@std@@CAXPEAV12@@Z */
113 void CDECL
mutex_mutex_dtor(mutex
*m
)
118 static CRITICAL_SECTION lockit_cs
[_MAX_LOCK
];
120 /* ?_Lockit_ctor@_Lockit@std@@SAXH@Z */
121 void __cdecl
_Lockit_init(int locktype
) {
122 InitializeCriticalSection(&lockit_cs
[locktype
]);
123 lockit_cs
[locktype
].DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": _Lockit critical section");
126 /* ?_Lockit_dtor@_Lockit@std@@SAXH@Z */
127 void __cdecl
_Lockit_free(int locktype
)
129 lockit_cs
[locktype
].DebugInfo
->Spare
[0] = 0;
130 DeleteCriticalSection(&lockit_cs
[locktype
]);
133 void init_lockit(void) {
136 for(i
=0; i
<_MAX_LOCK
; i
++)
140 void free_lockit(void) {
143 for(i
=0; i
<_MAX_LOCK
; i
++)
147 /* ?_Lockit_ctor@_Lockit@std@@CAXPAV12@H@Z */
148 /* ?_Lockit_ctor@_Lockit@std@@CAXPEAV12@H@Z */
149 void __cdecl
_Lockit__Lockit_ctor_locktype(_Lockit
*lockit
, int locktype
)
151 lockit
->locktype
= locktype
;
152 EnterCriticalSection(&lockit_cs
[locktype
]);
155 /* ?_Lockit_ctor@_Lockit@std@@CAXPAV12@@Z */
156 /* ?_Lockit_ctor@_Lockit@std@@CAXPEAV12@@Z */
157 void __cdecl
_Lockit__Lockit_ctor(_Lockit
*lockit
)
159 _Lockit__Lockit_ctor_locktype(lockit
, 0);
162 /* ??0_Lockit@std@@QAE@H@Z */
163 /* ??0_Lockit@std@@QEAA@H@Z */
164 DEFINE_THISCALL_WRAPPER(_Lockit_ctor_locktype
, 8)
165 _Lockit
* __thiscall
_Lockit_ctor_locktype(_Lockit
*this, int locktype
)
167 _Lockit__Lockit_ctor_locktype(this, locktype
);
171 /* ??0_Lockit@std@@QAE@XZ */
172 /* ??0_Lockit@std@@QEAA@XZ */
173 DEFINE_THISCALL_WRAPPER(_Lockit_ctor
, 4)
174 _Lockit
* __thiscall
_Lockit_ctor(_Lockit
*this)
176 _Lockit__Lockit_ctor_locktype(this, 0);
180 /* ?_Lockit_dtor@_Lockit@std@@CAXPAV12@@Z */
181 /* ?_Lockit_dtor@_Lockit@std@@CAXPEAV12@@Z */
182 void __cdecl
_Lockit__Lockit_dtor(_Lockit
*lockit
)
184 LeaveCriticalSection(&lockit_cs
[lockit
->locktype
]);
187 /* ??1_Lockit@std@@QAE@XZ */
188 /* ??1_Lockit@std@@QEAA@XZ */
189 DEFINE_THISCALL_WRAPPER(_Lockit_dtor
, 4)
190 void __thiscall
_Lockit_dtor(_Lockit
*this)
192 _Lockit__Lockit_dtor(this);
196 unsigned short __cdecl
wctype(const char *property
)
198 static const struct {
202 { "alnum", _DIGIT
|_ALPHA
},
204 { "cntrl", _CONTROL
},
206 { "graph", _DIGIT
|_PUNCT
|_ALPHA
},
208 { "print", _DIGIT
|_PUNCT
|_BLANK
|_ALPHA
},
216 for(i
=0; i
<sizeof(properties
)/sizeof(properties
[0]); i
++)
217 if(!strcmp(property
, properties
[i
].name
))
218 return properties
[i
].mask
;
223 typedef void (__cdecl
*MSVCP_new_handler_func
)(void);
224 static MSVCP_new_handler_func MSVCP_new_handler
;
225 static int __cdecl
new_handler_wrapper(MSVCP_size_t unused
)
231 /* ?set_new_handler@std@@YAP6AXXZP6AXXZ@Z */
232 MSVCP_new_handler_func __cdecl
set_new_handler(MSVCP_new_handler_func new_handler
)
234 MSVCP_new_handler_func old_handler
= MSVCP_new_handler
;
236 TRACE("%p\n", new_handler
);
238 MSVCP_new_handler
= new_handler
;
239 MSVCRT_set_new_handler(new_handler
? new_handler_wrapper
: NULL
);
243 /* ?set_new_handler@std@@YAP6AXXZH@Z */
244 MSVCP_new_handler_func __cdecl
set_new_handler_reset(int unused
)
246 return set_new_handler(NULL
);
249 /* _Container_base0 is used by apps compiled without iterator checking
250 * (i.e. with _ITERATOR_DEBUG_LEVEL=0 ).
251 * It provides empty versions of methods used by visual c++'s stl's
253 * msvcr100 has to provide them in case apps are compiled with /Od
254 * or the optimizer fails to inline those (empty) calls.
257 /* ?_Orphan_all@_Container_base0@std@@QAEXXZ */
258 /* ?_Orphan_all@_Container_base0@std@@QEAAXXZ */
259 DEFINE_THISCALL_WRAPPER(Container_base0_Orphan_all
, 4)
260 void __thiscall
Container_base0_Orphan_all(void *this)
264 /* ?_Swap_all@_Container_base0@std@@QAEXAAU12@@Z */
265 /* ?_Swap_all@_Container_base0@std@@QEAAXAEAU12@@Z */
266 DEFINE_THISCALL_WRAPPER(Container_base0_Swap_all
, 8)
267 void __thiscall
Container_base0_Swap_all(void *this, void *that
)
271 /* ??4_Container_base0@std@@QAEAAU01@ABU01@@Z */
272 /* ??4_Container_base0@std@@QEAAAEAU01@AEBU01@@Z */
273 DEFINE_THISCALL_WRAPPER(Container_base0_op_assign
, 8)
274 void* __thiscall
Container_base0_op_assign(void *this, const void *that
)
279 /* ??0_Container_base12@std@@QAE@ABU01@@Z */
280 /* ??0_Container_base12@std@@QEAA@AEBU01@@Z */
281 DEFINE_THISCALL_WRAPPER(_Container_base12_copy_ctor
, 8)
282 _Container_base12
* __thiscall
_Container_base12_copy_ctor(
283 _Container_base12
*this, _Container_base12
*that
)
289 /* ??0_Container_base12@std@@QAE@XZ */
290 /* ??0_Container_base12@std@@QEAA@XZ */
291 DEFINE_THISCALL_WRAPPER(_Container_base12_ctor
, 4)
292 _Container_base12
* __thiscall
_Container_base12_ctor(_Container_base12
*this)
298 /* ??1_Container_base12@std@@QAE@XZ */
299 /* ??1_Container_base12@std@@QEAA@XZ */
300 DEFINE_THISCALL_WRAPPER(_Container_base12_dtor
, 4)
301 void __thiscall
_Container_base12_dtor(_Container_base12
*this)
305 /* ??4_Container_base12@std@@QAEAAU01@ABU01@@Z */
306 /* ??4_Container_base12@std@@QEAAAEAU01@AEBU01@@ */
307 DEFINE_THISCALL_WRAPPER(_Container_base12_op_assign
, 8)
308 _Container_base12
* __thiscall
_Container_base12_op_assign(
309 _Container_base12
*this, const _Container_base12
*that
)
314 /* ?_Getpfirst@_Container_base12@std@@QBEPAPAU_Iterator_base12@2@XZ */
315 /* ?_Getpfirst@_Container_base12@std@@QEBAPEAPEAU_Iterator_base12@2@XZ */
316 DEFINE_THISCALL_WRAPPER(_Container_base12__Getpfirst
, 4)
317 _Iterator_base12
** __thiscall
_Container_base12__Getpfirst(_Container_base12
*this)
319 return this->proxy
? &this->proxy
->head
: NULL
;
322 /* ?_Orphan_all@_Container_base12@std@@QAEXXZ */
323 /* ?_Orphan_all@_Container_base12@std@@QEAAXXZ */
324 DEFINE_THISCALL_WRAPPER(_Container_base12__Orphan_all
, 4)
325 void __thiscall
_Container_base12__Orphan_all(_Container_base12
*this)
329 /* ?_Swap_all@_Container_base12@std@@QAEXAAU12@@Z */
330 /* ?_Swap_all@_Container_base12@std@@QEAAXAEAU12@@Z */
331 DEFINE_THISCALL_WRAPPER(_Container_base12__Swap_all
, 8)
332 void __thiscall
_Container_base12__Swap_all(
333 _Container_base12
*this, _Container_base12
*that
)
335 _Container_proxy
*tmp
;
338 this->proxy
= that
->proxy
;
342 this->proxy
->cont
= this;
344 that
->proxy
->cont
= that
;