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
redox-os
relibc
Commits
cfbe2749
Commit
cfbe2749
authored
7 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Remove allocation, fix pipe example
parent
0bcabc21
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/platform/Cargo.toml
+0
-3
0 additions, 3 deletions
src/platform/Cargo.toml
src/platform/src/lib.rs
+0
-2
0 additions, 2 deletions
src/platform/src/lib.rs
src/platform/src/redox/mod.rs
+5
-8
5 additions, 8 deletions
src/platform/src/redox/mod.rs
tests/pipe.c
+12
-2
12 additions, 2 deletions
tests/pipe.c
with
17 additions
and
15 deletions
src/platform/Cargo.toml
+
0
−
3
View file @
cfbe2749
...
@@ -8,6 +8,3 @@ sc = "0.2"
...
@@ -8,6 +8,3 @@ sc = "0.2"
[target.'cfg(target_os = "redox")'.dependencies]
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall
=
"0.1"
redox_syscall
=
"0.1"
[dependencies]
alloc-no-stdlib
=
"1.2"
This diff is collapsed.
Click to expand it.
src/platform/src/lib.rs
+
0
−
2
View file @
cfbe2749
...
@@ -3,8 +3,6 @@
...
@@ -3,8 +3,6 @@
#![no_std]
#![no_std]
#![allow(non_camel_case_types)]
#![allow(non_camel_case_types)]
//TODO #![feature(thread_local)]
//TODO #![feature(thread_local)]
#![feature(alloc)]
extern
crate
alloc
;
#[cfg(all(not(feature
=
"no_std"
),
target_os
=
"linux"
))]
#[cfg(all(not(feature
=
"no_std"
),
target_os
=
"linux"
))]
#[macro_use]
#[macro_use]
...
...
This diff is collapsed.
Click to expand it.
src/platform/src/redox/mod.rs
+
5
−
8
View file @
cfbe2749
extern
crate
alloc
;
use
core
::
ptr
;
use
core
::
ptr
;
use
core
::
slice
;
use
core
::
slice
;
use
alloc
::
Vec
;
use
syscall
;
use
syscall
;
use
c_str
;
use
c_str
;
...
@@ -127,11 +124,11 @@ pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
...
@@ -127,11 +124,11 @@ pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
}
}
pub
fn
pipe
(
fds
:
[
c_int
;
2
])
->
c_int
{
pub
fn
pipe
(
fds
:
[
c_int
;
2
])
->
c_int
{
let
usize_
vec
=
fds
.iter
()
.map
(|
x
|
*
x
as
usize
)
.collect
::
<
Vec
<
usize
>>
()
;
let
mut
usize_
fds
:
[
usize
;
2
]
=
[
0
;
2
]
;
let
usize_slice
=
usize_vec
.as_slice
(
);
let
res
=
e
(
syscall
::
pipe2
(
&
mut
usize_fds
)
);
let
mut
usize_arr
:
[
usize
;
2
]
=
Default
::
default
()
;
fds
[
0
]
=
usize_fds
[
0
]
as
c_int
;
usize_arr
.copy_from_slice
(
usize_slice
)
;
fds
[
1
]
=
usize_fds
[
1
]
as
c_int
;
e
(
syscall
::
pipe2
(
&
mut
usize_arr
,
0
))
as
c_int
res
as
c_int
}
}
pub
fn
read
(
fd
:
c_int
,
buf
:
&
mut
[
u8
])
->
ssize_t
{
pub
fn
read
(
fd
:
c_int
,
buf
:
&
mut
[
u8
])
->
ssize_t
{
...
...
This diff is collapsed.
Click to expand it.
tests/pipe.c
+
12
−
2
View file @
cfbe2749
//http://www2.cs.uregina.ca/~hamilton/courses/330/notes/unix/pipes/pipes.html
//http://www2.cs.uregina.ca/~hamilton/courses/330/notes/unix/pipes/pipes.html
#include
<string.h>
#include
<unistd.h>
#include
<unistd.h>
int
main
()
int
main
()
...
@@ -6,18 +7,27 @@ int main()
...
@@ -6,18 +7,27 @@ int main()
int
pid
,
pip
[
2
];
int
pid
,
pip
[
2
];
char
instring
[
20
];
char
instring
[
20
];
char
*
outstring
=
"Hello World!"
;
pipe
(
pip
);
pipe
(
pip
);
pid
=
fork
();
pid
=
fork
();
if
(
pid
==
0
)
/* child : sends message to parent*/
if
(
pid
==
0
)
/* child : sends message to parent*/
{
{
/* close read end */
close
(
pip
[
0
]);
/* send 7 characters in the string, including end-of-string */
/* send 7 characters in the string, including end-of-string */
write
(
pip
[
1
],
"Hi Mom!"
,
7
);
write
(
pip
[
1
],
outstring
,
strlen
(
outstring
));
/* close write end */
close
(
pip
[
1
]);
}
}
else
/* parent : receives message from child */
else
/* parent : receives message from child */
{
{
/* close write end */
close
(
pip
[
1
]);
/* read from the pipe */
/* read from the pipe */
read
(
pip
[
0
],
instring
,
7
);
read
(
pip
[
0
],
instring
,
7
);
/* close read end */
close
(
pip
[
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