Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lfmiao0
rt-thread
提交
a0e80061
R
rt-thread
项目概览
lfmiao0
/
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,发现更多精彩内容 >>
提交
a0e80061
编写于
9月 25, 2021
作者:
mysterywolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[libc][newlib] 优化syscall 将minilib.c并入syscalls.c
上级
d4a5edf0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
76 addition
and
142 deletion
+76
-142
components/libc/compilers/newlib/SConscript
components/libc/compilers/newlib/SConscript
+1
-2
components/libc/compilers/newlib/minilib.c
components/libc/compilers/newlib/minilib.c
+0
-72
components/libc/compilers/newlib/syscalls.c
components/libc/compilers/newlib/syscalls.c
+75
-68
未找到文件。
components/libc/compilers/newlib/SConscript
浏览文件 @
a0e80061
...
...
@@ -18,11 +18,10 @@ if rtconfig.PLATFORM == 'gcc':
LIBS
+=
[
'c'
,
'm'
]
src
+=
Glob
(
'*.c'
)
SrcRemove
(
src
,
[
'minilib.c'
])
if
GetDepend
(
'RT_USING_MODULE'
)
==
False
:
SrcRemove
(
src
,
[
'libc_syms.c'
])
else
:
src
+=
[
'
minilib
.c'
]
src
+=
[
'
syscalls
.c'
]
group
=
DefineGroup
(
'libc'
,
src
,
depend
=
[],
CPPPATH
=
CPPPATH
,
CPPDEFINES
=
CPPDEFINES
,
LIBS
=
LIBS
)
...
...
components/libc/compilers/newlib/minilib.c
已删除
100644 → 0
浏览文件 @
d4a5edf0
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-02-23 Meco Man first version
*/
#include <reent.h>
#include <rtthread.h>
#ifdef RT_USING_HEAP
/* Memory routine */
#include <sys/errno.h>
void
*
_malloc_r
(
struct
_reent
*
ptr
,
size_t
size
)
{
void
*
result
;
result
=
(
void
*
)
rt_malloc
(
size
);
if
(
result
==
RT_NULL
)
{
ptr
->
_errno
=
ENOMEM
;
}
return
result
;
}
void
*
_realloc_r
(
struct
_reent
*
ptr
,
void
*
old
,
size_t
newlen
)
{
void
*
result
;
result
=
(
void
*
)
rt_realloc
(
old
,
newlen
);
if
(
result
==
RT_NULL
)
{
ptr
->
_errno
=
ENOMEM
;
}
return
result
;
}
void
*
_calloc_r
(
struct
_reent
*
ptr
,
size_t
size
,
size_t
len
)
{
void
*
result
;
result
=
(
void
*
)
rt_calloc
(
size
,
len
);
if
(
result
==
RT_NULL
)
{
ptr
->
_errno
=
ENOMEM
;
}
return
result
;
}
void
_free_r
(
struct
_reent
*
ptr
,
void
*
addr
)
{
rt_free
(
addr
);
}
#else
void
*
_sbrk_r
(
struct
_reent
*
ptr
,
ptrdiff_t
incr
)
{
return
RT_NULL
;
}
#endif
/*RT_USING_HEAP*/
void
__libc_init_array
(
void
)
{
/* we not use __libc init_aray to initialize C++ objects */
/* __libc_init_array is ARM code, not Thumb; it will cause hardfault. */
}
components/libc/compilers/newlib/syscalls.c
浏览文件 @
a0e80061
...
...
@@ -11,17 +11,81 @@
* 2020-02-24 Meco Man fix bug of _isatty_r()
*/
#include <reent.h>
#include <errno.h>
#include <stdio.h>
#include <sys/time.h>
#include <rtthread.h>
#include <stddef.h>
#include <sys/errno.h>
#define DBG_TAG "newlib.syscalls"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#ifdef RT_USING_HEAP
/* Memory routine */
void
*
_malloc_r
(
struct
_reent
*
ptr
,
size_t
size
)
{
void
*
result
;
result
=
(
void
*
)
rt_malloc
(
size
);
if
(
result
==
RT_NULL
)
{
ptr
->
_errno
=
ENOMEM
;
}
return
result
;
}
void
*
_realloc_r
(
struct
_reent
*
ptr
,
void
*
old
,
size_t
newlen
)
{
void
*
result
;
result
=
(
void
*
)
rt_realloc
(
old
,
newlen
);
if
(
result
==
RT_NULL
)
{
ptr
->
_errno
=
ENOMEM
;
}
return
result
;
}
void
*
_calloc_r
(
struct
_reent
*
ptr
,
size_t
size
,
size_t
len
)
{
void
*
result
;
result
=
(
void
*
)
rt_calloc
(
size
,
len
);
if
(
result
==
RT_NULL
)
{
ptr
->
_errno
=
ENOMEM
;
}
return
result
;
}
void
_free_r
(
struct
_reent
*
ptr
,
void
*
addr
)
{
rt_free
(
addr
);
}
#else
void
*
_sbrk_r
(
struct
_reent
*
ptr
,
ptrdiff_t
incr
)
{
LOG_E
(
"Please enable RT_USING_HEAP or RT_USING_LIBC"
);
RT_ASSERT
(
0
);
return
RT_NULL
;
}
#endif
/*RT_USING_HEAP*/
void
__libc_init_array
(
void
)
{
/* we not use __libc init_aray to initialize C++ objects */
/* __libc_init_array is ARM code, not Thumb; it will cause a hardfault. */
}
#ifdef RT_USING_LIBC
#include <reent.h>
#include <stdio.h>
#ifdef RT_USING_DFS
#include <dfs_posix.h>
#endif
#ifdef RT_USING_MODULE
#include <dlmodule.h>
#endif
...
...
@@ -233,58 +297,11 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
#endif
}
#ifdef RT_USING_HEAP
/* Memory routine */
void
*
_malloc_r
(
struct
_reent
*
ptr
,
size_t
size
)
{
void
*
result
;
result
=
(
void
*
)
rt_malloc
(
size
);
if
(
result
==
RT_NULL
)
{
ptr
->
_errno
=
ENOMEM
;
}
return
result
;
}
void
*
_realloc_r
(
struct
_reent
*
ptr
,
void
*
old
,
size_t
newlen
)
{
void
*
result
;
result
=
(
void
*
)
rt_realloc
(
old
,
newlen
);
if
(
result
==
RT_NULL
)
{
ptr
->
_errno
=
ENOMEM
;
}
return
result
;
}
void
*
_calloc_r
(
struct
_reent
*
ptr
,
size_t
size
,
size_t
len
)
{
void
*
result
;
result
=
(
void
*
)
rt_calloc
(
size
,
len
);
if
(
result
==
RT_NULL
)
{
ptr
->
_errno
=
ENOMEM
;
}
return
result
;
}
void
_free_r
(
struct
_reent
*
ptr
,
void
*
addr
)
{
rt_free
(
addr
);
}
#else
void
*
_sbrk_r
(
struct
_reent
*
ptr
,
ptrdiff_t
incr
)
void
_system
(
const
char
*
s
)
{
return
RT_NULL
;
extern
int
__rt_libc_system
(
const
char
*
string
);
__rt_libc_system
(
s
);
}
#endif
/*RT_USING_HEAP*/
/* for exit() and abort() */
__attribute__
((
noreturn
))
void
_exit
(
int
status
)
...
...
@@ -294,18 +311,6 @@ __attribute__ ((noreturn)) void _exit (int status)
while
(
1
);
}
void
_system
(
const
char
*
s
)
{
extern
int
__rt_libc_system
(
const
char
*
string
);
__rt_libc_system
(
s
);
}
void
__libc_init_array
(
void
)
{
/* we not use __libc init_aray to initialize C++ objects */
/* __libc_init_array is ARM code, not Thumb; it will cause hardfault. */
}
mode_t
umask
(
mode_t
mask
)
{
return
022
;
...
...
@@ -321,3 +326,5 @@ These functions are implemented and replaced by the 'common/time.c' file
int _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp);
_CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms);
*/
#endif
/* RT_USING_LIBC */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录