Skip to content

Commit 1d4594c

Browse files
authored
Merge pull request #5317 from mysterywolf/PSE
[PSE分支] 替换宏定义 将posix单独划分为一个Kconfig目录
2 parents 838d108 + 7b1f65a commit 1d4594c

File tree

8 files changed

+80
-64
lines changed

8 files changed

+80
-64
lines changed

bsp/lpc55sxx/lpc55s69_nxp_evk/board/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ menu "On-chip Peripheral Drivers"
137137
select RT_USING_SDIO
138138
select RT_USING_DFS
139139
select RT_USING_DFS_ELMFAT
140-
select RT_USING_LIBC
141140
select RT_LIBC_USING_TIME
142141
default y
143142

bsp/stm32/stm32l475-atk-pandora/board/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ menu "Onboard Peripheral Drivers"
137137
select RT_WLAN_PROT_LWIP_PBUF_FORCE
138138
select RT_USING_LWIP
139139
select RT_USING_LIBC
140-
select RT_USING_POSIX
141140
select RT_USING_DFS
141+
select DFS_USING_POSIX
142142
select PKG_USING_FAL
143143
select PKG_USING_EASYFLASH
144144
select RT_USING_WIFI_6181_LIB

components/cplusplus/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if RT_USING_CPLUSPLUS
1010
bool "Enable c++11 threading feature support"
1111
default n
1212
select RT_USING_LIBC
13-
select RT_USING_DFS
13+
select RT_LIBC_USING_FILEIO
1414
select RT_USING_PTHREADS
1515
select RT_USING_RTC
1616

components/drivers/src/pipe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ const static struct rt_device_ops pipe_ops =
439439
rt_pipe_write,
440440
rt_pipe_control,
441441
};
442-
#endif
442+
#endif /* RT_USING_DEVICE_OPS */
443443

444444
rt_pipe_t *rt_pipe_create(const char *name, int bufsz)
445445
{
@@ -481,7 +481,7 @@ rt_pipe_t *rt_pipe_create(const char *name, int bufsz)
481481
}
482482
#ifdef RT_USING_POSIX_DEVIO
483483
dev->fops = (void*)&pipe_fops;
484-
#endif
484+
#endif /* RT_USING_POSIX_DEVIO */
485485

486486
return pipe;
487487
}

components/libc/Kconfig

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
menu "POSIX layer and C standard library"
22

33
config RT_USING_LIBC
4-
bool "Enable libc APIs from toolchain"
4+
bool "Enable libc APIs from the toolchain"
55
default n
66

77
if RT_USING_LIBC
@@ -37,59 +37,6 @@ config RT_LIBC_DEFAULT_TIMEZONE
3737
range -12 12
3838
default 8
3939

40-
config RT_USING_POSIX_FS
41-
bool "Enable POSIX file system, open()/read()/write()/close() etc"
42-
select RT_USING_DFS
43-
select DFS_USING_POSIX
44-
default n
45-
46-
if RT_USING_POSIX_FS
47-
config RT_USING_POSIX_DEVIO
48-
bool "Enable devices as file descriptors"
49-
select RT_USING_DFS_DEVFS
50-
default n
51-
52-
config RT_USING_POSIX_POLL
53-
bool "Enable poll()"
54-
default n
55-
56-
config RT_USING_POSIX_SELECT
57-
bool "Enable select()"
58-
select RT_USING_POSIX_POLL
59-
default n
60-
endif
61-
62-
config RT_USING_POSIX_DELAY
63-
bool "Enable delay APIs, sleep()/usleep()/msleep() etc"
64-
default n
65-
66-
config RT_USING_POSIX_GETLINE
67-
bool "Enable getline()/getdelim()"
68-
select RT_USING_LIBC
69-
select RT_LIBC_USING_FILEIO
70-
default n
71-
72-
config RT_USING_POSIX_MMAP
73-
bool "Enable mmap()"
74-
select RT_USING_POSIX_FS
75-
default n
76-
77-
config RT_USING_POSIX_TERMIOS
78-
bool "Enable termios APIs"
79-
default n
80-
81-
config RT_USING_POSIX_AIO
82-
bool "Enable AIO APIs"
83-
default n
84-
85-
config RT_USING_PTHREADS
86-
bool "Enable pthreads APIs"
87-
default n
88-
89-
if RT_USING_PTHREADS
90-
config PTHREAD_NUM_MAX
91-
int "Maximum number of pthreads"
92-
default 8
93-
endif
40+
source "$RTT_DIR/components/libc/posix/Kconfig"
9441

9542
endmenu

components/libc/compilers/armlibc/syscalls.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,22 +156,26 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
156156
return 0; /* error, but keep going */
157157
}
158158
size = read(STDIN_FILENO, buf, len);
159-
return 0; /* success */
159+
return len - size; /* success */
160160
#else
161161
return 0; /* error */
162162
#endif /* RT_USING_POSIX_DEVIO */
163163
}
164164
else if (fh == STDOUT || fh == STDERR)
165165
{
166-
return 0; /* error */
166+
return -1; /* 100% error */
167167
}
168168
else
169169
{
170170
size = read(fh, buf, len);
171171
if (size >= 0)
172+
{
172173
return len - size; /* success */
174+
}
173175
else
176+
{
174177
return 0; /* error */
178+
}
175179
}
176180
#else
177181
return 0; /* error */
@@ -209,16 +213,20 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
209213
}
210214
else if (fh == STDIN)
211215
{
212-
return 0; /* error */
216+
return -1; /* 100% error */
213217
}
214218
else
215219
{
216220
#ifdef DFS_USING_POSIX
217221
size = write(fh, buf, len);
218222
if (size >= 0)
219-
return 0; /* success */
223+
{
224+
return len - size; /* success */
225+
}
220226
else
227+
{
221228
return 0; /* error */
229+
}
222230
#else
223231
return 0; /* error */
224232
#endif /* DFS_USING_POSIX */

components/libc/posix/Kconfig

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
menu "POSIX (Portable Operating System Interface) layer"
2+
3+
config RT_USING_POSIX_FS
4+
bool "Enable POSIX file system, open()/read()/write()/close() etc"
5+
select RT_USING_DFS
6+
select DFS_USING_POSIX
7+
default n
8+
9+
if RT_USING_POSIX_FS
10+
config RT_USING_POSIX_DEVIO
11+
bool "Enable devices as file descriptors"
12+
select RT_USING_DFS_DEVFS
13+
default n
14+
15+
config RT_USING_POSIX_POLL
16+
bool "Enable poll()"
17+
default n
18+
19+
config RT_USING_POSIX_SELECT
20+
bool "Enable select()"
21+
select RT_USING_POSIX_POLL
22+
default n
23+
endif
24+
25+
config RT_USING_POSIX_DELAY
26+
bool "Enable delay APIs, sleep()/usleep()/msleep() etc"
27+
default n
28+
29+
config RT_USING_POSIX_GETLINE
30+
bool "Enable getline()/getdelim()"
31+
select RT_USING_LIBC
32+
select RT_LIBC_USING_FILEIO
33+
default n
34+
35+
config RT_USING_POSIX_MMAP
36+
bool "Enable mmap()"
37+
select RT_USING_POSIX_FS
38+
default n
39+
40+
config RT_USING_POSIX_TERMIOS
41+
bool "Enable termios APIs"
42+
default n
43+
44+
config RT_USING_POSIX_AIO
45+
bool "Enable AIO APIs"
46+
default n
47+
48+
config RT_USING_PTHREADS
49+
bool "Enable pthreads APIs"
50+
default n
51+
52+
if RT_USING_PTHREADS
53+
config PTHREAD_NUM_MAX
54+
int "Maximum number of pthreads"
55+
default 8
56+
endif
57+
58+
endmenu

components/utilities/ymodem/ry_sy.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#include <stdlib.h>
1818
#include <string.h>
1919

20+
#ifndef DFS_USING_POSIX
21+
#error "Please enable DFS_USING_POSIX"
22+
#endif
23+
2024
struct custom_ctx
2125
{
2226
struct rym_ctx parent;

0 commit comments

Comments
 (0)