diff --git a/Package.resolved b/Package.resolved index bcdba49..88ba5ac 100644 --- a/Package.resolved +++ b/Package.resolved @@ -9,6 +9,15 @@ "version" : "0.9.0" } }, + { + "identity" : "clinuxgcd", + "kind" : "remoteSourceControl", + "location" : "https://github.com/PADL/CLinuxGCD.git", + "state" : { + "revision" : "75635d354c4ef14675803e2d6c5dd08026e7b61a", + "version" : "6.0.2" + } + }, { "identity" : "ioringswift", "kind" : "remoteSourceControl", diff --git a/Package.swift b/Package.swift index 3834123..eedcbf6 100644 --- a/Package.swift +++ b/Package.swift @@ -44,6 +44,7 @@ let package = Package( // Dependencies declare other packages that this package depends on. .package(url: "https://github.com/madmachineio/SwiftIO", from: "0.1.0"), .package(url: "https://github.com/PADL/IORingSwift.git", from: "0.1.2"), + .package(url: "https://github.com/PADL/CLinuxGCD.git", from: "6.0.2"), .package(url: "https://github.com/apple/swift-async-algorithms", from: "1.0.0"), .package(url: "https://github.com/lhoward/AsyncExtensions", from: "0.9.0"), .package(url: "https://github.com/apple/swift-system", from: "1.0.0"), @@ -53,6 +54,8 @@ let package = Package( name: "LinuxHalSwiftIO", dependencies: [ .product(name: "CSwiftIO", package: "SwiftIO"), + .product(name: "CBlockHeaders", package: "CLinuxGCD"), + .product(name: "CDispatchHeaders", package: "CLinuxGCD") ], linkerSettings: [ .linkedLibrary("gpiod", .when(platforms: [.linux])), diff --git a/Sources/LinuxHalSwiftIO/swift_hal_internal.h b/Sources/LinuxHalSwiftIO/swift_hal_internal.h index 6eba55d..3332894 100644 --- a/Sources/LinuxHalSwiftIO/swift_hal_internal.h +++ b/Sources/LinuxHalSwiftIO/swift_hal_internal.h @@ -16,12 +16,6 @@ #pragma once -#include -#include -#include - -#include - #if __has_include() #include #elif __has_include() @@ -31,51 +25,7 @@ void *_Block_copy(const void *); void _Block_release(const void *); #endif -#if __has_include() #include -#else -// on Linux dispatch/dispatch.h is only available with unsafe Swift flags, -// which preclude the use of this package as a versioned dependency -struct dispatch_source_type_s {} __attribute__((aligned(sizeof(uintptr_t)))); - -typedef struct dispatch_source_s *dispatch_source_t; -typedef struct dispatch_queue_s *dispatch_queue_t; -typedef const struct dispatch_source_type_s *dispatch_source_type_t; - -typedef void (^dispatch_block_t)(void); - -extern const struct dispatch_source_type_s _dispatch_source_type_read; -extern const struct dispatch_source_type_s _dispatch_source_type_write; -extern const struct dispatch_source_type_s _dispatch_source_type_timer; - -void dispatch_release(void *object); -void dispatch_resume(void *object); -void dispatch_suspend(void *object); - -void *dispatch_get_context(void *object); -void dispatch_set_context(void *object, void *context); - -void dispatch_source_cancel(void *object); -void dispatch_source_set_event_handler(dispatch_source_t source, dispatch_block_t handler); -void dispatch_source_set_cancel_handler(dispatch_source_t source, dispatch_block_t handler); - -typedef uint64_t dispatch_time_t; - -uintptr_t dispatch_source_get_handle(dispatch_source_t source); - -dispatch_queue_t dispatch_get_global_queue(intptr_t identifier, uintptr_t flags); -dispatch_source_t dispatch_source_create(dispatch_source_type_t type, uintptr_t handle, uintptr_t mask, dispatch_queue_t queue); -void dispatch_source_set_timer(dispatch_source_t source, dispatch_time_t start, uint64_t interval, uint64_t leeway); -dispatch_time_t dispatch_time(dispatch_time_t when, int64_t delta); - -#define dispatch_cancel dispatch_source_cancel -#define DISPATCH_QUEUE_PRIORITY_DEFAULT 0 -#define DISPATCH_SOURCE_TYPE_READ (&_dispatch_source_type_read) -#define DISPATCH_SOURCE_TYPE_WRITE (&_dispatch_source_type_write) -#define DISPATCH_SOURCE_TYPE_TIMER (&_dispatch_source_type_timer) -#define DISPATCH_TIME_NOW (0ull) -#define DISPATCH_TIME_FOREVER (~0ull) -#endif #include