Skip to content

[FreeBSD] Enable CFRunLoop support #5188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Sources/CoreFoundation/CFRunLoop.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ extern bool _dispatch_runloop_root_queue_perform_4CF(dispatch_queue_t queue);

#if TARGET_OS_MAC
typedef mach_port_t dispatch_runloop_handle_t;
#elif defined(__linux__) || defined(__FreeBSD__)
#elif TARGET_OS_LINUX
typedef int dispatch_runloop_handle_t;
#elif TARGET_OS_BSD
typedef uint64_t dispatch_runloop_handle_t;
#elif TARGET_OS_WIN32
typedef HANDLE dispatch_runloop_handle_t;
#else
typedef uint64_t dispatch_runloop_handle_t;
#error "runloop support not implemented on this platform"
#endif

#if TARGET_OS_MAC
Expand Down
2 changes: 1 addition & 1 deletion Sources/Foundation/RunLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ open class RunLoop: NSObject {
// Make sure we honor the override -- var currentCFRunLoop will do so on platforms where overrides are available.

// TODO: This has been removed as public API in port to the package, because CoreFoundation cannot be available as both toolchain "CoreFoundation" and package "_CoreFoundation"
#if os(Linux) || os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(OpenBSD)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just be #if !os(Windows)? Otherwise it seems like we'll just need to keep tweaking this over and over again. We probably want to take this code path on visionOS, NetBSD, Solaris, Android, and so on, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not necessarily true, since whether we should enable this code path depends on if such platform implemented the bits to support CFRunLoop, which is not necessarily true and by default we should assume it does not have support.

#if os(Linux) || os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(OpenBSD) || os(FreeBSD)
internal var currentCFRunLoop: CFRunLoop { getCFRunLoop() }

internal func getCFRunLoop() -> CFRunLoop {
Expand Down