Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
人间散章
rt-thread
提交
7b43cf97
R
rt-thread
项目概览
人间散章
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
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,发现更多精彩内容 >>
提交
7b43cf97
编写于
10月 28, 2021
作者:
mysterywolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[libc][posix] move libc.c/.h to posix folder
上级
da1cc99f
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
82 addition
and
302 deletion
+82
-302
components/libc/compilers/armlibc/SConscript
components/libc/compilers/armlibc/SConscript
+2
-8
components/libc/compilers/armlibc/libc.c
components/libc/compilers/armlibc/libc.c
+0
-35
components/libc/compilers/armlibc/stdio.c
components/libc/compilers/armlibc/stdio.c
+0
-52
components/libc/compilers/armlibc/syscalls.c
components/libc/compilers/armlibc/syscalls.c
+5
-4
components/libc/compilers/common/SConscript
components/libc/compilers/common/SConscript
+3
-3
components/libc/compilers/dlib/SConscript
components/libc/compilers/dlib/SConscript
+1
-6
components/libc/compilers/dlib/libc.c
components/libc/compilers/dlib/libc.c
+0
-35
components/libc/compilers/dlib/libc.h
components/libc/compilers/dlib/libc.h
+0
-28
components/libc/compilers/dlib/stdio.c
components/libc/compilers/dlib/stdio.c
+0
-49
components/libc/compilers/dlib/syscall_read.c
components/libc/compilers/dlib/syscall_read.c
+2
-0
components/libc/compilers/dlib/syscall_write.c
components/libc/compilers/dlib/syscall_write.c
+2
-0
components/libc/compilers/gcc/newlib/SConscript
components/libc/compilers/gcc/newlib/SConscript
+2
-9
components/libc/compilers/gcc/newlib/libc.c
components/libc/compilers/gcc/newlib/libc.c
+0
-39
components/libc/compilers/gcc/newlib/libc.h
components/libc/compilers/gcc/newlib/libc.h
+0
-29
components/libc/compilers/gcc/newlib/syscalls.c
components/libc/compilers/gcc/newlib/syscalls.c
+2
-0
components/libc/posix/src/SConscript
components/libc/posix/src/SConscript
+3
-2
components/libc/posix/src/libc.c
components/libc/posix/src/libc.c
+60
-3
components/libc/posix/src/libc.h
components/libc/posix/src/libc.h
+0
-0
未找到文件。
components/libc/compilers/armlibc/SConscript
浏览文件 @
7b43cf97
from
building
import
*
Import
(
'rtconfig'
)
src
=
Glob
(
'*.c'
)
+
Glob
(
'*.cpp'
)
cwd
=
GetCurrentDir
()
src
=
Glob
(
'*.c'
)
group
=
[]
CPPPATH
=
[
cwd
]
CPPDEFINES
=
[
'RT_USING_ARM_LIBC'
]
if
GetDepend
(
'RT_USING_MODULE'
)
==
False
:
SrcRemove
(
src
,
[
'libc_syms.c'
])
if
rtconfig
.
PLATFORM
==
'armcc'
or
rtconfig
.
PLATFORM
==
'armclang'
:
group
=
DefineGroup
(
'libc'
,
src
,
depend
=
[
'RT_USING_LIBC'
],
CPPPATH
=
CPPPATH
,
CPPDEFINES
=
CPPDEFINES
)
group
=
DefineGroup
(
'libc'
,
src
,
depend
=
[
'RT_USING_LIBC'
],
CPPDEFINES
=
CPPDEFINES
)
Return
(
'group'
)
components/libc/compilers/armlibc/libc.c
已删除
100644 → 0
浏览文件 @
da1cc99f
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017/10/15 bernard the first version
*/
#include <rtthread.h>
#include <fcntl.h>
#include "libc.h"
#ifdef RT_USING_PTHREADS
#include <pthread.h>
#endif
int
libc_system_init
(
void
)
{
#ifdef RT_USING_POSIX
rt_device_t
dev_console
;
dev_console
=
rt_console_get_device
();
if
(
dev_console
)
{
libc_stdio_set_console
(
dev_console
->
parent
.
name
,
O_RDWR
);
}
#endif
/* RT_USING_POSIX */
#if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
pthread_system_init
();
#endif
return
0
;
}
INIT_COMPONENT_EXPORT
(
libc_system_init
);
components/libc/compilers/armlibc/stdio.c
已删除
100644 → 0
浏览文件 @
da1cc99f
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017/10/15 bernard implement stdio for armcc.
*/
#include <rtthread.h>
#ifdef RT_USING_POSIX
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libc.h"
#include <fcntl.h>
#include <unistd.h>
#define STDIO_DEVICE_NAME_MAX 32
static
int
std_fd
=
-
1
;
int
libc_stdio_set_console
(
const
char
*
device_name
,
int
mode
)
{
int
fd
;
char
name
[
STDIO_DEVICE_NAME_MAX
];
snprintf
(
name
,
sizeof
(
name
)
-
1
,
"/dev/%s"
,
device_name
);
name
[
STDIO_DEVICE_NAME_MAX
-
1
]
=
'\0'
;
fd
=
open
(
name
,
mode
,
0
);
if
(
fd
>=
0
)
{
if
(
std_fd
>=
0
)
{
close
(
std_fd
);
}
std_fd
=
fd
;
}
return
std_fd
;
}
int
libc_stdio_get_console
(
void
)
{
return
std_fd
;
}
#endif
/* RT_USING_POSIX */
components/libc/compilers/armlibc/syscalls.c
浏览文件 @
7b43cf97
...
...
@@ -14,15 +14,16 @@
* 2020-02-13 Meco Man re-implement exit() and abort()
* 2020-02-14 Meco Man implement _sys_tmpnam()
*/
#include <string.h>
#include <rt_sys.h>
#include <rt_sys.h>
#include <rtthread.h>
#include "libc.h"
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#ifdef RT_USING_POSIX
#include "libc.h"
#endif
#define DBG_TAG "armlibc.syscalls"
#define DBG_LVL DBG_INFO
...
...
components/libc/compilers/common/SConscript
浏览文件 @
7b43cf97
...
...
@@ -8,14 +8,14 @@ group = []
CPPPATH
=
[
cwd
]
CPPDEFINES
=
[]
if
rtconfig
.
CROSS_TOOL
==
'keil'
:
CPPDEFINES
+=
[
'__CLK_TCK=RT_TICK_PER_SECOND'
]
if
GetDepend
(
'RT_USING_LIBC'
):
src
+=
Glob
(
'*.c'
)
elif
GetDepend
(
'RT_LIBC_USING_TIME'
):
src
+=
[
'time.c'
]
if
rtconfig
.
CROSS_TOOL
==
'keil'
:
CPPDEFINES
+=
[
'__CLK_TCK=RT_TICK_PER_SECOND'
]
group
=
DefineGroup
(
'libc'
,
src
,
depend
=
[],
CPPPATH
=
CPPPATH
,
CPPDEFINES
=
CPPDEFINES
)
list
=
os
.
listdir
(
cwd
)
...
...
components/libc/compilers/dlib/SConscript
浏览文件 @
7b43cf97
from
building
import
*
Import
(
'rtconfig'
)
src
=
Glob
(
'*.c'
)
cwd
=
GetCurrentDir
()
group
=
[]
CPPPATH
=
[
cwd
]
CPPDEFINES
=
[
'RT_USING_DLIBC'
]
if
rtconfig
.
PLATFORM
==
'iar'
:
if
GetDepend
(
'RT_USING_POSIX'
):
from
distutils.version
import
LooseVersion
from
iar
import
IARVersion
CPPDEFINES
=
CPPDEFINES
+
[
'_DLIB_FILE_DESCRIPTOR'
]
if
LooseVersion
(
IARVersion
())
<
LooseVersion
(
"8.20.1"
):
CPPDEFINES
=
CPPDEFINES
+
[
'_DLIB_THREAD_SUPPORT'
]
group
=
DefineGroup
(
'libc'
,
src
,
depend
=
[
'RT_USING_LIBC'
],
CPP
PATH
=
CPPPATH
,
CPP
DEFINES
=
CPPDEFINES
)
group
=
DefineGroup
(
'libc'
,
src
,
depend
=
[
'RT_USING_LIBC'
],
CPPDEFINES
=
CPPDEFINES
)
Return
(
'group'
)
components/libc/compilers/dlib/libc.c
已删除
100644 → 0
浏览文件 @
da1cc99f
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017/10/15 bernard the first version
*/
#include <rtthread.h>
#include <fcntl.h>
#include "libc.h"
#ifdef RT_USING_PTHREADS
#include <pthread.h>
#endif
int
libc_system_init
(
void
)
{
#ifdef RT_USING_POSIX
rt_device_t
dev_console
;
dev_console
=
rt_console_get_device
();
if
(
dev_console
)
{
libc_stdio_set_console
(
dev_console
->
parent
.
name
,
O_RDWR
);
}
#endif
/* RT_USING_POSIX */
#if defined (RT_USING_PTHREADS) && !defined (RT_USING_COMPONENTS_INIT)
pthread_system_init
();
#endif
return
0
;
}
INIT_COMPONENT_EXPORT
(
libc_system_init
);
components/libc/compilers/dlib/libc.h
已删除
100644 → 0
浏览文件 @
da1cc99f
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017/10/15 bernard the first version
*/
#ifndef __RTT_LIBC_H__
#define __RTT_LIBC_H__
#ifdef __cplusplus
extern
"C"
{
#endif
int
libc_system_init
(
void
);
#ifdef RT_USING_POSIX
int
libc_stdio_get_console
(
void
);
int
libc_stdio_set_console
(
const
char
*
device_name
,
int
mode
);
#endif
/* RT_USING_POSIX */
#ifdef __cplusplus
}
#endif
#endif
components/libc/compilers/dlib/stdio.c
已删除
100644 → 0
浏览文件 @
da1cc99f
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017/10/15 bernard implement stdio for IAR dlib.
*/
#include <rtthread.h>
#ifdef RT_USING_POSIX
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include "libc.h"
#define STDIO_DEVICE_NAME_MAX 32
static
int
std_fd
=
-
1
;
int
libc_stdio_set_console
(
const
char
*
device_name
,
int
mode
)
{
int
fd
;
char
name
[
STDIO_DEVICE_NAME_MAX
];
snprintf
(
name
,
sizeof
(
name
)
-
1
,
"/dev/%s"
,
device_name
);
name
[
STDIO_DEVICE_NAME_MAX
-
1
]
=
'\0'
;
fd
=
open
(
name
,
mode
,
0
);
if
(
fd
>=
0
)
{
if
(
std_fd
>=
0
)
{
close
(
std_fd
);
}
std_fd
=
fd
;
}
return
std_fd
;
}
int
libc_stdio_get_console
(
void
)
{
return
std_fd
;
}
#endif
/* RT_USING_POSIX */
components/libc/compilers/dlib/syscall_read.c
浏览文件 @
7b43cf97
...
...
@@ -11,7 +11,9 @@
#include <rtthread.h>
#include <yfuns.h>
#include <unistd.h>
#ifdef RT_USING_POSIX
#include "libc.h"
#endif
#define DBG_TAG "dlib.syscall_read"
#define DBG_LVL DBG_INFO
...
...
components/libc/compilers/dlib/syscall_write.c
浏览文件 @
7b43cf97
...
...
@@ -11,7 +11,9 @@
#include <rtthread.h>
#include <yfuns.h>
#include <unistd.h>
#ifdef RT_USING_POSIX
#include "libc.h"
#endif
#define DBG_TAG "dlib.syscall_write"
#define DBG_LVL DBG_INFO
...
...
components/libc/compilers/gcc/newlib/SConscript
浏览文件 @
7b43cf97
...
...
@@ -4,21 +4,14 @@ Import('rtconfig')
src
=
[]
cwd
=
GetCurrentDir
()
group
=
[]
LIBS
=
[
'm'
]
LIBS
=
[
'm'
]
# link libm
CPPDEFINES
=
[
'RT_USING_NEWLIB'
]
CPPPATH
=
[
cwd
]
if
rtconfig
.
PLATFORM
==
'gcc'
:
if
GetDepend
(
'RT_USING_LIBC'
):
# link with libc and libm:
# libm is a frequently used lib. Newlib is compiled with -ffunction-sections in
# recent GCC tool chains. The linker would just link in the functions that have
# been referenced. So setting this won't result in bigger text size.
LIBS
+=
[
'c'
]
LIBS
+=
[
'c'
]
# link libc
src
+=
Glob
(
'*.c'
)
if
GetDepend
(
'RT_USING_MODULE'
)
==
False
:
SrcRemove
(
src
,
[
'libc_syms.c'
])
else
:
src
+=
[
'syscalls.c'
]
...
...
components/libc/compilers/gcc/newlib/libc.c
已删除
100644 → 0
浏览文件 @
da1cc99f
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017/10/15 bernard the first version
*/
#include <rtthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/time.h>
#include "libc.h"
#ifdef RT_USING_PTHREADS
#include <pthread.h>
#endif
int
libc_system_init
(
void
)
{
#ifdef RT_USING_POSIX
rt_device_t
dev_console
;
dev_console
=
rt_console_get_device
();
if
(
dev_console
)
{
libc_stdio_set_console
(
dev_console
->
parent
.
name
,
O_RDWR
);
}
#endif
/* RT_USING_POSIX */
#if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
pthread_system_init
();
#endif
return
0
;
}
INIT_COMPONENT_EXPORT
(
libc_system_init
);
components/libc/compilers/gcc/newlib/libc.h
已删除
100644 → 0
浏览文件 @
da1cc99f
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2017/10/15 bernard the first version
*/
#ifndef __RTT_LIBC_H__
#define __RTT_LIBC_H__
#ifdef __cplusplus
extern
"C"
{
#endif
int
libc_system_init
(
void
);
#ifdef RT_USING_POSIX
int
libc_stdio_get_console
(
void
);
int
libc_stdio_set_console
(
const
char
*
device_name
,
int
mode
);
#endif
/* RT_USING_POSIX */
#ifdef __cplusplus
}
#endif
#endif
components/libc/compilers/gcc/newlib/syscalls.c
浏览文件 @
7b43cf97
...
...
@@ -20,7 +20,9 @@
#include <unistd.h>
#include <sys/errno.h>
#include <sys/stat.h>
#ifdef RT_USING_POSIX
#include "libc.h"
#endif
#ifdef RT_USING_MODULE
#include <dlmodule.h>
#endif
...
...
components/libc/posix/src/SConscript
浏览文件 @
7b43cf97
...
...
@@ -2,9 +2,10 @@
from
building
import
*
cwd
=
GetCurrentDir
()
src
=
Glob
(
'*.c'
)
cwd
=
GetCurrentDir
()
CPPPATH
=
[
cwd
]
group
=
DefineGroup
(
'POSIX'
,
src
,
depend
=
[
'RT_USING_POSIX'
])
group
=
DefineGroup
(
'POSIX'
,
src
,
depend
=
[
'RT_USING_POSIX'
]
,
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
components/libc/
compilers/gcc/newlib/stdio
.c
→
components/libc/
posix/src/libc
.c
浏览文件 @
7b43cf97
...
...
@@ -7,16 +7,45 @@
* Date Author Notes
* 2017/10/15 bernard the first version
*/
#include <rtconfig.h>
#ifdef RT_USING_POSIX
#include <rtthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/time.h>
#include "libc.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef RT_USING_PTHREADS
#include <pthread.h>
#endif
int
libc_system_init
(
void
)
{
#ifdef RT_USING_POSIX
rt_device_t
dev_console
;
dev_console
=
rt_console_get_device
();
if
(
dev_console
)
{
libc_stdio_set_console
(
dev_console
->
parent
.
name
,
O_RDWR
);
}
#endif
/* RT_USING_POSIX */
#if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
pthread_system_init
();
#endif
return
0
;
}
INIT_COMPONENT_EXPORT
(
libc_system_init
);
#ifdef RT_USING_POSIX
#if defined(RT_USING_LIBC) && defined(RT_USING_NEWLIB)
#define STDIO_DEVICE_NAME_MAX 32
static
FILE
*
std_console
=
NULL
;
int
libc_stdio_set_console
(
const
char
*
device_name
,
int
mode
)
{
FILE
*
fp
;
...
...
@@ -88,4 +117,32 @@ int libc_stdio_get_console(void)
return
-
1
;
}
#else
#define STDIO_DEVICE_NAME_MAX 32
static
int
std_fd
=
-
1
;
int
libc_stdio_set_console
(
const
char
*
device_name
,
int
mode
)
{
int
fd
;
char
name
[
STDIO_DEVICE_NAME_MAX
];
snprintf
(
name
,
sizeof
(
name
)
-
1
,
"/dev/%s"
,
device_name
);
name
[
STDIO_DEVICE_NAME_MAX
-
1
]
=
'\0'
;
fd
=
open
(
name
,
mode
,
0
);
if
(
fd
>=
0
)
{
if
(
std_fd
>=
0
)
{
close
(
std_fd
);
}
std_fd
=
fd
;
}
return
std_fd
;
}
int
libc_stdio_get_console
(
void
)
{
return
std_fd
;
}
#endif
/* defined(RT_USING_LIBC) && (defined(__GNUC__) && !defined(__ARMCC_VERSION)) */
#endif
/* RT_USING_POSIX */
components/libc/
compilers/armlib
c/libc.h
→
components/libc/
posix/sr
c/libc.h
浏览文件 @
7b43cf97
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录