Skip to content

Commit

Permalink
Rename __getrandom_custom to __getrandom_v03_custom
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Oct 20, 2024
1 parent 41817c7 commit 6940716
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nopanic_check/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub extern "C" fn getrandom_wrapper(buf_ptr: *mut u8, buf_len: usize) -> u32 {

#[cfg(getrandom_backend = "custom")]
#[no_mangle]
unsafe extern "Rust" fn __getrandom_custom(
unsafe extern "Rust" fn __getrandom_v03_custom(
dest: *mut u8,
len: usize,
) -> Result<(), getrandom::Error> {
Expand Down
4 changes: 2 additions & 2 deletions src/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::mem::MaybeUninit;

pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
extern "Rust" {
fn __getrandom_custom(dest: *mut u8, len: usize) -> Result<(), Error>;
fn __getrandom_v03_custom(dest: *mut u8, len: usize) -> Result<(), Error>;
}
unsafe { __getrandom_custom(dest.as_mut_ptr().cast(), dest.len()) }
unsafe { __getrandom_v03_custom(dest.as_mut_ptr().cast(), dest.len()) }
}
10 changes: 8 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@
//! use getrandom::Error;
//!
//! #[no_mangle]
//! unsafe extern "Rust" fn __getrandom_custom(dest: *mut u8, len: usize) -> Result<(), Error> {
//! unsafe extern "Rust" fn __getrandom_v03_custom(
//! dest: *mut u8,
//! len: usize,
//! ) -> Result<(), Error> {
//! todo!()
//! }
//! ```
Expand All @@ -133,7 +136,10 @@
//! use getrandom::Error;
//!
//! #[no_mangle]
//! unsafe extern "Rust" fn __getrandom_custom(dest: *mut u8, len: usize) -> Result<(), Error> {
//! unsafe extern "Rust" fn __getrandom_v03_custom(
//! dest: *mut u8,
//! len: usize,
//! ) -> Result<(), Error> {
//! Err(Error::UNSUPPORTED)
//! }
//! ```
Expand Down
2 changes: 1 addition & 1 deletion tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ mod custom {
//
// WARNING: this custom implementation is for testing purposes ONLY!
#[no_mangle]
unsafe extern "Rust" fn __getrandom_custom(dest: *mut u8, len: usize) -> Result<(), Error> {
unsafe extern "Rust" fn __getrandom_v03_custom(dest: *mut u8, len: usize) -> Result<(), Error> {
use std::time::{SystemTime, UNIX_EPOCH};

assert_ne!(len, 0);
Expand Down

0 comments on commit 6940716

Please sign in to comment.