Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bare-boyes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fredrik Pettersson
bare-boyes
Commits
ee56513f
Commit
ee56513f
authored
7 years ago
by
DevDoggo
Browse files
Options
Downloads
Patches
Plain Diff
Done
parent
5fd97f80
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/bare4.rs
+7
-2
7 additions, 2 deletions
examples/bare4.rs
with
7 additions
and
2 deletions
examples/bare4.rs
+
7
−
2
View file @
ee56513f
...
...
@@ -27,8 +27,8 @@ use address::*;
#[inline(always)]
fn
read_u32
(
addr
:
u32
)
->
u32
{
unsafe
{
core
::
ptr
::
read_volatile
(
addr
as
*
const
_
)
}
//
core::ptr::read_volatile(addr as *const _)
//
unsafe { core::ptr::read_volatile(addr as *const _) }
core
::
ptr
::
read_volatile
(
addr
as
*
const
_
)
}
#[inline(always)]
...
...
@@ -101,10 +101,15 @@ fn main() {
// 2. comment out line 30 and uncomment line 31 (essentially omitting the `unsafe`)
// what was the error message and explain why,
//
// >> Call to unsafe function requires unsafe function or block
// ** your answer here **
//
// digging a bit deeper, why do you think `read_volatile` is declared `unsafe`
// (https://doc.rust-lang.org/core/ptr/fn.read_volatile.html, for some food for thought )
//
// >> While volatile will not be re-ordered by the compiler,
// this still doesn't prevent something to start changing the value
// as the program may try to read (since read may not be an atomic operation)
// ** your answer here **
//
// commit your answers (bare4_2)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment