From e2f3c494fe595ffd7bd54c5e45f325d77f61b804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Sun, 12 Mar 2023 14:42:05 +0300 Subject: [PATCH] Switch the custom backend to Rust ABI --- src/custom.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/custom.rs b/src/custom.rs index 76445ccf..c9207d06 100644 --- a/src/custom.rs +++ b/src/custom.rs @@ -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; @@ -97,7 +97,7 @@ macro_rules! register_custom_getrandom { #[allow(dead_code)] pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { - extern "C" { + extern "Rust" { fn __getrandom_custom(dest: *mut u8, len: usize) -> u32; } // Previously we always passed a valid, initialized slice to