Skip to content

Commit 50bb6e3

Browse files
authored
Merge pull request #5212 from mysterywolf/posix
[posix][dfs] move dfs_posix dfs_poll dfs_select.c to posix folder
2 parents c8ee4cc + f7548b9 commit 50bb6e3

File tree

28 files changed

+183
-217
lines changed

28 files changed

+183
-217
lines changed

bsp/gd32303e-eval/rtconfig.h

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
/* POSIX layer and C standard library */
126126

127127
#define RT_USING_LIBC
128+
#define RT_USING_POSIX
128129
#define RT_LIBC_USING_TIME
129130
#define RT_LIBC_DEFAULT_TIMEZONE 8
130131
/* end of POSIX layer and C standard library */

bsp/lm3s8962/applications/startup.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void rtthread_startup(void)
119119
#ifdef RT_USING_FINSH
120120
/* init finsh */
121121
finsh_system_init();
122-
#ifdef RT_USING_DEVICE
122+
#if !defined(RT_USING_LIBC) && defined(RT_USING_DEVICE)
123123
finsh_set_device("uart1");
124124
#endif
125125
#endif

bsp/lm3s8962/rtconfig.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@
7575
#define FINSH_USING_SYMTAB
7676
#define FINSH_USING_DESCRIPTION
7777

78+
#define RT_USING_LIBC
7879
#define RT_USING_DFS
79-
/* SECTION: DFS options */
80+
#define RT_USING_POSIX
81+
#define RT_USING_DFS_DEVFS
8082
#define RT_USING_DFS_ELMFAT
8183
#define RT_DFS_ELM_WORD_ACCESS
8284

@@ -144,6 +146,5 @@
144146
/* the size of each pbuf in the pbuf pool. */
145147
#define RT_LWIP_PBUF_POOL_BUFSIZE 1500
146148

147-
#define RT_USING_LIBC
148149
#define RT_USING_LWIP141
149150
#endif

components/dfs/SConscript

-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@ src = Split('''
55
src/dfs.c
66
src/dfs_file.c
77
src/dfs_fs.c
8-
src/dfs_posix.c
98
''')
109
cwd = GetCurrentDir()
1110
CPPPATH = [cwd + "/include"]
1211

13-
if GetDepend('RT_USING_POSIX'):
14-
src += ['src/dfs_poll.c', 'src/dfs_select.c']
15-
1612
group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS'], CPPPATH = CPPPATH)
1713

1814
if GetDepend('RT_USING_DFS'):

components/dfs/src/dfs.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <lwp.h>
1919
#endif
2020

21-
#if defined(RT_USING_DFS_DEVFS) && defined(RT_USING_POSIX)
21+
#ifdef RT_USING_LIBC
2222
#include <libc.h>
2323
#endif
2424

@@ -216,7 +216,7 @@ struct dfs_fd *fd_get(int fd)
216216
struct dfs_fd *d;
217217
struct dfs_fdtable *fdt;
218218

219-
#if defined(RT_USING_DFS_DEVFS) && defined(RT_USING_POSIX)
219+
#ifdef RT_USING_LIBC
220220
if ((0 <= fd) && (fd <= 2))
221221
fd = libc_stdio_get_console();
222222
#endif

components/dfs/src/dfs_file.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ void cat(const char *filename)
621621
}
622622
FINSH_FUNCTION_EXPORT(cat, print file);
623623

624+
#ifdef RT_USING_POSIX
624625
#define BUF_SZ 4096
625626
static void copyfile(const char *src, const char *dst)
626627
{
@@ -749,6 +750,7 @@ static const char *_get_path_lastname(const char *path)
749750
/* skip the '/' then return */
750751
return ++ptr;
751752
}
753+
752754
void copy(const char *src, const char *dst)
753755
{
754756
#define FLAG_SRC_TYPE 0x03
@@ -841,7 +843,8 @@ void copy(const char *src, const char *dst)
841843
}
842844
}
843845
FINSH_FUNCTION_EXPORT(copy, copy file or dir)
846+
#endif /* RT_USING_POSIX */
844847

845-
#endif
848+
#endif /* RT_USING_FINSH */
846849
/* @} */
847850

components/finsh/SConscript

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ msh.c
99
if GetDepend('MSH_USING_BUILT_IN_COMMANDS'):
1010
src += ['cmd.c']
1111

12-
if GetDepend('RT_USING_DFS'):
12+
if GetDepend('RT_USING_POSIX'):
1313
src += ['msh_file.c']
1414

1515
CPPPATH = [cwd]

components/finsh/finsh.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ extern struct finsh_syscall *_syscall_table_begin, *_syscall_table_end;
169169
struct finsh_syscall *finsh_syscall_lookup(const char *name);
170170

171171
#ifdef RT_USING_DEVICE
172-
void finsh_set_device(const char *device_name);
172+
void finsh_set_device(const char *device_name);
173173
#endif
174174

175175
#endif

components/finsh/msh.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "msh.h"
2222
#include "shell.h"
2323

24-
#ifdef RT_USING_DFS
24+
#ifdef RT_USING_POSIX
2525
#include <dfs_posix.h>
2626
#endif
2727

@@ -186,7 +186,7 @@ static cmd_function_t msh_get_cmd(char *cmd, int size)
186186
return cmd_func;
187187
}
188188

189-
#if defined(RT_USING_MODULE) && defined(RT_USING_DFS)
189+
#if defined(RT_USING_MODULE) && defined(RT_USING_POSIX)
190190
/* Return 0 on module executed. Other value indicate error.
191191
*/
192192
int msh_exec_module(const char *cmd_line, int size)
@@ -257,7 +257,7 @@ int msh_exec_module(const char *cmd_line, int size)
257257
rt_free(pg_name);
258258
return ret;
259259
}
260-
#endif /* defined(RT_USING_MODULE) && defined(RT_USING_DFS) */
260+
#endif /* defined(RT_USING_MODULE) && defined(RT_USING_POSIX) */
261261

262262
static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp)
263263
{
@@ -290,7 +290,7 @@ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp)
290290
return 0;
291291
}
292292

293-
#if defined(RT_USING_LWP) && defined(RT_USING_DFS)
293+
#if defined(RT_USING_LWP) && defined(RT_USING_POSIX)
294294
static int _msh_exec_lwp(char *cmd, rt_size_t length)
295295
{
296296
int argc;
@@ -350,7 +350,7 @@ int msh_exec(char *cmd, rt_size_t length)
350350
{
351351
return cmd_ret;
352352
}
353-
#ifdef RT_USING_DFS
353+
#ifdef RT_USING_POSIX
354354
#ifdef DFS_USING_WORKDIR
355355
if (msh_exec_script(cmd, length) == 0)
356356
{
@@ -371,7 +371,7 @@ int msh_exec(char *cmd, rt_size_t length)
371371
return 0;
372372
}
373373
#endif /* RT_USING_LWP */
374-
#endif /* RT_USING_DFS */
374+
#endif /* RT_USING_POSIX */
375375

376376
/* truncate the cmd at the first space. */
377377
{
@@ -400,7 +400,7 @@ static int str_common(const char *str1, const char *str2)
400400
return (str - str1);
401401
}
402402

403-
#ifdef RT_USING_DFS
403+
#ifdef RT_USING_POSIX
404404
void msh_auto_complete_path(char *path)
405405
{
406406
DIR *dir = RT_NULL;
@@ -521,7 +521,7 @@ void msh_auto_complete_path(char *path)
521521
closedir(dir);
522522
rt_free(full_path);
523523
}
524-
#endif /* RT_USING_DFS */
524+
#endif /* RT_USING_POSIX */
525525

526526
void msh_auto_complete(char *prefix)
527527
{
@@ -538,7 +538,7 @@ void msh_auto_complete(char *prefix)
538538
return;
539539
}
540540

541-
#ifdef RT_USING_DFS
541+
#ifdef RT_USING_POSIX
542542
/* check whether a spare in the command */
543543
{
544544
char *ptr;

components/finsh/msh_file.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include <rtthread.h>
1313

14-
#if defined(RT_USING_FINSH) && defined(RT_USING_DFS)
14+
#if defined(RT_USING_FINSH) && defined(RT_USING_POSIX)
1515

1616
#include <finsh.h>
1717
#include "msh.h"
@@ -702,5 +702,5 @@ static int cmd_tail(int argc, char **argv)
702702
}
703703
MSH_CMD_EXPORT_ALIAS(cmd_tail, tail, print the last N - lines data of the given file);
704704

705-
#endif /* defined(RT_USING_FINSH) && defined(RT_USING_DFS) */
705+
#endif /* defined(RT_USING_FINSH) && defined(RT_USING_POSIX) */
706706

components/finsh/shell.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
#include "shell.h"
2828
#include "msh.h"
2929

30-
#if defined(RT_USING_DFS)
31-
#include <dfs_posix.h>
32-
#endif /* RT_USING_DFS */
30+
#ifdef RT_USING_POSIX
31+
#include <dfs_posix.h>
32+
#endif /* RT_USING_POSIX */
3333

3434
/* finsh thread */
3535
#ifndef RT_USING_HEAP
@@ -104,7 +104,7 @@ const char *finsh_get_prompt(void)
104104
}
105105
strcpy(finsh_prompt, _MSH_PROMPT);
106106

107-
#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
107+
#if defined(RT_USING_POSIX) && defined(DFS_USING_WORKDIR)
108108
/* get current working directory */
109109
getcwd(&finsh_prompt[rt_strlen(finsh_prompt)], RT_CONSOLEBUF_SIZE - rt_strlen(finsh_prompt));
110110
#endif
@@ -145,7 +145,7 @@ void finsh_set_prompt_mode(rt_uint32_t prompt_mode)
145145
int finsh_getchar(void)
146146
{
147147
#ifdef RT_USING_DEVICE
148-
#ifdef RT_USING_POSIX
148+
#ifdef RT_USING_LIBC
149149
return getchar();
150150
#else
151151
char ch = 0;
@@ -163,14 +163,14 @@ int finsh_getchar(void)
163163
rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER);
164164

165165
return ch;
166-
#endif /* RT_USING_POSIX */
166+
#endif /* RT_USING_LIBC */
167167
#else
168168
extern char rt_hw_console_getchar(void);
169169
return rt_hw_console_getchar();
170170
#endif /* RT_USING_DEVICE */
171171
}
172172

173-
#if !defined(RT_USING_POSIX) && defined(RT_USING_DEVICE)
173+
#if !defined(RT_USING_LIBC) && defined(RT_USING_DEVICE)
174174
static rt_err_t finsh_rx_ind(rt_device_t dev, rt_size_t size)
175175
{
176176
RT_ASSERT(shell != RT_NULL);
@@ -436,7 +436,7 @@ void finsh_thread_entry(void *parameter)
436436
shell->echo_mode = 0;
437437
#endif
438438

439-
#if !defined(RT_USING_POSIX) && defined(RT_USING_DEVICE)
439+
#if !defined(RT_USING_LIBC) && defined(RT_USING_DEVICE)
440440
/* set console device as shell device */
441441
if (shell->device == RT_NULL)
442442
{

components/finsh/shell.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct finsh_shell
7878
rt_uint16_t line_position;
7979
rt_uint16_t line_curpos;
8080

81-
#if !defined(RT_USING_POSIX) && defined(RT_USING_DEVICE)
81+
#if !defined(RT_USING_LIBC) && defined(RT_USING_DEVICE)
8282
rt_device_t device;
8383
#endif
8484

components/libc/Kconfig

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ menu "POSIX layer and C standard library"
22

33
config RT_USING_LIBC
44
bool "Enable libc APIs from toolchain"
5+
select RT_USING_DFS
6+
select RT_USING_POSIX
57
default y
68

79
config RT_USING_PTHREADS
@@ -14,9 +16,9 @@ if RT_USING_PTHREADS
1416
default 8
1517
endif
1618

17-
if RT_USING_LIBC && RT_USING_DFS
19+
if RT_USING_DFS
1820
config RT_USING_POSIX
19-
bool "Enable POSIX layer for compatibility with UNIX APIs, poll/select etc"
21+
bool "Enable POSIX layer, open/read/write/select etc"
2022
select RT_USING_DFS_DEVFS
2123
default y
2224

@@ -49,9 +51,9 @@ if RT_USING_LIBC
4951
default n
5052

5153
if RT_USING_MODULE
52-
config RT_USING_CUSTOM_DLMODULE
53-
bool "Enable load dynamic module by custom"
54-
default n
54+
config RT_USING_CUSTOM_DLMODULE
55+
bool "Enable load dynamic module by custom"
56+
default n
5557
endif
5658

5759
endif

components/libc/compilers/common/SConscript

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@ src = []
66
cwd = GetCurrentDir()
77
group = []
88
CPPPATH = [cwd]
9+
CPPDEFINES = []
910

1011
if GetDepend('RT_USING_LIBC'):
1112
src += Glob('*.c')
12-
if GetDepend('RT_USING_POSIX') == False:
13-
SrcRemove(src, ['unistd.c', 'delay.c'])
1413
elif GetDepend('RT_LIBC_USING_TIME'):
1514
src += Glob('time.c')
1615

1716
if rtconfig.CROSS_TOOL == 'keil':
18-
CPPDEFINES = ['__CLK_TCK=RT_TICK_PER_SECOND']
19-
else:
20-
CPPDEFINES = []
17+
CPPDEFINES += ['__CLK_TCK=RT_TICK_PER_SECOND']
2118

2219
group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
2320

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
## Attentions
2-
3-
1. This folder is "common" for all toolchains.
4-
5-
2. If you want to add new `.c` files, please do not forget to fix SConscript file too. eg:
6-
7-
```python
8-
if GetDepend('RT_USING_POSIX') == False:
9-
SrcRemove(src, ['unistd.c'])
10-
```
1+
This folder is "common" for all toolchains.

0 commit comments

Comments
 (0)