msvcirt: Add implementation of streambuf locking.
This commit is contained in:
parent
2e880feaab
commit
70b447d078
|
@ -45,7 +45,7 @@ typedef struct {
|
||||||
char *eback;
|
char *eback;
|
||||||
char *gptr;
|
char *gptr;
|
||||||
char *egptr;
|
char *egptr;
|
||||||
int unknown2;
|
int do_lock;
|
||||||
CRITICAL_SECTION lock;
|
CRITICAL_SECTION lock;
|
||||||
} streambuf;
|
} streambuf;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ streambuf* __thiscall streambuf_reserve_ctor(streambuf *this, char *buffer, int
|
||||||
this->vtable = &MSVCP_streambuf_vtable;
|
this->vtable = &MSVCP_streambuf_vtable;
|
||||||
this->allocated = 0;
|
this->allocated = 0;
|
||||||
this->unknown = -1;
|
this->unknown = -1;
|
||||||
this->unknown2 = -1;
|
this->do_lock = -1;
|
||||||
this->base = NULL;
|
this->base = NULL;
|
||||||
streambuf_setbuf(this, buffer, length);
|
streambuf_setbuf(this, buffer, length);
|
||||||
streambuf_setg(this, NULL, NULL, NULL);
|
streambuf_setg(this, NULL, NULL, NULL);
|
||||||
|
@ -288,6 +288,35 @@ char* __thiscall streambuf_pptr(const streambuf *this)
|
||||||
return this->pptr;
|
return this->pptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ?clrlock@streambuf@@QAEXXZ */
|
||||||
|
/* ?clrlock@streambuf@@QEAAXXZ */
|
||||||
|
DEFINE_THISCALL_WRAPPER(streambuf_clrlock, 4)
|
||||||
|
void __thiscall streambuf_clrlock(streambuf *this)
|
||||||
|
{
|
||||||
|
TRACE("(%p)\n", this);
|
||||||
|
if (this->do_lock <= 0)
|
||||||
|
this->do_lock++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ?lock@streambuf@@QAEXXZ */
|
||||||
|
/* ?lock@streambuf@@QEAAXXZ */
|
||||||
|
DEFINE_THISCALL_WRAPPER(streambuf_lock, 4)
|
||||||
|
void __thiscall streambuf_lock(streambuf *this)
|
||||||
|
{
|
||||||
|
TRACE("(%p)\n", this);
|
||||||
|
if (this->do_lock < 0)
|
||||||
|
EnterCriticalSection(&this->lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ */
|
||||||
|
/* ?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ */
|
||||||
|
DEFINE_THISCALL_WRAPPER(streambuf_lockptr, 4)
|
||||||
|
CRITICAL_SECTION* __thiscall streambuf_lockptr(streambuf *this)
|
||||||
|
{
|
||||||
|
TRACE("(%p)\n", this);
|
||||||
|
return &this->lock;
|
||||||
|
}
|
||||||
|
|
||||||
/* Unexported */
|
/* Unexported */
|
||||||
DEFINE_THISCALL_WRAPPER(streambuf_overflow, 8)
|
DEFINE_THISCALL_WRAPPER(streambuf_overflow, 8)
|
||||||
int __thiscall streambuf_overflow(streambuf *this, int c)
|
int __thiscall streambuf_overflow(streambuf *this, int c)
|
||||||
|
@ -366,6 +395,15 @@ void __thiscall streambuf_setg(streambuf *this, char *ek, char *gp, char *eg)
|
||||||
this->egptr = eg;
|
this->egptr = eg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ?setlock@streambuf@@QAEXXZ */
|
||||||
|
/* ?setlock@streambuf@@QEAAXXZ */
|
||||||
|
DEFINE_THISCALL_WRAPPER(streambuf_setlock, 4)
|
||||||
|
void __thiscall streambuf_setlock(streambuf *this)
|
||||||
|
{
|
||||||
|
TRACE("(%p)\n", this);
|
||||||
|
this->do_lock--;
|
||||||
|
}
|
||||||
|
|
||||||
/* ?setp@streambuf@@IAEXPAD0@Z */
|
/* ?setp@streambuf@@IAEXPAD0@Z */
|
||||||
/* ?setp@streambuf@@IEAAXPEAD0@Z */
|
/* ?setp@streambuf@@IEAAXPEAD0@Z */
|
||||||
DEFINE_THISCALL_WRAPPER(streambuf_setp, 12)
|
DEFINE_THISCALL_WRAPPER(streambuf_setp, 12)
|
||||||
|
@ -410,6 +448,16 @@ int __thiscall streambuf_underflow(streambuf *this)
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ?unlock@streambuf@@QAEXXZ */
|
||||||
|
/* ?unlock@streambuf@@QEAAXXZ */
|
||||||
|
DEFINE_THISCALL_WRAPPER(streambuf_unlock, 4)
|
||||||
|
void __thiscall streambuf_unlock(streambuf *this)
|
||||||
|
{
|
||||||
|
TRACE("(%p)\n", this);
|
||||||
|
if (this->do_lock < 0)
|
||||||
|
LeaveCriticalSection(&this->lock);
|
||||||
|
}
|
||||||
|
|
||||||
/* ?xsgetn@streambuf@@UAEHPADH@Z */
|
/* ?xsgetn@streambuf@@UAEHPADH@Z */
|
||||||
/* ?xsgetn@streambuf@@UEAAHPEADH@Z */
|
/* ?xsgetn@streambuf@@UEAAHPEADH@Z */
|
||||||
DEFINE_THISCALL_WRAPPER(streambuf_xsgetn, 12)
|
DEFINE_THISCALL_WRAPPER(streambuf_xsgetn, 12)
|
||||||
|
|
|
@ -434,8 +434,8 @@
|
||||||
@ stub -arch=win64 ?close@ofstream@@QEAAXXZ
|
@ stub -arch=win64 ?close@ofstream@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?clrlock@ios@@QAAXXZ # void __cdecl ios::clrlock(void)
|
@ stub -arch=win32 ?clrlock@ios@@QAAXXZ # void __cdecl ios::clrlock(void)
|
||||||
@ stub -arch=win64 ?clrlock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?clrlock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?clrlock@streambuf@@QAEXXZ # void __thiscall streambuf::clrlock(void)
|
@ thiscall -arch=win32 ?clrlock@streambuf@@QAEXXZ(ptr) streambuf_clrlock
|
||||||
@ stub -arch=win64 ?clrlock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?clrlock@streambuf@@QEAAXXZ(ptr) streambuf_clrlock
|
||||||
@ stub ?cout@@3Vostream_withassign@@A # class ostream_withassign cout
|
@ stub ?cout@@3Vostream_withassign@@A # class ostream_withassign cout
|
||||||
@ stub -arch=win32 ?dbp@streambuf@@QAEXXZ # void __thiscall streambuf::dbp(void)
|
@ stub -arch=win32 ?dbp@streambuf@@QAEXXZ # void __thiscall streambuf::dbp(void)
|
||||||
@ stub -arch=win64 ?dbp@streambuf@@QEAAXXZ
|
@ stub -arch=win64 ?dbp@streambuf@@QEAAXXZ
|
||||||
|
@ -551,15 +551,15 @@
|
||||||
@ stub -arch=win64 ?iword@ios@@QEBAAEAJH@Z
|
@ stub -arch=win64 ?iword@ios@@QEBAAEAJH@Z
|
||||||
@ stub -arch=win32 ?lock@ios@@QAAXXZ # void __cdecl ios::lock(void)
|
@ stub -arch=win32 ?lock@ios@@QAAXXZ # void __cdecl ios::lock(void)
|
||||||
@ stub -arch=win64 ?lock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?lock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?lock@streambuf@@QAEXXZ # void __thiscall streambuf::lock(void)
|
@ thiscall -arch=win32 ?lock@streambuf@@QAEXXZ(ptr) streambuf_lock
|
||||||
@ stub -arch=win64 ?lock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?lock@streambuf@@QEAAXXZ(ptr) streambuf_lock
|
||||||
@ stub -arch=win32 ?lockbuf@ios@@QAAXXZ # void __cdecl ios::lockbuf(void)
|
@ stub -arch=win32 ?lockbuf@ios@@QAAXXZ # void __cdecl ios::lockbuf(void)
|
||||||
@ stub -arch=win64 ?lockbuf@ios@@QEAAXXZ
|
@ stub -arch=win64 ?lockbuf@ios@@QEAAXXZ
|
||||||
@ stub ?lockc@ios@@KAXXZ # static void __cdecl ios::lockc(void)
|
@ stub ?lockc@ios@@KAXXZ # static void __cdecl ios::lockc(void)
|
||||||
@ stub -arch=win32 ?lockptr@ios@@IAEPAU_CRT_CRITICAL_SECTION@@XZ # struct _CRT_CRITICAL_SECTION * __thiscall ios::lockptr(void)
|
@ stub -arch=win32 ?lockptr@ios@@IAEPAU_CRT_CRITICAL_SECTION@@XZ # struct _CRT_CRITICAL_SECTION * __thiscall ios::lockptr(void)
|
||||||
@ stub -arch=win64 ?lockptr@ios@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ
|
@ stub -arch=win64 ?lockptr@ios@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ
|
||||||
@ stub -arch=win32 ?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ # struct _CRT_CRITICAL_SECTION * __thiscall streambuf::lockptr(void)
|
@ thiscall -arch=win32 ?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ(ptr) streambuf_lockptr
|
||||||
@ stub -arch=win64 ?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ
|
@ cdecl -arch=win64 ?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ(ptr) streambuf_lockptr
|
||||||
@ stub -arch=win32 ?oct@@YAAAVios@@AAV1@@Z # class ios & __cdecl oct(class ios &)
|
@ stub -arch=win32 ?oct@@YAAAVios@@AAV1@@Z # class ios & __cdecl oct(class ios &)
|
||||||
@ stub -arch=win64 ?oct@@YAAEAVios@@AEAV1@@Z
|
@ stub -arch=win64 ?oct@@YAAEAVios@@AEAV1@@Z
|
||||||
@ stub -arch=win32 ?open@filebuf@@QAEPAV1@PBDHH@Z # class filebuf * __thiscall filebuf::open(char const *,int,int)
|
@ stub -arch=win32 ?open@filebuf@@QAEPAV1@PBDHH@Z # class filebuf * __thiscall filebuf::open(char const *,int,int)
|
||||||
|
@ -679,8 +679,8 @@
|
||||||
@ cdecl -arch=win64 ?setg@streambuf@@IEAAXPEAD00@Z(ptr ptr ptr ptr) streambuf_setg
|
@ cdecl -arch=win64 ?setg@streambuf@@IEAAXPEAD00@Z(ptr ptr ptr ptr) streambuf_setg
|
||||||
@ stub -arch=win32 ?setlock@ios@@QAAXXZ # void __cdecl ios::setlock(void)
|
@ stub -arch=win32 ?setlock@ios@@QAAXXZ # void __cdecl ios::setlock(void)
|
||||||
@ stub -arch=win64 ?setlock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?setlock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?setlock@streambuf@@QAEXXZ # void __thiscall streambuf::setlock(void)
|
@ thiscall -arch=win32 ?setlock@streambuf@@QAEXXZ(ptr) streambuf_setlock
|
||||||
@ stub -arch=win64 ?setlock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?setlock@streambuf@@QEAAXXZ(ptr) streambuf_setlock
|
||||||
@ stub -arch=win32 ?setmode@filebuf@@QAEHH@Z # int __thiscall filebuf::setmode(int)
|
@ stub -arch=win32 ?setmode@filebuf@@QAEHH@Z # int __thiscall filebuf::setmode(int)
|
||||||
@ stub -arch=win64 ?setmode@filebuf@@QEAAHH@Z
|
@ stub -arch=win64 ?setmode@filebuf@@QEAAHH@Z
|
||||||
@ stub -arch=win32 ?setmode@fstream@@QAEHH@Z # int __thiscall fstream::setmode(int)
|
@ stub -arch=win32 ?setmode@fstream@@QAEHH@Z # int __thiscall fstream::setmode(int)
|
||||||
|
@ -753,8 +753,8 @@
|
||||||
@ stub -arch=win64 ?underflow@strstreambuf@@UEAAHXZ
|
@ stub -arch=win64 ?underflow@strstreambuf@@UEAAHXZ
|
||||||
@ stub -arch=win32 ?unlock@ios@@QAAXXZ # void __cdecl ios::unlock(void)
|
@ stub -arch=win32 ?unlock@ios@@QAAXXZ # void __cdecl ios::unlock(void)
|
||||||
@ stub -arch=win64 ?unlock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?unlock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?unlock@streambuf@@QAEXXZ # void __thiscall streambuf::unlock(void)
|
@ thiscall -arch=win32 ?unlock@streambuf@@QAEXXZ(ptr) streambuf_unlock
|
||||||
@ stub -arch=win64 ?unlock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?unlock@streambuf@@QEAAXXZ(ptr) streambuf_unlock
|
||||||
@ stub -arch=win32 ?unlockbuf@ios@@QAAXXZ # void __cdecl ios::unlockbuf(void)
|
@ stub -arch=win32 ?unlockbuf@ios@@QAAXXZ # void __cdecl ios::unlockbuf(void)
|
||||||
@ stub -arch=win64 ?unlockbuf@ios@@QEAAXXZ
|
@ stub -arch=win64 ?unlockbuf@ios@@QEAAXXZ
|
||||||
@ stub ?unlockc@ios@@KAXXZ # static void __cdecl ios::unlockc(void)
|
@ stub ?unlockc@ios@@KAXXZ # static void __cdecl ios::unlockc(void)
|
||||||
|
|
|
@ -37,7 +37,7 @@ typedef struct {
|
||||||
char *eback;
|
char *eback;
|
||||||
char *gptr;
|
char *gptr;
|
||||||
char *egptr;
|
char *egptr;
|
||||||
int unknown2;
|
int do_lock;
|
||||||
CRITICAL_SECTION lock;
|
CRITICAL_SECTION lock;
|
||||||
} streambuf;
|
} streambuf;
|
||||||
|
|
||||||
|
@ -53,9 +53,13 @@ static streambuf* (*__thiscall p_streambuf_reserve_ctor)(streambuf*, char*, int)
|
||||||
static streambuf* (*__thiscall p_streambuf_ctor)(streambuf*);
|
static streambuf* (*__thiscall p_streambuf_ctor)(streambuf*);
|
||||||
static void (*__thiscall p_streambuf_dtor)(streambuf*);
|
static void (*__thiscall p_streambuf_dtor)(streambuf*);
|
||||||
static int (*__thiscall p_streambuf_allocate)(streambuf*);
|
static int (*__thiscall p_streambuf_allocate)(streambuf*);
|
||||||
|
static void (*__thiscall p_streambuf_clrclock)(streambuf*);
|
||||||
static int (*__thiscall p_streambuf_doallocate)(streambuf*);
|
static int (*__thiscall p_streambuf_doallocate)(streambuf*);
|
||||||
|
static void (*__thiscall p_streambuf_lock)(streambuf*);
|
||||||
static void (*__thiscall p_streambuf_setb)(streambuf*, char*, char*, int);
|
static void (*__thiscall p_streambuf_setb)(streambuf*, char*, char*, int);
|
||||||
|
static void (*__thiscall p_streambuf_setlock)(streambuf*);
|
||||||
static streambuf* (*__thiscall p_streambuf_setbuf)(streambuf*, char*, int);
|
static streambuf* (*__thiscall p_streambuf_setbuf)(streambuf*, char*, int);
|
||||||
|
static void (*__thiscall p_streambuf_unlock)(streambuf*);
|
||||||
|
|
||||||
/* Emulate a __thiscall */
|
/* Emulate a __thiscall */
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
|
@ -130,28 +134,65 @@ static BOOL init(void)
|
||||||
SET(p_streambuf_ctor, "??0streambuf@@IEAA@XZ");
|
SET(p_streambuf_ctor, "??0streambuf@@IEAA@XZ");
|
||||||
SET(p_streambuf_dtor, "??1streambuf@@UEAA@XZ");
|
SET(p_streambuf_dtor, "??1streambuf@@UEAA@XZ");
|
||||||
SET(p_streambuf_allocate, "?allocate@streambuf@@IEAAHXZ");
|
SET(p_streambuf_allocate, "?allocate@streambuf@@IEAAHXZ");
|
||||||
|
SET(p_streambuf_clrclock, "?clrlock@streambuf@@QEAAXXZ");
|
||||||
SET(p_streambuf_doallocate, "?doallocate@streambuf@@MEAAHXZ");
|
SET(p_streambuf_doallocate, "?doallocate@streambuf@@MEAAHXZ");
|
||||||
|
SET(p_streambuf_lock, "?lock@streambuf@@QEAAXXZ");
|
||||||
SET(p_streambuf_setb, "?setb@streambuf@@IEAAXPEAD0H@Z");
|
SET(p_streambuf_setb, "?setb@streambuf@@IEAAXPEAD0H@Z");
|
||||||
SET(p_streambuf_setbuf, "?setbuf@streambuf@@UEAAPEAV1@PEADH@Z");
|
SET(p_streambuf_setbuf, "?setbuf@streambuf@@UEAAPEAV1@PEADH@Z");
|
||||||
|
SET(p_streambuf_setlock, "?setlock@streambuf@@QEAAXXZ");
|
||||||
|
SET(p_streambuf_unlock, "?unlock@streambuf@@QEAAXXZ");
|
||||||
} else {
|
} else {
|
||||||
SET(p_streambuf_reserve_ctor, "??0streambuf@@IAE@PADH@Z");
|
SET(p_streambuf_reserve_ctor, "??0streambuf@@IAE@PADH@Z");
|
||||||
SET(p_streambuf_ctor, "??0streambuf@@IAE@XZ");
|
SET(p_streambuf_ctor, "??0streambuf@@IAE@XZ");
|
||||||
SET(p_streambuf_dtor, "??1streambuf@@UAE@XZ");
|
SET(p_streambuf_dtor, "??1streambuf@@UAE@XZ");
|
||||||
SET(p_streambuf_allocate, "?allocate@streambuf@@IAEHXZ");
|
SET(p_streambuf_allocate, "?allocate@streambuf@@IAEHXZ");
|
||||||
|
SET(p_streambuf_clrclock, "?clrlock@streambuf@@QAEXXZ");
|
||||||
SET(p_streambuf_doallocate, "?doallocate@streambuf@@MAEHXZ");
|
SET(p_streambuf_doallocate, "?doallocate@streambuf@@MAEHXZ");
|
||||||
|
SET(p_streambuf_lock, "?lock@streambuf@@QAEXXZ");
|
||||||
SET(p_streambuf_setb, "?setb@streambuf@@IAEXPAD0H@Z");
|
SET(p_streambuf_setb, "?setb@streambuf@@IAEXPAD0H@Z");
|
||||||
SET(p_streambuf_setbuf, "?setbuf@streambuf@@UAEPAV1@PADH@Z");
|
SET(p_streambuf_setbuf, "?setbuf@streambuf@@UAEPAV1@PADH@Z");
|
||||||
|
SET(p_streambuf_setlock, "?setlock@streambuf@@QAEXXZ");
|
||||||
|
SET(p_streambuf_unlock, "?unlock@streambuf@@QAEXXZ");
|
||||||
}
|
}
|
||||||
|
|
||||||
init_thiscall_thunk();
|
init_thiscall_thunk();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct streambuf_lock_arg
|
||||||
|
{
|
||||||
|
streambuf *sb;
|
||||||
|
HANDLE lock[4];
|
||||||
|
HANDLE test[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
static DWORD WINAPI lock_streambuf(void *arg)
|
||||||
|
{
|
||||||
|
struct streambuf_lock_arg *lock_arg = arg;
|
||||||
|
call_func1(p_streambuf_lock, lock_arg->sb);
|
||||||
|
SetEvent(lock_arg->lock[0]);
|
||||||
|
WaitForSingleObject(lock_arg->test[0], INFINITE);
|
||||||
|
call_func1(p_streambuf_lock, lock_arg->sb);
|
||||||
|
SetEvent(lock_arg->lock[1]);
|
||||||
|
WaitForSingleObject(lock_arg->test[1], INFINITE);
|
||||||
|
call_func1(p_streambuf_lock, lock_arg->sb);
|
||||||
|
SetEvent(lock_arg->lock[2]);
|
||||||
|
WaitForSingleObject(lock_arg->test[2], INFINITE);
|
||||||
|
call_func1(p_streambuf_unlock, lock_arg->sb);
|
||||||
|
SetEvent(lock_arg->lock[3]);
|
||||||
|
WaitForSingleObject(lock_arg->test[3], INFINITE);
|
||||||
|
call_func1(p_streambuf_unlock, lock_arg->sb);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void test_streambuf(void)
|
static void test_streambuf(void)
|
||||||
{
|
{
|
||||||
streambuf sb, sb2, *psb;
|
streambuf sb, sb2, *psb;
|
||||||
|
struct streambuf_lock_arg lock_arg;
|
||||||
|
HANDLE thread;
|
||||||
char reserve[16];
|
char reserve[16];
|
||||||
int ret;
|
int ret, i;
|
||||||
|
BOOL locked;
|
||||||
|
|
||||||
memset(&sb, 0xab, sizeof(streambuf));
|
memset(&sb, 0xab, sizeof(streambuf));
|
||||||
memset(&sb2, 0xab, sizeof(streambuf));
|
memset(&sb2, 0xab, sizeof(streambuf));
|
||||||
|
@ -170,6 +211,64 @@ static void test_streambuf(void)
|
||||||
ok(sb2.ebuf == reserve+16, "wrong ebuf pointer, expected %p got %p\n", reserve+16, sb2.ebuf);
|
ok(sb2.ebuf == reserve+16, "wrong ebuf pointer, expected %p got %p\n", reserve+16, sb2.ebuf);
|
||||||
ok(sb.lock.LockCount == -1, "wrong critical section state, expected -1 got %d\n", sb.lock.LockCount);
|
ok(sb.lock.LockCount == -1, "wrong critical section state, expected -1 got %d\n", sb.lock.LockCount);
|
||||||
|
|
||||||
|
/* setlock */
|
||||||
|
ok(sb.do_lock == -1, "expected do_lock value -1, got %d\n", sb.do_lock);
|
||||||
|
call_func1(p_streambuf_setlock, &sb);
|
||||||
|
ok(sb.do_lock == -2, "expected do_lock value -2, got %d\n", sb.do_lock);
|
||||||
|
call_func1(p_streambuf_setlock, &sb);
|
||||||
|
ok(sb.do_lock == -3, "expected do_lock value -3, got %d\n", sb.do_lock);
|
||||||
|
sb.do_lock = 3;
|
||||||
|
call_func1(p_streambuf_setlock, &sb);
|
||||||
|
ok(sb.do_lock == 2, "expected do_lock value 2, got %d\n", sb.do_lock);
|
||||||
|
|
||||||
|
/* clrlock */
|
||||||
|
sb.do_lock = -2;
|
||||||
|
call_func1(p_streambuf_clrclock, &sb);
|
||||||
|
ok(sb.do_lock == -1, "expected do_lock value -1, got %d\n", sb.do_lock);
|
||||||
|
call_func1(p_streambuf_clrclock, &sb);
|
||||||
|
ok(sb.do_lock == 0, "expected do_lock value 0, got %d\n", sb.do_lock);
|
||||||
|
call_func1(p_streambuf_clrclock, &sb);
|
||||||
|
ok(sb.do_lock == 1, "expected do_lock value 1, got %d\n", sb.do_lock);
|
||||||
|
call_func1(p_streambuf_clrclock, &sb);
|
||||||
|
ok(sb.do_lock == 1, "expected do_lock value 1, got %d\n", sb.do_lock);
|
||||||
|
|
||||||
|
/* lock/unlock */
|
||||||
|
lock_arg.sb = &sb;
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
lock_arg.lock[i] = CreateEventW(NULL, FALSE, FALSE, NULL);
|
||||||
|
ok(lock_arg.lock[i] != NULL, "CreateEventW failed\n");
|
||||||
|
lock_arg.test[i] = CreateEventW(NULL, FALSE, FALSE, NULL);
|
||||||
|
ok(lock_arg.test[i] != NULL, "CreateEventW failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.do_lock = 0;
|
||||||
|
thread = CreateThread(NULL, 0, lock_streambuf, (void*)&lock_arg, 0, NULL);
|
||||||
|
ok(thread != NULL, "CreateThread failed\n");
|
||||||
|
WaitForSingleObject(lock_arg.lock[0], INFINITE);
|
||||||
|
locked = TryEnterCriticalSection(&sb.lock);
|
||||||
|
ok(locked != 0, "could not lock the streambuf\n");
|
||||||
|
LeaveCriticalSection(&sb.lock);
|
||||||
|
|
||||||
|
sb.do_lock = 1;
|
||||||
|
SetEvent(lock_arg.test[0]);
|
||||||
|
WaitForSingleObject(lock_arg.lock[1], INFINITE);
|
||||||
|
locked = TryEnterCriticalSection(&sb.lock);
|
||||||
|
ok(locked != 0, "could not lock the streambuf\n");
|
||||||
|
LeaveCriticalSection(&sb.lock);
|
||||||
|
|
||||||
|
sb.do_lock = -1;
|
||||||
|
SetEvent(lock_arg.test[1]);
|
||||||
|
WaitForSingleObject(lock_arg.lock[2], INFINITE);
|
||||||
|
locked = TryEnterCriticalSection(&sb.lock);
|
||||||
|
ok(locked == 0, "the streambuf was not locked before\n");
|
||||||
|
|
||||||
|
sb.do_lock = 0;
|
||||||
|
SetEvent(lock_arg.test[2]);
|
||||||
|
WaitForSingleObject(lock_arg.lock[3], INFINITE);
|
||||||
|
locked = TryEnterCriticalSection(&sb.lock);
|
||||||
|
ok(locked == 0, "the streambuf was not locked before\n");
|
||||||
|
sb.do_lock = -1;
|
||||||
|
|
||||||
/* setb */
|
/* setb */
|
||||||
call_func4(p_streambuf_setb, &sb, reserve, reserve+16, 0);
|
call_func4(p_streambuf_setb, &sb, reserve, reserve+16, 0);
|
||||||
ok(sb.base == reserve, "wrong base pointer, expected %p got %p\n", reserve, sb.base);
|
ok(sb.base == reserve, "wrong base pointer, expected %p got %p\n", reserve, sb.base);
|
||||||
|
@ -219,8 +318,16 @@ static void test_streambuf(void)
|
||||||
ok(sb2.allocated == 1, "wrong allocate value, expected 1 got %d\n", sb2.allocated);
|
ok(sb2.allocated == 1, "wrong allocate value, expected 1 got %d\n", sb2.allocated);
|
||||||
ok(sb2.ebuf - sb2.base == 512 , "wrong reserve area size, expected 512 got %p-%p\n", sb2.ebuf, sb2.base);
|
ok(sb2.ebuf - sb2.base == 512 , "wrong reserve area size, expected 512 got %p-%p\n", sb2.ebuf, sb2.base);
|
||||||
|
|
||||||
|
SetEvent(lock_arg.test[3]);
|
||||||
|
WaitForSingleObject(thread, INFINITE);
|
||||||
|
|
||||||
call_func1(p_streambuf_dtor, &sb);
|
call_func1(p_streambuf_dtor, &sb);
|
||||||
call_func1(p_streambuf_dtor, &sb2);
|
call_func1(p_streambuf_dtor, &sb2);
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
CloseHandle(lock_arg.lock[i]);
|
||||||
|
CloseHandle(lock_arg.test[i]);
|
||||||
|
}
|
||||||
|
CloseHandle(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(msvcirt)
|
START_TEST(msvcirt)
|
||||||
|
|
|
@ -422,8 +422,8 @@
|
||||||
@ stub -arch=win64 ?close@ofstream@@QEAAXXZ
|
@ stub -arch=win64 ?close@ofstream@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?clrlock@ios@@QAAXXZ
|
@ stub -arch=win32 ?clrlock@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?clrlock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?clrlock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?clrlock@streambuf@@QAEXXZ
|
@ thiscall -arch=win32 ?clrlock@streambuf@@QAEXXZ(ptr) msvcirt.?clrlock@streambuf@@QAEXXZ
|
||||||
@ stub -arch=win64 ?clrlock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?clrlock@streambuf@@QEAAXXZ(ptr) msvcirt.?clrlock@streambuf@@QEAAXXZ
|
||||||
@ stub ?cout@@3Vostream_withassign@@A
|
@ stub ?cout@@3Vostream_withassign@@A
|
||||||
@ stub -arch=win32 ?dbp@streambuf@@QAEXXZ
|
@ stub -arch=win32 ?dbp@streambuf@@QAEXXZ
|
||||||
@ stub -arch=win64 ?dbp@streambuf@@QEAAXXZ
|
@ stub -arch=win64 ?dbp@streambuf@@QEAAXXZ
|
||||||
|
@ -537,15 +537,15 @@
|
||||||
@ stub -arch=win64 ?iword@ios@@QEBAAEAJH@Z
|
@ stub -arch=win64 ?iword@ios@@QEBAAEAJH@Z
|
||||||
@ stub -arch=win32 ?lock@ios@@QAAXXZ
|
@ stub -arch=win32 ?lock@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?lock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?lock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?lock@streambuf@@QAEXXZ
|
@ thiscall -arch=win32 ?lock@streambuf@@QAEXXZ(ptr) msvcirt.?lock@streambuf@@QAEXXZ
|
||||||
@ stub -arch=win64 ?lock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?lock@streambuf@@QEAAXXZ(ptr) msvcirt.?lock@streambuf@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?lockbuf@ios@@QAAXXZ
|
@ stub -arch=win32 ?lockbuf@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?lockbuf@ios@@QEAAXXZ
|
@ stub -arch=win64 ?lockbuf@ios@@QEAAXXZ
|
||||||
@ stub ?lockc@ios@@KAXXZ
|
@ stub ?lockc@ios@@KAXXZ
|
||||||
@ stub -arch=win32 ?lockptr@ios@@IAEPAU_CRT_CRITICAL_SECTION@@XZ
|
@ stub -arch=win32 ?lockptr@ios@@IAEPAU_CRT_CRITICAL_SECTION@@XZ
|
||||||
@ stub -arch=win64 ?lockptr@ios@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ
|
@ stub -arch=win64 ?lockptr@ios@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ
|
||||||
@ stub -arch=win32 ?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ
|
@ thiscall -arch=win32 ?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ(ptr) msvcirt.?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ
|
||||||
@ stub -arch=win64 ?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ
|
@ cdecl -arch=win64 ?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ(ptr) msvcirt.?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ
|
||||||
@ stub -arch=win32 ?oct@@YAAAVios@@AAV1@@Z
|
@ stub -arch=win32 ?oct@@YAAAVios@@AAV1@@Z
|
||||||
@ stub -arch=win64 ?oct@@YAAEAVios@@AEAV1@@Z
|
@ stub -arch=win64 ?oct@@YAAEAVios@@AEAV1@@Z
|
||||||
@ stub -arch=win32 ?open@filebuf@@QAEPAV1@PBDHH@Z
|
@ stub -arch=win32 ?open@filebuf@@QAEPAV1@PBDHH@Z
|
||||||
|
@ -667,8 +667,8 @@
|
||||||
@ cdecl -arch=win64 ?setg@streambuf@@IEAAXPEAD00@Z(ptr ptr ptr ptr) msvcirt.?setg@streambuf@@IEAAXPEAD00@Z
|
@ cdecl -arch=win64 ?setg@streambuf@@IEAAXPEAD00@Z(ptr ptr ptr ptr) msvcirt.?setg@streambuf@@IEAAXPEAD00@Z
|
||||||
@ stub -arch=win32 ?setlock@ios@@QAAXXZ
|
@ stub -arch=win32 ?setlock@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?setlock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?setlock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?setlock@streambuf@@QAEXXZ
|
@ thiscall -arch=win32 ?setlock@streambuf@@QAEXXZ(ptr) msvcirt.?setlock@streambuf@@QAEXXZ
|
||||||
@ stub -arch=win64 ?setlock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?setlock@streambuf@@QEAAXXZ(ptr) msvcirt.?setlock@streambuf@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?setmode@filebuf@@QAEHH@Z
|
@ stub -arch=win32 ?setmode@filebuf@@QAEHH@Z
|
||||||
@ stub -arch=win64 ?setmode@filebuf@@QEAAHH@Z
|
@ stub -arch=win64 ?setmode@filebuf@@QEAAHH@Z
|
||||||
@ stub -arch=win32 ?setmode@fstream@@QAEHH@Z
|
@ stub -arch=win32 ?setmode@fstream@@QAEHH@Z
|
||||||
|
@ -743,8 +743,8 @@
|
||||||
@ cdecl ?unexpected@@YAXXZ() msvcrt.?unexpected@@YAXXZ
|
@ cdecl ?unexpected@@YAXXZ() msvcrt.?unexpected@@YAXXZ
|
||||||
@ stub -arch=win32 ?unlock@ios@@QAAXXZ
|
@ stub -arch=win32 ?unlock@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?unlock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?unlock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?unlock@streambuf@@QAEXXZ
|
@ thiscall -arch=win32 ?unlock@streambuf@@QAEXXZ(ptr) msvcirt.?unlock@streambuf@@QAEXXZ
|
||||||
@ stub -arch=win64 ?unlock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?unlock@streambuf@@QEAAXXZ(ptr) msvcirt.?unlock@streambuf@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?unlockbuf@ios@@QAAXXZ
|
@ stub -arch=win32 ?unlockbuf@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?unlockbuf@ios@@QEAAXXZ
|
@ stub -arch=win64 ?unlockbuf@ios@@QEAAXXZ
|
||||||
@ stub ?unlockc@ios@@KAXXZ
|
@ stub ?unlockc@ios@@KAXXZ
|
||||||
|
|
|
@ -487,8 +487,8 @@
|
||||||
@ stub -arch=win64 ?close@ofstream@@QEAAXXZ
|
@ stub -arch=win64 ?close@ofstream@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?clrlock@ios@@QAAXXZ
|
@ stub -arch=win32 ?clrlock@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?clrlock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?clrlock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?clrlock@streambuf@@QAEXXZ
|
@ thiscall -arch=win32 ?clrlock@streambuf@@QAEXXZ(ptr) msvcirt.?clrlock@streambuf@@QAEXXZ
|
||||||
@ stub -arch=win64 ?clrlock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?clrlock@streambuf@@QEAAXXZ(ptr) msvcirt.?clrlock@streambuf@@QEAAXXZ
|
||||||
@ stub ?cout@@3Vostream_withassign@@A
|
@ stub ?cout@@3Vostream_withassign@@A
|
||||||
@ stub -arch=win32 ?dbp@streambuf@@QAEXXZ
|
@ stub -arch=win32 ?dbp@streambuf@@QAEXXZ
|
||||||
@ stub -arch=win64 ?dbp@streambuf@@QEAAXXZ
|
@ stub -arch=win64 ?dbp@streambuf@@QEAAXXZ
|
||||||
|
@ -604,15 +604,15 @@
|
||||||
@ stub -arch=win64 ?iword@ios@@QEBAAEAJH@Z
|
@ stub -arch=win64 ?iword@ios@@QEBAAEAJH@Z
|
||||||
@ stub -arch=win32 ?lock@ios@@QAAXXZ
|
@ stub -arch=win32 ?lock@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?lock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?lock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?lock@streambuf@@QAEXXZ
|
@ thiscall -arch=win32 ?lock@streambuf@@QAEXXZ(ptr) msvcirt.?lock@streambuf@@QAEXXZ
|
||||||
@ stub -arch=win64 ?lock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?lock@streambuf@@QEAAXXZ(ptr) msvcirt.?lock@streambuf@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?lockbuf@ios@@QAAXXZ
|
@ stub -arch=win32 ?lockbuf@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?lockbuf@ios@@QEAAXXZ
|
@ stub -arch=win64 ?lockbuf@ios@@QEAAXXZ
|
||||||
@ stub ?lockc@ios@@KAXXZ
|
@ stub ?lockc@ios@@KAXXZ
|
||||||
@ stub -arch=win32 ?lockptr@ios@@IAEPAU_CRT_CRITICAL_SECTION@@XZ
|
@ stub -arch=win32 ?lockptr@ios@@IAEPAU_CRT_CRITICAL_SECTION@@XZ
|
||||||
@ stub -arch=win64 ?lockptr@ios@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ
|
@ stub -arch=win64 ?lockptr@ios@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ
|
||||||
@ stub -arch=win32 ?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ
|
@ thiscall -arch=win32 ?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ(ptr) msvcirt.?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ
|
||||||
@ stub -arch=win64 ?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ
|
@ cdecl -arch=win64 ?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ(ptr) msvcirt.?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ
|
||||||
@ thiscall -arch=win32 ?name@type_info@@QBEPBDXZ(ptr) msvcrt.?name@type_info@@QBEPBDXZ
|
@ thiscall -arch=win32 ?name@type_info@@QBEPBDXZ(ptr) msvcrt.?name@type_info@@QBEPBDXZ
|
||||||
@ cdecl -arch=win64 ?name@type_info@@QEBAPEBDXZ(ptr) msvcrt.?name@type_info@@QEBAPEBDXZ
|
@ cdecl -arch=win64 ?name@type_info@@QEBAPEBDXZ(ptr) msvcrt.?name@type_info@@QEBAPEBDXZ
|
||||||
@ stub -arch=win32 ?oct@@YAAAVios@@AAV1@@Z
|
@ stub -arch=win32 ?oct@@YAAAVios@@AAV1@@Z
|
||||||
|
@ -739,8 +739,8 @@
|
||||||
@ cdecl -arch=win64 ?setg@streambuf@@IEAAXPEAD00@Z(ptr ptr ptr ptr) msvcirt.?setg@streambuf@@IEAAXPEAD00@Z
|
@ cdecl -arch=win64 ?setg@streambuf@@IEAAXPEAD00@Z(ptr ptr ptr ptr) msvcirt.?setg@streambuf@@IEAAXPEAD00@Z
|
||||||
@ stub -arch=win32 ?setlock@ios@@QAAXXZ
|
@ stub -arch=win32 ?setlock@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?setlock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?setlock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?setlock@streambuf@@QAEXXZ
|
@ thiscall -arch=win32 ?setlock@streambuf@@QAEXXZ(ptr) msvcirt.?setlock@streambuf@@QAEXXZ
|
||||||
@ stub -arch=win64 ?setlock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?setlock@streambuf@@QEAAXXZ(ptr) msvcirt.?setlock@streambuf@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?setmode@filebuf@@QAEHH@Z
|
@ stub -arch=win32 ?setmode@filebuf@@QAEHH@Z
|
||||||
@ stub -arch=win64 ?setmode@filebuf@@QEAAHH@Z
|
@ stub -arch=win64 ?setmode@filebuf@@QEAAHH@Z
|
||||||
@ stub -arch=win32 ?setmode@fstream@@QAEHH@Z
|
@ stub -arch=win32 ?setmode@fstream@@QAEHH@Z
|
||||||
|
@ -815,8 +815,8 @@
|
||||||
@ cdecl ?unexpected@@YAXXZ() msvcrt.?unexpected@@YAXXZ
|
@ cdecl ?unexpected@@YAXXZ() msvcrt.?unexpected@@YAXXZ
|
||||||
@ stub -arch=win32 ?unlock@ios@@QAAXXZ
|
@ stub -arch=win32 ?unlock@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?unlock@ios@@QEAAXXZ
|
@ stub -arch=win64 ?unlock@ios@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?unlock@streambuf@@QAEXXZ
|
@ thiscall -arch=win32 ?unlock@streambuf@@QAEXXZ(ptr) msvcirt.?unlock@streambuf@@QAEXXZ
|
||||||
@ stub -arch=win64 ?unlock@streambuf@@QEAAXXZ
|
@ cdecl -arch=win64 ?unlock@streambuf@@QEAAXXZ(ptr) msvcirt.?unlock@streambuf@@QEAAXXZ
|
||||||
@ stub -arch=win32 ?unlockbuf@ios@@QAAXXZ
|
@ stub -arch=win32 ?unlockbuf@ios@@QAAXXZ
|
||||||
@ stub -arch=win64 ?unlockbuf@ios@@QEAAXXZ
|
@ stub -arch=win64 ?unlockbuf@ios@@QEAAXXZ
|
||||||
@ stub ?unlockc@ios@@KAXXZ
|
@ stub ?unlockc@ios@@KAXXZ
|
||||||
|
|
Loading…
Reference in New Issue