Commit f2037e2e authored by Iván Matellanes's avatar Iván Matellanes Committed by Alexandre Julliard

msvcirt: Implement ios::bitalloc.

parent 3c5328dc
......@@ -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 */
......
......@@ -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
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment