msvcirt: Implement ios::setf.

This commit is contained in:
Iván Matellanes 2015-07-16 13:12:40 +02:00 committed by Alexandre Julliard
parent 6f89103b72
commit 968d07dd7b
2 changed files with 38 additions and 4 deletions

View File

@ -82,6 +82,8 @@ typedef struct {
} ios; } ios;
ios* __thiscall ios_assign(ios*, const ios*); ios* __thiscall ios_assign(ios*, const ios*);
void __cdecl ios_lock(ios*);
void __cdecl ios_unlock(ios*);
/* class ostream */ /* class ostream */
typedef struct _ostream { typedef struct _ostream {
@ -1086,8 +1088,14 @@ int __thiscall ios_rdstate(const ios *this)
DEFINE_THISCALL_WRAPPER(ios_setf, 8) DEFINE_THISCALL_WRAPPER(ios_setf, 8)
LONG __thiscall ios_setf(ios *this, LONG flags) LONG __thiscall ios_setf(ios *this, LONG flags)
{ {
FIXME("(%p %x) stub\n", this, flags); LONG prev = this->flags;
return 0;
TRACE("(%p %x)\n", this, flags);
ios_lock(this);
this->flags |= flags;
ios_unlock(this);
return prev;
} }
/* ?setf@ios@@QAEJJJ@Z */ /* ?setf@ios@@QAEJJJ@Z */
@ -1095,8 +1103,14 @@ LONG __thiscall ios_setf(ios *this, LONG flags)
DEFINE_THISCALL_WRAPPER(ios_setf_mask, 12) DEFINE_THISCALL_WRAPPER(ios_setf_mask, 12)
LONG __thiscall ios_setf_mask(ios *this, LONG flags, LONG mask) LONG __thiscall ios_setf_mask(ios *this, LONG flags, LONG mask)
{ {
FIXME("(%p %x %x) stub\n", this, flags, mask); LONG prev = this->flags;
return 0;
TRACE("(%p %x %x)\n", this, flags, mask);
ios_lock(this);
this->flags = (this->flags & (~mask)) | (flags & mask);
ios_unlock(this);
return prev;
} }
/* ?setlock@ios@@QAAXXZ */ /* ?setlock@ios@@QAAXXZ */

View File

@ -139,6 +139,8 @@ static void (*__cdecl p_ios_lockc)(void);
static void (*__cdecl p_ios_unlockc)(void); static void (*__cdecl p_ios_unlockc)(void);
static LONG (*__thiscall p_ios_flags_set)(ios*, LONG); static LONG (*__thiscall p_ios_flags_set)(ios*, LONG);
static LONG (*__thiscall p_ios_flags_get)(const ios*); static LONG (*__thiscall p_ios_flags_get)(const ios*);
static LONG (*__thiscall p_ios_setf)(ios*, LONG);
static LONG (*__thiscall p_ios_setf_mask)(ios*, LONG, LONG);
/* Emulate a __thiscall */ /* Emulate a __thiscall */
#ifdef __i386__ #ifdef __i386__
@ -249,6 +251,8 @@ static BOOL init(void)
SET(p_ios_unlockbuf, "?unlockbuf@ios@@QEAAXXZ"); SET(p_ios_unlockbuf, "?unlockbuf@ios@@QEAAXXZ");
SET(p_ios_flags_set, "?flags@ios@@QEAAJJ@Z"); SET(p_ios_flags_set, "?flags@ios@@QEAAJJ@Z");
SET(p_ios_flags_get, "?flags@ios@@QEBAJXZ"); SET(p_ios_flags_get, "?flags@ios@@QEBAJXZ");
SET(p_ios_setf, "?setf@ios@@QEAAJJ@Z");
SET(p_ios_setf_mask, "?setf@ios@@QEAAJJJ@Z");
} else { } else {
p_operator_new = (void*)GetProcAddress(msvcrt, "??2@YAPAXI@Z"); p_operator_new = (void*)GetProcAddress(msvcrt, "??2@YAPAXI@Z");
@ -289,6 +293,8 @@ static BOOL init(void)
SET(p_ios_unlockbuf, "?unlockbuf@ios@@QAAXXZ"); SET(p_ios_unlockbuf, "?unlockbuf@ios@@QAAXXZ");
SET(p_ios_flags_set, "?flags@ios@@QAEJJ@Z"); SET(p_ios_flags_set, "?flags@ios@@QAEJJ@Z");
SET(p_ios_flags_get, "?flags@ios@@QBEJXZ"); SET(p_ios_flags_get, "?flags@ios@@QBEJXZ");
SET(p_ios_setf, "?setf@ios@@QAEJJ@Z");
SET(p_ios_setf_mask, "?setf@ios@@QAEJJJ@Z");
} }
SET(p_ios_static_lock, "?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A"); SET(p_ios_static_lock, "?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A");
SET(p_ios_lockc, "?lockc@ios@@KAXXZ"); SET(p_ios_lockc, "?lockc@ios@@KAXXZ");
@ -1002,6 +1008,20 @@ static void test_ios(void)
ok(ret == 0x444, "expected %x got %x\n", 0x444, ret); ok(ret == 0x444, "expected %x got %x\n", 0x444, ret);
ok(ios_obj.flags == 0, "expected %x got %x\n", 0, ios_obj.flags); ok(ios_obj.flags == 0, "expected %x got %x\n", 0, ios_obj.flags);
/* setf */
ios_obj.do_lock = 0;
ios_obj.flags = 0x8400;
ret = (LONG) call_func2(p_ios_setf, &ios_obj, 0x444);
ok(ret == 0x8400, "expected %x got %x\n", 0x8400, ret);
ok(ios_obj.flags == 0x8444, "expected %x got %x\n", 0x8444, ios_obj.flags);
ret = (LONG) call_func3(p_ios_setf_mask, &ios_obj, 0x111, 0);
ok(ret == 0x8444, "expected %x got %x\n", 0x8444, ret);
ok(ios_obj.flags == 0x8444, "expected %x got %x\n", 0x8444, ios_obj.flags);
ret = (LONG) call_func3(p_ios_setf_mask, &ios_obj, 0x111, 0x105);
ok(ret == 0x8444, "expected %x got %x\n", 0x8444, ret);
ok(ios_obj.flags == 0x8541, "expected %x got %x\n", 0x8541, ios_obj.flags);
ios_obj.do_lock = -1;
SetEvent(lock_arg.release[0]); SetEvent(lock_arg.release[0]);
SetEvent(lock_arg.release[1]); SetEvent(lock_arg.release[1]);
SetEvent(lock_arg.release[2]); SetEvent(lock_arg.release[2]);