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
49be92f8
Commit
49be92f8
authored
7 years ago
by
Tom Almeida
Browse files
Options
Downloads
Patches
Plain Diff
ran fmt.sh cause I'm an idiot
parent
8374fcb4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!63
Implemented fputc, fputs, and puts
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/stdio/src/lib.rs
+10
-6
10 additions, 6 deletions
src/stdio/src/lib.rs
with
10 additions
and
6 deletions
src/stdio/src/lib.rs
+
10
−
6
View file @
49be92f8
...
@@ -105,7 +105,9 @@ pub extern "C" fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FI
...
@@ -105,7 +105,9 @@ pub extern "C" fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FI
#[no_mangle]
#[no_mangle]
pub
extern
"C"
fn
fputc
(
c
:
c_int
,
stream
:
*
mut
FILE
)
->
c_int
{
pub
extern
"C"
fn
fputc
(
c
:
c_int
,
stream
:
*
mut
FILE
)
->
c_int
{
platform
::
FileWriter
(
stream
as
c_int
)
.write_char
(
c
as
u8
as
char
)
.map_err
(|
_
|
return
-
1
);
platform
::
FileWriter
(
stream
as
c_int
)
.write_char
(
c
as
u8
as
char
)
.map_err
(|
_
|
return
-
1
);
c
c
}
}
...
@@ -114,12 +116,14 @@ pub unsafe extern "C" fn fputs(s: *const c_char, stream: *mut FILE) -> c_int {
...
@@ -114,12 +116,14 @@ pub unsafe extern "C" fn fputs(s: *const c_char, stream: *mut FILE) -> c_int {
extern
"C"
{
extern
"C"
{
fn
strlen
(
s
:
*
const
c_char
)
->
size_t
;
fn
strlen
(
s
:
*
const
c_char
)
->
size_t
;
}
}
use
core
::{
str
,
slice
};
use
core
::{
slice
,
str
};
let
len
=
strlen
(
s
);
let
len
=
strlen
(
s
);
platform
::
FileWriter
(
stream
as
c_int
)
.write_str
(
str
::
from_utf8_unchecked
(
slice
::
from_raw_parts
(
platform
::
FileWriter
(
stream
as
c_int
)
s
as
*
const
u8
,
.write_str
(
str
::
from_utf8_unchecked
(
slice
::
from_raw_parts
(
len
,
s
as
*
const
u8
,
)))
.map_err
(|
_
|
return
-
1
);
len
,
)))
.map_err
(|
_
|
return
-
1
);
len
as
i32
len
as
i32
}
}
...
...
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