diff options
| author | Bernard Xiong <[email protected]> | 2021-12-05 13:16:39 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-05 13:16:39 +0800 |
| commit | 36d51542565800d503ad204d882e4b1dd3fcfe7d (patch) | |
| tree | debed47f95688577bcbde7846fd9892e9283668e /components | |
| parent | 04535363844d30971edca03f643fc92ba2cd40a7 (diff) | |
| parent | 1040f4a3479b3751a7ad5d5383b62d602fccabed (diff) | |
Merge pull request #5320 from mysterywolf/pse-master
[POSIX] move PSE branch to master
Diffstat (limited to 'components')
30 files changed, 159 insertions, 152 deletions
diff --git a/components/cplusplus/Kconfig b/components/cplusplus/Kconfig index dfab433da0..42b5cf9556 100644 --- a/components/cplusplus/Kconfig +++ b/components/cplusplus/Kconfig @@ -10,7 +10,7 @@ if RT_USING_CPLUSPLUS bool "Enable c++11 threading feature support" default n select RT_USING_LIBC - select RT_USING_DFS + select RT_LIBC_USING_FILEIO select RT_USING_PTHREADS select RT_USING_RTC diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c index d615482452..d60f7ddc9b 100644 --- a/components/dfs/filesystems/devfs/devfs.c +++ b/components/dfs/filesystems/devfs/devfs.c @@ -173,7 +173,7 @@ int dfs_device_fs_open(struct dfs_fd *file) if (device == RT_NULL) return -ENODEV; -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO if (device->fops) { /* use device fops */ @@ -192,7 +192,7 @@ int dfs_device_fs_open(struct dfs_fd *file) } } else -#endif +#endif /* RT_USING_POSIX_DEVIO */ { result = rt_device_open(device, RT_DEVICE_OFLAG_RDWR); if (result == RT_EOK || result == -RT_ENOSYS) diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c index d3a859e287..95fcfc2df6 100644 --- a/components/dfs/src/dfs.c +++ b/components/dfs/src/dfs.c @@ -18,9 +18,9 @@ #include <lwp.h> #endif -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO #include <libc.h> -#endif /* RT_USING_POSIX_STDIO */ +#endif /* RT_USING_POSIX_DEVIO */ /* Global variables */ const struct dfs_filesystem_ops *filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX]; @@ -216,10 +216,10 @@ struct dfs_fd *fd_get(int fd) struct dfs_fd *d; struct dfs_fdtable *fdt; -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO if ((0 <= fd) && (fd <= 2)) fd = libc_stdio_get_console(); -#endif /* RT_USING_POSIX_STDIO */ +#endif /* RT_USING_POSIX_DEVIO */ fdt = dfs_fdtable_get(); fd = fd - DFS_FD_OFFSET; diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 289d523bd2..0e944b5e95 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -36,7 +36,7 @@ #define DBG_LVL DBG_INFO #include <rtdbg.h> -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO #include <dfs_posix.h> #include <poll.h> #include <sys/ioctl.h> @@ -203,7 +203,7 @@ const static struct dfs_file_ops _serial_fops = RT_NULL, /* getdents */ serial_fops_poll, }; -#endif +#endif /* RT_USING_POSIX_DEVIO */ /* * Serial poll routines @@ -362,7 +362,7 @@ static void _serial_check_buffer_size(void) } } -#if defined(RT_USING_POSIX) || defined(RT_SERIAL_USING_DMA) +#if defined(RT_USING_POSIX_DEVIO) || defined(RT_SERIAL_USING_DMA) static rt_size_t _serial_fifo_calc_recved_len(struct rt_serial_device *serial) { struct rt_serial_rx_fifo *rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx; @@ -385,7 +385,7 @@ static rt_size_t _serial_fifo_calc_recved_len(struct rt_serial_device *serial) } } } -#endif /* RT_USING_POSIX || RT_SERIAL_USING_DMA */ +#endif /* RT_USING_POSIX_DEVIO || RT_SERIAL_USING_DMA */ #ifdef RT_SERIAL_USING_DMA /** @@ -976,8 +976,7 @@ static void _tc_flush(struct rt_serial_device *serial, int queue) } } - -#endif +#endif /* RT_USING_POSIX_TERMIOS */ static rt_err_t rt_serial_control(struct rt_device *dev, int cmd, @@ -1020,7 +1019,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev, } break; -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO #ifdef RT_USING_POSIX_TERMIOS case TCGETA: { @@ -1134,6 +1133,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev, } else { + #include <shell.h> #define _TIO_BUFLEN 20 char _tio_buf[_TIO_BUFLEN]; unsigned char cnt1, cnt2, cnt3, i; @@ -1149,7 +1149,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev, i = 0; while(i < _TIO_BUFLEN) { - _tio_buf[i] = getchar(); + _tio_buf[i] = finsh_getchar(); if(_tio_buf[i] != 't') { i ++; @@ -1215,7 +1215,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev, *(rt_size_t *)args = recved; } break; -#endif /*RT_USING_POSIX*/ +#endif /* RT_USING_POSIX_DEVIO */ default : /* control device */ ret = serial->ops->control(serial, cmd, args); @@ -1270,7 +1270,7 @@ rt_err_t rt_hw_serial_register(struct rt_serial_device *serial, /* register a character device */ ret = rt_device_register(device, name, flag); -#if defined(RT_USING_POSIX) +#ifdef RT_USING_POSIX_DEVIO /* set fops */ device->fops = &_serial_fops; #endif diff --git a/components/drivers/serial/serial_v2.c b/components/drivers/serial/serial_v2.c index 390dd31748..4a43970126 100644 --- a/components/drivers/serial/serial_v2.c +++ b/components/drivers/serial/serial_v2.c @@ -16,7 +16,7 @@ #define DBG_LVL DBG_INFO #include <rtdbg.h> -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO #include <dfs_posix.h> #include <poll.h> #include <sys/ioctl.h> @@ -179,7 +179,7 @@ const static struct dfs_file_ops _serial_fops = RT_NULL, /* getdents */ serial_fops_poll, }; -#endif +#endif /* RT_USING_POSIX_DEVIO */ static rt_size_t rt_serial_get_linear_buffer(struct rt_ringbuffer *rb, rt_uint8_t **ptr) @@ -1135,7 +1135,7 @@ rt_err_t rt_hw_serial_register(struct rt_serial_device *serial, /* register a character device */ ret = rt_device_register(device, name, flag); -#if defined(RT_USING_POSIX) +#ifdef RT_USING_POSIX_DEVIO /* set fops */ device->fops = &_serial_fops; #endif diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c index bfb07fa950..89b544bc4e 100644 --- a/components/drivers/src/pipe.c +++ b/components/drivers/src/pipe.c @@ -13,7 +13,7 @@ #include <stdint.h> #include <sys/errno.h> -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO #include <dfs_file.h> #include <dfs_posix.h> #include <poll.h> @@ -320,7 +320,7 @@ static const struct dfs_file_ops pipe_fops = RT_NULL, pipe_fops_poll, }; -#endif /* end of RT_USING_POSIX */ +#endif /* RT_USING_POSIX_DEVIO */ rt_err_t rt_pipe_open(rt_device_t device, rt_uint16_t oflag) { @@ -439,7 +439,7 @@ const static struct rt_device_ops pipe_ops = rt_pipe_write, rt_pipe_control, }; -#endif +#endif /* RT_USING_DEVICE_OPS */ rt_pipe_t *rt_pipe_create(const char *name, int bufsz) { @@ -479,9 +479,9 @@ rt_pipe_t *rt_pipe_create(const char *name, int bufsz) rt_free(pipe); return RT_NULL; } -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO dev->fops = (void*)&pipe_fops; -#endif +#endif /* RT_USING_POSIX_DEVIO */ return pipe; } @@ -529,7 +529,7 @@ int rt_pipe_delete(const char *name) return result; } -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO int pipe(int fildes[2]) { rt_pipe_t *pipe; @@ -575,4 +575,4 @@ int mkfifo(const char *path, mode_t mode) return 0; } -#endif +#endif /* RT_USING_POSIX_DEVIO */ diff --git a/components/finsh/finsh.h b/components/finsh/finsh.h index f5e4df9e49..865627fd79 100644 --- a/components/finsh/finsh.h +++ b/components/finsh/finsh.h @@ -168,7 +168,7 @@ extern struct finsh_syscall *_syscall_table_begin, *_syscall_table_end; /* find out system call, which should be implemented in user program */ struct finsh_syscall *finsh_syscall_lookup(const char *name); -#ifdef RT_USING_DEVICE +#if !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) void finsh_set_device(const char *device_name); #endif diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 5b96d0daf9..c5242d9527 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -146,7 +146,7 @@ int finsh_getchar(void) { #ifdef RT_USING_DEVICE char ch = 0; -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO if(read(STDIN_FILENO, &ch, 1) > 0) { return ch; @@ -170,14 +170,14 @@ int finsh_getchar(void) rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER); return ch; -#endif /* RT_USING_POSIX_STDIO */ +#endif /* RT_USING_POSIX_DEVIO */ #else extern char rt_hw_console_getchar(void); return rt_hw_console_getchar(); #endif /* RT_USING_DEVICE */ } -#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) +#if !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) static rt_err_t finsh_rx_ind(rt_device_t dev, rt_size_t size) { RT_ASSERT(shell != RT_NULL); @@ -241,7 +241,7 @@ const char *finsh_get_device() RT_ASSERT(shell != RT_NULL); return shell->device->parent.name; } -#endif /* !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) */ +#endif /* !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) */ /** * @ingroup finsh @@ -443,7 +443,7 @@ void finsh_thread_entry(void *parameter) shell->echo_mode = 0; #endif -#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) +#if !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) /* set console device as shell device */ if (shell->device == RT_NULL) { @@ -453,7 +453,7 @@ void finsh_thread_entry(void *parameter) finsh_set_device(console->parent.name); } } -#endif /* !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) */ +#endif /* !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) */ #ifdef FINSH_USING_AUTH /* set the default password when the password isn't setting */ diff --git a/components/finsh/shell.h b/components/finsh/shell.h index d421f60374..0c20ba60dd 100644 --- a/components/finsh/shell.h +++ b/components/finsh/shell.h @@ -78,7 +78,7 @@ struct finsh_shell rt_uint16_t line_position; rt_uint16_t line_curpos; -#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) +#if !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE) rt_device_t device; #endif @@ -91,7 +91,6 @@ void finsh_set_echo(rt_uint32_t echo); rt_uint32_t finsh_get_echo(void); int finsh_system_init(void); -void finsh_set_device(const char *device_name); const char *finsh_get_device(void); int finsh_getchar(void); diff --git a/components/legacy/dfs/dfs_select.h b/components/legacy/dfs/dfs_select.h index 6eaaf3bf89..e7cf190e81 100644 --- a/components/legacy/dfs/dfs_select.h +++ b/components/legacy/dfs/dfs_select.h @@ -13,4 +13,4 @@ #include <sys/select.h> -#endif +#endif /* DFS_SELECT_H__ */ diff --git a/components/libc/Kconfig b/components/libc/Kconfig index 94793be569..69f8e1ae36 100644 --- a/components/libc/Kconfig +++ b/components/libc/Kconfig @@ -1,8 +1,7 @@ menu "POSIX layer and C standard library" config RT_USING_LIBC - bool "Enable libc APIs from toolchain" - select RT_USING_HEAP + bool "Enable libc APIs from the toolchain" default n if RT_USING_LIBC @@ -10,9 +9,9 @@ if RT_USING_LIBC default y config RT_LIBC_USING_FILEIO - bool "Enable libc with file operation, eg.fopen/fwrite/fread/getchar" - select RT_USING_POSIX - select RT_USING_POSIX_STDIO + bool "Enable libc with file operation, eg.fopen/fwrite/fread/getchar/STDIO" + select RT_USING_POSIX_FS + select RT_USING_POSIX_DEVIO default n config RT_USING_MODULE @@ -38,59 +37,6 @@ config RT_LIBC_DEFAULT_TIMEZONE range -12 12 default 8 -config RT_USING_POSIX - bool "Enable basic POSIX layer, open()/read()/write()/close() etc" - select RT_USING_DFS - default n - -if RT_USING_POSIX - config RT_USING_POSIX_STDIO - bool "Enable standard I/O, STDOUT_FILENO/STDIN_FILENO/STDERR_FILENO" - select RT_USING_DFS - select RT_USING_DFS_DEVFS - default n - - config RT_USING_POSIX_POLL - bool "Enable poll()" - select RT_USING_DFS - default n - - config RT_USING_POSIX_SELECT - bool "Enable select()" - select RT_USING_DFS - select RT_USING_POSIX_POLL - default n - - config RT_USING_POSIX_DELAY - bool "Enable delay APIs, sleep()/usleep()/msleep() etc" - default n - - config RT_USING_POSIX_GETLINE - bool "Enable getline()/getdelim()" - default n - - config RT_USING_POSIX_MMAP - bool "Enable mmap()" - select RT_USING_DFS - default n - - config RT_USING_POSIX_TERMIOS - bool "Enable termios APIs" - default n - - config RT_USING_POSIX_AIO - bool "Enable AIO APIs" - default n -endif - -config RT_USING_PTHREADS - bool "Enable pthreads APIs" - default n - -if RT_USING_PTHREADS - config PTHREAD_NUM_MAX - int "Maximum number of pthreads" - default 8 -endif +source "$RTT_DIR/components/libc/posix/Kconfig" endmenu diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c index 71eacb1c41..0e965d62af 100644 --- a/components/libc/compilers/armlibc/syscalls.c +++ b/components/libc/compilers/armlibc/syscalls.c @@ -21,9 +21,9 @@ #include <fcntl.h> #include <unistd.h> #include <sys/stat.h> -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO #include "libc.h" -#endif +#endif /* RT_USING_POSIX_DEVIO */ #define DBG_TAG "armlibc.syscalls" #define DBG_LVL DBG_INFO @@ -149,29 +149,33 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) if (fh == STDIN) { -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard output before initializing libc"); return 0; /* error, but keep going */ } size = read(STDIN_FILENO, buf, len); - return 0; /* success */ + return len - size; /* success */ #else return 0; /* error */ -#endif +#endif /* RT_USING_POSIX_DEVIO */ } else if (fh == STDOUT || fh == STDERR) { - return 0; /* error */ + return -1; /* 100% error */ } else { size = read(fh, buf, len); if (size >= 0) + { return len - size; /* success */ + } else + { return 0; /* error */ + } } #else return 0; /* error */ @@ -209,16 +213,20 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) } else if (fh == STDIN) { - return 0; /* error */ + return -1; /* 100% error */ } else { #ifdef DFS_USING_POSIX size = write(fh, buf, len); if (size >= 0) - return 0; /* success */ + { + return len - size; /* success */ + } else + { return 0; /* error */ + } #else return 0; /* error */ #endif /* DFS_USING_POSIX */ @@ -332,7 +340,7 @@ int fputc(int c, FILE *f) int fgetc(FILE *f) { -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO char ch; if (libc_stdio_get_console() < 0) @@ -343,7 +351,7 @@ int fgetc(FILE *f) if(read(STDIN_FILENO, &ch, 1) == 1) return ch; -#endif /* RT_USING_POSIX_STDIO */ +#endif /* RT_USING_POSIX_DEVIO */ return 0; /* error */ } diff --git a/components/libc/compilers/common/sys/ioctl.h b/components/libc/compilers/common/sys/ioctl.h index 04f73837bc..29ed3a8b84 100644 --- a/components/libc/compilers/common/sys/ioctl.h +++ b/components/libc/compilers/common/sys/ioctl.h @@ -11,9 +11,7 @@ #define _SYS_IOCTL_H #include <rtconfig.h> -#ifdef RT_USING_POSIX #include <dfs_posix.h> -#endif #ifdef _WIN32 #include <winsock.h> diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index d14905ebfb..93e3bb7ba4 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -72,7 +72,6 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz); struct tm *gmtime_r(const time_t *timep, struct tm *r); #endif -#ifdef RT_USING_POSIX /* POSIX clock and timer */ #define MILLISECOND_PER_SECOND 1000UL #define MICROSECOND_PER_SECOND 1000000UL @@ -103,8 +102,8 @@ int clock_getres (clockid_t clockid, struct timespec *res); int clock_gettime (clockid_t clockid, struct timespec *tp); int clock_settime (clockid_t clockid, const struct timespec *tp); int rt_timespec_to_tick(const struct timespec *time); -#endif /* RT_USING_POSIX */ +/* timezone */ void tz_set(int8_t tz); int8_t tz_get(void); int8_t tz_is_dst(void); diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 5bfff15914..73b6d76352 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -486,8 +486,6 @@ RTM_EXPORT(settimeofday); RTM_EXPORT(difftime); RTM_EXPORT(strftime); -#ifdef RT_USING_POSIX - #ifdef RT_USING_RTC static volatile struct timeval _timevalue; static int _rt_clock_time_system_init() @@ -690,9 +688,6 @@ int rt_timespec_to_tick(const struct timespec *time) } RTM_EXPORT(rt_timespec_to_tick); -#endif /* RT_USING_POSIX */ - - /* timezone */ #ifndef RT_LIBC_DEFAULT_TIMEZONE #define RT_LIBC_DEFAULT_TIMEZONE 8 diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c index 469ea7c1dd..62bc05d243 100644 --- a/components/libc/compilers/dlib/syscall_read.c +++ b/components/libc/compilers/dlib/syscall_read.c @@ -11,9 +11,9 @@ #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO #include "libc.h" -#endif +#endif /* RT_USING_POSIX_DEVIO */ #define DBG_TAG "dlib.syscall_read" #define DBG_LVL DBG_INFO @@ -39,7 +39,7 @@ size_t __read(int handle, unsigned char *buf, size_t len) if (handle == _LLIO_STDIN) { -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard input before initializing libc"); @@ -48,7 +48,7 @@ size_t __read(int handle, unsigned char *buf, size_t len) return read(STDIN_FILENO, buf, len); /* return the length of the data read */ #else return _LLIO_ERROR; -#endif /* RT_USING_POSIX_STDIO */ +#endif /* RT_USING_POSIX_DEVIO */ } else if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR)) { diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c index d5ede3e59e..2bc5863d8a 100644 --- a/components/libc/compilers/dlib/syscall_write.c +++ b/components/libc/compilers/dlib/syscall_write.c @@ -11,10 +11,6 @@ #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> -#ifdef RT_USING_POSIX_STDIO -#include "libc.h" -#endif - #define DBG_TAG "dlib.syscall_write" #define DBG_LVL DBG_INFO #include <rtdbg.h> diff --git a/components/libc/compilers/gcc/newlib/syscalls.c b/components/libc/compilers/gcc/newlib/syscalls.c index 8bb9af940d..8fe8c5be4b 100644 --- a/components/libc/compilers/gcc/newlib/syscalls.c +++ b/components/libc/compilers/gcc/newlib/syscalls.c @@ -20,12 +20,12 @@ #include <unistd.h> #include <sys/errno.h> #include <sys/stat.h> -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO #include "libc.h" -#endif +#endif /* RT_USING_POSIX_DEVIO */ #ifdef RT_USING_MODULE #include <dlmodule.h> -#endif +#endif /* RT_USING_MODULE */ #define DBG_TAG "newlib.syscalls" #define DBG_LVL DBG_INFO @@ -225,7 +225,7 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes) _ssize_t rc; if (fd == STDIN_FILENO) { -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard input before initializing libc"); @@ -234,7 +234,7 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes) #else ptr->_errno = ENOTSUP; return -1; -#endif /* RT_USING_POSIX_STDIO */ +#endif /* RT_USING_POSIX_DEVIO */ } else if (fd == STDOUT_FILENO || fd == STDERR_FILENO) { diff --git a/components/libc/posix/Kconfig b/components/libc/posix/Kconfig new file mode 100644 index 0000000000..0afff161ff --- /dev/null +++ b/components/libc/posix/Kconfig @@ -0,0 +1,58 @@ +menu "POSIX (Portable Operating System Interface) layer" + +config RT_USING_POSIX_FS + bool "Enable POSIX file system, open()/read()/write()/close() etc" + select RT_USING_DFS + select DFS_USING_POSIX + default n + +if RT_USING_POSIX_FS + config RT_USING_POSIX_DEVIO + bool "Enable devices as file descriptors" + select RT_USING_DFS_DEVFS + default n + + config RT_USING_POSIX_POLL + bool "Enable poll()" + default n + + config RT_USING_POSIX_SELECT + bool "Enable select()" + select RT_USING_POSIX_POLL + default n +endif + +config RT_USING_POSIX_DELAY + bool "Enable delay APIs, sleep()/usleep()/msleep() etc" + default n + +config RT_USING_POSIX_GETLINE + bool "Enable getline()/getdelim()" + select RT_USING_LIBC + 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 + +if RT_USING_PTHREADS + config PTHREAD_NUM_MAX + int "Maximum number of pthreads" + default 8 +endif + +endmenu diff --git a/components/libc/posix/aio/SConscript b/components/libc/posix/aio/SConscript index 445efaade5..139bc45749 100644 --- a/components/libc/posix/aio/SConscript +++ b/components/libc/posix/aio/SConscript @@ -6,6 +6,6 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX', 'RT_USING_POSIX_AIO'], CPPPATH = CPPPATH) +group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX_AIO'], CPPPATH = CPPPATH) Return('group') diff --git a/components/libc/posix/getline/SConscript b/components/libc/posix/getline/SConscript index bb18dc04c5..a0077b0ce9 100644 --- a/components/libc/posix/getline/SConscript +++ b/components/libc/posix/getline/SConscript @@ -3,11 +3,9 @@ from building import * cwd = GetCurrentDir() -src = Glob('*.c') + Glob('*.cpp') +src = Glob('*.c') CPPPATH = [cwd] -group = DefineGroup('POSIX', src, - depend = ['RT_USING_LIBC', 'RT_USING_POSIX','RT_USING_POSIX_GETLINE'], - CPPPATH = CPPPATH) +group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX_GETLINE'], CPPPATH = CPPPATH) Return('group') diff --git a/components/libc/posix/getline/posix_getline.c b/components/libc/posix/getline/posix_getline.c index da80242ecc..63fa33ea42 100644 --- a/components/libc/posix/getline/posix_getline.c +++ b/components/libc/posix/getline/posix_getline.c @@ -75,4 +75,3 @@ ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream) { ssize_t getline(char **lineptr, size_t *n, FILE *stream) { return getdelim(lineptr, n, '\n', stream); } - diff --git a/components/libc/posix/src/SConscript b/components/libc/posix/src/SConscript index 78a2a933ed..4be5ac83cc 100644 --- a/components/libc/posix/src/SConscript +++ b/components/libc/posix/src/SConscript @@ -2,25 +2,35 @@ from building import * -src = ['unistd.c'] +src = [] cwd = GetCurrentDir() CPPPATH = [cwd] +group = [] -if GetDepend('RT_USING_POSIX_STDIO'): +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 -group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX'], CPPPATH = CPPPATH) +if flag == True: + group = DefineGroup('POSIX', src, depend = [], CPPPATH = CPPPATH) Return('group') diff --git a/components/libc/posix/src/libc.c b/components/libc/posix/src/libc.c index 068719d5d6..c324d84ef8 100644 --- a/components/libc/posix/src/libc.c +++ b/components/libc/posix/src/libc.c @@ -23,7 +23,7 @@ int libc_system_init(void) { -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO rt_device_t dev_console; dev_console = rt_console_get_device(); @@ -31,7 +31,7 @@ int libc_system_init(void) { libc_stdio_set_console(dev_console->parent.name, O_RDWR); } -#endif /* RT_USING_POSIX */ +#endif /* RT_USING_POSIX_DEVIO */ #if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT pthread_system_init(); @@ -41,8 +41,7 @@ int libc_system_init(void) } INIT_COMPONENT_EXPORT(libc_system_init); -#ifdef RT_USING_POSIX - +#ifdef RT_USING_POSIX_DEVIO #if defined(RT_USING_LIBC) && defined(RT_USING_NEWLIB) #define STDIO_DEVICE_NAME_MAX 32 static FILE* std_console = NULL; @@ -145,4 +144,4 @@ int libc_stdio_get_console(void) { return std_fd; } #endif /* defined(RT_USING_LIBC) && defined(RT_USING_NEWLIB) */ -#endif /* RT_USING_POSIX */ +#endif /* RT_USING_POSIX_DEVIO */ diff --git a/components/libc/posix/src/libc.h b/components/libc/posix/src/libc.h index f81380bf78..b019267926 100644 --- a/components/libc/posix/src/libc.h +++ b/components/libc/posix/src/libc.h @@ -17,10 +17,10 @@ extern "C" { #endif int libc_system_init(void); -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO int libc_stdio_get_console(void); int libc_stdio_set_console(const char* device_name, int mode); -#endif /* RT_USING_POSIX */ +#endif /* RT_USING_POSIX_DEVIO */ #ifdef __cplusplus } diff --git a/components/libc/posix/termios/SConscript b/components/libc/posix/termios/SConscript index bd9a528461..3615926251 100644 --- a/components/libc/posix/termios/SConscript +++ b/components/libc/posix/termios/SConscript @@ -6,8 +6,6 @@ cwd = GetCurrentDir() src = Glob('*.c') + Glob('*.cpp') CPPPATH = [cwd] -group = DefineGroup('POSIX', src, - depend = ['RT_USING_LIBC', 'RT_USING_POSIX', 'RT_USING_POSIX_TERMIOS'], - CPPPATH = CPPPATH) +group = DefineGroup('POSIX', src, depend = ['RT_USING_LIBC', 'RT_USING_POSIX_TERMIOS'], CPPPATH = CPPPATH) Return('group') diff --git a/components/lwp/Kconfig b/components/lwp/Kconfig index 3e1982001e..82193e3b00 100644 --- a/components/lwp/Kconfig +++ b/components/lwp/Kconfig @@ -1,6 +1,6 @@ config RT_USING_LWP bool "Using light-weight process" - select RT_USING_POSIX + select RT_USING_POSIX_FS select RT_USING_POSIX_SELECT select RT_USING_LIBC depends on ARCH_ARM_CORTEX_M || ARCH_ARM_ARM9 || ARCH_ARM_CORTEX_A diff --git a/components/net/Kconfig b/components/net/Kconfig index 4d6317bac6..d9ed7d9542 100644 --- a/components/net/Kconfig +++ b/components/net/Kconfig @@ -41,7 +41,7 @@ config RT_USING_SAL config SAL_USING_POSIX bool "Enable BSD socket operated by file system API" default n - select RT_USING_POSIX + select RT_USING_POSIX_FS select RT_USING_POSIX_SELECT help Let BSD socket operated by file system API, such as read/write and involveed in select/poll POSIX APIs. diff --git a/components/utilities/rt-link/src/rtlink_dev.c b/components/utilities/rt-link/src/rtlink_dev.c index efebf37565..e91736251d 100644 --- a/components/utilities/rt-link/src/rtlink_dev.c +++ b/components/utilities/rt-link/src/rtlink_dev.c @@ -19,7 +19,7 @@ #define RTLINK_SERV(dev) (((struct rt_link_device*)dev)->service) -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO #include <dfs_posix.h> #include <poll.h> @@ -148,7 +148,7 @@ const static struct dfs_file_ops _rtlink_fops = RT_NULL, /* getdents */ rtlink_fops_poll, }; -#endif /* RT_USING_POSIX */ +#endif /* RT_USING_POSIX_DEVIO */ /* The event type for the service channel number, * which is used to wake up the service thread in blocking receive mode */ @@ -386,7 +386,7 @@ rt_err_t rt_link_dev_register(struct rt_link_device *rtlink, /* register a character device */ ret = rt_device_register(device, name, flag); -#if defined(RT_USING_POSIX) +#ifdef RT_USING_POSIX_DEVIO /* set fops */ device->fops = &_rtlink_fops; #endif diff --git a/components/utilities/ymodem/ry_sy.c b/components/utilities/ymodem/ry_sy.c index caad51d6cd..3f3b022d7e 100644 --- a/components/utilities/ymodem/ry_sy.c +++ b/components/utilities/ymodem/ry_sy.c @@ -17,6 +17,10 @@ #include <stdlib.h> #include <string.h> +#ifndef DFS_USING_POSIX +#error "Please enable DFS_USING_POSIX" +#endif + struct custom_ctx { struct rym_ctx parent; |
