Skip to content

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

Merged
merged 9 commits into from
Dec 15, 2018
Merged

Windows Port Continuation #1805

merged 9 commits into from
Dec 15, 2018

Conversation

compnerd
Copy link
Member

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.

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.
@compnerd
Copy link
Member Author

CC: @millenomi @parkera @phausler

@compnerd
Copy link
Member Author

@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.
@compnerd
Copy link
Member Author

@swift-ci please test

Copy link
Contributor

@millenomi millenomi left a 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.

@compnerd compnerd merged commit a9c0598 into swiftlang:master Dec 15, 2018
@compnerd compnerd deleted the windows-3 branch December 15, 2018 02:34
@parkera
Copy link
Contributor

parkera commented Dec 20, 2018

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.

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.

4 participants