Merge pull request #5184 from mysterywolf/revert-5169-libc

Revert "[libc]&[dfs] remove unnecessary RT_USING_POSIX and RT_USING_DFS_DEVFS"
This commit is contained in:
guo 2021-10-15 09:15:43 +08:00 committed by GitHub
commit 762e1ea9b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 27 deletions

View File

@ -18,7 +18,7 @@
#include <lwp.h> #include <lwp.h>
#endif #endif
#if defined(RT_USING_DFS_DEVFS) && defined(RT_USING_LIBC) #if defined(RT_USING_DFS_DEVFS) && defined(RT_USING_POSIX)
#include <libc.h> #include <libc.h>
#endif #endif
@ -216,7 +216,7 @@ struct dfs_fd *fd_get(int fd)
struct dfs_fd *d; struct dfs_fd *d;
struct dfs_fdtable *fdt; struct dfs_fdtable *fdt;
#if defined(RT_USING_DFS_DEVFS) && defined(RT_USING_LIBC) #if defined(RT_USING_DFS_DEVFS) && defined(RT_USING_POSIX)
if ((0 <= fd) && (fd <= 2)) if ((0 <= fd) && (fd <= 2))
fd = libc_stdio_get_console(); fd = libc_stdio_get_console();
#endif #endif

View File

@ -17,23 +17,23 @@
int libc_system_init(void) int libc_system_init(void)
{ {
#ifdef RT_USING_DFS_DEVFS #if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS)
rt_device_t dev_console; rt_device_t dev_console;
dev_console = rt_console_get_device(); dev_console = rt_console_get_device();
if (dev_console) if (dev_console)
{ {
#ifdef RT_USING_POSIX #if defined(RT_USING_POSIX)
libc_stdio_set_console(dev_console->parent.name, O_RDWR); libc_stdio_set_console(dev_console->parent.name, O_RDWR);
#else #else
libc_stdio_set_console(dev_console->parent.name, O_WRONLY); libc_stdio_set_console(dev_console->parent.name, O_WRONLY);
#endif /* RT_USING_POSIX */ #endif
} }
#endif /* RT_USING_DFS_DEVFS */ #endif
#if defined(RT_USING_PTHREADS) && !defined(RT_USING_COMPONENTS_INIT) #if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
pthread_system_init(); pthread_system_init();
#endif /* defined(RT_USING_PTHREADS) && !defined(RT_USING_COMPONENTS_INIT) */ #endif
return 0; return 0;
} }

View File

@ -187,14 +187,14 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
{ {
#ifdef RT_USING_DFS #ifdef RT_USING_DFS
int size; int size;
#endif /* RT_USING_DFS */ #endif
if ((fh == STDOUT) || (fh == STDERR)) if ((fh == STDOUT) || (fh == STDERR))
{ {
#if !defined(RT_USING_CONSOLE) || !defined(RT_USING_DEVICE) #if !defined(RT_USING_CONSOLE) || !defined(RT_USING_DEVICE)
return 0; return 0;
#else #else
#ifdef RT_USING_DFS #ifdef RT_USING_POSIX
if (libc_stdio_get_console() < 0) if (libc_stdio_get_console() < 0)
{ {
LOG_W("Do not invoke standard input before initializing libc"); LOG_W("Do not invoke standard input before initializing libc");
@ -210,8 +210,8 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
} }
return -1; return -1;
#endif /* RT_USING_DFS */ #endif
#endif /* !defined(RT_USING_CONSOLE) || !defined(RT_USING_DEVICE) */ #endif
} }
else if (fh == STDIN) else if (fh == STDIN)
{ {
@ -226,7 +226,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
return len - size; return len - size;
else else
return -1; return -1;
#endif /* RT_USING_DFS */ #endif
} }
/* /*

View File

@ -17,23 +17,23 @@
int libc_system_init(void) int libc_system_init(void)
{ {
#ifdef RT_USING_DFS_DEVFS #if defined(RT_USING_DFS) && defined(RT_USING_DFS_DEVFS)
rt_device_t dev_console; rt_device_t dev_console;
dev_console = rt_console_get_device(); dev_console = rt_console_get_device();
if (dev_console) if (dev_console)
{ {
#ifdef RT_USING_POSIX #if defined(RT_USING_POSIX)
libc_stdio_set_console(dev_console->parent.name, O_RDWR); libc_stdio_set_console(dev_console->parent.name, O_RDWR);
#else #else
libc_stdio_set_console(dev_console->parent.name, O_WRONLY); libc_stdio_set_console(dev_console->parent.name, O_WRONLY);
#endif /* RT_USING_POSIX */ #endif
} }
#endif /* RT_USING_DFS_DEVFS */ #endif
#if defined (RT_USING_PTHREADS) && !defined (RT_USING_COMPONENTS_INIT) #if defined (RT_USING_PTHREADS) && !defined (RT_USING_COMPONENTS_INIT)
pthread_system_init(); pthread_system_init();
#endif /* defined (RT_USING_PTHREADS) && !defined (RT_USING_COMPONENTS_INIT) */ #endif
return 0; return 0;
} }

View File

@ -25,7 +25,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
{ {
#ifdef RT_USING_DFS #ifdef RT_USING_DFS
int size; int size;
#endif /* RT_USING_DFS */ #endif
if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR)) if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
{ {
@ -33,7 +33,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
return _LLIO_ERROR; return _LLIO_ERROR;
#else #else
#ifdef RT_USING_DFS #ifdef RT_USING_POSIX
if (libc_stdio_get_console() < 0) if (libc_stdio_get_console() < 0)
{ {
LOG_W("Do not invoke standard output before initializing libc"); LOG_W("Do not invoke standard output before initializing libc");
@ -50,8 +50,8 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
} }
return len; return len;
#endif /* RT_USING_DFS */ #endif
#endif /* RT_USING_CONSOLE */ #endif
} }
else if (handle == _LLIO_STDIN) else if (handle == _LLIO_STDIN)
{ {
@ -63,6 +63,6 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
#else #else
size = write(handle, buf, len); size = write(handle, buf, len);
return size; return size;
#endif /* RT_USING_DFS */ #endif
} }

View File

@ -23,7 +23,7 @@ int _EXFUN(putenv,(char *__string));
int libc_system_init(void) int libc_system_init(void)
{ {
#if defined(RT_USING_DFS_DEVFS) & defined(RT_USING_CONSOLE) #if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS) & defined(RT_USING_CONSOLE)
rt_device_t dev_console; rt_device_t dev_console;
dev_console = rt_console_get_device(); dev_console = rt_console_get_device();
@ -39,11 +39,11 @@ int libc_system_init(void)
/* set PATH and HOME */ /* set PATH and HOME */
putenv("PATH=/bin"); putenv("PATH=/bin");
putenv("HOME=/home"); putenv("HOME=/home");
#endif /* defined(RT_USING_DFS_DEVFS) & defined(RT_USING_CONSOLE) */ #endif
#if defined(RT_USING_PTHREADS) && !defined(RT_USING_COMPONENTS_INIT) #if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
pthread_system_init(); pthread_system_init();
#endif /* defined(RT_USING_PTHREADS) && !defined(RT_USING_COMPONENTS_INIT) */ #endif
return 0; return 0;
} }