Module: wine
Branch: master
Commit: 2e88169d7be6ccfed9a79344bec59d92e82e4da4
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2e88169d7be6ccfed9a79344…
Author: Daniel Lehman <dlehman(a)esri.com>
Date: Wed Jan 26 17:24:35 2022 +0100
msvcp140_atomic_wait: Implement __std_parallel_algorithms_hw_threads.
Signed-off-by: Daniel Lehman <dlehman(a)esri.com>
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
configure | 1 +
configure.ac | 1 +
dlls/msvcp140_atomic_wait/Makefile.in | 4 ++
dlls/msvcp140_atomic_wait/main.c | 32 ++++++++++++
.../msvcp140_atomic_wait/msvcp140_atomic_wait.spec | 2 +-
dlls/msvcp140_atomic_wait/tests/Makefile.in | 4 ++
.../tests/msvcp140_atomic_wait.c | 60 ++++++++++++++++++++++
7 files changed, 103 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index ce3ecb0fee4..7760e43b8e9 100755
--- a/configure
+++ b/configure
@@ -22132,6 +22132,7 @@ wine_fn_config_makefile dlls/msvcp140/tests enable_tests
wine_fn_config_makefile dlls/msvcp140_1 enable_msvcp140_1
wine_fn_config_makefile dlls/msvcp140_1/tests enable_tests
wine_fn_config_makefile dlls/msvcp140_atomic_wait enable_msvcp140_atomic_wait
+wine_fn_config_makefile dlls/msvcp140_atomic_wait/tests enable_tests
wine_fn_config_makefile dlls/msvcp60 enable_msvcp60
wine_fn_config_makefile dlls/msvcp60/tests enable_tests
wine_fn_config_makefile dlls/msvcp70 enable_msvcp70
diff --git a/configure.ac b/configure.ac
index bf590be0072..181047ef0d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3056,6 +3056,7 @@ WINE_CONFIG_MAKEFILE(dlls/msvcp140/tests)
WINE_CONFIG_MAKEFILE(dlls/msvcp140_1)
WINE_CONFIG_MAKEFILE(dlls/msvcp140_1/tests)
WINE_CONFIG_MAKEFILE(dlls/msvcp140_atomic_wait)
+WINE_CONFIG_MAKEFILE(dlls/msvcp140_atomic_wait/tests)
WINE_CONFIG_MAKEFILE(dlls/msvcp60)
WINE_CONFIG_MAKEFILE(dlls/msvcp60/tests)
WINE_CONFIG_MAKEFILE(dlls/msvcp70)
diff --git a/dlls/msvcp140_atomic_wait/Makefile.in b/dlls/msvcp140_atomic_wait/Makefile.in
index 0d1aac64b53..42f8d7157b1 100644
--- a/dlls/msvcp140_atomic_wait/Makefile.in
+++ b/dlls/msvcp140_atomic_wait/Makefile.in
@@ -1 +1,5 @@
MODULE = msvcp140_atomic_wait.dll
+IMPORTS = msvcp140
+
+C_SRCS = \
+ main.c
diff --git a/dlls/msvcp140_atomic_wait/main.c b/dlls/msvcp140_atomic_wait/main.c
new file mode 100644
index 00000000000..5c430ffd959
--- /dev/null
+++ b/dlls/msvcp140_atomic_wait/main.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2022 Daniel Lehman
+ *
+ * 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 <stdarg.h>
+#include "windef.h"
+#include "winbase.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
+
+extern unsigned int __cdecl _Thrd_hardware_concurrency(void);
+
+unsigned int __stdcall __std_parallel_algorithms_hw_threads(void)
+{
+ TRACE("()\n");
+ return _Thrd_hardware_concurrency();
+}
diff --git a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec
index 34ca996f2f5..1e5d1a5128b 100644
--- a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec
+++ b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec
@@ -18,7 +18,7 @@
@ stub __std_execution_wait_on_uchar
@ stub __std_execution_wake_by_address_all
@ stub __std_free_crt
-@ stub __std_parallel_algorithms_hw_threads
+@ stdcall __std_parallel_algorithms_hw_threads()
@ stub __std_release_shared_mutex_for_instance
@ stub __std_submit_threadpool_work
@ stub __std_tzdb_delete_current_zone
diff --git a/dlls/msvcp140_atomic_wait/tests/Makefile.in b/dlls/msvcp140_atomic_wait/tests/Makefile.in
new file mode 100644
index 00000000000..7f58d06d8f3
--- /dev/null
+++ b/dlls/msvcp140_atomic_wait/tests/Makefile.in
@@ -0,0 +1,4 @@
+TESTDLL = msvcp140_atomic_wait.dll
+
+C_SRCS = \
+ msvcp140_atomic_wait.c
diff --git a/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c
new file mode 100644
index 00000000000..aee852afd98
--- /dev/null
+++ b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2022 Daniel Lehman
+ *
+ * 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 <stdio.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wine/test.h"
+
+static unsigned int (__stdcall *p___std_parallel_algorithms_hw_threads)(void);
+
+#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)
+{
+ HMODULE msvcp;
+
+ if (!(msvcp = LoadLibraryA("msvcp140_atomic_wait.dll")))
+ return NULL;
+
+ SET(p___std_parallel_algorithms_hw_threads, "__std_parallel_algorithms_hw_threads");
+ return msvcp;
+}
+
+static void test___std_parallel_algorithms_hw_threads(void)
+{
+ SYSTEM_INFO si;
+ unsigned int nthr;
+
+ GetSystemInfo(&si);
+ nthr = p___std_parallel_algorithms_hw_threads();
+ ok(nthr == si.dwNumberOfProcessors, "expected %u, got %u\n", si.dwNumberOfProcessors, nthr);
+}
+
+START_TEST(msvcp140_atomic_wait)
+{
+ HMODULE msvcp;
+ if (!(msvcp = init()))
+ {
+ win_skip("msvcp140_atomic_wait.dll not installed\n");
+ return;
+ }
+ test___std_parallel_algorithms_hw_threads();
+ FreeLibrary(msvcp);
+}