Skip to content

Commit 251d7dc

Browse files
committed
Export RAND_MAX symbol
1 parent ec8d0b3 commit 251d7dc

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub use self::abs::abs;
2828

2929
mod rand_r;
3030
#[cfg(feature = "rand_r")]
31-
pub use self::rand_r::rand_r;
31+
pub use self::rand_r::{rand_r, RAND_MAX};
3232
#[cfg(feature = "rand")]
3333
mod rand;
3434
#[cfg(feature = "rand")]

src/rand_r.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
//! Licensed under the Blue Oak Model Licence 1.0.0
44
use core::ffi::{c_int, c_uint};
55

6+
#[cfg_attr(not(feature = "rand_r"), export_name = "tinyrlibc_RAND_MAX")]
7+
#[cfg_attr(feature = "rand_r", no_mangle)]
8+
pub static RAND_MAX: c_int = 0x7FFF_FFFC as _;
9+
610
/// Rust implementation of C library function `rand_r`
711
///
812
/// Passing NULL (core::ptr::null()) gives undefined behaviour.
@@ -29,7 +33,7 @@ pub unsafe extern "C" fn rand_r(seedp: *mut c_uint) -> c_int {
2933

3034
*seedp = next;
3135

32-
result
36+
result - 1
3337
}
3438

3539
#[cfg(test)]

0 commit comments

Comments
 (0)