vcomp: Handle begin == NULL in _vcomp_for_static_init.

Sebastian Lackner sebastian at fds-team.de
Mon Apr 24 09:12:43 CDT 2017


Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---

Actually I was hoping that I could use the fancy new with_context() stuff for that ... ;)
It is intentional that lastchunk is ignored when begin == NULL (see tests).

 dlls/vcomp/main.c        |    7 ++++++
 dlls/vcomp/tests/vcomp.c |   48 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/dlls/vcomp/main.c b/dlls/vcomp/main.c
index 34e327eedb..5206e474b3 100644
--- a/dlls/vcomp/main.c
+++ b/dlls/vcomp/main.c
@@ -1171,10 +1171,17 @@ void CDECL _vcomp_for_static_init(int first, int last, int step, int chunksize,
     struct vcomp_team_data *team_data = thread_data->team;
     int num_threads = team_data ? team_data->num_threads : 1;
     int thread_num = thread_data->thread_num;
+    int no_begin, no_lastchunk;
 
     TRACE("(%d, %d, %d, %d, %p, %p, %p, %p, %p)\n",
           first, last, step, chunksize, loops, begin, end, next, lastchunk);
 
+    if (!begin)
+    {
+        begin = &no_begin;
+        lastchunk = &no_lastchunk;
+    }
+
     if (num_threads == 1 && chunksize != 1)
     {
         *loops      = 1;
diff --git a/dlls/vcomp/tests/vcomp.c b/dlls/vcomp/tests/vcomp.c
index f0d8b3ae21..9aec5cccf7 100644
--- a/dlls/vcomp/tests/vcomp.c
+++ b/dlls/vcomp/tests/vcomp.c
@@ -1002,6 +1002,30 @@ static void CDECL for_static_cb(void)
         p_vcomp_for_static_end();
         p_vcomp_barrier();
 
+        loops = end = next = lastchunk = 0xdeadbeef;
+        p_vcomp_for_static_init(tests[i].first, tests[i].last, tests[i].step, tests[i].chunksize,
+                                &loops, NULL, &end, &next, &lastchunk);
+
+        if (broken_flags & VCOMP_FOR_STATIC_BROKEN_LOOP)
+        {
+            ok(loops == 0 || loops == 1, "test %d, thread %d/%d: expected loops == 0 or 1, got %u\n",
+               i, thread_num, num_threads, loops);
+        }
+        else
+        {
+            ok(loops == my_loops, "test %d, thread %d/%d: expected loops == %u, got %u\n",
+               i, thread_num, num_threads, my_loops, loops);
+            ok(end == my_end, "test %d, thread %d/%d: expected end == %d, got %d\n",
+               i, thread_num, num_threads, my_end, end);
+            ok(next == my_next || broken(broken_flags & VCOMP_FOR_STATIC_BROKEN_NEXT),
+               "test %d, thread %d/%d: expected next == %d, got %d\n", i, thread_num, num_threads, my_next, next);
+            ok(lastchunk == 0xdeadbeef, "test %d, thread %d/%d: expected lastchunk == 0xdeadbeef, got %d\n",
+               i, thread_num, num_threads, lastchunk);
+        }
+
+        p_vcomp_for_static_end();
+        p_vcomp_barrier();
+
         if (tests[i].first == tests[i].last) continue;
 
         my_loops = my_begin = my_end = my_next = my_lastchunk = 0xdeadbeef;
@@ -1032,6 +1056,30 @@ static void CDECL for_static_cb(void)
 
         p_vcomp_for_static_end();
         p_vcomp_barrier();
+
+        loops = end = next = lastchunk = 0xdeadbeef;
+        p_vcomp_for_static_init(tests[i].last, tests[i].first, tests[i].step, tests[i].chunksize,
+                                &loops, NULL, &end, &next, &lastchunk);
+
+        if (broken_flags & VCOMP_FOR_STATIC_BROKEN_LOOP)
+        {
+            ok(loops == 0 || loops == 1, "test %d, thread %d/%d: expected loops == 0 or 1, got %u\n",
+               i, thread_num, num_threads, loops);
+        }
+        else
+        {
+            ok(loops == my_loops, "test %d, thread %d/%d: expected loops == %u, got %u\n",
+               i, thread_num, num_threads, my_loops, loops);
+            ok(end == my_end, "test %d, thread %d/%d: expected end == %d, got %d\n",
+               i, thread_num, num_threads, my_end, end);
+            ok(next == my_next || broken(broken_flags & VCOMP_FOR_STATIC_BROKEN_NEXT),
+               "test %d, thread %d/%d: expected next == %d, got %d\n", i, thread_num, num_threads, my_next, next);
+            ok(lastchunk == 0xdeadbeef, "test %d, thread %d/%d: expected lastchunk == 0xdeadbeef, got %d\n",
+               i, thread_num, num_threads, lastchunk);
+        }
+
+        p_vcomp_for_static_end();
+        p_vcomp_barrier();
     }
 }
 
-- 
2.12.2



More information about the wine-patches mailing list