add RT_USING_POSIX_STDIO
This commit is contained in:
parent
251e17b41a
commit
f8388c572e
|
@ -133,7 +133,7 @@ if RT_USING_DFS
|
||||||
|
|
||||||
config RT_USING_DFS_DEVFS
|
config RT_USING_DFS_DEVFS
|
||||||
bool "Using devfs for device objects"
|
bool "Using devfs for device objects"
|
||||||
default y
|
default n
|
||||||
|
|
||||||
config RT_USING_DFS_ROMFS
|
config RT_USING_DFS_ROMFS
|
||||||
bool "Enable ReadOnly file system on flash"
|
bool "Enable ReadOnly file system on flash"
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
#include <lwp.h>
|
#include <lwp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#endif /* RT_USING_POSIX */
|
#endif /* RT_USING_POSIX_STDIO */
|
||||||
|
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
const struct dfs_filesystem_ops *filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX];
|
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_fd *d;
|
||||||
struct dfs_fdtable *fdt;
|
struct dfs_fdtable *fdt;
|
||||||
|
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
if ((0 <= fd) && (fd <= 2))
|
if ((0 <= fd) && (fd <= 2))
|
||||||
fd = libc_stdio_get_console();
|
fd = libc_stdio_get_console();
|
||||||
#endif /* RT_USING_POSIX */
|
#endif /* RT_USING_POSIX_STDIO */
|
||||||
|
|
||||||
fdt = dfs_fdtable_get();
|
fdt = dfs_fdtable_get();
|
||||||
fd = fd - DFS_FD_OFFSET;
|
fd = fd - DFS_FD_OFFSET;
|
||||||
|
|
|
@ -146,7 +146,7 @@ int finsh_getchar(void)
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_DEVICE
|
#ifdef RT_USING_DEVICE
|
||||||
char ch = 0;
|
char ch = 0;
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
if(read(STDIN_FILENO, &ch, 1) > 0)
|
if(read(STDIN_FILENO, &ch, 1) > 0)
|
||||||
{
|
{
|
||||||
return ch;
|
return ch;
|
||||||
|
@ -170,14 +170,14 @@ int finsh_getchar(void)
|
||||||
rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER);
|
rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER);
|
||||||
|
|
||||||
return ch;
|
return ch;
|
||||||
#endif /* RT_USING_POSIX */
|
#endif /* RT_USING_POSIX_STDIO */
|
||||||
#else
|
#else
|
||||||
extern char rt_hw_console_getchar(void);
|
extern char rt_hw_console_getchar(void);
|
||||||
return rt_hw_console_getchar();
|
return rt_hw_console_getchar();
|
||||||
#endif /* RT_USING_DEVICE */
|
#endif /* RT_USING_DEVICE */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(RT_USING_POSIX) && defined(RT_USING_DEVICE)
|
#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE)
|
||||||
static rt_err_t finsh_rx_ind(rt_device_t dev, rt_size_t size)
|
static rt_err_t finsh_rx_ind(rt_device_t dev, rt_size_t size)
|
||||||
{
|
{
|
||||||
RT_ASSERT(shell != RT_NULL);
|
RT_ASSERT(shell != RT_NULL);
|
||||||
|
@ -241,7 +241,7 @@ const char *finsh_get_device()
|
||||||
RT_ASSERT(shell != RT_NULL);
|
RT_ASSERT(shell != RT_NULL);
|
||||||
return shell->device->parent.name;
|
return shell->device->parent.name;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup finsh
|
* @ingroup finsh
|
||||||
|
@ -443,7 +443,7 @@ void finsh_thread_entry(void *parameter)
|
||||||
shell->echo_mode = 0;
|
shell->echo_mode = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(RT_USING_POSIX) && defined(RT_USING_DEVICE)
|
#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE)
|
||||||
/* set console device as shell device */
|
/* set console device as shell device */
|
||||||
if (shell->device == RT_NULL)
|
if (shell->device == RT_NULL)
|
||||||
{
|
{
|
||||||
|
@ -453,7 +453,7 @@ void finsh_thread_entry(void *parameter)
|
||||||
finsh_set_device(console->parent.name);
|
finsh_set_device(console->parent.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) */
|
||||||
|
|
||||||
#ifdef FINSH_USING_AUTH
|
#ifdef FINSH_USING_AUTH
|
||||||
/* set the default password when the password isn't setting */
|
/* set the default password when the password isn't setting */
|
||||||
|
|
|
@ -78,7 +78,7 @@ struct finsh_shell
|
||||||
rt_uint16_t line_position;
|
rt_uint16_t line_position;
|
||||||
rt_uint16_t line_curpos;
|
rt_uint16_t line_curpos;
|
||||||
|
|
||||||
#if !defined(RT_USING_POSIX) && defined(RT_USING_DEVICE)
|
#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE)
|
||||||
rt_device_t device;
|
rt_device_t device;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,13 @@ config RT_LIBC_DEFAULT_TIMEZONE
|
||||||
config RT_USING_POSIX
|
config RT_USING_POSIX
|
||||||
bool "Enable basic POSIX layer, open/read/write/close etc"
|
bool "Enable basic POSIX layer, open/read/write/close etc"
|
||||||
select RT_USING_DFS
|
select RT_USING_DFS
|
||||||
select RT_USING_DFS_DEVFS
|
|
||||||
default n
|
default n
|
||||||
|
|
||||||
if RT_USING_POSIX
|
if RT_USING_POSIX
|
||||||
|
config RT_USING_POSIX_STDIO
|
||||||
|
bool "Enable standard IO"
|
||||||
|
select RT_USING_DFS_DEVFS
|
||||||
|
default n
|
||||||
|
|
||||||
config RT_USING_POSIX_POLL
|
config RT_USING_POSIX_POLL
|
||||||
bool "Enable poll()"
|
bool "Enable poll()"
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ int _sys_close(FILEHANDLE fh)
|
||||||
*/
|
*/
|
||||||
int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
|
int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
if (fh == STDIN)
|
if (fh == STDIN)
|
||||||
|
@ -169,7 +169,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
|
||||||
return 0; /* error */
|
return 0; /* error */
|
||||||
#else
|
#else
|
||||||
return 0; /* error */
|
return 0; /* error */
|
||||||
#endif /* RT_USING_POSIX */
|
#endif /* RT_USING_POSIX_STDIO */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -185,7 +185,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
|
||||||
|
|
||||||
if ((fh == STDOUT) || (fh == STDERR))
|
if ((fh == STDOUT) || (fh == STDERR))
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
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");
|
||||||
|
@ -200,7 +200,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; /* error */
|
return 0; /* error */
|
||||||
#endif /* RT_USING_POSIX */
|
#endif /* RT_USING_POSIX_STDIO */
|
||||||
}
|
}
|
||||||
else if (fh == STDIN)
|
else if (fh == STDIN)
|
||||||
{
|
{
|
||||||
|
@ -325,7 +325,7 @@ int fputc(int c, FILE *f)
|
||||||
|
|
||||||
int fgetc(FILE *f)
|
int fgetc(FILE *f)
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
if (libc_stdio_get_console() < 0)
|
if (libc_stdio_get_console() < 0)
|
||||||
|
@ -336,7 +336,7 @@ int fgetc(FILE *f)
|
||||||
|
|
||||||
if(read(STDIN_FILENO, &ch, 1) == 1)
|
if(read(STDIN_FILENO, &ch, 1) == 1)
|
||||||
return ch;
|
return ch;
|
||||||
#endif /* RT_USING_POSIX */
|
#endif /* RT_USING_POSIX_STDIO */
|
||||||
return 0; /* error */
|
return 0; /* error */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <yfuns.h>
|
#include <yfuns.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
#pragma module_name = "?__read"
|
#pragma module_name = "?__read"
|
||||||
size_t __read(int handle, unsigned char *buf, size_t len)
|
size_t __read(int handle, unsigned char *buf, size_t len)
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
if (handle == _LLIO_STDIN)
|
if (handle == _LLIO_STDIN)
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <yfuns.h>
|
#include <yfuns.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
|
||||||
|
|
||||||
if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
|
if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
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");
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef RT_USING_MODULE
|
#ifdef RT_USING_MODULE
|
||||||
|
@ -216,7 +216,7 @@ int _open_r(struct _reent *ptr, const char *file, int flags, int mode)
|
||||||
|
|
||||||
_ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
|
_ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
_ssize_t rc;
|
_ssize_t rc;
|
||||||
if (libc_stdio_get_console() < 0 && fd == STDIN_FILENO)
|
if (libc_stdio_get_console() < 0 && fd == STDIN_FILENO)
|
||||||
{
|
{
|
||||||
|
@ -271,11 +271,13 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX
|
||||||
_ssize_t rc;
|
_ssize_t rc;
|
||||||
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
if (libc_stdio_get_console() < 0 && fd == STDOUT_FILENO)
|
if (libc_stdio_get_console() < 0 && fd == STDOUT_FILENO)
|
||||||
{
|
{
|
||||||
LOG_W("Do not invoke standard output before initializing libc");
|
LOG_W("Do not invoke standard output before initializing libc");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif /* RT_USING_POSIX_STDIO */
|
||||||
rc = write(fd, buf, nbytes);
|
rc = write(fd, buf, nbytes);
|
||||||
return rc;
|
return rc;
|
||||||
#elif defined(RT_USING_CONSOLE)
|
#elif defined(RT_USING_CONSOLE)
|
||||||
|
|
|
@ -2,10 +2,13 @@
|
||||||
|
|
||||||
from building import *
|
from building import *
|
||||||
|
|
||||||
src = ['libc.c', 'unistd.c']
|
src = ['unistd.c']
|
||||||
cwd = GetCurrentDir()
|
cwd = GetCurrentDir()
|
||||||
CPPPATH = [cwd]
|
CPPPATH = [cwd]
|
||||||
|
|
||||||
|
if GetDepend('RT_USING_POSIX_STDIO'):
|
||||||
|
src += ['libc.c']
|
||||||
|
|
||||||
if GetDepend('RT_USING_POSIX_POLL'):
|
if GetDepend('RT_USING_POSIX_POLL'):
|
||||||
src += ['poll.c']
|
src += ['poll.c']
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,6 @@
|
||||||
|
|
||||||
#include <rtconfig.h>
|
#include <rtconfig.h>
|
||||||
|
|
||||||
/* settings depend check */
|
|
||||||
#ifdef RT_USING_POSIX
|
|
||||||
#if !defined(RT_USING_DFS) || !defined(RT_USING_DFS_DEVFS)
|
|
||||||
#error "POSIX poll/select, stdin need file system(RT_USING_DFS) and device file system(RT_USING_DFS_DEVFS)"
|
|
||||||
#endif
|
|
||||||
#endif /* RT_USING_POSIX */
|
|
||||||
|
|
||||||
/* Using this macro to control all kernel debug features. */
|
/* Using this macro to control all kernel debug features. */
|
||||||
#ifdef RT_DEBUG
|
#ifdef RT_DEBUG
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue