Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2345VOR
rt-thread
提交
c8c63251
R
rt-thread
项目概览
2345VOR
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c8c63251
编写于
9月 21, 2021
作者:
mysterywolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[libc][syscall]移除libc_stdio_read/write函数,优化syscall
上级
13b0b60b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
30 addition
and
60 deletion
+30
-60
components/libc/compilers/armlibc/libc.h
components/libc/compilers/armlibc/libc.h
+3
-6
components/libc/compilers/armlibc/stdio.c
components/libc/compilers/armlibc/stdio.c
+1
-25
components/libc/compilers/armlibc/syscalls.c
components/libc/compilers/armlibc/syscalls.c
+9
-6
components/libc/compilers/dlib/libc.h
components/libc/compilers/dlib/libc.h
+3
-6
components/libc/compilers/dlib/stdio.c
components/libc/compilers/dlib/stdio.c
+0
-9
components/libc/compilers/dlib/syscall_read.c
components/libc/compilers/dlib/syscall_read.c
+4
-3
components/libc/compilers/dlib/syscall_write.c
components/libc/compilers/dlib/syscall_write.c
+9
-4
components/libc/compilers/newlib/libc.h
components/libc/compilers/newlib/libc.h
+1
-1
未找到文件。
components/libc/compilers/armlibc/libc.h
浏览文件 @
c8c63251
...
@@ -10,17 +10,14 @@
...
@@ -10,17 +10,14 @@
#ifndef __RTT_LIBC_H__
#ifndef __RTT_LIBC_H__
#define __RTT_LIBC_H__
#define __RTT_LIBC_H__
#include <stddef.h>
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
int
libc_system_init
(
void
);
int
libc_s
tdio_set_console
(
const
char
*
device_name
,
int
mode
);
int
libc_s
ystem_init
(
void
);
int
libc_stdio_get_console
(
void
);
int
libc_stdio_get_console
(
void
);
int
libc_stdio_
read
(
void
*
buffer
,
size_t
siz
e
);
int
libc_stdio_
set_console
(
const
char
*
device_name
,
int
mod
e
);
int
libc_stdio_write
(
const
void
*
buffer
,
size_t
size
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
components/libc/compilers/armlibc/stdio.c
浏览文件 @
c8c63251
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#define STDIO_DEVICE_NAME_MAX 32
#define STDIO_DEVICE_NAME_MAX 32
static
int
std_fd
=
-
1
;
static
int
std_fd
=
-
1
;
int
libc_stdio_set_console
(
const
char
*
device_name
,
int
mode
)
int
libc_stdio_set_console
(
const
char
*
device_name
,
int
mode
)
{
{
int
fd
;
int
fd
;
...
@@ -47,29 +48,4 @@ int libc_stdio_get_console(void)
...
@@ -47,29 +48,4 @@ int libc_stdio_get_console(void)
return
std_fd
;
return
std_fd
;
}
}
int
libc_stdio_read
(
void
*
buffer
,
size_t
size
)
{
if
(
std_fd
>=
0
)
{
return
read
(
std_fd
,
buffer
,
size
);
}
else
{
rt_kprintf
(
"Illegal stdio input!
\n
"
);
return
0
;
}
}
int
libc_stdio_write
(
const
void
*
buffer
,
size_t
size
)
{
if
(
std_fd
>=
0
)
{
return
write
(
std_fd
,
buffer
,
size
);
}
else
{
rt_kprintf
(
"Illegal stdio output!
\n
"
);
return
size
;
}
}
#endif
#endif
components/libc/compilers/armlibc/syscalls.c
浏览文件 @
c8c63251
...
@@ -146,16 +146,17 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
...
@@ -146,16 +146,17 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
if
(
fh
==
STDIN
)
if
(
fh
==
STDIN
)
{
{
#ifdef RT_USING_POSIX
#ifdef RT_USING_POSIX
size
=
libc_stdio_read
(
buf
,
len
);
size
=
read
(
STDIN_FILENO
,
buf
,
len
);
return
len
-
size
;
return
len
-
size
;
#else
#else
/* no stdin */
/* no stdin */
return
-
1
;
return
-
1
;
#endif
#endif
}
}
else
if
((
fh
==
STDOUT
)
||
(
fh
==
STDERR
))
if
((
fh
==
STDOUT
)
||
(
fh
==
STDERR
))
{
return
-
1
;
return
-
1
;
}
#ifndef RT_USING_DFS
#ifndef RT_USING_DFS
return
0
;
return
0
;
...
@@ -185,7 +186,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
...
@@ -185,7 +186,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
return
0
;
return
0
;
#else
#else
#ifdef RT_USING_POSIX
#ifdef RT_USING_POSIX
size
=
libc_stdio_write
(
buf
,
len
);
size
=
write
(
STDOUT_FILENO
,
buf
,
len
);
return
len
-
size
;
return
len
-
size
;
#else
#else
if
(
rt_console_get_device
())
if
(
rt_console_get_device
())
...
@@ -198,8 +199,10 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
...
@@ -198,8 +199,10 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
#endif
#endif
#endif
#endif
}
}
else
if
(
fh
==
STDIN
)
if
(
fh
==
STDIN
)
return
-
1
;
{
return
-
1
;
}
#ifndef RT_USING_DFS
#ifndef RT_USING_DFS
return
0
;
return
0
;
...
...
components/libc/compilers/dlib/libc.h
浏览文件 @
c8c63251
...
@@ -11,17 +11,14 @@
...
@@ -11,17 +11,14 @@
#ifndef __RTT_LIBC_H__
#ifndef __RTT_LIBC_H__
#define __RTT_LIBC_H__
#define __RTT_LIBC_H__
#include <stddef.h>
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
int
libc_system_init
(
void
);
int
libc_s
tdio_set_console
(
const
char
*
device_name
,
int
mode
);
int
libc_s
ystem_init
(
void
);
int
libc_stdio_get_console
(
void
);
int
libc_stdio_get_console
(
void
);
int
libc_stdio_
read
(
void
*
buffer
,
size_t
siz
e
);
int
libc_stdio_
set_console
(
const
char
*
device_name
,
int
mod
e
);
int
libc_stdio_write
(
const
void
*
buffer
,
size_t
size
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
components/libc/compilers/dlib/stdio.c
浏览文件 @
c8c63251
...
@@ -46,13 +46,4 @@ int libc_stdio_get_console(void) {
...
@@ -46,13 +46,4 @@ int libc_stdio_get_console(void) {
return
std_fd
;
return
std_fd
;
}
}
int
libc_stdio_read
(
void
*
buffer
,
size_t
size
)
{
return
read
(
std_fd
,
buffer
,
size
);
}
int
libc_stdio_write
(
const
void
*
buffer
,
size_t
size
)
{
return
write
(
std_fd
,
buffer
,
size
);
}
#endif
#endif
components/libc/compilers/dlib/syscall_read.c
浏览文件 @
c8c63251
...
@@ -25,14 +25,15 @@ size_t __read(int handle, unsigned char *buf, size_t len)
...
@@ -25,14 +25,15 @@ size_t __read(int handle, unsigned char *buf, size_t len)
if
(
handle
==
_LLIO_STDIN
)
if
(
handle
==
_LLIO_STDIN
)
{
{
#ifdef RT_USING_POSIX
#ifdef RT_USING_POSIX
return
libc_stdio_read
(
buf
,
len
);
return
read
(
STDIN_FILENO
,
buf
,
len
);
#else
#else
return
_LLIO_ERROR
;
return
_LLIO_ERROR
;
#endif
#endif
}
}
else
if
((
handle
==
_LLIO_STDOUT
)
||
(
handle
==
_LLIO_STDERR
))
if
((
handle
==
_LLIO_STDOUT
)
||
(
handle
==
_LLIO_STDERR
))
{
return
_LLIO_ERROR
;
return
_LLIO_ERROR
;
}
#ifndef RT_USING_DFS
#ifndef RT_USING_DFS
return
_LLIO_ERROR
;
return
_LLIO_ERROR
;
...
...
components/libc/compilers/dlib/syscall_write.c
浏览文件 @
c8c63251
...
@@ -30,19 +30,24 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
...
@@ -30,19 +30,24 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
#else
#else
#ifdef RT_USING_POSIX
#ifdef RT_USING_POSIX
return
libc_stdio_write
(
(
void
*
)
buf
,
len
);
return
write
(
STDOUT_FILENO
,
(
void
*
)
buf
,
len
);
#else
#else
rt_device_t
console_device
;
rt_device_t
console_device
;
console_device
=
rt_console_get_device
();
console_device
=
rt_console_get_device
();
if
(
console_device
!=
0
)
rt_device_write
(
console_device
,
0
,
buf
,
len
);
if
(
console_device
!=
0
)
{
rt_device_write
(
console_device
,
0
,
buf
,
len
);
}
return
len
;
return
len
;
#endif
#endif
#endif
#endif
}
}
else
if
(
handle
==
_LLIO_STDIN
)
if
(
handle
==
_LLIO_STDIN
)
return
_LLIO_ERROR
;
{
return
_LLIO_ERROR
;
}
#ifndef RT_USING_DFS
#ifndef RT_USING_DFS
return
_LLIO_ERROR
;
return
_LLIO_ERROR
;
...
...
components/libc/compilers/newlib/libc.h
浏览文件 @
c8c63251
...
@@ -18,8 +18,8 @@
...
@@ -18,8 +18,8 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
int
libc_system_init
(
void
);
int
libc_system_init
(
void
);
int
libc_stdio_set_console
(
const
char
*
device_name
,
int
mode
);
int
libc_stdio_get_console
(
void
);
int
libc_stdio_get_console
(
void
);
int
libc_stdio_set_console
(
const
char
*
device_name
,
int
mode
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录