Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kernel
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
Container Registry
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
redox-os
kernel
Commits
fa7d1c82
Verified
Commit
fa7d1c82
authored
1 year ago
by
Jacob Lorentzon
Browse files
Options
Downloads
Patches
Plain Diff
Replace Box<dyn Fn> with fn in sys: scheme.
parent
acefb888
No related branches found
Branches containing commit
No related tags found
1 merge request
!231
Replace Box<dyn Fn> with fn in sys: scheme.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scheme/sys/mod.rs
+17
-18
17 additions, 18 deletions
src/scheme/sys/mod.rs
with
17 additions
and
18 deletions
src/scheme/sys/mod.rs
+
17
−
18
View file @
fa7d1c82
use
alloc
::
boxed
::
Box
;
use
alloc
::
collections
::
BTreeMap
;
use
alloc
::
collections
::
BTreeMap
;
use
alloc
::
vec
::
Vec
;
use
alloc
::
vec
::
Vec
;
use
core
::
str
;
use
core
::
str
;
...
@@ -30,33 +29,33 @@ struct Handle {
...
@@ -30,33 +29,33 @@ struct Handle {
seek
:
usize
seek
:
usize
}
}
type
SysFn
=
dyn
F
n
()
->
Result
<
Vec
<
u8
>>
+
Send
+
Sync
;
type
SysFn
=
f
n
()
->
Result
<
Vec
<
u8
>>
;
/// System information scheme
/// System information scheme
pub
struct
SysScheme
{
pub
struct
SysScheme
{
next_id
:
AtomicUsize
,
next_id
:
AtomicUsize
,
files
:
BTreeMap
<&
'static
str
,
Box
<
SysFn
>
>
,
files
:
BTreeMap
<&
'static
str
,
SysFn
>
,
handles
:
RwLock
<
BTreeMap
<
usize
,
Handle
>>
handles
:
RwLock
<
BTreeMap
<
usize
,
Handle
>>
}
}
impl
SysScheme
{
impl
SysScheme
{
pub
fn
new
()
->
SysScheme
{
pub
fn
new
()
->
SysScheme
{
let
mut
files
:
BTreeMap
<&
'static
str
,
Box
<
SysFn
>
>
=
BTreeMap
::
new
();
let
mut
files
:
BTreeMap
<&
'static
str
,
SysFn
>
=
BTreeMap
::
new
();
files
.insert
(
"block"
,
Box
::
new
(
block
::
resource
)
)
;
files
.insert
(
"block"
,
block
::
resource
);
files
.insert
(
"context"
,
Box
::
new
(
context
::
resource
)
)
;
files
.insert
(
"context"
,
context
::
resource
);
files
.insert
(
"cpu"
,
Box
::
new
(
cpu
::
resource
)
)
;
files
.insert
(
"cpu"
,
cpu
::
resource
);
files
.insert
(
"exe"
,
Box
::
new
(
exe
::
resource
)
)
;
files
.insert
(
"exe"
,
exe
::
resource
);
files
.insert
(
"iostat"
,
Box
::
new
(
iostat
::
resource
)
)
;
files
.insert
(
"iostat"
,
iostat
::
resource
);
files
.insert
(
"irq"
,
Box
::
new
(
irq
::
resource
)
)
;
files
.insert
(
"irq"
,
irq
::
resource
);
files
.insert
(
"log"
,
Box
::
new
(
log
::
resource
)
)
;
files
.insert
(
"log"
,
log
::
resource
);
files
.insert
(
"scheme"
,
Box
::
new
(
scheme
::
resource
)
)
;
files
.insert
(
"scheme"
,
scheme
::
resource
);
files
.insert
(
"scheme_num"
,
Box
::
new
(
scheme_num
::
resource
)
)
;
files
.insert
(
"scheme_num"
,
scheme_num
::
resource
);
files
.insert
(
"syscall"
,
Box
::
new
(
syscall
::
resource
)
)
;
files
.insert
(
"syscall"
,
syscall
::
resource
);
files
.insert
(
"uname"
,
Box
::
new
(
uname
::
resource
)
)
;
files
.insert
(
"uname"
,
uname
::
resource
);
files
.insert
(
"env"
,
Box
::
new
(
||
Ok
(
Vec
::
from
(
crate
::
init_env
())))
)
;
files
.insert
(
"env"
,
||
Ok
(
Vec
::
from
(
crate
::
init_env
())));
#[cfg(any(target_arch
=
"x86"
,
target_arch
=
"x86_64"
))]
#[cfg(any(target_arch
=
"x86"
,
target_arch
=
"x86_64"
))]
files
.insert
(
"spurious_irq"
,
Box
::
new
(
interrupt
::
irq
::
spurious_irq_resource
)
)
;
files
.insert
(
"spurious_irq"
,
interrupt
::
irq
::
spurious_irq_resource
);
SysScheme
{
SysScheme
{
next_id
:
AtomicUsize
::
new
(
0
),
next_id
:
AtomicUsize
::
new
(
0
),
...
...
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