Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
u010088926
rt-thread
提交
f7548b93
R
rt-thread
项目概览
u010088926
/
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,发现更多精彩内容 >>
提交
f7548b93
编写于
10月 20, 2021
作者:
mysterywolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[posix][dfs] move dfs_posix dfs_poll dfs_select.c to posix folder
上级
bcdd4a62
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
183 addition
and
217 deletion
+183
-217
bsp/gd32303e-eval/rtconfig.h
bsp/gd32303e-eval/rtconfig.h
+1
-0
bsp/lm3s8962/applications/startup.c
bsp/lm3s8962/applications/startup.c
+1
-1
bsp/lm3s8962/rtconfig.h
bsp/lm3s8962/rtconfig.h
+3
-2
components/dfs/SConscript
components/dfs/SConscript
+0
-4
components/dfs/src/dfs.c
components/dfs/src/dfs.c
+2
-2
components/dfs/src/dfs_file.c
components/dfs/src/dfs_file.c
+4
-1
components/finsh/SConscript
components/finsh/SConscript
+1
-1
components/finsh/finsh.h
components/finsh/finsh.h
+1
-1
components/finsh/msh.c
components/finsh/msh.c
+9
-9
components/finsh/msh_file.c
components/finsh/msh_file.c
+2
-2
components/finsh/shell.c
components/finsh/shell.c
+8
-8
components/finsh/shell.h
components/finsh/shell.h
+1
-1
components/libc/Kconfig
components/libc/Kconfig
+7
-5
components/libc/compilers/common/SConscript
components/libc/compilers/common/SConscript
+2
-5
components/libc/compilers/common/readme.md
components/libc/compilers/common/readme.md
+1
-10
components/libc/compilers/common/unistd.c
components/libc/compilers/common/unistd.c
+0
-119
components/libc/posix/aio/SConscript
components/libc/posix/aio/SConscript
+2
-2
components/libc/posix/getline/SConscript
components/libc/posix/getline/SConscript
+1
-1
components/libc/posix/mmap/SConscript
components/libc/posix/mmap/SConscript
+1
-1
components/libc/posix/pthreads/SConscript
components/libc/posix/pthreads/SConscript
+1
-1
components/libc/posix/signal/SConscript
components/libc/posix/signal/SConscript
+1
-1
components/libc/posix/src/SConscript
components/libc/posix/src/SConscript
+10
-0
components/libc/posix/src/delay.c
components/libc/posix/src/delay.c
+9
-0
components/libc/posix/src/poll.c
components/libc/posix/src/poll.c
+0
-5
components/libc/posix/src/select.c
components/libc/posix/src/select.c
+1
-4
components/libc/posix/src/unistd.c
components/libc/posix/src/unistd.c
+112
-18
components/libc/posix/termios/SConscript
components/libc/posix/termios/SConscript
+1
-1
include/rtdebug.h
include/rtdebug.h
+1
-12
未找到文件。
bsp/gd32303e-eval/rtconfig.h
浏览文件 @
f7548b93
...
...
@@ -125,6 +125,7 @@
/* POSIX layer and C standard library */
#define RT_USING_LIBC
#define RT_USING_POSIX
#define RT_LIBC_USING_TIME
#define RT_LIBC_DEFAULT_TIMEZONE 8
/* end of POSIX layer and C standard library */
...
...
bsp/lm3s8962/applications/startup.c
浏览文件 @
f7548b93
...
...
@@ -119,7 +119,7 @@ void rtthread_startup(void)
#ifdef RT_USING_FINSH
/* init finsh */
finsh_system_init
();
#if
def RT_USING_DEVICE
#if
!defined(RT_USING_LIBC) && defined(RT_USING_DEVICE)
finsh_set_device
(
"uart1"
);
#endif
#endif
...
...
bsp/lm3s8962/rtconfig.h
浏览文件 @
f7548b93
...
...
@@ -75,8 +75,10 @@
#define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION
#define RT_USING_LIBC
#define RT_USING_DFS
/* SECTION: DFS options */
#define RT_USING_POSIX
#define RT_USING_DFS_DEVFS
#define RT_USING_DFS_ELMFAT
#define RT_DFS_ELM_WORD_ACCESS
...
...
@@ -144,6 +146,5 @@
/* the size of each pbuf in the pbuf pool. */
#define RT_LWIP_PBUF_POOL_BUFSIZE 1500
#define RT_USING_LIBC
#define RT_USING_LWIP141
#endif
components/dfs/SConscript
浏览文件 @
f7548b93
...
...
@@ -5,14 +5,10 @@ src = Split('''
src/dfs.c
src/dfs_file.c
src/dfs_fs.c
src/dfs_posix.c
'''
)
cwd
=
GetCurrentDir
()
CPPPATH
=
[
cwd
+
"/include"
]
if
GetDepend
(
'RT_USING_POSIX'
):
src
+=
[
'src/dfs_poll.c'
,
'src/dfs_select.c'
]
group
=
DefineGroup
(
'Filesystem'
,
src
,
depend
=
[
'RT_USING_DFS'
],
CPPPATH
=
CPPPATH
)
if
GetDepend
(
'RT_USING_DFS'
):
...
...
components/dfs/src/dfs.c
浏览文件 @
f7548b93
...
...
@@ -18,7 +18,7 @@
#include <lwp.h>
#endif
#if
defined(RT_USING_DFS_DEVFS) && defined(RT_USING_POSIX)
#if
def RT_USING_LIBC
#include <libc.h>
#endif
...
...
@@ -216,7 +216,7 @@ struct dfs_fd *fd_get(int fd)
struct
dfs_fd
*
d
;
struct
dfs_fdtable
*
fdt
;
#if
defined(RT_USING_DFS_DEVFS) && defined(RT_USING_POSIX)
#if
def RT_USING_LIBC
if
((
0
<=
fd
)
&&
(
fd
<=
2
))
fd
=
libc_stdio_get_console
();
#endif
...
...
components/dfs/src/dfs_file.c
浏览文件 @
f7548b93
...
...
@@ -621,6 +621,7 @@ void cat(const char *filename)
}
FINSH_FUNCTION_EXPORT
(
cat
,
print
file
);
#ifdef RT_USING_POSIX
#define BUF_SZ 4096
static
void
copyfile
(
const
char
*
src
,
const
char
*
dst
)
{
...
...
@@ -749,6 +750,7 @@ static const char *_get_path_lastname(const char *path)
/* skip the '/' then return */
return
++
ptr
;
}
void
copy
(
const
char
*
src
,
const
char
*
dst
)
{
#define FLAG_SRC_TYPE 0x03
...
...
@@ -841,7 +843,8 @@ void copy(const char *src, const char *dst)
}
}
FINSH_FUNCTION_EXPORT
(
copy
,
copy
file
or
dir
)
#endif
/* RT_USING_POSIX */
#endif
#endif
/* RT_USING_FINSH */
/* @} */
components/finsh/SConscript
浏览文件 @
f7548b93
...
...
@@ -9,7 +9,7 @@ msh.c
if
GetDepend
(
'MSH_USING_BUILT_IN_COMMANDS'
):
src
+=
[
'cmd.c'
]
if
GetDepend
(
'RT_USING_
DFS
'
):
if
GetDepend
(
'RT_USING_
POSIX
'
):
src
+=
[
'msh_file.c'
]
CPPPATH
=
[
cwd
]
...
...
components/finsh/finsh.h
浏览文件 @
f7548b93
...
...
@@ -169,7 +169,7 @@ extern struct finsh_syscall *_syscall_table_begin, *_syscall_table_end;
struct
finsh_syscall
*
finsh_syscall_lookup
(
const
char
*
name
);
#ifdef RT_USING_DEVICE
void
finsh_set_device
(
const
char
*
device_name
);
void
finsh_set_device
(
const
char
*
device_name
);
#endif
#endif
components/finsh/msh.c
浏览文件 @
f7548b93
...
...
@@ -21,7 +21,7 @@
#include "msh.h"
#include "shell.h"
#ifdef RT_USING_
DFS
#ifdef RT_USING_
POSIX
#include <dfs_posix.h>
#endif
...
...
@@ -186,7 +186,7 @@ static cmd_function_t msh_get_cmd(char *cmd, int size)
return
cmd_func
;
}
#if defined(RT_USING_MODULE) && defined(RT_USING_
DFS
)
#if defined(RT_USING_MODULE) && defined(RT_USING_
POSIX
)
/* Return 0 on module executed. Other value indicate error.
*/
int
msh_exec_module
(
const
char
*
cmd_line
,
int
size
)
...
...
@@ -257,7 +257,7 @@ int msh_exec_module(const char *cmd_line, int size)
rt_free
(
pg_name
);
return
ret
;
}
#endif
/* defined(RT_USING_MODULE) && defined(RT_USING_
DFS
) */
#endif
/* defined(RT_USING_MODULE) && defined(RT_USING_
POSIX
) */
static
int
_msh_exec_cmd
(
char
*
cmd
,
rt_size_t
length
,
int
*
retp
)
{
...
...
@@ -290,7 +290,7 @@ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp)
return
0
;
}
#if defined(RT_USING_LWP) && defined(RT_USING_
DFS
)
#if defined(RT_USING_LWP) && defined(RT_USING_
POSIX
)
static
int
_msh_exec_lwp
(
char
*
cmd
,
rt_size_t
length
)
{
int
argc
;
...
...
@@ -350,7 +350,7 @@ int msh_exec(char *cmd, rt_size_t length)
{
return
cmd_ret
;
}
#ifdef RT_USING_
DFS
#ifdef RT_USING_
POSIX
#ifdef DFS_USING_WORKDIR
if
(
msh_exec_script
(
cmd
,
length
)
==
0
)
{
...
...
@@ -371,7 +371,7 @@ int msh_exec(char *cmd, rt_size_t length)
return
0
;
}
#endif
/* RT_USING_LWP */
#endif
/* RT_USING_
DFS
*/
#endif
/* RT_USING_
POSIX
*/
/* truncate the cmd at the first space. */
{
...
...
@@ -400,7 +400,7 @@ static int str_common(const char *str1, const char *str2)
return
(
str
-
str1
);
}
#ifdef RT_USING_
DFS
#ifdef RT_USING_
POSIX
void
msh_auto_complete_path
(
char
*
path
)
{
DIR
*
dir
=
RT_NULL
;
...
...
@@ -521,7 +521,7 @@ void msh_auto_complete_path(char *path)
closedir
(
dir
);
rt_free
(
full_path
);
}
#endif
/* RT_USING_
DFS
*/
#endif
/* RT_USING_
POSIX
*/
void
msh_auto_complete
(
char
*
prefix
)
{
...
...
@@ -538,7 +538,7 @@ void msh_auto_complete(char *prefix)
return
;
}
#ifdef RT_USING_
DFS
#ifdef RT_USING_
POSIX
/* check whether a spare in the command */
{
char
*
ptr
;
...
...
components/finsh/msh_file.c
浏览文件 @
f7548b93
...
...
@@ -11,7 +11,7 @@
#include <rtthread.h>
#if defined(RT_USING_FINSH) && defined(RT_USING_
DFS
)
#if defined(RT_USING_FINSH) && defined(RT_USING_
POSIX
)
#include <finsh.h>
#include "msh.h"
...
...
@@ -702,5 +702,5 @@ static int cmd_tail(int argc, char **argv)
}
MSH_CMD_EXPORT_ALIAS
(
cmd_tail
,
tail
,
print
the
last
N
-
lines
data
of
the
given
file
);
#endif
/* defined(RT_USING_FINSH) && defined(RT_USING_
DFS
) */
#endif
/* defined(RT_USING_FINSH) && defined(RT_USING_
POSIX
) */
components/finsh/shell.c
浏览文件 @
f7548b93
...
...
@@ -27,9 +27,9 @@
#include "shell.h"
#include "msh.h"
#if
defined(RT_USING_DFS)
#include <dfs_posix.h>
#endif
/* RT_USING_
DFS
*/
#if
def RT_USING_POSIX
#include <dfs_posix.h>
#endif
/* RT_USING_
POSIX
*/
/* finsh thread */
#ifndef RT_USING_HEAP
...
...
@@ -104,7 +104,7 @@ const char *finsh_get_prompt(void)
}
strcpy
(
finsh_prompt
,
_MSH_PROMPT
);
#if defined(RT_USING_
DFS
) && defined(DFS_USING_WORKDIR)
#if defined(RT_USING_
POSIX
) && defined(DFS_USING_WORKDIR)
/* get current working directory */
getcwd
(
&
finsh_prompt
[
rt_strlen
(
finsh_prompt
)],
RT_CONSOLEBUF_SIZE
-
rt_strlen
(
finsh_prompt
));
#endif
...
...
@@ -145,7 +145,7 @@ void finsh_set_prompt_mode(rt_uint32_t prompt_mode)
int
finsh_getchar
(
void
)
{
#ifdef RT_USING_DEVICE
#ifdef RT_USING_
POSIX
#ifdef RT_USING_
LIBC
return
getchar
();
#else
char
ch
=
0
;
...
...
@@ -163,14 +163,14 @@ int finsh_getchar(void)
rt_sem_take
(
&
shell
->
rx_sem
,
RT_WAITING_FOREVER
);
return
ch
;
#endif
/* RT_USING_
POSIX
*/
#endif
/* RT_USING_
LIBC
*/
#else
extern
char
rt_hw_console_getchar
(
void
);
return
rt_hw_console_getchar
();
#endif
/* RT_USING_DEVICE */
}
#if !defined(RT_USING_
POSIX
) && defined(RT_USING_DEVICE)
#if !defined(RT_USING_
LIBC
) && defined(RT_USING_DEVICE)
static
rt_err_t
finsh_rx_ind
(
rt_device_t
dev
,
rt_size_t
size
)
{
RT_ASSERT
(
shell
!=
RT_NULL
);
...
...
@@ -436,7 +436,7 @@ void finsh_thread_entry(void *parameter)
shell
->
echo_mode
=
0
;
#endif
#if !defined(RT_USING_
POSIX
) && defined(RT_USING_DEVICE)
#if !defined(RT_USING_
LIBC
) && defined(RT_USING_DEVICE)
/* set console device as shell device */
if
(
shell
->
device
==
RT_NULL
)
{
...
...
components/finsh/shell.h
浏览文件 @
f7548b93
...
...
@@ -78,7 +78,7 @@ struct finsh_shell
rt_uint16_t
line_position
;
rt_uint16_t
line_curpos
;
#if !defined(RT_USING_
POSIX
) && defined(RT_USING_DEVICE)
#if !defined(RT_USING_
LIBC
) && defined(RT_USING_DEVICE)
rt_device_t
device
;
#endif
...
...
components/libc/Kconfig
浏览文件 @
f7548b93
...
...
@@ -2,6 +2,8 @@ menu "POSIX layer and C standard library"
config RT_USING_LIBC
bool "Enable libc APIs from toolchain"
select RT_USING_DFS
select RT_USING_POSIX
default y
config RT_USING_PTHREADS
...
...
@@ -14,9 +16,9 @@ if RT_USING_PTHREADS
default 8
endif
if RT_USING_
LIBC && RT_USING_
DFS
if RT_USING_DFS
config RT_USING_POSIX
bool "Enable POSIX layer
for compatibility with UNIX APIs, poll
/select etc"
bool "Enable POSIX layer
, open/read/write
/select etc"
select RT_USING_DFS_DEVFS
default y
...
...
@@ -49,9 +51,9 @@ if RT_USING_LIBC
default n
if RT_USING_MODULE
config RT_USING_CUSTOM_DLMODULE
bool "Enable load dynamic module by custom"
default n
config RT_USING_CUSTOM_DLMODULE
bool "Enable load dynamic module by custom"
default n
endif
endif
...
...
components/libc/compilers/common/SConscript
浏览文件 @
f7548b93
...
...
@@ -6,18 +6,15 @@ src = []
cwd
=
GetCurrentDir
()
group
=
[]
CPPPATH
=
[
cwd
]
CPPDEFINES
=
[]
if
GetDepend
(
'RT_USING_LIBC'
):
src
+=
Glob
(
'*.c'
)
if
GetDepend
(
'RT_USING_POSIX'
)
==
False
:
SrcRemove
(
src
,
[
'unistd.c'
,
'delay.c'
])
elif
GetDepend
(
'RT_LIBC_USING_TIME'
):
src
+=
[
'time.c'
]
if
rtconfig
.
CROSS_TOOL
==
'keil'
:
CPPDEFINES
=
[
'__CLK_TCK=RT_TICK_PER_SECOND'
]
else
:
CPPDEFINES
=
[]
CPPDEFINES
+=
[
'__CLK_TCK=RT_TICK_PER_SECOND'
]
group
=
DefineGroup
(
'libc'
,
src
,
depend
=
[],
CPPPATH
=
CPPPATH
,
CPPDEFINES
=
CPPDEFINES
)
...
...
components/libc/compilers/common/readme.md
浏览文件 @
f7548b93
## Attentions
1.
This folder is "common" for all toolchains.
2.
If you want to add new
`.c`
files, please do not forget to fix SConscript file too. eg:
```
python
if
GetDepend
(
'RT_USING_POSIX'
)
==
False
:
SrcRemove
(
src
,
[
'unistd.c'
])
```
\ No newline at end of file
This folder is "common" for all toolchains.
\ No newline at end of file
components/libc/compilers/common/unistd.c
已删除
100644 → 0
浏览文件 @
bcdd4a62
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-09-01 Meco Man first Version
* 2021-02-12 Meco Man move all functions located in <pthread_sleep.c> to this file
*/
#include <unistd.h>
#include <rtthread.h>
#include <rthw.h>
#ifdef RT_USING_POSIX_TERMIOS
#include "termios.h"
int
isatty
(
int
fd
)
{
struct
termios
ts
;
return
(
tcgetattr
(
fd
,
&
ts
)
!=
-
1
);
/*true if no error (is a tty)*/
}
#else
int
isatty
(
int
fd
)
{
if
(
fd
>=
0
&&
fd
<
3
)
{
return
1
;
}
else
{
return
0
;
}
}
#endif
RTM_EXPORT
(
isatty
);
char
*
ttyname
(
int
fd
)
{
return
"/dev/tty"
;
/* TODO: need to add more specific */
}
RTM_EXPORT
(
ttyname
);
unsigned
int
sleep
(
unsigned
int
seconds
)
{
if
(
rt_thread_self
()
!=
RT_NULL
)
{
rt_thread_delay
(
seconds
*
RT_TICK_PER_SECOND
);
}
else
/* scheduler has not run yet */
{
while
(
seconds
>
0
)
{
rt_hw_us_delay
(
1000000u
);
seconds
--
;
}
}
return
0
;
}
RTM_EXPORT
(
sleep
);
int
usleep
(
useconds_t
usec
)
{
if
(
rt_thread_self
()
!=
RT_NULL
)
{
rt_thread_mdelay
(
usec
/
1000u
);
}
else
/* scheduler has not run yet */
{
rt_hw_us_delay
(
usec
/
1000u
);
}
rt_hw_us_delay
(
usec
%
1000u
);
return
0
;
}
RTM_EXPORT
(
usleep
);
pid_t
gettid
(
void
)
{
/*TODO*/
return
0
;
}
pid_t
getpid
(
void
)
{
return
gettid
();
}
RTM_EXPORT
(
getpid
);
pid_t
getppid
(
void
)
{
return
0
;
}
RTM_EXPORT
(
getppid
);
uid_t
getuid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
getuid
);
uid_t
geteuid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
geteuid
);
gid_t
getgid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
getgid
);
gid_t
getegid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
getegid
);
components/libc/posix/aio/SConscript
浏览文件 @
f7548b93
...
...
@@ -3,9 +3,9 @@
from
building
import
*
cwd
=
GetCurrentDir
()
src
=
Glob
(
'*.c'
)
+
Glob
(
'*.cpp'
)
src
=
Glob
(
'*.c'
)
CPPPATH
=
[
cwd
]
group
=
DefineGroup
(
'
libc
'
,
src
,
depend
=
[
'RT_USING_POSIX'
,
'RT_USING_POSIX_AIO'
],
CPPPATH
=
CPPPATH
)
group
=
DefineGroup
(
'
POSIX
'
,
src
,
depend
=
[
'RT_USING_POSIX'
,
'RT_USING_POSIX_AIO'
],
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
components/libc/posix/getline/SConscript
浏览文件 @
f7548b93
...
...
@@ -6,7 +6,7 @@ cwd = GetCurrentDir()
src
=
Glob
(
'*.c'
)
+
Glob
(
'*.cpp'
)
CPPPATH
=
[
cwd
]
group
=
DefineGroup
(
'
libc'
,
src
,
group
=
DefineGroup
(
'
POSIX'
,
src
,
depend
=
[
'RT_USING_LIBC'
,
'RT_USING_POSIX'
,
'RT_USING_POSIX_GETLINE'
],
CPPPATH
=
CPPPATH
)
...
...
components/libc/posix/mmap/SConscript
浏览文件 @
f7548b93
...
...
@@ -6,7 +6,7 @@ cwd = GetCurrentDir()
src
=
Glob
(
'*.c'
)
+
Glob
(
'*.cpp'
)
CPPPATH
=
[
cwd
]
group
=
DefineGroup
(
'
libc'
,
src
,
group
=
DefineGroup
(
'
POSIX'
,
src
,
depend
=
[
'RT_USING_DFS'
,
'RT_USING_POSIX_MMAP'
],
CPPPATH
=
CPPPATH
)
...
...
components/libc/posix/pthreads/SConscript
浏览文件 @
f7548b93
...
...
@@ -16,7 +16,7 @@ try:
except
:
pass
group
=
DefineGroup
(
'
libc
'
,
src
,
group
=
DefineGroup
(
'
POSIX
'
,
src
,
depend
=
[
'RT_USING_PTHREADS'
,
'RT_USING_LIBC'
],
CPPPATH
=
CPPPATH
,
CPPDEFINES
=
CPPDEFINES
)
Return
(
'group'
)
components/libc/posix/signal/SConscript
浏览文件 @
f7548b93
...
...
@@ -6,7 +6,7 @@ cwd = GetCurrentDir()
src
=
Glob
(
'*.c'
)
+
Glob
(
'*.cpp'
)
CPPPATH
=
[
cwd
]
group
=
DefineGroup
(
'
libc
'
,
src
,
group
=
DefineGroup
(
'
POSIX
'
,
src
,
depend
=
[
'RT_USING_SIGNALS'
,
'RT_USING_PTHREADS'
,
'RT_USING_LIBC'
],
CPPPATH
=
CPPPATH
)
...
...
components/libc/posix/src/SConscript
0 → 100644
浏览文件 @
f7548b93
# RT-Thread building script for component
from
building
import
*
cwd
=
GetCurrentDir
()
src
=
Glob
(
'*.c'
)
group
=
DefineGroup
(
'POSIX'
,
src
,
depend
=
[
'RT_USING_POSIX'
])
Return
(
'group'
)
components/libc/
compilers/common
/delay.c
→
components/libc/
posix/src
/delay.c
浏览文件 @
f7548b93
...
...
@@ -9,6 +9,15 @@
*/
#include <rtthread.h>
#include <rthw.h>
#define DBG_TAG "POSIX.delay"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
RT_WEAK
void
rt_hw_us_delay
(
rt_uint32_t
us
)
{
(
void
)
us
;
LOG_W
(
"Please consider implementing rt_hw_us_delay() in another file."
);
}
void
msleep
(
unsigned
int
msecs
)
{
...
...
components/
dfs/src/dfs_
poll.c
→
components/
libc/posix/src/
poll.c
浏览文件 @
f7548b93
...
...
@@ -9,14 +9,9 @@
* 2018-03-09 Bernard Add protection for pt->triggered.
*/
#include <stdint.h>
#include <rthw.h>
#include <rtdevice.h>
#include <rtthread.h>
#include <dfs.h>
#include <dfs_file.h>
#include <dfs_posix.h>
#include <poll.h>
#ifdef RT_USING_POSIX
...
...
components/
dfs/src/dfs_
select.c
→
components/
libc/posix/src/
select.c
浏览文件 @
f7548b93
...
...
@@ -7,10 +7,7 @@
* Date Author Notes
* 2016-12-28 Bernard first version
*/
#include <dfs.h>
#include <dfs_fs.h>
#include <dfs_posix.h>
#include <rtthread.h>
#include <poll.h>
#include <sys/select.h>
...
...
components/
dfs/src/dfs_posix
.c
→
components/
libc/posix/src/unistd
.c
浏览文件 @
f7548b93
...
...
@@ -5,19 +5,15 @@
*
* Change Logs:
* Date Author Notes
* 20
09-05-27 Yi.qiu The first v
ersion
* 20
18-02-07 Bernard Change the 3rd parameter of open/fcntl/ioctl to '...'
* 20
20-09-01 Meco Man first V
ersion
* 20
21-02-12 Meco Man move all functions located in <pthread_sleep.c> to this file
*/
#include <dfs.h>
#include <dfs_posix.h>
#include "dfs_private.h"
/**
* @addtogroup FsPosixApi
*/
/*@{*/
#include <rtthread.h>
#include <dfs_file.h>
#include <dfs_private.h>
#include <sys/errno.h>
#include <unistd.h>
#include <delay.h>
/**
* this function is a POSIX compliant version, which will open a file and
...
...
@@ -585,11 +581,6 @@ int mkdir(const char *path, mode_t mode)
}
RTM_EXPORT
(
mkdir
);
#ifdef RT_USING_FINSH
#include <finsh.h>
FINSH_FUNCTION_EXPORT
(
mkdir
,
create
a
directory
);
#endif
/**
* this function is a POSIX compliant version, which will remove a directory.
*
...
...
@@ -947,4 +938,107 @@ char *getcwd(char *buf, size_t size)
}
RTM_EXPORT
(
getcwd
);
/* @} */
#ifdef RT_USING_POSIX_TERMIOS
#include "termios.h"
int
isatty
(
int
fd
)
{
struct
termios
ts
;
return
(
tcgetattr
(
fd
,
&
ts
)
!=
-
1
);
/*true if no error (is a tty)*/
}
#else
int
isatty
(
int
fd
)
{
if
(
fd
>=
0
&&
fd
<
3
)
{
return
1
;
}
else
{
return
0
;
}
}
#endif
RTM_EXPORT
(
isatty
);
char
*
ttyname
(
int
fd
)
{
return
"/dev/tty"
;
/* TODO: need to add more specific */
}
RTM_EXPORT
(
ttyname
);
unsigned
int
sleep
(
unsigned
int
seconds
)
{
if
(
rt_thread_self
()
!=
RT_NULL
)
{
ssleep
(
seconds
);
}
else
/* scheduler has not run yet */
{
while
(
seconds
>
0
)
{
udelay
(
1000000u
);
seconds
--
;
}
}
return
0
;
}
RTM_EXPORT
(
sleep
);
int
usleep
(
useconds_t
usec
)
{
if
(
rt_thread_self
()
!=
RT_NULL
)
{
msleep
(
usec
/
1000u
);
}
else
/* scheduler has not run yet */
{
udelay
(
usec
/
1000u
);
}
udelay
(
usec
%
1000u
);
return
0
;
}
RTM_EXPORT
(
usleep
);
pid_t
gettid
(
void
)
{
/*TODO*/
return
0
;
}
pid_t
getpid
(
void
)
{
return
gettid
();
}
RTM_EXPORT
(
getpid
);
pid_t
getppid
(
void
)
{
return
0
;
}
RTM_EXPORT
(
getppid
);
uid_t
getuid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
getuid
);
uid_t
geteuid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
geteuid
);
gid_t
getgid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
getgid
);
gid_t
getegid
(
void
)
{
return
0
;
/*ROOT*/
}
RTM_EXPORT
(
getegid
);
components/libc/posix/termios/SConscript
浏览文件 @
f7548b93
...
...
@@ -6,7 +6,7 @@ cwd = GetCurrentDir()
src
=
Glob
(
'*.c'
)
+
Glob
(
'*.cpp'
)
CPPPATH
=
[
cwd
]
group
=
DefineGroup
(
'
libc
'
,
src
,
group
=
DefineGroup
(
'
POSIX
'
,
src
,
depend
=
[
'RT_USING_LIBC'
,
'RT_USING_POSIX'
,
'RT_USING_POSIX_TERMIOS'
],
CPPPATH
=
CPPPATH
)
...
...
include/rtdebug.h
浏览文件 @
f7548b93
...
...
@@ -17,18 +17,7 @@
#if !defined(RT_USING_DFS) || !defined(RT_USING_DFS_DEVFS)
#error "POSIX poll/select, stdin need file system(RT_USING_DFS) and device file system(RT_USING_DFS_DEVFS)"
#endif
#if !defined(RT_USING_LIBC)
#error "POSIX layer need standard C library(RT_USING_LIBC)"
#endif
#endif
#ifdef RT_USING_POSIX_TERMIOS
#if !defined(RT_USING_POSIX)
#error "termios need POSIX layer(RT_USING_POSIX)"
#endif
#endif
#endif
/* RT_USING_POSIX */
/* Using this macro to control all kernel debug features. */
#ifdef RT_DEBUG
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录