[PATCH 3/6] vcomp: better stub for _vcomp_for_static_init

Dan Kegel dank at kegel.com
Tue Oct 2 23:58:03 CDT 2012


---
 dlls/vcomp/tests/work.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 dlls/vcomp/vcomp.spec   |    2 +-
 dlls/vcomp/work.c       |   11 +++++++++++
 3 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/dlls/vcomp/tests/work.c b/dlls/vcomp/tests/work.c
index c2403f4..d88f597 100644
--- a/dlls/vcomp/tests/work.c
+++ b/dlls/vcomp/tests/work.c
@@ -22,6 +22,7 @@
 
 static void WINAPIV (*p_vcomp_fork)(DWORD parallel, int nargs, void *helper, ...);
 static void CDECL (*p_vcomp_for_static_end)(void);
+static void CDECL (*p_vcomp_for_static_init)(int first, int last, int mystep, int chunksize, int *pnloops, int *pfirst, int *plast, int *pchunksize, int *pfinalchunkstart);
 static void CDECL (*p_vcomp_for_static_simple_init)(int first, int last, int mystep, int step, int *pfirst, int *plast);
 
 #define GETFUNC(x) do { p##x = (void*)GetProcAddress(vcomp, #x); ok(p##x != NULL, "Export '%s' not found\n", #x); } while(0)
@@ -36,6 +37,7 @@ static BOOL init(void)
 
     GETFUNC(_vcomp_fork);
     GETFUNC(_vcomp_for_static_end);
+    GETFUNC(_vcomp_for_static_init);
     GETFUNC(_vcomp_for_static_simple_init);
 
     return TRUE;
@@ -44,6 +46,45 @@ static BOOL init(void)
 static LONG volatile ncalls;
 static LONG volatile nsum;
 
+static void CDECL _test_vcomp_for_static_init_worker(void)
+{
+    const int my_start = 0;
+    const int my_end = 12;
+    const int my_incr = 1;
+    const int my_chunksize = 1;
+    int nloops, chunkstart, chunkend, chunksize, finalchunkstart;
+
+    InterlockedIncrement(&ncalls);
+
+    /* for (i=0; i<=12; i++) */
+    p_vcomp_for_static_init(my_start, my_end, my_incr, my_chunksize,
+        &nloops, &chunkstart, &chunkend, &chunksize, &finalchunkstart);
+
+    do {
+        int i;
+        if (chunkstart == finalchunkstart) chunkend = my_end;
+
+        for (i=chunkstart; i <= chunkend; i += my_incr) {
+            int j;
+            for (j=0; j<i; j++)
+                InterlockedIncrement(&nsum);
+        }
+        chunkstart += chunksize;
+        chunkend += chunksize;
+    } while (--nloops > 0);
+
+    p_vcomp_for_static_end();
+}
+
+static void test_vcomp_for_static_init(void)
+{
+    ncalls = 0;
+    nsum = 0;
+    p_vcomp_fork(1, 0, _test_vcomp_for_static_init_worker);
+    ok(ncalls >= 1, "expected >= 1 call, got %d\n", ncalls);
+    ok(nsum == 6*13, "expected sum 6*13, got %d\n", nsum);
+}
+
 static void CDECL _test_vcomp_for_static_simple_init_worker(void)
 {
     int i, my_limit;
@@ -77,5 +118,6 @@ START_TEST(work)
     if (!init())
         return;
 
+    test_vcomp_for_static_init();
     test_vcomp_for_static_simple_init();
 }
diff --git a/dlls/vcomp/vcomp.spec b/dlls/vcomp/vcomp.spec
index f564a60..8c8c51c 100644
--- a/dlls/vcomp/vcomp.spec
+++ b/dlls/vcomp/vcomp.spec
@@ -60,7 +60,7 @@
 @ stub _vcomp_for_dynamic_next
 @ stub _vcomp_for_dynamic_next_i8
 @ cdecl _vcomp_for_static_end()
-@ stub _vcomp_for_static_init
+@ cdecl _vcomp_for_static_init(long long long long ptr ptr ptr ptr ptr)
 @ stub _vcomp_for_static_init_i8
 @ cdecl _vcomp_for_static_simple_init(long long long long ptr ptr)
 @ stub _vcomp_for_static_simple_init_i8
diff --git a/dlls/vcomp/work.c b/dlls/vcomp/work.c
index 0f9ff78..6fad901 100644
--- a/dlls/vcomp/work.c
+++ b/dlls/vcomp/work.c
@@ -28,6 +28,17 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(vcomp);
 
+void CDECL _vcomp_for_static_init(int first, int last, int mystep, int chunksize, int *pnloops, int *pfirst, int *plast, int *pchunksize, int *pfinalchunkstart)
+{
+    TRACE("(%d, %d, %d, %d, %p, %p, %p, %p, %p): stub\n",
+      first, last, mystep, chunksize, pnloops, pfirst, plast, pchunksize, pfinalchunkstart);
+    *pfirst = first;
+    *plast = last;
+    *pfinalchunkstart = last;
+    *pnloops = 1;
+    *pchunksize = 0;  /* moot, since nloops=1 */
+}
+
 void CDECL _vcomp_for_static_simple_init(int first, int last, int mystep, int step, int *pfirst, int *plast)
 {
     TRACE("(%d, %d, %d, %d, %p, %p): stub\n", first, last, mystep, step, pfirst, plast);
-- 
1.7.9.5




More information about the wine-patches mailing list