-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Windows Port Continuation #1805
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
Conversation
Replace instances of raw `pthread_t` with `_CFThreadRef` to prepare for the Windows threading support.
Update the type definitions to use the native windows threading primitives on Windows targets
Windows does not use POSIX threads. We emulate some of the behaviours. The thread handle type on Windows is `HANDLE` rather than `pthread_t`. Use the invalid handle instead to indicate that we do not have the value yet.
On Windows, there is no `pthread_self`. Duplicate and leak the handle for the main thread. Since this is a global singleton, the overhead should be fine.
Define _CFThreadCreate in terms of _beginthreadex on Windows rather than pthread_create.
@swift-ci please test |
Use _binaryLoadable to ensure that the path exists rather than _urlExists.
Remove the error condition that no longer applies to the current code.
Add an assertion to ensure that we do not truncate the thread reference.
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me as is given that this is 1:1, with just the comment.
I'm late on this one, but re: the C11 thing - we use it for Darwin, and I'm ok with it here, assuming that all our target platforms support it. I didn't think VS had C11 support but happy to hear I'm wrong on that, if so. |
This replaces some of the threading types to allow us to use the Windows threading model rather than POSIX threads. This is still incomplete, but these should also be pretty safe without changing the semantics for the other platforms.