Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
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
Peter Limkilde Svendsen
relibc
Commits
cea5101c
Verified
Commit
cea5101c
authored
6 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Implement shm_ functions and add MAP_FIXED
parent
5b779448
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/header/sys_mman/linux.rs
+4
-9
4 additions, 9 deletions
src/header/sys_mman/linux.rs
src/header/sys_mman/mod.rs
+43
-6
43 additions, 6 deletions
src/header/sys_mman/mod.rs
src/header/sys_mman/redox.rs
+4
-9
4 additions, 9 deletions
src/header/sys_mman/redox.rs
with
51 additions
and
24 deletions
src/header/sys_mman/linux.rs
+
4
−
9
View file @
cea5101c
use
platform
::
types
::
*
;
pub
const
PROT_READ
:
c_int
=
0x1
;
pub
const
PROT_WRITE
:
c_int
=
0x2
;
pub
const
PROT_EXEC
:
c_int
=
0x4
;
pub
const
PROT_NONE
:
c_int
=
0x0
;
pub
const
MAP_SHARED
:
c_int
=
0x1
;
pub
const
MAP_PRIVATE
:
c_int
=
0x2
;
pub
const
MAP_ANON
:
c_int
=
0x20
;
pub
const
MAP_ANONYMOUS
:
c_int
=
MAP_ANON
;
pub
const
PROT_READ
:
c_int
=
0x0001
;
pub
const
PROT_WRITE
:
c_int
=
0x0002
;
pub
const
PROT_EXEC
:
c_int
=
0x0004
;
pub
const
PROT_NONE
:
c_int
=
0x0000
;
This diff is collapsed.
Click to expand it.
src/header/sys_mman/mod.rs
+
43
−
6
View file @
cea5101c
use
c_str
::{
CStr
,
CString
};
use
header
::{
fcntl
,
unistd
};
use
platform
::
types
::
*
;
use
platform
::{
Pal
,
Sys
};
...
...
@@ -11,6 +13,13 @@ pub mod sys;
#[path
=
"redox.rs"
]
pub
mod
sys
;
pub
const
MAP_SHARED
:
c_int
=
0x0001
;
pub
const
MAP_PRIVATE
:
c_int
=
0x0002
;
pub
const
MAP_TYPE
:
c_int
=
0x000F
;
pub
const
MAP_FIXED
:
c_int
=
0x0010
;
pub
const
MAP_ANON
:
c_int
=
0x0020
;
pub
const
MAP_ANONYMOUS
:
c_int
=
MAP_ANON
;
// #[no_mangle]
pub
extern
"C"
fn
mlock
(
addr
:
*
const
c_void
,
len
:
usize
)
->
c_int
{
unimplemented!
();
...
...
@@ -58,12 +67,40 @@ pub unsafe extern "C" fn munmap(addr: *mut c_void, len: size_t) -> c_int {
Sys
::
munmap
(
addr
,
len
)
}
// #[no_mangle]
pub
extern
"C"
fn
shm_open
(
name
:
*
const
c_char
,
oflag
:
c_int
,
mode
:
mode_t
)
->
c_int
{
unimplemented!
();
#[cfg(target_os
=
"linux"
)]
static
SHM_PATH
:
&
'static
[
u8
]
=
b"/dev/shm/"
;
#[cfg(target_os
=
"redox"
)]
static
SHM_PATH
:
&
'static
[
u8
]
=
b"shm:"
;
unsafe
fn
shm_path
(
name
:
*
const
c_char
)
->
CString
{
let
name_c
=
CStr
::
from_ptr
(
name
);
let
mut
path
=
SHM_PATH
.to_vec
();
let
mut
skip_slash
=
true
;
for
&
b
in
name_c
.to_bytes
()
{
if
skip_slash
{
if
b
==
b'/'
{
continue
;
}
else
{
skip_slash
=
false
;
}
}
path
.push
(
b
);
}
CString
::
from_vec_unchecked
(
path
)
}
// #[no_mangle]
pub
extern
"C"
fn
shm_unlink
(
name
:
*
const
c_char
)
->
c_int
{
unimplemented!
();
#[no_mangle]
pub
unsafe
extern
"C"
fn
shm_open
(
name
:
*
const
c_char
,
oflag
:
c_int
,
mode
:
mode_t
)
->
c_int
{
let
path
=
shm_path
(
name
);
fcntl
::
sys_open
(
path
.as_ptr
(),
oflag
,
mode
)
}
#[no_mangle]
pub
unsafe
extern
"C"
fn
shm_unlink
(
name
:
*
const
c_char
)
->
c_int
{
let
path
=
shm_path
(
name
);
unistd
::
unlink
(
path
.as_ptr
())
}
This diff is collapsed.
Click to expand it.
src/header/sys_mman/redox.rs
+
4
−
9
View file @
cea5101c
use
platform
::
types
::
*
;
pub
const
PROT_NONE
:
c_int
=
0
;
pub
const
PROT_EXEC
:
c_int
=
1
;
pub
const
PROT_WRITE
:
c_int
=
2
;
pub
const
PROT_READ
:
c_int
=
4
;
pub
const
MAP_SHARED
:
c_int
=
1
;
pub
const
MAP_PRIVATE
:
c_int
=
2
;
pub
const
MAP_ANON
:
c_int
=
4
;
pub
const
MAP_ANONYMOUS
:
c_int
=
MAP_ANON
;
pub
const
PROT_NONE
:
c_int
=
0x0000
;
pub
const
PROT_EXEC
:
c_int
=
0x0001
;
pub
const
PROT_WRITE
:
c_int
=
0x0002
;
pub
const
PROT_READ
:
c_int
=
0x0004
;
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