-
Notifications
You must be signed in to change notification settings - Fork 181
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
Use configuration flags to switch between backends #504
base: master
Are you sure you want to change the base?
Conversation
#[cfg(not(any(target_arch = "x86_64", target_arch = "x86")))] | ||
compile_error!("`rdrand` backend can be enabled only for x86 and x86-64 targets!"); | ||
#[path = "rdrand.rs"] mod imp; | ||
} else if #[cfg(getrandom_backend = "wasm_js")] { |
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.
We could split wasm_js
feature further into wasm_node
and wasm_web
parts. But I don't know whether people need WASM files which can run both on Node and Web.
Alternatively, we could make the JS backend enabled by default and require users targeting non-JS WASM to enable the custom backend. But personally I dislike such approach since it's technically wrong and we play into the poor handling of the wasm32-unknown-unknown
target by the Rust ecosystem.
// `len`). | ||
let dest = uninit_slice_fill_zero(dest); | ||
let ret = unsafe { __getrandom_custom(dest.as_mut_ptr(), dest.len()) }; | ||
let ret = unsafe { __getrandom_custom(dest.as_mut_ptr().cast(), dest.len()) }; |
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.
Note that in v0.3 we no longer need to zeroize the destination buffer since we can specify that uninitialized buffers may be passed to __getrandom_custom
.
We also probably could use NonZeroUsize
for len
to improve code generation for __getrandom_custom
provider.
#[path = "js.rs"] mod imp; | ||
} else if #[cfg(getrandom_backend = "esp_idf")] { | ||
#[cfg(not(target_os = "espidf"))] | ||
compile_error!("`esp_idf` backend can be enabled only for ESP-IDF targets!"); |
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.
ESP-IDF support is now optional because of the concerns raised in #397.
cc @briansmith |
Closes #498