msvcirt: Implement ios static locking.

oldstable
Iván Matellanes 2015-07-16 13:12:30 +02:00 committed by Alexandre Julliard
parent 9939ac8fe0
commit 277da0ea5d
5 changed files with 34 additions and 7 deletions

View File

@ -31,6 +31,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcirt);
#define RESERVE_SIZE 512
/* ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A */
extern CRITICAL_SECTION ios_static_lock;
CRITICAL_SECTION_DEBUG ios_static_lock_debug =
{
0, 0, &ios_static_lock,
{ &ios_static_lock_debug.ProcessLocksList, &ios_static_lock_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": ios_static_lock") }
};
CRITICAL_SECTION ios_static_lock = { &ios_static_lock_debug, -1, 0, 0, 0, 0 };
/* class streambuf */
typedef struct {
const vtable_ptr *vtable;
@ -1001,7 +1011,8 @@ void __cdecl ios_lockbuf(ios *this)
/* ?lockc@ios@@KAXXZ */
void __cdecl ios_lockc(void)
{
FIXME("() stub\n");
TRACE("()\n");
EnterCriticalSection(&ios_static_lock);
}
/* ?lockptr@ios@@IAEPAU_CRT_CRITICAL_SECTION@@XZ */
@ -1138,7 +1149,8 @@ void __cdecl ios_unlockbuf(ios *this)
/* ?unlockc@ios@@KAXXZ */
void __cdecl ios_unlockc(void)
{
FIXME("() stub\n");
TRACE("()\n");
LeaveCriticalSection(&ios_static_lock);
}
/* ?unsetf@ios@@QAEJJ@Z */

View File

@ -777,7 +777,7 @@
@ stub -arch=win32 ?ws@@YAAAVistream@@AAV1@@Z # class istream & __cdecl ws(class istream &)
@ stub -arch=win64 ?ws@@YAAEAVistream@@AEAV1@@Z
# @ extern ?x_curindex@ios@@0HA # static int ios::x_curindex
# @ extern ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A # static struct _CRT_CRITICAL_SECTION ios::x_lockc
@ extern ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A ios_static_lock
# @ extern ?x_maxbit@ios@@0JA # static long ios::x_maxbit
# @ extern ?x_statebuf@ios@@0PAJA # static long * ios::x_statebuf
@ cdecl ?xalloc@ios@@SAHXZ() ios_xalloc

View File

@ -134,6 +134,9 @@ static void (*__cdecl p_ios_lock)(ios*);
static void (*__cdecl p_ios_unlock)(ios*);
static void (*__cdecl p_ios_lockbuf)(ios*);
static void (*__cdecl p_ios_unlockbuf)(ios*);
static CRITICAL_SECTION *p_ios_static_lock;
static void (*__cdecl p_ios_lockc)(void);
static void (*__cdecl p_ios_unlockc)(void);
/* Emulate a __thiscall */
#ifdef __i386__
@ -281,6 +284,9 @@ static BOOL init(void)
SET(p_ios_lockbuf, "?lockbuf@ios@@QAAXXZ");
SET(p_ios_unlockbuf, "?unlockbuf@ios@@QAAXXZ");
}
SET(p_ios_static_lock, "?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A");
SET(p_ios_lockc, "?lockc@ios@@KAXXZ");
SET(p_ios_unlockc, "?unlockc@ios@@KAXXZ");
init_thiscall_thunk();
return TRUE;
@ -827,7 +833,7 @@ struct ios_lock_arg
{
ios *ios_obj;
HANDLE lock;
HANDLE release[2];
HANDLE release[3];
};
static DWORD WINAPI lock_ios(void *arg)
@ -835,10 +841,13 @@ static DWORD WINAPI lock_ios(void *arg)
struct ios_lock_arg *lock_arg = arg;
p_ios_lock(lock_arg->ios_obj);
p_ios_lockbuf(lock_arg->ios_obj);
p_ios_lockc();
SetEvent(lock_arg->lock);
WaitForSingleObject(lock_arg->release[0], INFINITE);
p_ios_unlockbuf(lock_arg->ios_obj);
p_ios_unlockc();
WaitForSingleObject(lock_arg->release[1], INFINITE);
p_ios_unlockbuf(lock_arg->ios_obj);
WaitForSingleObject(lock_arg->release[2], INFINITE);
p_ios_unlock(lock_arg->ios_obj);
return 0;
}
@ -962,6 +971,8 @@ static void test_ios(void)
ok(lock_arg.release[0] != NULL, "CreateEventW failed\n");
lock_arg.release[1] = CreateEventW(NULL, FALSE, FALSE, NULL);
ok(lock_arg.release[1] != NULL, "CreateEventW failed\n");
lock_arg.release[2] = CreateEventW(NULL, FALSE, FALSE, NULL);
ok(lock_arg.release[2] != NULL, "CreateEventW failed\n");
thread = CreateThread(NULL, 0, lock_ios, (void*)&lock_arg, 0, NULL);
ok(thread != NULL, "CreateThread failed\n");
WaitForSingleObject(lock_arg.lock, INFINITE);
@ -970,9 +981,12 @@ static void test_ios(void)
ok(locked == 0, "the ios object was not locked before\n");
locked = TryEnterCriticalSection(&ios_obj.sb->lock);
ok(locked == 0, "the streambuf was not locked before\n");
locked = TryEnterCriticalSection(p_ios_static_lock);
ok(locked == 0, "the static critical section was not locked before\n");
SetEvent(lock_arg.release[0]);
SetEvent(lock_arg.release[1]);
SetEvent(lock_arg.release[2]);
WaitForSingleObject(thread, INFINITE);
ios_obj.delbuf = 1;
@ -981,6 +995,7 @@ static void test_ios(void)
CloseHandle(lock_arg.lock);
CloseHandle(lock_arg.release[0]);
CloseHandle(lock_arg.release[1]);
CloseHandle(lock_arg.release[2]);
CloseHandle(thread);
}

View File

@ -765,7 +765,7 @@
@ stub -arch=win32 ?ws@@YAAAVistream@@AAV1@@Z
@ stub -arch=win64 ?ws@@YAAEAVistream@@AEAV1@@Z
# @ extern ?x_curindex@ios@@0HA
# @ extern ?x_lockc@ios@@0U_RTL_CRITICAL_SECTION@@A
@ extern ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A msvcirt.?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A
# @ extern ?x_maxbit@ios@@0JA
# @ extern ?x_statebuf@ios@@0QAJA
@ cdecl ?xalloc@ios@@SAHXZ() msvcirt.?xalloc@ios@@SAHXZ

View File

@ -839,7 +839,7 @@
@ stub -arch=win32 ?ws@@YAAAVistream@@AAV1@@Z
@ stub -arch=win64 ?ws@@YAAEAVistream@@AEAV1@@Z
# @ extern ?x_curindex@ios@@0HA
# @ extern ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A
@ extern ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A msvcirt.?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A
# @ extern ?x_maxbit@ios@@0JA
# @ extern ?x_statebuf@ios@@0PAJA
@ cdecl ?xalloc@ios@@SAHXZ() msvcirt.?xalloc@ios@@SAHXZ