Module: wine Branch: master Commit: f2037e2e96e5ec79902ed5ef80527bf2e05f2c15 URL: http://source.winehq.org/git/wine.git/?a=commit;h=f2037e2e96e5ec79902ed5ef80...
Author: Iván Matellanes matellanesivan@gmail.com Date: Fri Jul 17 16:37:14 2015 +0200
msvcirt: Implement ios::bitalloc.
---
dlls/msvcirt/msvcirt.c | 11 +++++++++-- dlls/msvcirt/msvcirt.spec | 2 +- dlls/msvcirt/tests/msvcirt.c | 17 ++++++++++++++++- dlls/msvcrt20/msvcrt20.spec | 2 +- dlls/msvcrt40/msvcrt40.spec | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c index bbcefbf..0ce9fff 100644 --- a/dlls/msvcirt/msvcirt.c +++ b/dlls/msvcirt/msvcirt.c @@ -46,6 +46,8 @@ CRITICAL_SECTION_DEBUG ios_static_lock_debug = 0, 0, { (DWORD_PTR)(__FILE__ ": ios_static_lock") } }; CRITICAL_SECTION ios_static_lock = { &ios_static_lock_debug, -1, 0, 0, 0, 0 }; +/* ?x_maxbit@ios@@0JA */ +LONG ios_maxbit = 0x8000;
/* class streambuf */ typedef struct { @@ -90,8 +92,10 @@ typedef struct { ios* __thiscall ios_assign(ios*, const ios*); int __thiscall ios_fail(const ios*); void __cdecl ios_lock(ios*); +void __cdecl ios_lockc(void); LONG __thiscall ios_setf_mask(ios*, LONG, LONG); void __cdecl ios_unlock(ios*); +void __cdecl ios_unlockc(void);
/* class ostream */ typedef struct _ostream { @@ -858,8 +862,11 @@ int __thiscall ios_bad(const ios *this) /* ?bitalloc@ios@@SAJXZ */ LONG __cdecl ios_bitalloc(void) { - FIXME("() stub\n"); - return 0; + TRACE("()\n"); + ios_lockc(); + ios_maxbit <<= 1; + ios_unlockc(); + return ios_maxbit; }
/* ?clear@ios@@QAEXH@Z */ diff --git a/dlls/msvcirt/msvcirt.spec b/dlls/msvcirt/msvcirt.spec index b64b41a..b4dcdc2 100644 --- a/dlls/msvcirt/msvcirt.spec +++ b/dlls/msvcirt/msvcirt.spec @@ -778,7 +778,7 @@ @ 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 ios_static_lock -# @ extern ?x_maxbit@ios@@0JA # static long ios::x_maxbit +@ extern ?x_maxbit@ios@@0JA ios_maxbit # @ extern ?x_statebuf@ios@@0PAJA # static long * ios::x_statebuf @ cdecl ?xalloc@ios@@SAHXZ() ios_xalloc @ thiscall -arch=win32 ?xsgetn@streambuf@@UAEHPADH@Z(ptr ptr long) streambuf_xsgetn diff --git a/dlls/msvcirt/tests/msvcirt.c b/dlls/msvcirt/tests/msvcirt.c index c65d419..5fac801 100644 --- a/dlls/msvcirt/tests/msvcirt.c +++ b/dlls/msvcirt/tests/msvcirt.c @@ -147,6 +147,8 @@ static int (*__thiscall p_ios_bad)(const ios*); static int (*__thiscall p_ios_eof)(const ios*); 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);
/* Emulate a __thiscall */ #ifdef __i386__ @@ -317,6 +319,8 @@ static BOOL init(void) 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");
init_thiscall_thunk(); return TRUE; @@ -889,7 +893,8 @@ static void test_ios(void) struct ios_lock_arg lock_arg; HANDLE thread; BOOL locked; - LONG ret; + LONG expected, ret; + int i;
memset(&ios_obj, 0xab, sizeof(ios)); memset(&ios_obj2, 0xab, sizeof(ios)); @@ -1084,6 +1089,16 @@ static void test_ios(void) ios_obj.do_lock = -1;
SetEvent(lock_arg.release[0]); + + /* bitalloc */ + expected = 0x10000; + for (i = 0; i < 20; i++) { + ret = p_ios_bitalloc(); + ok(ret == expected, "expected %x got %x\n", expected, ret); + ok(*p_ios_maxbit == expected, "expected %x got %x\n", expected, *p_ios_maxbit); + expected <<= 1; + } + 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 aa6f5bc..529c0d9 100644 --- a/dlls/msvcrt20/msvcrt20.spec +++ b/dlls/msvcrt20/msvcrt20.spec @@ -766,7 +766,7 @@ @ stub -arch=win64 ?ws@@YAAEAVistream@@AEAV1@@Z # @ extern ?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 +@ extern ?x_maxbit@ios@@0JA msvcirt.?x_maxbit@ios@@0JA # @ extern ?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 diff --git a/dlls/msvcrt40/msvcrt40.spec b/dlls/msvcrt40/msvcrt40.spec index a80fd20..e5a2852 100644 --- a/dlls/msvcrt40/msvcrt40.spec +++ b/dlls/msvcrt40/msvcrt40.spec @@ -840,7 +840,7 @@ @ stub -arch=win64 ?ws@@YAAEAVistream@@AEAV1@@Z # @ extern ?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 +@ extern ?x_maxbit@ios@@0JA msvcirt.?x_maxbit@ios@@0JA # @ extern ?x_statebuf@ios@@0PAJA @ cdecl ?xalloc@ios@@SAHXZ() msvcirt.?xalloc@ios@@SAHXZ @ thiscall -arch=win32 ?xsgetn@streambuf@@UAEHPADH@Z(ptr ptr long) msvcirt.?xsgetn@streambuf@@UAEHPADH@Z