diff options
Diffstat (limited to 'components/libc/posix')
24 files changed, 279 insertions, 52 deletions
diff --git a/components/libc/posix/Kconfig b/components/libc/posix/Kconfig index 0afff161ff..4534da7118 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_MMAN + 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 @@ -55,4 +55,6 @@ if RT_USING_PTHREADS default 8 endif +source "$RTT_DIR/components/libc/posix/ipc/Kconfig" + endmenu diff --git a/components/libc/posix/io/SConscript b/components/libc/posix/io/SConscript new file mode 100644 index 0000000000..32654674e8 --- /dev/null +++ b/components/libc/posix/io/SConscript @@ -0,0 +1,30 @@ +# 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 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/io/mman/SConscript b/components/libc/posix/io/mman/SConscript new file mode 100644 index 0000000000..7dd096c998 --- /dev/null +++ b/components/libc/posix/io/mman/SConscript @@ -0,0 +1,11 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = ['mman.c'] +CPPPATH = [cwd] + +group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX_MMAN'], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/libc/posix/src/mmap.c b/components/libc/posix/io/mman/mman.c index e68b82e640..827f2cbb14 100644 --- a/components/libc/posix/src/mmap.c +++ b/components/libc/posix/io/mman/mman.c @@ -14,7 +14,7 @@ #include <rtthread.h> #include <dfs_posix.h> -#include <sys/mman.h> +#include "sys/mman.h" void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) diff --git a/components/libc/posix/io/mman/sys/mman.h b/components/libc/posix/io/mman/sys/mman.h new file mode 100644 index 0000000000..a730f33b6b --- /dev/null +++ b/components/libc/posix/io/mman/sys/mman.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2017/11/30 Bernard The first version. + */ + +#ifndef __SYS_MMAN_H__ +#define __SYS_MMAN_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <sys/types.h> + +#define MAP_FAILED ((void *) -1) + +#define MAP_SHARED 0x01 +#define MAP_PRIVATE 0x02 +#define MAP_TYPE 0x0f +#define MAP_FIXED 0x10 +#define MAP_ANON 0x20 +#define MAP_ANONYMOUS MAP_ANON +#define MAP_NORESERVE 0x4000 +#define MAP_GROWSDOWN 0x0100 +#define MAP_DENYWRITE 0x0800 +#define MAP_EXECUTABLE 0x1000 +#define MAP_LOCKED 0x2000 +#define MAP_POPULATE 0x8000 +#define MAP_NONBLOCK 0x10000 +#define MAP_STACK 0x20000 +#define MAP_HUGETLB 0x40000 +#define MAP_FILE 0 + +#define PROT_NONE 0 +#define PROT_READ 1 +#define PROT_WRITE 2 +#define PROT_EXEC 4 +#define PROT_GROWSDOWN 0x01000000 +#define PROT_GROWSUP 0x02000000 + +#define MS_ASYNC 1 +#define MS_INVALIDATE 2 +#define MS_SYNC 4 + +#define MCL_CURRENT 1 +#define MCL_FUTURE 2 +#define MCL_ONFAULT 4 + +void *mmap (void *start, size_t len, int prot, int flags, int fd, off_t off); +int munmap (void *start, size_t len); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/components/libc/posix/io/poll/SConscript b/components/libc/posix/io/poll/SConscript new file mode 100644 index 0000000000..7d82ade035 --- /dev/null +++ b/components/libc/posix/io/poll/SConscript @@ -0,0 +1,14 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = [] +CPPPATH = [cwd] + +if GetDepend('RT_USING_POSIX_POLL'): + src += ['poll.c'] + +group = DefineGroup('POSIX', src, depend = [], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/libc/posix/src/poll.c b/components/libc/posix/io/poll/poll.c index 0c773b306c..a1500ba109 100644 --- a/components/libc/posix/src/poll.c +++ b/components/libc/posix/io/poll/poll.c @@ -12,7 +12,7 @@ #include <rthw.h> #include <rtthread.h> #include <dfs_file.h> -#include <poll.h> +#include "poll.h" struct rt_poll_node; diff --git a/components/libc/posix/io/poll/poll.h b/components/libc/posix/io/poll/poll.h new file mode 100644 index 0000000000..aea73d6eaf --- /dev/null +++ b/components/libc/posix/io/poll/poll.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-11 Meco Man First version + */ +#ifndef __POLL_H__ +#define __POLL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(POLLIN) && !defined(POLLOUT) +#define POLLIN (0x01) +#define POLLRDNORM (0x01) +#define POLLRDBAND (0x01) +#define POLLPRI (0x01) + +#define POLLOUT (0x02) +#define POLLWRNORM (0x02) +#define POLLWRBAND (0x02) + +#define POLLERR (0x04) +#define POLLHUP (0x08) +#define POLLNVAL (0x10) + +typedef unsigned int nfds_t; + +struct pollfd +{ + int fd; + short events; + short revents; +}; +#endif /* !defined(POLLIN) && !defined(POLLOUT) */ + +#define POLLMASK_DEFAULT (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM) + +int poll(struct pollfd *fds, nfds_t nfds, int timeout); + +#ifdef __cplusplus +} +#endif + +#endif /* __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/ipc/Kconfig b/components/libc/posix/ipc/Kconfig new file mode 100644 index 0000000000..f5ec6ad040 --- /dev/null +++ b/components/libc/posix/ipc/Kconfig @@ -0,0 +1,17 @@ +menu "Interprocess Communication (IPC)" + +config RT_USING_POSIX_PIPE + bool "Enable pipe and FIFO" + select RT_USING_POSIX_FS + select RT_USING_POSIX_DEVIO + select RT_USING_POSIX_POLL + default n + +config RT_USING_POSIX_PIPE_SIZE + int "Set pipe buffer size" + depends on RT_USING_POSIX_PIPE + default 512 + +comment "Socket is in the 'Network' category" + +endmenu diff --git a/components/libc/posix/ipc/sys/ipc.h b/components/libc/posix/ipc/sys/ipc.h new file mode 100644 index 0000000000..03b5458d51 --- /dev/null +++ b/components/libc/posix/ipc/sys/ipc.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-07 Meco Man First version + */ +#ifndef __SYS_IPC_H__ +#define __SYS_IPC_H__ + + + +#endif diff --git a/components/libc/posix/ipc/sys/msg.h b/components/libc/posix/ipc/sys/msg.h new file mode 100644 index 0000000000..c030c9e8cb --- /dev/null +++ b/components/libc/posix/ipc/sys/msg.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-07 Meco Man First version + */ +#ifndef __SYS_MSG_H__ +#define __SYS_MSG_H__ + + + +#endif diff --git a/components/libc/posix/ipc/sys/sem.h b/components/libc/posix/ipc/sys/sem.h new file mode 100644 index 0000000000..b849bd687d --- /dev/null +++ b/components/libc/posix/ipc/sys/sem.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-07 Meco Man First version + */ +#ifndef __SYS_SEM_H__ +#define __SYS_SEM_H__ + + + +#endif diff --git a/components/libc/posix/ipc/sys/shm.h b/components/libc/posix/ipc/sys/shm.h new file mode 100644 index 0000000000..762d68891a --- /dev/null +++ b/components/libc/posix/ipc/sys/shm.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-12-07 Meco Man First version + */ +#ifndef __SYS_SHM_H__ +#define __SYS_SHM_H__ + + + +#endif 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') |
