forked from apple/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add _stdlib_random
for more platforms
#1
Merged
Azoy
merged 8 commits into
Azoy:random-unification
from
benrimmington:random-unification
Feb 10, 2018
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e61e1f5
Remove refs to Countable ranges
Azoy 3be8722
Add `_stdlib_random` for more platforms
benrimmington a66a5a7
Use `getrandom` (if available) for Android, Cygwin
benrimmington d4fceb2
Reorder the `_stdlib_random` functions
benrimmington e02595a
Merge branch 'random-unification' of https://github.com/Azoy/swift in…
benrimmington 24cf260
Also include <features.h> on Linux
benrimmington b145189
Add `#error TODO` in `_stdlib_random` for Windows
benrimmington d31a2e6
Colon after Fatal Error
Azoy File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Out of curiosity, why isn't this conditional written in the form of a macro? And why not just stick with
SecRandomCopyBytes
for all Apple platforms?(I recognize that this isn't being changed here, but I thought I'd ask.)
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.
Yea so Greg Parker brought this up as well in the actual pr, but I know a few on the mailing list had said that the Darwin solution should use
arc4random
. In addition to those comments, the whole family ofarc4random
is advertised as beingalways successful
on the mac man pagesman arc4random
, so removing the possibility of error in something I'm in favor of. Although, I do see using one solution for all versions as an easier implementation.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.
@xwu The original was using macros. I suggested __builtin_available because it should be a runtime conditional. AFAIK, until the stdlib is a system library,
MAC_OS_X_VERSION_MIN_REQUIRED
will always beMAC_OS_X_VERSION_10_9
(see supported target platforms).