Skip to content

Commit 31c3214

Browse files
authored
[posix][io]整理posix/io文件夹 (#5539)
* [posix][io]整理posix/io文件夹 - 将select.c移入到poll文件夹 - 将libc.c移入到tty文件夹,isatty函数归并到libc.c中, termios并入tty文件夹中 - 整理Sconscript Signed-off-by: Meco Man <[email protected]> * [libc][newlib]调整文件夹结构
1 parent e10173d commit 31c3214

File tree

14 files changed

+64
-133
lines changed

14 files changed

+64
-133
lines changed

components/libc/compilers/newlib/libc_syms.c

Lines changed: 0 additions & 53 deletions
This file was deleted.

components/libc/posix/io/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
This folder contains:
2+
3+
| sub-folders | description |
4+
| ----------- | ------------------------- |
5+
| aio | Asynchronous I/O |
6+
| mman | Memory-Mapped I/O |
7+
| poll | Nonblocking I/O |
8+
| stdio | Standard Input/Output I/O |
9+
| termios | Terminal I/O |
10+

components/libc/posix/io/SConscript

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,9 @@
33
import os
44
from building import *
55

6-
src = []
76
cwd = GetCurrentDir()
8-
CPPPATH = [cwd]
97
group = []
108

11-
flag = False
12-
13-
if GetDepend('RT_USING_POSIX_STDIO'):
14-
src += ['libc.c']
15-
flag = True
16-
17-
if GetDepend('RT_USING_POSIX_SELECT'):
18-
src += ['select.c']
19-
flag = True
20-
21-
if flag == True:
22-
group = DefineGroup('POSIX', src, depend = [''], CPPPATH = CPPPATH)
23-
249
list = os.listdir(cwd)
2510
for d in list:
2611
path = os.path.join(cwd, d)

components/libc/posix/io/poll/SConscript

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ src = []
77
CPPPATH = [cwd]
88

99
if GetDepend('RT_USING_POSIX_POLL'):
10-
src += ['poll.c']
10+
src += ['poll.c']
11+
12+
if GetDepend('RT_USING_POSIX_SELECT'):
13+
src += ['select.c']
1114

1215
group = DefineGroup('POSIX', src, depend = [''], CPPPATH = CPPPATH)
1316

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# RT-Thread building script for component
2+
3+
import os
4+
from building import *
5+
6+
src = []
7+
cwd = GetCurrentDir()
8+
CPPPATH = [cwd]
9+
group = []
10+
11+
if GetDepend('RT_USING_POSIX_STDIO'):
12+
src += ['libc.c']
13+
14+
group = DefineGroup('POSIX', src, depend = [''], CPPPATH = CPPPATH)
15+
16+
list = os.listdir(cwd)
17+
for d in list:
18+
path = os.path.join(cwd, d)
19+
if os.path.isfile(os.path.join(path, 'SConscript')):
20+
group = group + SConscript(os.path.join(d, 'SConscript'))
21+
22+
Return('group')
Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
#include <unistd.h>
1616
#include <fcntl.h>
1717
#include <sys/time.h>
18+
#include <sys/errno.h>
1819
#include "libc.h"
19-
#include <stdio.h>
20-
#include <stdlib.h>
2120

2221
int libc_system_init(void)
2322
{
@@ -108,7 +107,7 @@ int libc_stdio_get_console(void)
108107
return -1;
109108
}
110109

111-
#else
110+
#elif defined(RT_USING_POSIX_STDIO)
112111
#define STDIO_DEVICE_NAME_MAX 32
113112
static int std_fd = -1;
114113
int libc_stdio_set_console(const char* device_name, int mode)
@@ -136,3 +135,24 @@ int libc_stdio_get_console(void) {
136135
return std_fd;
137136
}
138137
#endif /* defined(RT_USING_POSIX_STDIO) && defined(RT_USING_NEWLIB) */
138+
139+
int isatty(int fd)
140+
{
141+
#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
142+
if(fd == STDOUT_FILENO || fd == STDERR_FILENO)
143+
{
144+
return 1;
145+
}
146+
#endif
147+
148+
#ifdef RT_USING_POSIX_STDIO
149+
if(fd == STDIN_FILENO)
150+
{
151+
return 1;
152+
}
153+
#endif
154+
155+
rt_set_errno(ENOTTY);
156+
return 0;
157+
}
158+
RTM_EXPORT(isatty);

components/libc/posix/io/termios/termios.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
#include <stdlib.h>
1212
#include <string.h>
1313
#include <unistd.h>
14-
#include <sys/stat.h>
15-
#include <sys/statfs.h>
1614
#include <sys/errno.h>
1715
#include "termios.h"
1816

components/libc/posix/libdl/SConscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from building import *
22
Import('rtconfig')
33

4-
src = Glob('*.c') + Glob('*.cpp') + Glob('arch/*.c')
4+
src = Glob('*.c') + Glob('arch/*.c')
55
cwd = GetCurrentDir()
66
group = []
77
CPPPATH = [cwd]

0 commit comments

Comments
 (0)