Skip to content

Commit d9f7899

Browse files
committed
Revert "remove dispatch declarations; use CLinuxGCD"
This reverts commit af0b5e9.
1 parent af0b5e9 commit d9f7899

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

Package.resolved

Lines changed: 2 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ let package = Package(
5353
.package(url: "https://github.com/apple/swift-log", from: "1.6.2"),
5454
.package(url: "https://github.com/apple/swift-system", from: "1.0.0"),
5555
.package(url: "https://github.com/PADL/SocketAddress", from: "0.0.1"),
56-
.package(url: "https://github.com/PADL/CLinuxGCD", from: "6.0.2"),
5756
],
5857
targets: [
5958
.systemLibrary(
@@ -62,10 +61,7 @@ let package = Package(
6261
),
6362
.target(
6463
name: "CIORingShims",
65-
dependencies: ["CIOURing",
66-
.product(name: "CBlockHeaders", package: "CLinuxGCD"),
67-
.product(name: "CDispatchHeaders", package: "CLinuxGCD")
68-
],
64+
dependencies: ["CIOURing"],
6965
cSettings: [
7066
.define("_XOPEN_SOURCE=700"),
7167
.define("_DEFAULT_SOURCE"),
@@ -147,6 +143,8 @@ let package = Package(
147143
name: "IORingDeviceSpy",
148144
dependencies: ["IORing", "IORingUtils"],
149145
path: "Examples/IORingDeviceSpy"
150-
)
151-
]
146+
),
147+
],
148+
cLanguageStandard: .c18,
149+
cxxLanguageStandard: .cxx20
152150
)

Sources/CIORingShims/CQHandlerInternal.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,41 @@ extern "C" void *_Block_copy(const void *);
2828
extern "C" void _Block_release(const void *);
2929
#endif
3030

31+
#if __has_include(<dispatch/dispatch.h>)
3132
#include <dispatch/dispatch.h>
33+
#else
34+
// on Linux dispatch/dispatch.h is only available with unsafe Swift flags,
35+
// which preclude the use of this package as a versioned dependency
36+
struct dispatch_source_type_s {} __attribute__((aligned(sizeof(uintptr_t))));
37+
38+
typedef struct dispatch_source_s *dispatch_source_t;
39+
typedef struct dispatch_queue_s *dispatch_queue_t;
40+
typedef const struct dispatch_source_type_s *dispatch_source_type_t;
41+
42+
typedef void (^dispatch_block_t)(void);
43+
44+
extern "C" {
45+
extern const struct dispatch_source_type_s _dispatch_source_type_read;
46+
47+
void dispatch_release(void *object);
48+
void dispatch_resume(void *object);
49+
50+
void *dispatch_get_context(void *object);
51+
void dispatch_set_context(void *object, void *context);
52+
53+
void dispatch_source_cancel(void *object);
54+
void dispatch_source_set_event_handler(dispatch_source_t source, dispatch_block_t handler);
55+
void dispatch_source_set_cancel_handler(dispatch_source_t source, dispatch_block_t handler);
56+
57+
dispatch_queue_t dispatch_get_global_queue(intptr_t identifier, uintptr_t flags);
58+
dispatch_source_t dispatch_source_create(dispatch_source_type_t type, uintptr_t handle, uintptr_t mask, dispatch_queue_t queue);
59+
}
60+
61+
#define dispatch_cancel dispatch_source_cancel
62+
#define DISPATCH_QUEUE_PRIORITY_DEFAULT 0
63+
#define DISPATCH_SOURCE_TYPE_READ (&_dispatch_source_type_read)
64+
65+
#endif
3266

3367
#include "CIORingShims.h"
3468

0 commit comments

Comments
 (0)