[PATCH 2/6] vcomp: better stubs for _vcomp_for_static_simple_init, _vcomp_for_static_end
Dan Kegel
dank at kegel.com
Tue Oct 2 23:58:02 CDT 2012
---
dlls/vcomp/Makefile.in | 3 +-
dlls/vcomp/tests/Makefile.in | 3 +-
dlls/vcomp/tests/work.c | 81 ++++++++++++++++++++++++++++++++++++++++++
dlls/vcomp/vcomp.spec | 4 +--
dlls/vcomp/work.c | 41 +++++++++++++++++++++
5 files changed, 128 insertions(+), 4 deletions(-)
create mode 100644 dlls/vcomp/tests/work.c
create mode 100644 dlls/vcomp/work.c
diff --git a/dlls/vcomp/Makefile.in b/dlls/vcomp/Makefile.in
index 971cf0f..9140945 100644
--- a/dlls/vcomp/Makefile.in
+++ b/dlls/vcomp/Makefile.in
@@ -2,6 +2,7 @@ MODULE = vcomp.dll
C_SRCS = \
fork.c \
- main.c
+ main.c \
+ work.c
@MAKE_DLL_RULES@
diff --git a/dlls/vcomp/tests/Makefile.in b/dlls/vcomp/tests/Makefile.in
index 7a2e103..69d5043 100644
--- a/dlls/vcomp/tests/Makefile.in
+++ b/dlls/vcomp/tests/Makefile.in
@@ -2,7 +2,8 @@ TESTDLL = vcomp.dll
IMPORTS = vcomp
C_SRCS = \
- fork.c
+ fork.c \
+ work.c
RC_SRCS = \
vcomp.rc
diff --git a/dlls/vcomp/tests/work.c b/dlls/vcomp/tests/work.c
new file mode 100644
index 0000000..c2403f4
--- /dev/null
+++ b/dlls/vcomp/tests/work.c
@@ -0,0 +1,81 @@
+/*
+ * Unit test suite for vcomp work-sharing implementation
+ *
+ * Copyright 2012 Dan Kegel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "wine/test.h"
+
+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_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)
+
+static BOOL init(void)
+{
+ HMODULE vcomp = LoadLibraryA("vcomp.dll");
+ if(!vcomp) {
+ win_skip("vcomp.dll not installed\n");
+ return FALSE;
+ }
+
+ GETFUNC(_vcomp_fork);
+ GETFUNC(_vcomp_for_static_end);
+ GETFUNC(_vcomp_for_static_simple_init);
+
+ return TRUE;
+}
+
+static LONG volatile ncalls;
+static LONG volatile nsum;
+
+static void CDECL _test_vcomp_for_static_simple_init_worker(void)
+{
+ int i, my_limit;
+
+ InterlockedIncrement(&ncalls);
+
+ /* for (i=0; i<=12; i++) */
+ p_vcomp_for_static_simple_init(0, 12, 1, 1, &i, &my_limit);
+
+ while (i <= my_limit) {
+ int j;
+ for (j=0; j<i; j++)
+ InterlockedIncrement(&nsum);
+ i++;
+ }
+
+ p_vcomp_for_static_end();
+}
+
+static void test_vcomp_for_static_simple_init(void)
+{
+ ncalls = 0;
+ nsum = 0;
+ p_vcomp_fork(1, 0, _test_vcomp_for_static_simple_init_worker);
+ ok(ncalls >= 1, "expected >= 1 call, got %d\n", ncalls);
+ ok(nsum == 6*13, "expected sum 6*13, got %d\n", nsum);
+}
+
+START_TEST(work)
+{
+ if (!init())
+ return;
+
+ test_vcomp_for_static_simple_init();
+}
diff --git a/dlls/vcomp/vcomp.spec b/dlls/vcomp/vcomp.spec
index 1378c8d..f564a60 100644
--- a/dlls/vcomp/vcomp.spec
+++ b/dlls/vcomp/vcomp.spec
@@ -59,10 +59,10 @@
@ stub _vcomp_for_dynamic_init_i8
@ stub _vcomp_for_dynamic_next
@ stub _vcomp_for_dynamic_next_i8
-@ stub _vcomp_for_static_end
+@ cdecl _vcomp_for_static_end()
@ stub _vcomp_for_static_init
@ stub _vcomp_for_static_init_i8
-@ stub _vcomp_for_static_simple_init
+@ cdecl _vcomp_for_static_simple_init(long long long long ptr ptr)
@ stub _vcomp_for_static_simple_init_i8
@ varargs _vcomp_fork(long long ptr)
@ stub _vcomp_get_thread_num
diff --git a/dlls/vcomp/work.c b/dlls/vcomp/work.c
new file mode 100644
index 0000000..0f9ff78
--- /dev/null
+++ b/dlls/vcomp/work.c
@@ -0,0 +1,41 @@
+/*
+ * vcomp work-sharing implementation
+ *
+ * Copyright 2012 Dan Kegel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(vcomp);
+
+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);
+ *pfirst = first;
+ *plast = last;
+}
+
+void CDECL _vcomp_for_static_end(void)
+{
+ TRACE("stub\n");
+}
--
1.7.9.5
More information about the wine-patches
mailing list