Daniel Lehman : msvcp140_atomic_wait: Implement __std_create_threadpool_work.

Alexandre Julliard julliard at winehq.org
Fri Jan 28 14:29:33 CST 2022


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

Author: Daniel Lehman <dlehman at esri.com>
Date:   Fri Jan 28 16:18:51 2022 +0100

msvcp140_atomic_wait: Implement __std_create_threadpool_work.

Signed-off-by: Daniel Lehman <dlehman at esri.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcp140_atomic_wait/main.c                       |  7 +++++++
 dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec    |  2 +-
 dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c | 17 +++++++++++++----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/dlls/msvcp140_atomic_wait/main.c b/dlls/msvcp140_atomic_wait/main.c
index 5c430ffd959..bdc46412771 100644
--- a/dlls/msvcp140_atomic_wait/main.c
+++ b/dlls/msvcp140_atomic_wait/main.c
@@ -30,3 +30,10 @@ unsigned int __stdcall __std_parallel_algorithms_hw_threads(void)
     TRACE("()\n");
     return _Thrd_hardware_concurrency();
 }
+
+PTP_WORK __stdcall __std_create_threadpool_work(PTP_WORK_CALLBACK callback, void *context,
+                                                PTP_CALLBACK_ENVIRON environ)
+{
+    TRACE("(%p %p %p)\n", callback, context, environ);
+    return CreateThreadpoolWork(callback, context, environ);
+}
diff --git a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec
index 1e5d1a5128b..3b4fd48dc7f 100644
--- a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec
+++ b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec
@@ -14,7 +14,7 @@
 @ stub __std_bulk_submit_threadpool_work
 @ stub __std_calloc_crt
 @ stub __std_close_threadpool_work
-@ stub __std_create_threadpool_work
+@ stdcall __std_create_threadpool_work(ptr ptr ptr)
 @ stub __std_execution_wait_on_uchar
 @ stub __std_execution_wake_by_address_all
 @ stub __std_free_crt
diff --git a/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c
index e0dfef3222d..097a81e5029 100644
--- a/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c
+++ b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c
@@ -24,6 +24,8 @@
 
 static unsigned int (__stdcall *p___std_parallel_algorithms_hw_threads)(void);
 
+static PTP_WORK (__stdcall *p___std_create_threadpool_work)(PTP_WORK_CALLBACK, void*, PTP_CALLBACK_ENVIRON);
+
 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
 #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
 static HMODULE init(void)
@@ -34,6 +36,8 @@ static HMODULE init(void)
         return NULL;
 
     SET(p___std_parallel_algorithms_hw_threads, "__std_parallel_algorithms_hw_threads");
+
+    SET(p___std_create_threadpool_work, "__std_create_threadpool_work");
     return msvcp;
 }
 
@@ -74,9 +78,14 @@ static void test_threadpool_work(void)
     TP_CALLBACK_ENVIRON environment;
     TP_CALLBACK_ENVIRON_V3 environment3;
 
+    if (0) /* crash on windows */
+    {
+        p___std_create_threadpool_work(NULL, NULL, NULL);
+    }
+
     /* simple test */
     workcalled = 0;
-    work = CreateThreadpoolWork(threadpool_workcallback, &workcalled, NULL);
+    work = p___std_create_threadpool_work(threadpool_workcallback, &workcalled, NULL);
     ok(!!work, "failed to create threadpool_work\n");
     SubmitThreadpoolWork(work);
     WaitForThreadpoolWorkCallbacks(work, FALSE);
@@ -91,7 +100,7 @@ static void test_threadpool_work(void)
     environment.Version = 1;
     environment.FinalizationCallback = threadpool_workfinalization;
     workcalled = 0;
-    work = CreateThreadpoolWork(threadpool_workcallback, &workcalled, &environment);
+    work = p___std_create_threadpool_work(threadpool_workcallback, &workcalled, &environment);
     ok(!!work, "failed to create threadpool_work\n");
     SubmitThreadpoolWork(work);
     WaitForThreadpoolWorkCallbacks(work, FALSE);
@@ -106,7 +115,7 @@ static void test_threadpool_work(void)
     environment3.Version = 3;
     environment3.CallbackPriority = TP_CALLBACK_PRIORITY_NORMAL;
     SetLastError(0xdeadbeef);
-    work = CreateThreadpoolWork(threadpool_workcallback, &workcalled,
+    work = p___std_create_threadpool_work(threadpool_workcallback, &workcalled,
                                           (TP_CALLBACK_ENVIRON *)&environment3);
     gle = GetLastError();
     ok(gle == 0xdeadbeef, "expected 0xdeadbeef, got %x\n", gle);
@@ -117,7 +126,7 @@ static void test_threadpool_work(void)
     environment3.Version = 3;
     environment3.CallbackPriority = TP_CALLBACK_PRIORITY_INVALID;
     SetLastError(0xdeadbeef);
-    work = CreateThreadpoolWork(threadpool_workcallback, &workcalled,
+    work = p___std_create_threadpool_work(threadpool_workcallback, &workcalled,
                                           (TP_CALLBACK_ENVIRON *)&environment3);
     gle = GetLastError();
     ok(gle == ERROR_INVALID_PARAMETER, "expected %d, got %d\n", ERROR_INVALID_PARAMETER, gle);




More information about the wine-cvs mailing list