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
c4c8b739
Commit
c4c8b739
authored
7 years ago
by
Tom Almeida
Browse files
Options
Downloads
Patches
Plain Diff
Formatted stdio files
parent
8648fd39
No related branches found
No related tags found
1 merge request
!85
Added functions for stdio.h
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/stdio/src/default.rs
+1
-1
1 addition, 1 deletion
src/stdio/src/default.rs
src/stdio/src/helpers.rs
+1
-1
1 addition, 1 deletion
src/stdio/src/helpers.rs
src/stdio/src/internal.rs
+10
-6
10 additions, 6 deletions
src/stdio/src/internal.rs
src/stdio/src/lib.rs
+4
-7
4 additions, 7 deletions
src/stdio/src/lib.rs
with
16 additions
and
15 deletions
src/stdio/src/default.rs
+
1
−
1
View file @
c4c8b739
use
core
::
sync
::
atomic
::
AtomicBool
;
use
core
::
ptr
;
use
super
::{
internal
,
BUFSIZ
,
FILE
,
UNGET
,
constants
};
use
super
::{
constants
,
internal
,
BUFSIZ
,
FILE
,
UNGET
};
#[allow(non_upper_case_globals)]
static
mut
default_stdin_buf
:
[
u8
;
BUFSIZ
as
usize
+
UNGET
]
=
[
0
;
BUFSIZ
as
usize
+
UNGET
];
...
...
This diff is collapsed.
Click to expand it.
src/stdio/src/helpers.rs
+
1
−
1
View file @
c4c8b739
...
...
@@ -32,7 +32,7 @@ pub unsafe fn parse_mode_flags(mode_str: *const c_char) -> i32 {
flags
|
=
O_TRUNC
;
}
if
(
*
mode_str
)
!=
b'a'
as
i8
{
flags
|
=
O_APPEND
;
flags
|
=
O_APPEND
;
}
flags
...
...
This diff is collapsed.
Click to expand it.
src/stdio/src/internal.rs
+
10
−
6
View file @
c4c8b739
use
super
::{
FILE
,
constants
};
use
super
::{
constants
,
FILE
};
use
platform
;
use
platform
::
types
::
*
;
use
core
::{
mem
,
ptr
,
slice
};
...
...
@@ -16,7 +16,11 @@ pub fn stdio_read(stream: *mut FILE, buf: *mut u8, size: usize) -> usize {
mem
::
forget
(
buff
);
mem
::
forget
(
file_buf
);
if
count
<=
0
{
(
*
stream
)
.flags
|
=
if
count
==
0
{
constants
::
F_EOF
}
else
{
constants
::
F_ERR
};
(
*
stream
)
.flags
|
=
if
count
==
0
{
constants
::
F_EOF
}
else
{
constants
::
F_ERR
};
return
0
;
}
if
count
as
usize
<=
size
{
...
...
@@ -46,7 +50,7 @@ pub fn stdio_write(stream: *mut FILE, buf: *const u8, size: usize) -> usize {
file
.write
(
&
f_buf
[
advance
..
])
+
file
.write
(
buff
)
};
if
count
==
rem
as
isize
{
(
*
stream
)
.wend
=
(
*
stream
)
.buf
.add
((
*
stream
)
.buf_size
-
1
);
(
*
stream
)
.wend
=
(
*
stream
)
.buf
.add
((
*
stream
)
.buf_size
-
1
);
(
*
stream
)
.wpos
=
(
*
stream
)
.buf
;
(
*
stream
)
.wbase
=
(
*
stream
)
.buf
;
return
size
;
...
...
@@ -89,8 +93,8 @@ pub unsafe fn to_read(stream: *mut FILE) -> bool {
(
*
stream
)
.flags
|
=
constants
::
F_ERR
;
return
true
;
}
(
*
stream
)
.rpos
=
(
*
stream
)
.buf
.offset
((
*
stream
)
.buf_size
as
isize
-
1
);
(
*
stream
)
.rend
=
(
*
stream
)
.buf
.offset
((
*
stream
)
.buf_size
as
isize
-
1
);
(
*
stream
)
.rpos
=
(
*
stream
)
.buf
.offset
((
*
stream
)
.buf_size
as
isize
-
1
);
(
*
stream
)
.rend
=
(
*
stream
)
.buf
.offset
((
*
stream
)
.buf_size
as
isize
-
1
);
if
(
*
stream
)
.flags
&
constants
::
F_EOF
>
0
{
true
}
else
{
...
...
@@ -113,7 +117,7 @@ pub unsafe fn to_write(stream: *mut FILE) -> bool {
(
*
stream
)
.rend
=
ptr
::
null_mut
();
(
*
stream
)
.wpos
=
(
*
stream
)
.buf
;
(
*
stream
)
.wbase
=
(
*
stream
)
.buf
;
(
*
stream
)
.wend
=
(
*
stream
)
.buf
.offset
((
*
stream
)
.buf_size
as
isize
-
1
);
(
*
stream
)
.wend
=
(
*
stream
)
.buf
.offset
((
*
stream
)
.buf_size
as
isize
-
1
);
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
src/stdio/src/lib.rs
+
4
−
7
View file @
c4c8b739
...
...
@@ -80,7 +80,7 @@ pub unsafe extern "C" fn fclose(stream: *mut FILE) -> c_int {
use
stdlib
::
free
;
flockfile
(
stream
);
let
r
=
helpers
::
fflush_unlocked
(
stream
)
|
platform
::
close
((
*
stream
)
.fd
);
if
(
*
stream
)
.flags
&
constants
::
F_PERM
==
0
{
if
(
*
stream
)
.flags
&
constants
::
F_PERM
==
0
{
// Not one of stdin, stdout or stderr
free
(
stream
as
*
mut
_
);
}
...
...
@@ -234,7 +234,7 @@ pub unsafe extern "C" fn fopen(filename: *const c_char, mode: *const c_char) ->
fcntl
::
sys_fcntl
(
fd
,
fcntl
::
F_SETFD
,
fcntl
::
FD_CLOEXEC
);
}
let
f
=
helpers
::
_fdopen
(
fd
,
mode
);
let
f
=
helpers
::
_fdopen
(
fd
,
mode
);
if
f
.is_null
()
{
platform
::
close
(
fd
);
return
ptr
::
null_mut
();
...
...
@@ -292,8 +292,7 @@ pub unsafe extern "C" fn fread(
}
else
{
if
let
Some
(
f
)
=
(
*
stream
)
.read
{
(
*
f
)(
stream
,
dest
,
l
as
usize
)
}
else
{
}
else
{
0
}
};
...
...
@@ -662,9 +661,7 @@ pub unsafe extern "C" fn ungetc(c: c_int, stream: *mut FILE) -> c_int {
if
(
*
stream
)
.rpos
.is_null
()
{
internal
::
to_read
(
stream
);
}
if
(
*
stream
)
.rpos
.is_null
()
||
(
*
stream
)
.rpos
<=
(
*
stream
)
.buf
.sub
((
*
stream
)
.unget
)
{
if
(
*
stream
)
.rpos
.is_null
()
||
(
*
stream
)
.rpos
<=
(
*
stream
)
.buf
.sub
((
*
stream
)
.unget
)
{
funlockfile
(
stream
);
return
-
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