Module: wine Branch: master Commit: b6c5bd15c488bfb89f5f4b55721f5af87db49ca1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=b6c5bd15c488bfb89f5f4b5572...
Author: Iván Matellanes matellanesivan@gmail.com Date: Fri Jul 17 16:37:18 2015 +0200
msvcirt: Add support for ios state variables.
---
dlls/msvcirt/msvcirt.c | 23 +++++++++++++++++------ dlls/msvcirt/msvcirt.spec | 4 ++-- dlls/msvcirt/tests/msvcirt.c | 33 ++++++++++++++++++++++++++++++++- dlls/msvcrt20/msvcrt20.spec | 4 ++-- dlls/msvcrt40/msvcrt40.spec | 4 ++-- 5 files changed, 55 insertions(+), 13 deletions(-)
diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c index 0ce9fff..eb4e3e4 100644 --- a/dlls/msvcirt/msvcirt.c +++ b/dlls/msvcirt/msvcirt.c @@ -30,6 +30,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcirt);
#define RESERVE_SIZE 512 +#define STATEBUF_SIZE 8
/* ?adjustfield@ios@@2JB */ const LONG ios_adjustfield = FLAGS_left | FLAGS_right | FLAGS_internal; @@ -48,6 +49,10 @@ CRITICAL_SECTION_DEBUG ios_static_lock_debug = CRITICAL_SECTION ios_static_lock = { &ios_static_lock_debug, -1, 0, 0, 0, 0 }; /* ?x_maxbit@ios@@0JA */ LONG ios_maxbit = 0x8000; +/* ?x_curindex@ios@@0HA */ +int ios_curindex = -1; +/* ?x_statebuf@ios@@0PAJA */ +LONG ios_statebuf[STATEBUF_SIZE] = {0};
/* class streambuf */ typedef struct { @@ -1018,8 +1023,8 @@ void __thiscall ios_init(ios *this, streambuf *sb) DEFINE_THISCALL_WRAPPER(ios_iword, 8) LONG* __thiscall ios_iword(const ios *this, int index) { - FIXME("(%p %d) stub\n", this, index); - return NULL; + TRACE("(%p %d)\n", this, index); + return &ios_statebuf[index]; }
/* ?lock@ios@@QAAXXZ */ @@ -1091,8 +1096,8 @@ int __thiscall ios_precision_get(const ios *this) DEFINE_THISCALL_WRAPPER(ios_pword, 8) void** __thiscall ios_pword(const ios *this, int index) { - FIXME("(%p %d) stub\n", this, index); - return NULL; + TRACE("(%p %d)\n", this, index); + return (void**)&ios_statebuf[index]; }
/* ?rdbuf@ios@@QBEPAVstreambuf@@XZ */ @@ -1245,8 +1250,14 @@ int __thiscall ios_width_get(const ios *this) /* ?xalloc@ios@@SAHXZ */ int __cdecl ios_xalloc(void) { - FIXME("() stub\n"); - return 0; + int ret; + + TRACE("()\n"); + + ios_lockc(); + ret = (ios_curindex < STATEBUF_SIZE-1) ? ++ios_curindex : -1; + ios_unlockc(); + return ret; }
/****************************************************************** diff --git a/dlls/msvcirt/msvcirt.spec b/dlls/msvcirt/msvcirt.spec index b4dcdc2..4d15bdb 100644 --- a/dlls/msvcirt/msvcirt.spec +++ b/dlls/msvcirt/msvcirt.spec @@ -776,10 +776,10 @@ @ stub -arch=win64 ?writepad@ostream@@AEAAAEAV1@PEBD0@Z @ 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_curindex@ios@@0HA ios_curindex @ extern ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A ios_static_lock @ extern ?x_maxbit@ios@@0JA ios_maxbit -# @ extern ?x_statebuf@ios@@0PAJA # static long * ios::x_statebuf +@ extern ?x_statebuf@ios@@0PAJA ios_statebuf @ cdecl ?xalloc@ios@@SAHXZ() ios_xalloc @ thiscall -arch=win32 ?xsgetn@streambuf@@UAEHPADH@Z(ptr ptr long) streambuf_xsgetn @ cdecl -arch=win64 ?xsgetn@streambuf@@UEAAHPEADH@Z(ptr ptr long) streambuf_xsgetn diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c index 5fac801..e1390b5 100644 --- a/dlls/msvcirt/tests/msvcirt.c +++ b/dlls/msvcirt/tests/msvcirt.c @@ -149,6 +149,11 @@ static int (*__thiscall p_ios_fail)(const ios*); static void (*__thiscall p_ios_clear)(ios*, int); static LONG *p_ios_maxbit; static LONG (*__cdecl p_ios_bitalloc)(void); +static int *p_ios_curindex; +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);
/* Emulate a __thiscall */ #ifdef __i386__ @@ -267,6 +272,8 @@ static BOOL init(void) SET(p_ios_eof, "?eof@ios@@QEBAHXZ"); SET(p_ios_fail, "?fail@ios@@QEBAHXZ"); SET(p_ios_clear, "?clear@ios@@QEAAXH@Z"); + SET(p_ios_iword, "?iword@ios@@QEBAAEAJH@Z"); + SET(p_ios_pword, "?pword@ios@@QEBAAEAPEAXH@Z"); } else { p_operator_new = (void*)GetProcAddress(msvcrt, "??2@YAPAXI@Z");
@@ -315,12 +322,17 @@ static BOOL init(void) SET(p_ios_eof, "?eof@ios@@QBEHXZ"); SET(p_ios_fail, "?fail@ios@@QBEHXZ"); SET(p_ios_clear, "?clear@ios@@QAEXH@Z"); + SET(p_ios_iword, "?iword@ios@@QBEAAJH@Z"); + SET(p_ios_pword, "?pword@ios@@QBEAAPAXH@Z"); } 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"); SET(p_ios_maxbit, "?x_maxbit@ios@@0JA"); SET(p_ios_bitalloc, "?bitalloc@ios@@SAJXZ"); + SET(p_ios_curindex, "?x_curindex@ios@@0HA"); + SET(p_ios_statebuf, "?x_statebuf@ios@@0PAJA"); + SET(p_ios_xalloc, "?xalloc@ios@@SAHXZ");
init_thiscall_thunk(); return TRUE; @@ -893,7 +905,8 @@ static void test_ios(void) struct ios_lock_arg lock_arg; HANDLE thread; BOOL locked; - LONG expected, ret; + LONG *pret, expected, ret; + void **pret2; int i;
memset(&ios_obj, 0xab, sizeof(ios)); @@ -1099,6 +1112,24 @@ static void test_ios(void) expected <<= 1; }
+ /* xalloc/pword/iword */ + ok(*p_ios_curindex == -1, "expected -1 got %d\n", *p_ios_curindex); + expected = 0; + for (i = 0; i < 8; i++) { + ret = p_ios_xalloc(); + ok(ret == expected, "expected %d got %d\n", expected, ret); + ok(*p_ios_curindex == expected, "expected %d got %d\n", expected, *p_ios_curindex); + pret = (LONG*) call_func2(p_ios_iword, &ios_obj, ret); + ok(pret == &p_ios_statebuf[ret], "expected %p got %p\n", &p_ios_statebuf[ret], pret); + ok(*pret == 0, "expected 0 got %d\n", *pret); + pret2 = (void**) call_func2(p_ios_pword, &ios_obj, ret); + ok(pret2 == (void**)&p_ios_statebuf[ret], "expected %p got %p\n", (void**)&p_ios_statebuf[ret], pret2); + expected++; + } + ret = p_ios_xalloc(); + ok(ret == -1, "expected -1 got %d\n", ret); + ok(*p_ios_curindex == 7, "expected 7 got %d\n", *p_ios_curindex); + SetEvent(lock_arg.release[1]); SetEvent(lock_arg.release[2]); WaitForSingleObject(thread, INFINITE); diff --git a/dlls/msvcrt20/msvcrt20.spec b/dlls/msvcrt20/msvcrt20.spec index 529c0d9..d110d28 100644 --- a/dlls/msvcrt20/msvcrt20.spec +++ b/dlls/msvcrt20/msvcrt20.spec @@ -764,10 +764,10 @@ @ stub -arch=win64 ?writepad@ostream@@AEAAAEAV1@PEBD0@Z @ stub -arch=win32 ?ws@@YAAAVistream@@AAV1@@Z @ stub -arch=win64 ?ws@@YAAEAVistream@@AEAV1@@Z -# @ extern ?x_curindex@ios@@0HA +@ extern ?x_curindex@ios@@0HA msvcirt.?x_curindex@ios@@0HA @ extern ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A msvcirt.?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A @ extern ?x_maxbit@ios@@0JA msvcirt.?x_maxbit@ios@@0JA -# @ extern ?x_statebuf@ios@@0QAJA +@ extern ?x_statebuf@ios@@0QAJA msvcrt40.?x_statebuf@ios@@0QAJA @ cdecl ?xalloc@ios@@SAHXZ() msvcirt.?xalloc@ios@@SAHXZ @ thiscall -arch=win32 ?xsgetn@streambuf@@UAEHPADH@Z(ptr ptr long) msvcirt.?xsgetn@streambuf@@UAEHPADH@Z @ cdecl -arch=win64 ?xsgetn@streambuf@@UEAAHPEADH@Z(ptr ptr long) msvcirt.?xsgetn@streambuf@@UEAAHPEADH@Z diff --git a/dlls/msvcrt40/msvcrt40.spec b/dlls/msvcrt40/msvcrt40.spec index e5a2852..afd9894 100644 --- a/dlls/msvcrt40/msvcrt40.spec +++ b/dlls/msvcrt40/msvcrt40.spec @@ -838,10 +838,10 @@ @ stub -arch=win64 ?writepad@ostream@@AEAAAEAV1@PEBD0@Z @ stub -arch=win32 ?ws@@YAAAVistream@@AAV1@@Z @ stub -arch=win64 ?ws@@YAAEAVistream@@AEAV1@@Z -# @ extern ?x_curindex@ios@@0HA +@ extern ?x_curindex@ios@@0HA msvcirt.?x_curindex@ios@@0HA @ extern ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A msvcirt.?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A @ extern ?x_maxbit@ios@@0JA msvcirt.?x_maxbit@ios@@0JA -# @ extern ?x_statebuf@ios@@0PAJA +@ extern ?x_statebuf@ios@@0QAJA msvcirt.?x_statebuf@ios@@0QAJA @ cdecl ?xalloc@ios@@SAHXZ() msvcirt.?xalloc@ios@@SAHXZ @ thiscall -arch=win32 ?xsgetn@streambuf@@UAEHPADH@Z(ptr ptr long) msvcirt.?xsgetn@streambuf@@UAEHPADH@Z @ cdecl -arch=win64 ?xsgetn@streambuf@@UEAAHPEADH@Z(ptr ptr long) msvcirt.?xsgetn@streambuf@@UEAAHPEADH@Z