Skip to content

Commit

Permalink
Export RAND_MAX symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
Sympatron committed Oct 25, 2024
1 parent ec8d0b3 commit 251d7dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub use self::abs::abs;

mod rand_r;
#[cfg(feature = "rand_r")]
pub use self::rand_r::rand_r;
pub use self::rand_r::{rand_r, RAND_MAX};
#[cfg(feature = "rand")]
mod rand;
#[cfg(feature = "rand")]
Expand Down
6 changes: 5 additions & 1 deletion src/rand_r.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
//! Licensed under the Blue Oak Model Licence 1.0.0
use core::ffi::{c_int, c_uint};

#[cfg_attr(not(feature = "rand_r"), export_name = "tinyrlibc_RAND_MAX")]
#[cfg_attr(feature = "rand_r", no_mangle)]
pub static RAND_MAX: c_int = 0x7FFF_FFFC as _;

/// Rust implementation of C library function `rand_r`
///
/// Passing NULL (core::ptr::null()) gives undefined behaviour.
Expand All @@ -29,7 +33,7 @@ pub unsafe extern "C" fn rand_r(seedp: *mut c_uint) -> c_int {

*seedp = next;

result
result - 1
}

#[cfg(test)]
Expand Down

0 comments on commit 251d7dc

Please sign in to comment.