From 35997c344c221bce1f343fa40de6f274721c71b1 Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Fri, 21 Jan 2022 15:51:08 -0800 Subject: [PATCH 2/2] msvcp140_atomic_wait: Implement __std_parallel_algorithms_hw_threads. Signed-off-by: Daniel Lehman --- copy of _Thrd_hardware_concurrency --- configure.ac | 1 + dlls/msvcp140_atomic_wait/Makefile.in | 3 + dlls/msvcp140_atomic_wait/main.c | 47 +++++++++++++++ .../msvcp140_atomic_wait.spec | 2 +- dlls/msvcp140_atomic_wait/tests/Makefile.in | 4 ++ .../tests/msvcp140_atomic_wait.c | 60 +++++++++++++++++++ 6 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 dlls/msvcp140_atomic_wait/main.c create mode 100644 dlls/msvcp140_atomic_wait/tests/Makefile.in create mode 100644 dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c diff --git a/configure.ac b/configure.ac index bf590be00725..181047ef0d85 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 8b51acf9060e..c7ce1fcb87d7 100644 --- a/dlls/msvcp140_atomic_wait/Makefile.in +++ b/dlls/msvcp140_atomic_wait/Makefile.in @@ -1 +1,4 @@ MODULE = msvcp140_atomic_wait.dll + +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 000000000000..51f20b8d8c79 --- /dev/null +++ b/dlls/msvcp140_atomic_wait/main.c @@ -0,0 +1,47 @@ +/* + * 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 +#include "windef.h" +#include "winbase.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(msvcp); + +BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) +{ + TRACE("(0x%p, %d, %p)\n", instance, reason, reserved); + return TRUE; +} + +unsigned int __stdcall __std_parallel_algorithms_hw_threads(void) +{ + static unsigned int val = -1; + + TRACE("()\n"); + + if (val == -1) + { + SYSTEM_INFO si; + + GetSystemInfo(&si); + val = si.dwNumberOfProcessors; + } + + return val; +} diff --git a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec index 34ca996f2f58..1e5d1a5128bc 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 000000000000..7f58d06d8f30 --- /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 000000000000..aee852afd986 --- /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 + +#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); +} -- 2.34.1