Merge pull request #5334 from mysterywolf/posix

[posix] 按照高级unix环境编程整理IO类别
This commit is contained in:
Bernard Xiong
2021-12-07 23:54:44 +08:00
committed by GitHub
22 changed files with 240 additions and 136 deletions
+1 -1
View File
@@ -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. */
@@ -1,8 +0,0 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
*/
@@ -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
+16 -16
View File
@@ -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
+34
View File
@@ -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')
@@ -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)
@@ -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;
@@ -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>
+11
View File
@@ -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')
@@ -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')
@@ -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)
{
@@ -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>
-16
View File
@@ -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)
-11
View File
@@ -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')