[Threading] Create new threading library and use it.

Moved all the threading code to one place.  Added explicit support for
Darwin, Linux, Pthreads, C11 threads and Win32 threads, including new
implementations of Once for Linux, Pthreads, C11 and Win32.

rdar://90776105
This commit is contained in:
Alastair Houghton
2022-04-15 13:50:33 +01:00
parent 66b9d21000
commit f5bdb858e0
98 changed files with 2286 additions and 1410 deletions

View File

@@ -6,6 +6,19 @@ include(${CMAKE_CURRENT_LIST_DIR}/../../../cmake/modules/Threading.cmake)
precondition(SWIFT_HOST_VARIANT_SDK)
precondition(SWIFT_DARWIN_PLATFORMS)
# +----------------------------------------------------------------------+
# | |
# | NOTE: It makes no sense setting defaults here on the basis of |
# | SWIFT_HOST_VARIANT_SDK, because the stdlib is a *TARGET* |
# | library, not a host library. |
# | |
# | Rather, if you have a default to set, you need to do that |
# | in AddSwiftStdlib.cmake, in an appropriate place, |
# | likely on the basis of CFLAGS_SDK, SWIFTLIB_SINGLE_SDK or |
# | similar. |
# | |
# +----------------------------------------------------------------------+
if("${SWIFT_HOST_VARIANT_SDK}" MATCHES "CYGWIN")
set(SWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING_default FALSE)
elseif("${SWIFT_HOST_VARIANT_SDK}" MATCHES "HAIKU")
@@ -178,6 +191,16 @@ else()
set(SWIFT_CONCURRENCY_GLOBAL_EXECUTOR_default "dispatch")
endif()
include(Threading)
threading_package_default("${SWIFT_HOST_VARIANT_SDK}"
SWIFT_THREADING_PACKAGE_default)
set(SWIFT_THREADING_PACKAGE "${SWIFT_THREADING_PACKAGE_default}"
CACHE STRING
"The threading package to use. Must be one of 'none', 'pthreads',
'darwin', 'linux', 'win32', 'c11'.")
set(SWIFT_CONCURRENCY_GLOBAL_EXECUTOR
"${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR_default}" CACHE STRING
"Build the concurrency library to use the given global executor (options: dispatch, singlethreaded, hooked)")