msvcirt: Add ios instance counter.

This commit is contained in:
Iván Matellanes 2015-07-17 16:37:24 +02:00 committed by Alexandre Julliard
parent b6c5bd15c4
commit 6812bb7469
5 changed files with 19 additions and 3 deletions

View File

@ -38,6 +38,9 @@ const LONG ios_adjustfield = FLAGS_left | FLAGS_right | FLAGS_internal;
const LONG ios_basefield = FLAGS_dec | FLAGS_oct | FLAGS_hex;
/* ?floatfield@ios@@2JB */
const LONG ios_floatfield = FLAGS_scientific | FLAGS_fixed;
/* ?fLockcInit@ios@@0HA */
/* FIXME: should be initialized to 0 and increased on construction of cin, cout, cerr and clog */
int ios_fLockcInit = 4;
/* ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A */
extern CRITICAL_SECTION ios_static_lock;
CRITICAL_SECTION_DEBUG ios_static_lock_debug =
@ -741,6 +744,7 @@ DEFINE_THISCALL_WRAPPER(ios_copy_ctor, 8)
ios* __thiscall ios_copy_ctor(ios *this, const ios *copy)
{
TRACE("(%p %p)\n", this, copy);
ios_fLockcInit++;
this->vtable = &MSVCP_ios_vtable;
this->sb = NULL;
this->delbuf = 0;
@ -754,6 +758,7 @@ DEFINE_THISCALL_WRAPPER(ios_sb_ctor, 8)
ios* __thiscall ios_sb_ctor(ios *this, streambuf *sb)
{
TRACE("(%p %p)\n", this, sb);
ios_fLockcInit++;
this->vtable = &MSVCP_ios_vtable;
this->sb = sb;
this->state = sb ? IOSTATE_goodbit : IOSTATE_badbit;
@ -783,6 +788,7 @@ DEFINE_THISCALL_WRAPPER(ios_dtor, 4)
void __thiscall ios_dtor(ios *this)
{
TRACE("(%p)\n", this);
ios_fLockcInit--;
if (this->delbuf && this->sb)
call_streambuf_vector_dtor(this->sb, 1);
this->sb = NULL;

View File

@ -465,7 +465,7 @@
@ cdecl -arch=win64 ?eof@ios@@QEBAHXZ(ptr) ios_eof
@ thiscall -arch=win32 ?epptr@streambuf@@IBEPADXZ(ptr) streambuf_epptr
@ cdecl -arch=win64 ?epptr@streambuf@@IEBAPEADXZ(ptr) streambuf_epptr
# @ extern ?fLockcInit@ios@@0HA # static int ios::fLockcInit
@ extern ?fLockcInit@ios@@0HA ios_fLockcInit
@ thiscall -arch=win32 ?fail@ios@@QBEHXZ(ptr) ios_fail
@ cdecl -arch=win64 ?fail@ios@@QEBAHXZ(ptr) ios_fail
@ stub -arch=win32 ?fd@filebuf@@QBEHXZ # int __thiscall filebuf::fd(void)const

View File

@ -154,6 +154,7 @@ static LONG *p_ios_statebuf;
static LONG* (*__thiscall p_ios_iword)(const ios*, int);
static void** (*__thiscall p_ios_pword)(const ios*, int);
static int (*__cdecl p_ios_xalloc)(void);
static int *p_ios_fLockcInit;
/* Emulate a __thiscall */
#ifdef __i386__
@ -333,6 +334,7 @@ static BOOL init(void)
SET(p_ios_curindex, "?x_curindex@ios@@0HA");
SET(p_ios_statebuf, "?x_statebuf@ios@@0PAJA");
SET(p_ios_xalloc, "?xalloc@ios@@SAHXZ");
SET(p_ios_fLockcInit, "?fLockcInit@ios@@0HA");
init_thiscall_thunk();
return TRUE;
@ -916,6 +918,7 @@ static void test_ios(void)
call_func1(p_streambuf_ctor, psb);
/* constructor/destructor */
ok(*p_ios_fLockcInit == 4, "expected 4 got %d\n", *p_ios_fLockcInit);
call_func2(p_ios_sb_ctor, &ios_obj, NULL);
ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
@ -929,23 +932,28 @@ static void test_ios(void)
ok(ios_obj.width == 0, "expected 0 got %d\n", ios_obj.width);
ok(ios_obj.do_lock == -1, "expected -1 got %d\n", ios_obj.do_lock);
ok(ios_obj.lock.LockCount == -1, "expected -1 got %d\n", ios_obj.lock.LockCount);
ok(*p_ios_fLockcInit == 5, "expected 5 got %d\n", *p_ios_fLockcInit);
ios_obj.state = 0x8;
call_func1(p_ios_dtor, &ios_obj);
ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
ok(*p_ios_fLockcInit == 4, "expected 4 got %d\n", *p_ios_fLockcInit);
ios_obj.state = 0x8;
call_func2(p_ios_sb_ctor, &ios_obj, psb);
ok(ios_obj.sb == psb, "expected %p got %p\n", psb, ios_obj.sb);
ok(ios_obj.state == IOSTATE_goodbit, "expected %x got %x\n", IOSTATE_goodbit, ios_obj.state);
ok(ios_obj.delbuf == 0, "expected 0 got %d\n", ios_obj.delbuf);
ok(*p_ios_fLockcInit == 5, "expected 5 got %d\n", *p_ios_fLockcInit);
ios_obj.state = 0x8;
call_func1(p_ios_dtor, &ios_obj);
ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
ok(*p_ios_fLockcInit == 4, "expected 4 got %d\n", *p_ios_fLockcInit);
ios_obj.sb = psb;
ios_obj.state = 0x8;
call_func1(p_ios_ctor, &ios_obj);
ok(ios_obj.sb == NULL, "expected %p got %p\n", NULL, ios_obj.sb);
ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
ok(*p_ios_fLockcInit == 5, "expected 5 got %d\n", *p_ios_fLockcInit);
/* init */
ios_obj.state |= 0x8;
@ -973,6 +981,7 @@ static void test_ios(void)
ok(ios_obj.fill == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.fill);
ok(ios_obj.width == (char)0xab, "expected %d got %d\n", (char)0xab, ios_obj.width);
ok(ios_obj.do_lock == -1, "expected -1 got %d\n", ios_obj.do_lock);
ok(*p_ios_fLockcInit == 5, "expected 5 got %d\n", *p_ios_fLockcInit);
/* assignment */
ios_obj.state = 0x8;
@ -1137,6 +1146,7 @@ static void test_ios(void)
ios_obj.delbuf = 1;
call_func1(p_ios_dtor, &ios_obj);
ok(ios_obj.state == IOSTATE_badbit, "expected %x got %x\n", IOSTATE_badbit, ios_obj.state);
ok(*p_ios_fLockcInit == 4, "expected 4 got %d\n", *p_ios_fLockcInit);
CloseHandle(lock_arg.lock);
CloseHandle(lock_arg.release[0]);
CloseHandle(lock_arg.release[1]);

View File

@ -453,7 +453,7 @@
@ cdecl -arch=win64 ?eof@ios@@QEBAHXZ(ptr) msvcirt.?eof@ios@@QEBAHXZ
@ thiscall -arch=win32 ?epptr@streambuf@@IBEPADXZ(ptr) msvcirt.?epptr@streambuf@@IBEPADXZ
@ cdecl -arch=win64 ?epptr@streambuf@@IEBAPEADXZ(ptr) msvcirt.?epptr@streambuf@@IEBAPEADXZ
# @ extern ?fLockcInit@ios@@0HA
@ extern ?fLockcInit@ios@@0HA msvcirt.?fLockcInit@ios@@0HA
@ thiscall -arch=win32 ?fail@ios@@QBEHXZ(ptr) msvcirt.?fail@ios@@QBEHXZ
@ cdecl -arch=win64 ?fail@ios@@QEBAHXZ(ptr) msvcirt.?fail@ios@@QEBAHXZ
@ stub -arch=win32 ?fd@filebuf@@QBEHXZ

View File

@ -518,7 +518,7 @@
@ cdecl -arch=win64 ?eof@ios@@QEBAHXZ(ptr) msvcirt.?eof@ios@@QEBAHXZ
@ thiscall -arch=win32 ?epptr@streambuf@@IBEPADXZ(ptr) msvcirt.?epptr@streambuf@@IBEPADXZ
@ cdecl -arch=win64 ?epptr@streambuf@@IEBAPEADXZ(ptr) msvcirt.?epptr@streambuf@@IEBAPEADXZ
# @ extern ?fLockcInit@ios@@0HA
@ extern ?fLockcInit@ios@@0HA msvcirt.?fLockcInit@ios@@0HA
@ thiscall -arch=win32 ?fail@ios@@QBEHXZ(ptr) msvcirt.?fail@ios@@QBEHXZ
@ cdecl -arch=win64 ?fail@ios@@QEBAHXZ(ptr) msvcirt.?fail@ios@@QEBAHXZ
@ stub -arch=win32 ?fd@filebuf@@QBEHXZ