From 34f67c57223d73ad40d583ccc033c75eb0df2453 Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Fri, 21 Aug 2020 22:10:55 +0200 Subject: [PATCH] Explicitly rely on pthreads if possible allows us to set the needed stacksize on thread creation. Useful for environments with too small a default stack size (e.g. Alpine Linux with musl). Passed STC, no regression: LLR: 2.96 (-2.94,2.94) {-1.25,0.25} Total: 17816 W: 1344 L: 1275 D: 15197 Ptnml(0-2): 30, 1057, 6682, 1092, 47 https://tests.stockfishchess.org/tests/view/5f402b5587a5c3c63d8f534d closes https://github.com/official-stockfish/Stockfish/pull/3047 fixes https://github.com/official-stockfish/Stockfish/issues/3041 No functional change. --- src/Makefile | 1 + src/thread_win32_osx.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index b969ba04..74ef87b9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -417,6 +417,7 @@ endif ### On mingw use Windows threads, otherwise POSIX ifneq ($(comp),mingw) + CXXFLAGS += -DUSE_PTHREADS # On Android Bionic's C library comes with its own pthread implementation bundled in ifneq ($(OS),Android) # Haiku has pthreads in its libroot, so only link it in on other platforms diff --git a/src/thread_win32_osx.h b/src/thread_win32_osx.h index c4b55a48..75ef5d9a 100644 --- a/src/thread_win32_osx.h +++ b/src/thread_win32_osx.h @@ -27,7 +27,7 @@ /// The implementation calls pthread_create() with the stack size parameter /// equal to the linux 8MB default, on platforms that support it. -#if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__) +#if defined(__APPLE__) || defined(__MINGW32__) || defined(__MINGW64__) || defined(USE_PTHREADS) #include -- 2.39.2