-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance rand to support macos #159
base: main
Are you sure you want to change the base?
Conversation
bdfa3f2
to
db643da
Compare
The rand::timestamp_cycles() may return duplicated value on non-x86 architectures, so fixes it by retry. Signed-off-by: Liu Jiang <[email protected]>
Some assumptions in unit test cases are not suitable for Darwin/macos, so relax those test cases. Signed-off-by: Liu Jiang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to see support for macos being added to rust-vmm. Thanks Gerry 👍
@@ -144,6 +144,7 @@ mod tests { | |||
let path = t.as_path(); | |||
assert!(path.exists()); | |||
assert!(path.is_dir()); | |||
#[cfg(not(target_os = "macos"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we instead check that the path is in the equivalent temp_dir for mac os? Otherwise this test is not very useful.
@@ -185,12 +186,14 @@ mod tests { | |||
let path = t.as_path(); | |||
assert!(path.exists()); | |||
assert!(path.is_dir()); | |||
#[cfg(not(target_os = "macos"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an equivalent check here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, not all platforms have 64bit atomic types. There's configuration to check: cfg(target_has_atomic = "64"). I just submitted an issue to omit compilation of src/metrics.rs if target does not have 64bit atomics. Examples of such platforms are armel, mipsel and (surprize!) x32 (tho I think this last one is due to lack of proper rust support there, since i386 does have 64bit atomics).
@@ -24,17 +24,28 @@ pub fn timestamp_cycles() -> u64 { | |||
|
|||
#[cfg(not(target_arch = "x86_64"))] | |||
{ | |||
use std::sync::atomic::{AtomicU64, Ordering}; | |||
static TIMESTAMP: AtomicU64 = AtomicU64::new(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be static?
Summary of the PR
Enhance rand to support macos, also fixes some failure in unit tests on macos
Requirements
Before submitting your PR, please make sure you addressed the following
requirements:
git commit -s
), and the commitmessage has max 60 characters for the summary and max 75 characters for each
description line.
test.
unsafe
code is properly documented.