Skip to content

Commit d1b5230

Browse files
Backport a patch from qthreads that switches to the fallback implementation of context swapping on ppc64le since the fast one is broken there.
Signed-off-by: Ian Henriksen <iandhenriksen@gmail.com>
1 parent 924a78e commit d1b5230

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

third-party/qthread/qthread-src/src/CMakeLists.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,26 @@ set(QTHREADS_DEFAULT_STACK_SIZE 32768 CACHE STRING "Default qthread stack size."
88
set(QTHREADS_HASHMAP hashmap CACHE STRING "Which hashmap implementation to use. Valid values are \"hashmap\" and \"lf_hashmap\".")
99
set(QTHREADS_DICT_TYPE shavit CACHE STRING "Which dictionary implementation to use. Valid values are \"shavit\", \"trie\", and \"simple\".")
1010
set(QTHREADS_TIMER_TYPE gettimeofday CACHE STRING "Which timer implementation to use. Valid values are \"clock_gettime\", \"mach\", \"gettimeofday\", and \"gethrtime\".")
11-
set(QTHREADS_CONTEXT_SWAP_IMPL fastcontext CACHE STRING "Which context swap implementation to use. Valid values are \"system\" and \"fastcontext\".")
11+
# Only default to the fastcontext implementation in cases where it's confirmed to work.
12+
# Note: apparently 32-bit x86 may show up as i386, i486, i586, or i686.
13+
# Little-endian powerpc variants are excluded here as they're known not to work
14+
# due to an unresolved bug in our fastcontext code.
15+
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR
16+
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64" OR
17+
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR
18+
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64" OR
19+
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm" OR
20+
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386" OR
21+
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i486" OR
22+
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i586" OR
23+
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686" OR
24+
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64" OR
25+
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc")
26+
set(QTHREADS_CONTEXT_SWAP_IMPL fastcontext CACHE STRING "Which context swap implementation to use. Valid values are \"system\" and \"fastcontext\".")
27+
else()
28+
message(WARNING "No fast context swap available on this system, falling back to the system-provided one.")
29+
set(QTHREADS_CONTEXT_SWAP_IMPL system CACHE STRING "Which context swap implementation to use. Valid values are \"system\" and \"fastcontext\".")
30+
endif()
1231
set(QTHREADS_HWLOC_GET_TOPOLOGY_FUNCTION "" CACHE STRING "function to get hwloc topology (otherwise uses hwloc_topology_init and hwloc_topology_load)")
1332
set(QTHREADS_GUARD_PAGES OFF CACHE BOOL "Whether or not to guard memory pages to help with debugging stack overflows. Default is OFF.")
1433
set(QTHREADS_CONDWAIT_QUEUE OFF CACHE BOOL "Use a waiting queue based on pthread condition variables instead of a spin-based queue for inter-thread communication. Default is OFF.")

0 commit comments

Comments
 (0)