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
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
);
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
)
73 /* ?_Mutex_Unlock@_Mutex@std@@CAXPAV12@@Z */
74 /* ?_Mutex_Unlock@_Mutex@std@@CAXPEAV12@@Z */
75 void CDECL
mutex_mutex_unlock(mutex
*m
)
80 /* ?_Mutex_ctor@_Mutex@std@@CAXPAV12@@Z */
81 /* ?_Mutex_ctor@_Mutex@std@@CAXPEAV12@@Z */
82 void CDECL
mutex_mutex_ctor(mutex
*m
)
87 /* ?_Mutex_dtor@_Mutex@std@@CAXPAV12@@Z */
88 /* ?_Mutex_dtor@_Mutex@std@@CAXPEAV12@@Z */
89 void CDECL
mutex_mutex_dtor(mutex
*m
)
94 #define _LOCK_LOCALE 0
95 #define _LOCK_MALLOC 1
96 #define _LOCK_STREAM 2
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) {
117 for(i
=0; i
<_MAX_LOCK
; i
++)
121 void free_lockit(void) {
124 for(i
=0; i
<_MAX_LOCK
; 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
);
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);
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);