Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[posix][dfs] move dfs_posix dfs_poll dfs_select.c to posix folder #5212

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bsp/gd32303e-eval/rtconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion bsp/lm3s8962/applications/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void rtthread_startup(void)
#ifdef RT_USING_FINSH
/* init finsh */
finsh_system_init();
#ifdef RT_USING_DEVICE
#if !defined(RT_USING_LIBC) && defined(RT_USING_DEVICE)
finsh_set_device("uart1");
#endif
#endif
Expand Down
5 changes: 3 additions & 2 deletions bsp/lm3s8962/rtconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
4 changes: 0 additions & 4 deletions components/dfs/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down
4 changes: 2 additions & 2 deletions components/dfs/src/dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <lwp.h>
#endif

#if defined(RT_USING_DFS_DEVFS) && defined(RT_USING_POSIX)
#ifdef RT_USING_LIBC
#include <libc.h>
#endif

Expand Down Expand Up @@ -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)
#ifdef RT_USING_LIBC
if ((0 <= fd) && (fd <= 2))
fd = libc_stdio_get_console();
#endif
Expand Down
5 changes: 4 additions & 1 deletion components/dfs/src/dfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
/* @} */

2 changes: 1 addition & 1 deletion components/finsh/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion components/finsh/finsh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 9 additions & 9 deletions components/finsh/msh.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "msh.h"
#include "shell.h"

#ifdef RT_USING_DFS
#ifdef RT_USING_POSIX
#include <dfs_posix.h>
#endif

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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. */
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions components/finsh/msh_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) */

16 changes: 8 additions & 8 deletions components/finsh/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
#include "shell.h"
#include "msh.h"

#if defined(RT_USING_DFS)
#include <dfs_posix.h>
#endif /* RT_USING_DFS */
#ifdef RT_USING_POSIX
#include <dfs_posix.h>
#endif /* RT_USING_POSIX */

/* finsh thread */
#ifndef RT_USING_HEAP
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion components/finsh/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 7 additions & 5 deletions components/libc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions components/libc/compilers/common/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 1 addition & 10 deletions components/libc/compilers/common/readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
## 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'])
```
This folder is "common" for all toolchains.
Loading