oleaut32: Use type names and sizeof() instead of hardcoded values for save/load methods.
[wine/multimedia.git] / dlls / msvcp90 / misc.c
blob3ce1784cb2877f8bba4b9e583ae88c89dd1688d7
1 /*
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
19 #include "config.h"
21 #include <stdarg.h>
22 #include <limits.h>
24 #include "msvcp90.h"
26 #include "windef.h"
27 #include "winbase.h"
29 typedef struct {
30 void *mutex;
31 } mutex;
33 /* ??0_Mutex@std@@QAE@XZ */
34 /* ??0_Mutex@std@@QEAA@XZ */
35 DEFINE_THISCALL_WRAPPER(mutex_ctor, 4)
36 mutex* __thiscall mutex_ctor(mutex *this)
38 this->mutex = CreateMutexW(NULL, FALSE, NULL);
39 return this;
42 /* ??1_Mutex@std@@QAE@XZ */
43 /* ??1_Mutex@std@@QEAA@XZ */
44 DEFINE_THISCALL_WRAPPER(mutex_dtor, 4)
45 void __thiscall mutex_dtor(mutex *this)
47 CloseHandle(this->mutex);
50 /* ?_Lock@_Mutex@std@@QAEXXZ */
51 /* ?_Lock@_Mutex@std@@QEAAXXZ */
52 DEFINE_THISCALL_WRAPPER(mutex_lock, 4)
53 void __thiscall mutex_lock(mutex *this)
55 WaitForSingleObject(this->mutex, INFINITE);
58 /* ?_Unlock@_Mutex@std@@QAEXXZ */
59 /* ?_Unlock@_Mutex@std@@QEAAXXZ */
60 DEFINE_THISCALL_WRAPPER(mutex_unlock, 4)
61 void __thiscall mutex_unlock(mutex *this)
63 ReleaseMutex(this->mutex);
66 /* ?_Mutex_Lock@_Mutex@std@@CAXPAV12@@Z */
67 /* ?_Mutex_Lock@_Mutex@std@@CAXPEAV12@@Z */
68 void CDECL mutex_mutex_lock(mutex *m)
70 mutex_lock(m);
73 /* ?_Mutex_Unlock@_Mutex@std@@CAXPAV12@@Z */
74 /* ?_Mutex_Unlock@_Mutex@std@@CAXPEAV12@@Z */
75 void CDECL mutex_mutex_unlock(mutex *m)
77 mutex_unlock(m);
80 /* ?_Mutex_ctor@_Mutex@std@@CAXPAV12@@Z */
81 /* ?_Mutex_ctor@_Mutex@std@@CAXPEAV12@@Z */
82 void CDECL mutex_mutex_ctor(mutex *m)
84 mutex_ctor(m);
87 /* ?_Mutex_dtor@_Mutex@std@@CAXPAV12@@Z */
88 /* ?_Mutex_dtor@_Mutex@std@@CAXPEAV12@@Z */
89 void CDECL mutex_mutex_dtor(mutex *m)
91 mutex_dtor(m);
94 #define _LOCK_LOCALE 0
95 #define _LOCK_MALLOC 1
96 #define _LOCK_STREAM 2
97 #define _LOCK_DEBUG 3
98 #define _MAX_LOCK 4
99 static CRITICAL_SECTION lockit_cs[_MAX_LOCK];
101 /* ?_Lockit_ctor@_Lockit@std@@SAXH@Z */
102 void __cdecl _Lockit_init(int locktype) {
103 InitializeCriticalSection(&lockit_cs[locktype]);
104 lockit_cs[locktype].DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": _Lockit critical section");
107 /* ?_Lockit_dtor@_Lockit@std@@SAXH@Z */
108 void __cdecl _Lockit_free(int locktype)
110 lockit_cs[locktype].DebugInfo->Spare[0] = (DWORD_PTR)0;
111 DeleteCriticalSection(&lockit_cs[locktype]);
114 void init_lockit(void) {
115 int i;
117 for(i=0; i<_MAX_LOCK; i++)
118 _Lockit_init(i);
121 void free_lockit(void) {
122 int i;
124 for(i=0; i<_MAX_LOCK; i++)
125 _Lockit_free(i);
128 /* ?_Lockit_ctor@_Lockit@std@@CAXPAV12@H@Z */
129 /* ?_Lockit_ctor@_Lockit@std@@CAXPEAV12@H@Z */
130 void __cdecl _Lockit__Lockit_ctor_locktype(_Lockit *lockit, int locktype)
132 lockit->locktype = locktype;
133 EnterCriticalSection(&lockit_cs[locktype]);
136 /* ?_Lockit_ctor@_Lockit@std@@CAXPAV12@@Z */
137 /* ?_Lockit_ctor@_Lockit@std@@CAXPEAV12@@Z */
138 void __cdecl _Lockit__Lockit_ctor(_Lockit *lockit)
140 _Lockit__Lockit_ctor_locktype(lockit, 0);
143 /* ??0_Lockit@std@@QAE@H@Z */
144 /* ??0_Lockit@std@@QEAA@H@Z */
145 DEFINE_THISCALL_WRAPPER(_Lockit_ctor_locktype, 8)
146 _Lockit* __thiscall _Lockit_ctor_locktype(_Lockit *this, int locktype)
148 _Lockit__Lockit_ctor_locktype(this, locktype);
149 return this;
152 /* ??0_Lockit@std@@QAE@XZ */
153 /* ??0_Lockit@std@@QEAA@XZ */
154 DEFINE_THISCALL_WRAPPER(_Lockit_ctor, 4)
155 _Lockit* __thiscall _Lockit_ctor(_Lockit *this)
157 _Lockit__Lockit_ctor_locktype(this, 0);
158 return this;
161 /* ?_Lockit_dtor@_Lockit@std@@CAXPAV12@@Z */
162 /* ?_Lockit_dtor@_Lockit@std@@CAXPEAV12@@Z */
163 void __cdecl _Lockit__Lockit_dtor(_Lockit *lockit)
165 LeaveCriticalSection(&lockit_cs[lockit->locktype]);
168 /* ??1_Lockit@std@@QAE@XZ */
169 /* ??1_Lockit@std@@QEAA@XZ */
170 DEFINE_THISCALL_WRAPPER(_Lockit_dtor, 4)
171 void __thiscall _Lockit_dtor(_Lockit *this)
173 _Lockit__Lockit_dtor(this);
176 /* wctype */
177 unsigned short __cdecl wctype(const char *property)
179 static const struct {
180 const char *name;
181 unsigned short mask;
182 } properties[] = {
183 { "alnum", _DIGIT|_ALPHA },
184 { "alpha", _ALPHA },
185 { "cntrl", _CONTROL },
186 { "digit", _DIGIT },
187 { "graph", _DIGIT|_PUNCT|_ALPHA },
188 { "lower", _LOWER },
189 { "print", _DIGIT|_PUNCT|_BLANK|_ALPHA },
190 { "punct", _PUNCT },
191 { "space", _SPACE },
192 { "upper", _UPPER },
193 { "xdigit", _HEX }
195 int i;
197 for(i=0; i<sizeof(properties)/sizeof(properties[0]); i++)
198 if(!strcmp(property, properties[i].name))
199 return properties[i].mask;
201 return 0;