Skip to content
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

[FreeBSD] Enable CFRunLoop support #5188

Open
wants to merge 1 commit 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
2 changes: 1 addition & 1 deletion Sources/CoreFoundation/CFRunLoop.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ 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 defined(__linux__)
typedef int dispatch_runloop_handle_t;
Copy link
Member

Choose a reason for hiding this comment

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

I believe that there is a type mismatch here which could truncate the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing || defined(__FreeBSD__) here makes dispatch_runloop_handle_t type alias to 'uint64_t' (line 80), which fallback to the generic unix implementation.

Currently, although the runloop handle type is defined for FreeBSD, it is not doing anything useful.

#elif TARGET_OS_WIN32
typedef HANDLE dispatch_runloop_handle_t;
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)
#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