Merge pull request #406 from adierking/printflike
dispatch_c99: remove unnecessary __printflike() definition
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b0a23e..f0632af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,38 +44,32 @@
option(ENABLE_DISPATCH_INIT_CONSTRUCTOR "enable libdispatch_init as a constructor" ON)
set(USE_LIBDISPATCH_INIT_CONSTRUCTOR ${ENABLE_DISPATCH_INIT_CONSTRUCTOR})
+# NOTE(abdulras) this is the CMake supported way to control whether we generate
+# shared or static libraries. This impacts the behaviour of `add_library` in
+# what type of library it generates.
+option(BUILD_SHARED_LIBS "build shared libraries" ON)
+
option(ENABLE_SWIFT "enable libdispatch swift overlay" OFF)
if(ENABLE_SWIFT)
if(NOT CMAKE_SWIFT_COMPILER)
message(FATAL_ERROR "CMAKE_SWIFT_COMPILER must be defined to enable swift")
endif()
- get_filename_component(SWIFT_TOOLCHAIN ${CMAKE_SWIFT_COMPILER} DIRECTORY)
- get_filename_component(SWIFT_TOOLCHAIN ${SWIFT_TOOLCHAIN} DIRECTORY)
+ find_package(Swift REQUIRED CONFIG)
- string(TOLOWER ${CMAKE_SYSTEM_NAME} SWIFT_OS)
- get_swift_host_arch(SWIFT_HOST_ARCH)
+ string(TOLOWER ${CMAKE_SYSTEM_NAME} swift_os)
+ get_swift_host_arch(swift_arch)
- set(SWIFT_RUNTIME_LIBDIR ${SWIFT_TOOLCHAIN}/${SWIFT_LIBDIR}/swift/${SWIFT_OS}/${SWIFT_HOST_ARCH})
+ if(BUILD_SHARED_LIBS)
+ set(swift_dir swift)
+ else()
+ set(swift_dir swift_static)
+ endif()
- add_library(swiftCore
- SHARED IMPORTED GLOBAL)
- set_target_properties(swiftCore
- PROPERTIES
- IMPORTED_LOCATION
- ${SWIFT_RUNTIME_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}swiftCore${CMAKE_SHARED_LIBRARY_SUFFIX})
-
- add_library(swiftSwiftOnoneSupport
- SHARED IMPORTED GLOBAL)
- set_target_properties(swiftSwiftOnoneSupport
- PROPERTIES
- IMPORTED_LOCATION
- ${SWIFT_RUNTIME_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}swiftSwiftOnoneSupport${CMAKE_SHARED_LIBRARY_SUFFIX})
-
- set(INSTALL_TARGET_DIR "${INSTALL_LIBDIR}/swift/${SWIFT_OS}" CACHE PATH "Path where the libraries will be installed")
- set(INSTALL_DISPATCH_HEADERS_DIR "${INSTALL_LIBDIR}/swift/dispatch" CACHE PATH "Path where the headers will be installed for libdispatch")
- set(INSTALL_BLOCK_HEADERS_DIR "${INSTALL_LIBDIR}/swift/Block" CACHE PATH "Path where the headers will be installed for the blocks runtime")
- set(INSTALL_OS_HEADERS_DIR "${INSTALL_LIBDIR}/swift/os" CACHE PATH "Path where the os/ headers will be installed")
+ set(INSTALL_TARGET_DIR "${INSTALL_LIBDIR}/${swift_dir}/${swift_os}" CACHE PATH "Path where the libraries will be installed")
+ set(INSTALL_DISPATCH_HEADERS_DIR "${INSTALL_LIBDIR}/${swift_dir}/dispatch" CACHE PATH "Path where the headers will be installed for libdispatch")
+ set(INSTALL_BLOCK_HEADERS_DIR "${INSTALL_LIBDIR}/${swift_dir}/Block" CACHE PATH "Path where the headers will be installed for the blocks runtime")
+ set(INSTALL_OS_HEADERS_DIR "${INSTALL_LIBDIR}/${swift_dir}/os" CACHE PATH "Path where the os/ headers will be installed")
endif()
if(NOT ENABLE_SWIFT)
@@ -87,11 +81,6 @@
option(ENABLE_DTRACE "enable dtrace support" "")
-# NOTE(abdulras) this is the CMake supported way to control whether we generate
-# shared or static libraries. This impacts the behaviour of `add_library` in
-# what type of library it generates.
-option(BUILD_SHARED_LIBS "build shared libraries" ON)
-
option(ENABLE_TESTING "build libdispatch tests" ON)
option(USE_LLD_LINKER "use the lld linker" FALSE)
diff --git a/cmake/modules/SwiftSupport.cmake b/cmake/modules/SwiftSupport.cmake
index bae1f9f..2a3f4d6 100644
--- a/cmake/modules/SwiftSupport.cmake
+++ b/cmake/modules/SwiftSupport.cmake
@@ -101,6 +101,8 @@
set("${result_var_name}" "itanium" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86")
set("${result_var_name}" "i686" PARENT_SCOPE)
+ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
+ set("${result_var_name}" "i686" PARENT_SCOPE)
else()
message(FATAL_ERROR "Unrecognized architecture on host system: ${CMAKE_SYSTEM_PROCESSOR}")
endif()
diff --git a/private/queue_private.h b/private/queue_private.h
index f71e5e3..b7ab515 100644
--- a/private/queue_private.h
+++ b/private/queue_private.h
@@ -342,7 +342,7 @@
* "detached" before the thread exits or the application will crash.
*/
DISPATCH_EXPORT
-void _dispatch_install_thread_detach_callback(dispatch_function_t cb);
+void _dispatch_install_thread_detach_callback(void (*cb)(void));
#endif
__END_DECLS
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9782fed..efe3aed 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -112,11 +112,16 @@
${swift_optimization_flags}
DEPENDS
${PROJECT_SOURCE_DIR}/dispatch/module.modulemap)
+
+ get_filename_component(swift_toolchain ${CMAKE_SWIFT_COMPILER} DIRECTORY)
+ get_filename_component(swift_toolchain ${swift_toolchain} DIRECTORY)
+ set(swift_runtime_libdir ${swift_toolchain}/lib/${swift_dir}/${swift_os}/${swift_arch})
+
target_sources(dispatch
PRIVATE
swift/DispatchStubs.cc
${CMAKE_CURRENT_BINARY_DIR}/swiftDispatch.o
- ${SWIFT_RUNTIME_LIBDIR}/swiftrt.o)
+ ${swift_runtime_libdir}/swiftrt.o)
if(CMAKE_BUILD_TYPE MATCHES Debug)
target_link_libraries(dispatch
PRIVATE
diff --git a/src/queue.c b/src/queue.c
index 6c7593f..b2e1f91 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -953,7 +953,7 @@
static void (*_dispatch_thread_detach_callback)(void);
void
-_dispatch_install_thread_detach_callback(dispatch_function_t cb)
+_dispatch_install_thread_detach_callback(void (*cb)(void))
{
if (os_atomic_xchg(&_dispatch_thread_detach_callback, cb, relaxed)) {
DISPATCH_CLIENT_CRASH(0, "Installing a thread detach callback twice");
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 3d0ccdd..eca431c 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -59,8 +59,8 @@
if(ENABLE_SWIFT)
target_link_libraries(bsdtestharness
PRIVATE
- swiftCore
- swiftSwiftOnoneSupport)
+ swiftCore-${swift_os}-${swift_arch}
+ swiftSwiftOnoneSupport-${swift_os}-${swift_arch})
endif()
function(add_unit_test name)
@@ -83,7 +83,10 @@
# For testing in swift.org CI system; make deadlines lenient by default
# to reduce probability of test failures due to machine load.
target_compile_options(${name} PRIVATE -DLENIENT_DEADLINES=1)
- target_link_libraries(${name} PRIVATE swiftCore swiftSwiftOnoneSupport)
+ target_link_libraries(${name}
+ PRIVATE
+ swiftCore-${swift_os}-${swift_arch}
+ swiftSwiftOnoneSupport-${swift_os}-${swift_arch})
endif()
target_include_directories(${name}
SYSTEM BEFORE PRIVATE
@@ -114,8 +117,8 @@
if(ENABLE_SWIFT)
target_link_libraries(${name}
PRIVATE
- swiftCore
- swiftSwiftOnoneSupport)
+ swiftCore-${swift_os}-${swift_arch}
+ swiftSwiftOnoneSupport-${swift_os}-${swift_arch})
endif()
target_link_libraries(${name} PRIVATE bsdtests)
add_test(NAME ${name}