forked from eclipse-zenoh/zenoh-c
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/platform-primitives-sleep-clock
- Loading branch information
Showing
5 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
sphinx==4.5.0 | ||
sphinx_c_autodoc | ||
sphinx_rtd_theme | ||
clang==14 | ||
sphinx==7.2.6 | ||
sphinx_c_autodoc==1.3.0 | ||
sphinx_rtd_theme==2.0.0 | ||
clang==14.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,6 @@ pub use sleep::*; | |
mod sleep; | ||
pub use synchronization::*; | ||
mod synchronization; | ||
|
||
pub use random::*; | ||
mod random; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::slice::from_raw_parts_mut; | ||
|
||
use libc::c_void; | ||
use rand::{random, thread_rng, RngCore}; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn z_random_u8() -> u8 { | ||
random::<u8>() | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn z_random_u16() -> u16 { | ||
random::<u16>() | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn z_random_u32() -> u32 { | ||
random::<u32>() | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn z_random_u64() -> u64 { | ||
random::<u64>() | ||
} | ||
|
||
#[no_mangle] | ||
#[allow(clippy::missing_safety_doc)] | ||
pub unsafe extern "C" fn z_random_fill(buf: *mut c_void, len: usize) { | ||
if buf.is_null() || len == 0 { | ||
return; | ||
} | ||
let b: &mut [u8] = from_raw_parts_mut(buf as *mut u8, len); | ||
thread_rng().fill_bytes(b); | ||
} |