Skip to content
Snippets Groups Projects
Commit da193fc7 authored by Anton Grahn's avatar Anton Grahn
Browse files

bare0_5

parent 54dc13eb
Branches
No related tags found
No related merge requests found
...@@ -33,17 +33,33 @@ const X_INIT: u32 = core::u32::MAX; ...@@ -33,17 +33,33 @@ const X_INIT: u32 = core::u32::MAX;
static mut X: u32 = X_INIT; static mut X: u32 = X_INIT;
static mut Y: u32 = 0; static mut Y: u32 = 0;
fn read_x()->u32{
unsafe{X}
}
fn read_y()->u32{
unsafe{Y}
}
fn write_y(y:u32){
unsafe{Y=y};
}
fn write_x(x:u32){
unsafe{X=x};
}
#[entry] #[entry]
fn main() -> ! { fn main() -> ! {
// local mutable variable (changed in safe code) // local mutable variable (changed in safe code)
let mut x = unsafe { X }; let mut x = read_x();
loop { loop {
x = x.wrapping_add(1); // <- place breakpoint here (3) x = x.wrapping_add(1); // <- place breakpoint here (3)
unsafe {
X = X.wrapping_add(1); write_x(read_x().wrapping_add(1));
Y = X; write_y(read_x());
assert!(x == X && X == Y+1); assert!(x == read_x() && read_x() == read_y()+1);
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment