=?UTF-8?Q?Iv=C3=A1n=20Matellanes=20?=: msvcirt: Implement ios::bitalloc.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jul 20 14:20:49 CDT 2015


Module: wine
Branch: master
Commit: f2037e2e96e5ec79902ed5ef80527bf2e05f2c15
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f2037e2e96e5ec79902ed5ef80527bf2e05f2c15

Author: Iván Matellanes <matellanesivan at 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 at 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 at 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 at ios@@QAEXH at 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 at ios@@0HA  # static int ios::x_curindex
 @ extern ?x_lockc at ios@@0U_CRT_CRITICAL_SECTION@@A ios_static_lock
-# @ extern ?x_maxbit at ios@@0JA  # static long ios::x_maxbit
+@ extern ?x_maxbit at ios@@0JA ios_maxbit
 # @ extern ?x_statebuf at ios@@0PAJA  # static long * ios::x_statebuf
 @ cdecl ?xalloc at ios@@SAHXZ() ios_xalloc
 @ thiscall -arch=win32 ?xsgetn at streambuf@@UAEHPADH at 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 at ios@@0U_CRT_CRITICAL_SECTION@@A");
     SET(p_ios_lockc, "?lockc at ios@@KAXXZ");
     SET(p_ios_unlockc, "?unlockc at ios@@KAXXZ");
+    SET(p_ios_maxbit, "?x_maxbit at ios@@0JA");
+    SET(p_ios_bitalloc, "?bitalloc at 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 at ios@@0HA
 @ extern ?x_lockc at ios@@0U_CRT_CRITICAL_SECTION@@A msvcirt.?x_lockc at ios@@0U_CRT_CRITICAL_SECTION@@A
-# @ extern ?x_maxbit at ios@@0JA
+@ extern ?x_maxbit at ios@@0JA msvcirt.?x_maxbit at ios@@0JA
 # @ extern ?x_statebuf at ios@@0QAJA
 @ cdecl ?xalloc at ios@@SAHXZ() msvcirt.?xalloc at ios@@SAHXZ
 @ thiscall -arch=win32 ?xsgetn at streambuf@@UAEHPADH at Z(ptr ptr long) msvcirt.?xsgetn at streambuf@@UAEHPADH at 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 at ios@@0HA
 @ extern ?x_lockc at ios@@0U_CRT_CRITICAL_SECTION@@A msvcirt.?x_lockc at ios@@0U_CRT_CRITICAL_SECTION@@A
-# @ extern ?x_maxbit at ios@@0JA
+@ extern ?x_maxbit at ios@@0JA msvcirt.?x_maxbit at ios@@0JA
 # @ extern ?x_statebuf at ios@@0PAJA
 @ cdecl ?xalloc at ios@@SAHXZ() msvcirt.?xalloc at ios@@SAHXZ
 @ thiscall -arch=win32 ?xsgetn at streambuf@@UAEHPADH at Z(ptr ptr long) msvcirt.?xsgetn at streambuf@@UAEHPADH at Z




More information about the wine-cvs mailing list