Skip to content

Commit

Permalink
remove dispatch declarations; use CLinuxGCD
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoward committed Nov 30, 2024
1 parent c5c26fd commit af0b5e9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 41 deletions.
13 changes: 11 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"version" : "0.9.0"
}
},
{
"identity" : "clinuxgcd",
"kind" : "remoteSourceControl",
"location" : "https://github.com/PADL/CLinuxGCD",
"state" : {
"revision" : "75635d354c4ef14675803e2d6c5dd08026e7b61a",
"version" : "6.0.2"
}
},
{
"identity" : "socketaddress",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -59,8 +68,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log",
"state" : {
"revision" : "9cb486020ebf03bfa5b5df985387a14a98744537",
"version" : "1.6.1"
"revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91",
"version" : "1.6.2"
}
},
{
Expand Down
12 changes: 7 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-log", from: "1.6.2"),
.package(url: "https://github.com/apple/swift-system", from: "1.0.0"),
.package(url: "https://github.com/PADL/SocketAddress", from: "0.0.1"),
.package(url: "https://github.com/PADL/CLinuxGCD", from: "6.0.2"),
],
targets: [
.systemLibrary(
Expand All @@ -61,7 +62,10 @@ let package = Package(
),
.target(
name: "CIORingShims",
dependencies: ["CIOURing"],
dependencies: ["CIOURing",
.product(name: "CBlockHeaders", package: "CLinuxGCD"),
.product(name: "CDispatchHeaders", package: "CLinuxGCD")
],
cSettings: [
.define("_XOPEN_SOURCE=700"),
.define("_DEFAULT_SOURCE"),
Expand Down Expand Up @@ -143,8 +147,6 @@ let package = Package(
name: "IORingDeviceSpy",
dependencies: ["IORing", "IORingUtils"],
path: "Examples/IORingDeviceSpy"
),
],
cLanguageStandard: .c18,
cxxLanguageStandard: .cxx20
)
]
)
34 changes: 0 additions & 34 deletions Sources/CIORingShims/CQHandlerInternal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,7 @@ extern "C" void *_Block_copy(const void *);
extern "C" void _Block_release(const void *);
#endif

#if __has_include(<dispatch/dispatch.h>)
#include <dispatch/dispatch.h>
#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 "C" {
extern const struct dispatch_source_type_s _dispatch_source_type_read;

void dispatch_release(void *object);
void dispatch_resume(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);

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);
}

#define dispatch_cancel dispatch_source_cancel
#define DISPATCH_QUEUE_PRIORITY_DEFAULT 0
#define DISPATCH_SOURCE_TYPE_READ (&_dispatch_source_type_read)

#endif

#include "CIORingShims.h"

Expand Down

0 comments on commit af0b5e9

Please sign in to comment.