Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Verlässliche Systemsoftware
projects
osv
Commits
e4552a8b
Commit
e4552a8b
authored
11 years ago
by
Avi Kivity
Browse files
Options
Downloads
Patches
Plain Diff
file: generalize make_file() to be able to create derived types
Signed-off-by:
Avi Kivity
<
avi@cloudius-systems.com
>
parent
af5d4fc8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fs/fs.hh
+15
-8
15 additions, 8 deletions
fs/fs.hh
fs/vfs/kern_descrip.cc
+0
-10
0 additions, 10 deletions
fs/vfs/kern_descrip.cc
with
15 additions
and
18 deletions
fs/fs.hh
+
15
−
8
View file @
e4552a8b
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include
<cstdint>
#include
<cstdint>
#include
<boost/intrusive_ptr.hpp>
#include
<boost/intrusive_ptr.hpp>
#include
<osv/file.h>
#include
<osv/file.h>
#include
<utility>
static
inline
void
intrusive_ptr_add_ref
(
file
*
fp
)
static
inline
void
intrusive_ptr_add_ref
(
file
*
fp
)
{
{
...
@@ -43,23 +44,29 @@ uint64_t size(fileref f);
...
@@ -43,23 +44,29 @@ uint64_t size(fileref f);
void
read
(
fileref
f
,
void
*
buffer
,
uint64_t
offset
,
uint64_t
len
);
void
read
(
fileref
f
,
void
*
buffer
,
uint64_t
offset
,
uint64_t
len
);
void
write
(
fileref
f
,
const
void
*
buffer
,
uint64_t
offset
,
uint64_t
len
);
void
write
(
fileref
f
,
const
void
*
buffer
,
uint64_t
offset
,
uint64_t
len
);
template
<
class
file_type
=
file
>
template
<
class
file_type
,
typename
...
args
>
fileref
fileref
make_file
(
unsigned
flags
,
filetype_t
type
,
make_file
(
args
&&
...
a
)
void
*
opaque
,
struct
fileops
*
ops
)
{
{
file
*
fp
=
new
(
std
::
nothrow
)
file_type
(
flags
,
type
,
opaque
,
ops
);
file
*
fp
=
new
(
std
::
nothrow
)
file_type
(
std
::
forward
<
args
>
(
a
)...
);
if
(
!
fp
)
{
if
(
!
fp
)
{
throw
ENOMEM
;
throw
ENOMEM
;
}
}
return
fileref
(
fp
,
false
);
return
fileref
(
fp
,
false
);
}
}
template
<
class
T
,
class
file_type
=
file
>
inline
fileref
make_file
(
unsigned
flags
,
filetype_t
type
,
fileref
make_file
(
unsigned
flags
,
filetype_t
type
,
void
*
opaque
,
std
::
unique_ptr
<
T
>&&
opaque
,
struct
fileops
*
ops
)
struct
fileops
*
ops
)
{
{
auto
f
=
make_file
<
file_type
>
(
flags
,
type
,
opaque
.
get
(),
ops
);
return
make_file
<
file
>
(
flags
,
type
,
opaque
,
ops
);
}
template
<
typename
T
>
fileref
make_file
(
unsigned
flags
,
filetype_t
type
,
std
::
unique_ptr
<
T
>&&
opaque
,
struct
fileops
*
ops
)
{
auto
f
=
make_file
<
file
>
(
flags
,
type
,
opaque
.
get
(),
ops
);
opaque
.
release
();
opaque
.
release
();
return
f
;
return
f
;
}
}
...
...
This diff is collapsed.
Click to expand it.
fs/vfs/kern_descrip.cc
+
0
−
10
View file @
e4552a8b
...
@@ -166,16 +166,6 @@ file::file(unsigned flags, filetype_t type, void *opaque,
...
@@ -166,16 +166,6 @@ file::file(unsigned flags, filetype_t type, void *opaque,
fo_init
(
fp
);
fo_init
(
fp
);
}
}
fileref
make_file
(
unsigned
flags
,
filetype_t
type
,
void
*
opaque
,
struct
fileops
*
ops
)
{
file
*
fp
=
new
(
std
::
nothrow
)
file
(
flags
,
type
,
opaque
,
ops
);
if
(
!
fp
)
{
throw
ENOMEM
;
}
return
fileref
(
fp
,
false
);
}
void
fhold
(
struct
file
*
fp
)
void
fhold
(
struct
file
*
fp
)
{
{
__sync_fetch_and_add
(
&
fp
->
f_count
,
1
);
__sync_fetch_and_add
(
&
fp
->
f_count
,
1
);
...
...
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