-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Provide an implementation of swift_stdlib_random()
derived from std::random_device
.
#84542
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
base: main
Are you sure you want to change the base?
Conversation
…d::random_device`. This PR provides an alternate platform-agnostic implementation of `swift_stdlib_random()` based on C++11's `std::random_device`. This implementation should be portable even to Embedded Swift, with the significant caveat that there is no way to know at compile time if the random numbers produced are _actually_ non-deterministic. (They _should_ be, but if the current implementation has no suitable RNG, the API doesn't provide a way to detect that statically.)
@swift-ci test |
@swift-ci test |
Embedded Swift doesn’t currently use |
The embedded version is defined here swift/stdlib/public/core/EmbeddedRuntime.swift Lines 536 to 541 in b15e24a
|
Thanks. I posted this for the sake of discussion. |
To clarify: there was a hallway discussion about needing an implementation of |
Math is hard.
@swift-ci test |
This PR provides an alternate platform-agnostic implementation of
swift_stdlib_random()
based on C++11'sstd::random_device
. This implementation should be portable even to Embedded Swift, with the significant caveat that there is no way to know at compile time if the random numbers produced are actually non-deterministic. (They should be, but if the current implementation has no suitable RNG, the API doesn't provide a way to detect that statically.)