diff options
| author | guo <[email protected]> | 2021-12-02 09:58:33 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-02 09:58:33 +0800 |
| commit | 1d4594c6fcad494ef256c9bbd8aa7d64132a0995 (patch) | |
| tree | 96465d7a6431653b5e11d4c4a2dae3c264841ffe /components/libc | |
| parent | 838d1087a05c1565aa8833d6a9dab7d3191e646e (diff) | |
| parent | 7b1f65a690c8f28d172e640989643df12597fa7a (diff) | |
Merge pull request #5317 from mysterywolf/PSE
[PSE分支] 替换宏定义 将posix单独划分为一个Kconfig目录
Diffstat (limited to 'components/libc')
| -rw-r--r-- | components/libc/Kconfig | 57 | ||||
| -rw-r--r-- | components/libc/compilers/armlibc/syscalls.c | 16 | ||||
| -rw-r--r-- | components/libc/posix/Kconfig | 58 |
3 files changed, 72 insertions, 59 deletions
diff --git a/components/libc/Kconfig b/components/libc/Kconfig index dfbe73aa14..69f8e1ae36 100644 --- a/components/libc/Kconfig +++ b/components/libc/Kconfig @@ -1,7 +1,7 @@ menu "POSIX layer and C standard library" config RT_USING_LIBC - bool "Enable libc APIs from toolchain" + bool "Enable libc APIs from the toolchain" default n if RT_USING_LIBC @@ -37,59 +37,6 @@ config RT_LIBC_DEFAULT_TIMEZONE range -12 12 default 8 -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 +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 bfd3777193..0e965d62af 100644 --- a/components/libc/compilers/armlibc/syscalls.c +++ b/components/libc/compilers/armlibc/syscalls.c @@ -156,22 +156,26 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) return 0; /* error, but keep going */ } size = read(STDIN_FILENO, buf, len); - return 0; /* success */ + return len - size; /* success */ #else return 0; /* error */ #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 */ 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 |
