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

Fix FreeBSD build and test #1149

Merged
merged 2 commits into from
Feb 3, 2025
Merged

Conversation

michael-yuji
Copy link
Contributor

Summary

This PR fixes building swift-docc on x86_64 FreeBSD

Testing

All test passes!

Build complete! (10.02s)
[1772/1772] Testing SwiftDocCTests.SwiftLMDBTests/testMultipleCustomObjects
➜  swift-docc git:(freebsd-wip) uname -msr
FreeBSD 14.1-RELEASE-p6 amd64

@michael-yuji
Copy link
Contributor Author

@swift-ci please test

@@ -53,6 +56,10 @@ public class Synchronized<Value> {
lock = UnsafeMutablePointer<pthread_mutex_t>.allocate(capacity: 1)
lock.initialize(to: pthread_mutex_t())
pthread_mutex_init(lock, nil)
#elseif os(FreeBSD)
lock = UnsafeMutablePointer<pthread_mutex_t?>.allocate(capacity: 1)
lock.initialize(to: nil)
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 be an initialized to pthread_mutex_t() like above (or rolled into the same #if scopes as the above?

Copy link
Contributor Author

@michael-yuji michael-yuji Jan 24, 2025

Choose a reason for hiding this comment

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

he main difference on BSD (FreeBSD, OpenBSD) platforms is that the lock type is a pthread_mutex_t? instead of pthread_mutex_t. This is due to on the BSDs, pthread_mutex_t is in fact a struct pthread_mutex pointer, thus it does not come with a default .init() constructor and we need initialize it to nil instead.

ref: http://fxr.watson.org/fxr/source/sys/_pthreadtypes.h?v=FREEBSD-13-STABLE;im=10#L71

Copy link
Contributor

@d-ronnqvist d-ronnqvist left a comment

Choose a reason for hiding this comment

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

Thank you. This looks good to me.

@d-ronnqvist
Copy link
Contributor

@swift-ci please test

@d-ronnqvist d-ronnqvist merged commit 4fd8aeb into swiftlang:main Feb 3, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants