summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-12-05 18:52:59 -0500
committerMeco Man <[email protected]>2021-12-05 23:07:41 -0500
commit67e14adc4f0dfbaef4762e383a5328add42f6cf5 (patch)
tree8a35775d716f5ca3f2d4bf8fc5caf58e0bc0ed40 /components
parent3dd1aa754c0ca9e8c5df0d3b3c98942d115149b1 (diff)
[posix] 按照高级unix环境编程整理IO类别
Diffstat (limited to 'components')
-rw-r--r--components/drivers/serial/serial.c2
-rw-r--r--components/libc/compilers/common/sys/termios.h8
-rw-r--r--components/libc/compilers/common/termios.h19
-rw-r--r--components/libc/posix/Kconfig32
-rw-r--r--components/libc/posix/io/SConscript34
-rw-r--r--components/libc/posix/io/aio/SConscript (renamed from components/libc/posix/aio/SConscript)2
-rw-r--r--components/libc/posix/io/aio/aio.c (renamed from components/libc/posix/aio/posix_aio.c)2
-rw-r--r--components/libc/posix/io/aio/aio.h (renamed from components/libc/posix/aio/posix_aio.h)4
-rw-r--r--components/libc/posix/io/libc.c (renamed from components/libc/posix/src/libc.c)0
-rw-r--r--components/libc/posix/io/libc.h (renamed from components/libc/posix/src/libc.h)0
-rw-r--r--components/libc/posix/io/mmap.c (renamed from components/libc/posix/src/mmap.c)0
-rw-r--r--components/libc/posix/io/poll/SConscript11
-rw-r--r--components/libc/posix/io/poll/poll.c (renamed from components/libc/posix/src/poll.c)0
-rw-r--r--components/libc/posix/io/poll/poll.h (renamed from components/libc/compilers/common/poll.h)0
-rw-r--r--components/libc/posix/io/select.c (renamed from components/libc/posix/src/select.c)0
-rw-r--r--components/libc/posix/io/termios/SConscript11
-rw-r--r--components/libc/posix/io/termios/termios.c (renamed from components/libc/posix/termios/posix_termios.c)2
-rw-r--r--components/libc/posix/io/termios/termios.h (renamed from components/libc/posix/termios/posix_termios.h)4
-rw-r--r--components/libc/posix/src/SConscript16
-rw-r--r--components/libc/posix/termios/SConscript11
20 files changed, 80 insertions, 78 deletions
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c
index 0e944b5e95..6f7e7d5b2b 100644
--- a/components/drivers/serial/serial.c
+++ b/components/drivers/serial/serial.c
@@ -42,7 +42,7 @@
#include <sys/ioctl.h>
#ifdef RT_USING_POSIX_TERMIOS
-#include <posix_termios.h>
+#include <termios.h>
#endif
/* it's possible the 'getc/putc' is defined by stdio.h in gcc/newlib. */
diff --git a/components/libc/compilers/common/sys/termios.h b/components/libc/compilers/common/sys/termios.h
deleted file mode 100644
index c4b42083c4..0000000000
--- a/components/libc/compilers/common/sys/termios.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- */
diff --git a/components/libc/compilers/common/termios.h b/components/libc/compilers/common/termios.h
deleted file mode 100644
index 2960d52c58..0000000000
--- a/components/libc/compilers/common/termios.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- */
-#ifndef _TERMIOS_H__
-#define _TERMIOS_H__
-
-#include <rtconfig.h>
-
-#ifdef RT_USING_POSIX_TERMIOS
-#include <sys/types.h>
-#include <posix_termios.h>
-#endif
-
-#endif
diff --git a/components/libc/posix/Kconfig b/components/libc/posix/Kconfig
index 0afff161ff..db83269dd0 100644
--- a/components/libc/posix/Kconfig
+++ b/components/libc/posix/Kconfig
@@ -1,7 +1,7 @@
menu "POSIX (Portable Operating System Interface) layer"
config RT_USING_POSIX_FS
- bool "Enable POSIX file system, open()/read()/write()/close() etc"
+ bool "Enable POSIX file system and I/O"
select RT_USING_DFS
select DFS_USING_POSIX
default n
@@ -13,13 +13,26 @@ if RT_USING_POSIX_FS
default n
config RT_USING_POSIX_POLL
- bool "Enable poll()"
+ bool "Enable I/O Multiplexing poll() <poll.h>"
default n
config RT_USING_POSIX_SELECT
- bool "Enable select()"
+ bool "Enable I/O Multiplexing select() <sys/select.h>"
select RT_USING_POSIX_POLL
default n
+
+ config RT_USING_POSIX_TERMIOS
+ bool "Enable Terminal I/O <termios.h>"
+ select RT_USING_POSIX_DEVIO
+ default n
+
+ config RT_USING_POSIX_AIO
+ bool "Enable Asynchronous I/O <aio.h>"
+ default n
+
+ config RT_USING_POSIX_MMAP
+ bool "Enable Memory-Mapped I/O <sys/mman.h>"
+ default n
endif
config RT_USING_POSIX_DELAY
@@ -32,19 +45,6 @@ config RT_USING_POSIX_GETLINE
select RT_LIBC_USING_FILEIO
default n
-config RT_USING_POSIX_MMAP
- bool "Enable mmap()"
- select RT_USING_POSIX_FS
- default n
-
-config RT_USING_POSIX_TERMIOS
- bool "Enable termios APIs"
- default n
-
-config RT_USING_POSIX_AIO
- bool "Enable AIO APIs"
- default n
-
config RT_USING_PTHREADS
bool "Enable pthreads APIs"
default n
diff --git a/components/libc/posix/io/SConscript b/components/libc/posix/io/SConscript
new file mode 100644
index 0000000000..2a7cd76ded
--- /dev/null
+++ b/components/libc/posix/io/SConscript
@@ -0,0 +1,34 @@
+# RT-Thread building script for component
+
+import os
+from building import *
+
+src = []
+cwd = GetCurrentDir()
+CPPPATH = [cwd]
+group = []
+
+flag = False
+
+if GetDepend('RT_USING_POSIX_DEVIO'):
+ src += ['libc.c']
+ flag = True
+
+if GetDepend('RT_USING_POSIX_SELECT'):
+ src += ['select.c']
+ flag = True
+
+if GetDepend('RT_USING_POSIX_MMAP'):
+ src += ['mmap.c']
+ flag = True
+
+if flag == True:
+ group = DefineGroup('POSIX', src, depend = [], CPPPATH = CPPPATH)
+
+list = os.listdir(cwd)
+for d in list:
+ path = os.path.join(cwd, d)
+ if os.path.isfile(os.path.join(path, 'SConscript')):
+ group = group + SConscript(os.path.join(d, 'SConscript'))
+
+Return('group')
diff --git a/components/libc/posix/aio/SConscript b/components/libc/posix/io/aio/SConscript
index 139bc45749..6d4014311c 100644
--- a/components/libc/posix/aio/SConscript
+++ b/components/libc/posix/io/aio/SConscript
@@ -3,7 +3,7 @@
from building import *
cwd = GetCurrentDir()
-src = Glob('*.c')
+src = ['aio.c']
CPPPATH = [cwd]
group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX_AIO'], CPPPATH = CPPPATH)
diff --git a/components/libc/posix/aio/posix_aio.c b/components/libc/posix/io/aio/aio.c
index 66cced8687..08ef4c634a 100644
--- a/components/libc/posix/aio/posix_aio.c
+++ b/components/libc/posix/io/aio/aio.c
@@ -11,7 +11,7 @@
#include <stdint.h>
#include <rthw.h>
#include <dfs_posix.h>
-#include "posix_aio.h"
+#include "aio.h"
struct rt_workqueue* aio_queue = NULL;
diff --git a/components/libc/posix/aio/posix_aio.h b/components/libc/posix/io/aio/aio.h
index 4e25e1d15b..35a5c194db 100644
--- a/components/libc/posix/aio/posix_aio.h
+++ b/components/libc/posix/io/aio/aio.h
@@ -8,8 +8,8 @@
* 2017/12/30 Bernard The first version.
*/
-#ifndef POSIX_AIO_H__
-#define POSIX_AIO_H__
+#ifndef __AIO_H__
+#define __AIO_H__
#include <stdio.h>
#include <sys/signal.h>
diff --git a/components/libc/posix/src/libc.c b/components/libc/posix/io/libc.c
index c324d84ef8..c324d84ef8 100644
--- a/components/libc/posix/src/libc.c
+++ b/components/libc/posix/io/libc.c
diff --git a/components/libc/posix/src/libc.h b/components/libc/posix/io/libc.h
index b019267926..b019267926 100644
--- a/components/libc/posix/src/libc.h
+++ b/components/libc/posix/io/libc.h
diff --git a/components/libc/posix/src/mmap.c b/components/libc/posix/io/mmap.c
index e68b82e640..e68b82e640 100644
--- a/components/libc/posix/src/mmap.c
+++ b/components/libc/posix/io/mmap.c
diff --git a/components/libc/posix/io/poll/SConscript b/components/libc/posix/io/poll/SConscript
new file mode 100644
index 0000000000..47f1722ed3
--- /dev/null
+++ b/components/libc/posix/io/poll/SConscript
@@ -0,0 +1,11 @@
+# RT-Thread building script for component
+
+from building import *
+
+cwd = GetCurrentDir()
+src = ['poll.c']
+CPPPATH = [cwd]
+
+group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX_POLL'], CPPPATH = CPPPATH)
+
+Return('group')
diff --git a/components/libc/posix/src/poll.c b/components/libc/posix/io/poll/poll.c
index 0c773b306c..0c773b306c 100644
--- a/components/libc/posix/src/poll.c
+++ b/components/libc/posix/io/poll/poll.c
diff --git a/components/libc/compilers/common/poll.h b/components/libc/posix/io/poll/poll.h
index aea73d6eaf..aea73d6eaf 100644
--- a/components/libc/compilers/common/poll.h
+++ b/components/libc/posix/io/poll/poll.h
diff --git a/components/libc/posix/src/select.c b/components/libc/posix/io/select.c
index 55d320e921..55d320e921 100644
--- a/components/libc/posix/src/select.c
+++ b/components/libc/posix/io/select.c
diff --git a/components/libc/posix/io/termios/SConscript b/components/libc/posix/io/termios/SConscript
new file mode 100644
index 0000000000..68bd9d81c9
--- /dev/null
+++ b/components/libc/posix/io/termios/SConscript
@@ -0,0 +1,11 @@
+# RT-Thread building script for component
+
+from building import *
+
+cwd = GetCurrentDir()
+src = ['termios.c']
+CPPPATH = [cwd]
+
+group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX_TERMIOS'], CPPPATH = CPPPATH)
+
+Return('group')
diff --git a/components/libc/posix/termios/posix_termios.c b/components/libc/posix/io/termios/termios.c
index 9f33c857e6..d7d869d67f 100644
--- a/components/libc/posix/termios/posix_termios.c
+++ b/components/libc/posix/io/termios/termios.c
@@ -11,7 +11,7 @@
#include <string.h>
#include <dfs_posix.h>
#include <sys/errno.h>
-#include <termios.h>
+#include "termios.h"
int tcgetattr(int fd, struct termios *tio)
{
diff --git a/components/libc/posix/termios/posix_termios.h b/components/libc/posix/io/termios/termios.h
index 6dc5531955..b647fa0728 100644
--- a/components/libc/posix/termios/posix_termios.h
+++ b/components/libc/posix/io/termios/termios.h
@@ -7,8 +7,8 @@
* Date Author Notes
* 2017/08/30 Bernard The first version
*/
-#ifndef TERMIOS_H__
-#define TERMIOS_H__
+#ifndef __TERMIOS_H__
+#define __TERMIOS_H__
#include <sys/types.h>
#include <sys/ioctl.h>
diff --git a/components/libc/posix/src/SConscript b/components/libc/posix/src/SConscript
index 4be5ac83cc..87be6b6a06 100644
--- a/components/libc/posix/src/SConscript
+++ b/components/libc/posix/src/SConscript
@@ -10,26 +10,10 @@ group = []
flag = False
src += ['unistd.c'] #TODO
-if GetDepend('RT_USING_POSIX_DEVIO'):
- src += ['libc.c']
- flag = True
-
if GetDepend('RT_USING_POSIX_DELAY'):
src += ['delay.c']
flag = True
-if GetDepend('RT_USING_POSIX_POLL'):
- src += ['poll.c']
- flag = True
-
-if GetDepend('RT_USING_POSIX_SELECT'):
- src += ['select.c']
- flag = True
-
-if GetDepend('RT_USING_POSIX_MMAP'):
- src += ['mmap.c']
- flag = True
-
if flag == True:
group = DefineGroup('POSIX', src, depend = [], CPPPATH = CPPPATH)
diff --git a/components/libc/posix/termios/SConscript b/components/libc/posix/termios/SConscript
deleted file mode 100644
index 3615926251..0000000000
--- a/components/libc/posix/termios/SConscript
+++ /dev/null
@@ -1,11 +0,0 @@
-# RT-Thread building script for component
-
-from building import *
-
-cwd = GetCurrentDir()
-src = Glob('*.c') + Glob('*.cpp')
-CPPPATH = [cwd]
-
-group = DefineGroup('POSIX', src, depend = ['RT_USING_LIBC', 'RT_USING_POSIX_TERMIOS'], CPPPATH = CPPPATH)
-
-Return('group')