[libc] Add RT_USING_POSIX macro.

1. Add macro check in rtdebug.h;
2. Use RT_USING_POSIX for poll/select, stdin etc.
3. Split dfs_posix.h to dfs_posix.h, dfs_poll.h and dfs_select.h;
This commit is contained in:
bernard
2017-10-17 22:27:06 +08:00
parent 947d8aa4d2
commit 8a38307e2c
21 changed files with 167 additions and 129 deletions
+5 -3
View File
@@ -1,4 +1,4 @@
menu "libc"
menu "POSIX layer and C standard library"
config RT_USING_LIBC
bool "Enable libc APIs from toolchain"
@@ -9,12 +9,13 @@ config RT_USING_PTHREADS
default n
if RT_USING_LIBC
config RT_USING_POSIX_STDIN
bool "Enable stdin"
config RT_USING_POSIX
bool "Enable POSIX layer for poll/select, stdin etc"
select RT_USING_DFS
select RT_USING_DFS_DEVFS
default y
if RT_USING_POSIX
config RT_USING_POSIX_MMAP
bool "Enable mmap() api"
default n
@@ -22,6 +23,7 @@ if RT_USING_LIBC
config RT_USING_POSIX_TERMIOS
bool "Enable termios feature"
default n
endif
endif
endmenu
+3 -3
View File
@@ -153,7 +153,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
if (fh == STDIN)
{
#ifdef RT_USING_POSIX_STDIN
#ifdef RT_USING_POSIX
size = libc_stdio_read(buf, len);
return len - size;
#else
@@ -192,7 +192,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
#ifndef RT_USING_CONSOLE
return 0;
#else
#ifdef RT_USING_POSIX_STDIN
#ifdef RT_USING_POSIX
size = libc_stdio_write(buf, len);
return len - size;
#else
@@ -319,7 +319,7 @@ int fgetc(FILE *f)
{
char ch;
#ifdef RT_USING_POSIX_STDIN
#ifdef RT_USING_POSIX
if (libc_stdio_read(&ch, 1) == 1)
return ch;
#endif
@@ -38,7 +38,7 @@ size_t __read(int handle, unsigned char *buf, size_t len)
if (handle == _LLIO_STDIN)
{
#ifdef RT_USING_POSIX_STDIN
#ifdef RT_USING_POSIX
return libc_stdio_read(buf, len);
#else
return _LLIO_ERROR;
@@ -43,7 +43,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
return _LLIO_ERROR;
#else
#ifdef RT_USING_POSIX_STDIN
#ifdef RT_USING_POSIX
return libc_stdio_write((void*)buf, len);
#else
rt_device_t console_device;
+1 -1
View File
@@ -43,7 +43,7 @@ int libc_system_init(void)
dev_console = rt_console_get_device();
if (dev_console)
{
#if defined(RT_USING_DFS_DEVFS) && defined(RT_USING_POSIX_STDIN)
#if defined(RT_USING_POSIX)
libc_stdio_set_console(dev_console->parent.name, O_RDWR);
#else
libc_stdio_set_console(dev_console->parent.name, O_WRONLY);