Skip to content
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

Switch the custom backend to Rust ABI #347

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Switch the custom backend to Rust ABI
  • Loading branch information
newpavlov committed Mar 12, 2023
commit e2f3c494fe595ffd7bd54c5e45f325d77f61b804
6 changes: 3 additions & 3 deletions src/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ macro_rules! register_custom_getrandom {
($path:path) => {
// TODO(MSRV 1.37): change to unnamed block
const __getrandom_internal: () = {
// We use an extern "C" function to get the guarantees of a stable ABI.
// We use Rust ABI to be safe against potential panics in the passed function.
#[no_mangle]
unsafe extern "C" fn __getrandom_custom(dest: *mut u8, len: usize) -> u32 {
unsafe fn __getrandom_custom(dest: *mut u8, len: usize) -> u32 {
// Make sure the passed function has the type of getrandom::getrandom
type F = fn(&mut [u8]) -> ::core::result::Result<(), $crate::Error>;
let _: F = $crate::getrandom;
Expand All @@ -97,7 +97,7 @@ macro_rules! register_custom_getrandom {

#[allow(dead_code)]
pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
extern "C" {
extern "Rust" {
fn __getrandom_custom(dest: *mut u8, len: usize) -> u32;
}
// Previously we always passed a valid, initialized slice to
Expand Down