未验证 提交 1d4594c6 编写于 作者: G guo 提交者: GitHub

Merge pull request #5317 from mysterywolf/PSE

[PSE分支] 替换宏定义 将posix单独划分为一个Kconfig目录
......@@ -137,7 +137,6 @@ menu "On-chip Peripheral Drivers"
select RT_USING_SDIO
select RT_USING_DFS
select RT_USING_DFS_ELMFAT
select RT_USING_LIBC
select RT_LIBC_USING_TIME
default y
......
......@@ -137,8 +137,8 @@ menu "Onboard Peripheral Drivers"
select RT_WLAN_PROT_LWIP_PBUF_FORCE
select RT_USING_LWIP
select RT_USING_LIBC
select RT_USING_POSIX
select RT_USING_DFS
select DFS_USING_POSIX
select PKG_USING_FAL
select PKG_USING_EASYFLASH
select RT_USING_WIFI_6181_LIB
......
......@@ -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
......
......@@ -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)
{
......@@ -481,7 +481,7 @@ rt_pipe_t *rt_pipe_create(const char *name, int bufsz)
}
#ifdef RT_USING_POSIX_DEVIO
dev->fops = (void*)&pipe_fops;
#endif
#endif /* RT_USING_POSIX_DEVIO */
return pipe;
}
......
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
......@@ -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 */
......
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
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册