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
78e421cb
Commit
78e421cb
authored
7 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Implement some functions on Linux
parent
9fb0b77d
No related branches found
No related tags found
No related merge requests found
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
tests/create.c
+14
-0
14 additions, 0 deletions
tests/create.c
tests/write.c
+2
-1
2 additions, 1 deletion
tests/write.c
unistd/Cargo.toml
+1
-1
1 addition, 1 deletion
unistd/Cargo.toml
unistd/src/lib.rs
+8
-5
8 additions, 5 deletions
unistd/src/lib.rs
with
25 additions
and
7 deletions
tests/create.c
0 → 100644
+
14
−
0
View file @
78e421cb
#include
<fcntl.h>
#include
<unistd.h>
int
main
(
int
argc
,
char
**
argv
)
{
int
fd
=
creat
(
"create.out"
,
0755
);
if
(
fd
>=
0
)
{
write
(
fd
,
"Hello World!
\n
"
,
14
);
close
(
fd
);
return
0
;
}
else
{
write
(
2
,
"creat failed
\n
"
,
14
);
return
1
;
}
}
This diff is collapsed.
Click to expand it.
tests/write.c
+
2
−
1
View file @
78e421cb
#include
<unistd.h>
void
_start
(
void
)
{
int
main
(
int
argc
,
char
**
argv
)
{
write
(
STDOUT_FILENO
,
"Hello World!
\n
"
,
14
);
return
0
;
}
This diff is collapsed.
Click to expand it.
unistd/Cargo.toml
+
1
−
1
View file @
78e421cb
...
...
@@ -8,4 +8,4 @@ build = "build.rs"
cbindgen
=
{
path
=
"../cbindgen"
}
[dependencies]
common
=
{
path
=
"../
common
"
}
platform
=
{
path
=
"../
platform
"
}
This diff is collapsed.
Click to expand it.
unistd/src/lib.rs
+
8
−
5
View file @
78e421cb
...
...
@@ -2,9 +2,9 @@
#![no_std]
extern
crate
common
;
extern
crate
platform
;
pub
use
common
::
*
;
pub
use
platform
::
types
::
*
;
pub
const
NULL
:
c_int
=
0
;
...
...
@@ -28,7 +28,7 @@ pub const STDERR_FILENO: c_int = 2;
#[no_mangle]
pub
extern
"C"
fn
_exit
(
status
:
c_int
)
{
unimplemented!
();
platform
::
exit
(
status
)
}
#[no_mangle]
...
...
@@ -63,7 +63,7 @@ pub extern "C" fn chown(path: *const c_char, owner: uid_t, group: gid_t) -> c_in
#[no_mangle]
pub
extern
"C"
fn
close
(
fildes
:
c_int
)
->
c_int
{
unimplemented!
();
platform
::
close
(
fildes
)
}
#[no_mangle]
...
...
@@ -448,7 +448,10 @@ pub extern "C" fn vfork() -> pid_t {
#[no_mangle]
pub
extern
"C"
fn
write
(
fildes
:
c_int
,
buf
:
*
const
c_void
,
nbyte
:
size_t
)
->
ssize_t
{
unimplemented!
();
use
core
::
slice
;
let
buf
=
unsafe
{
slice
::
from_raw_parts
(
buf
as
*
const
u8
,
nbyte
as
usize
)
};
platform
::
write
(
fildes
,
buf
)
}
/*
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
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