#![forbid(unsafe_code)]
#![allow(non_camel_case_types)]
#![forbid(missing_docs)]
pub struct BSD(u32);
const RAND_MAX: i32 = 0x7fffffff;
impl BSD {
pub fn new() -> Self {
Self (1)
}
pub fn srand(seed: u32) -> Self {
Self (seed)
}
pub fn rand(&mut self) -> i32 {
self.0 = self.0.wrapping_mul(1103515245).wrapping_add(12345);
( self.0 % (RAND_MAX as u32 + 1) ) as i32
}
pub fn rand_r(seed: &mut u32) -> i32 {
*seed = seed.wrapping_mul(1103515245).wrapping_add(12345);
( *seed % (RAND_MAX as u32 + 1) ) as i32
}
}
#[cfg(test)]
#[path = "bsd_tests.rs"]
mod tests;