mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-22 19:44:24 +08:00
[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:
@@ -44,14 +44,14 @@
|
||||
#define DEBUG_COLOR
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifdef RT_USING_POSIX
|
||||
#include <dfs_posix.h>
|
||||
#include <dfs_poll.h>
|
||||
|
||||
#ifdef RT_USING_POSIX_TERMIOS
|
||||
#include <posix_termios.h>
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
#ifdef RT_USING_DFS_DEVFS
|
||||
#include <dfs_posix.h>
|
||||
|
||||
/* it's possible the 'getc/putc' is defined by stdio.h in gcc/newlib. */
|
||||
#ifdef getc
|
||||
#undef getc
|
||||
@@ -97,7 +97,8 @@ static int serial_fops_open(struct dfs_fd *fd)
|
||||
break;
|
||||
}
|
||||
|
||||
rt_device_set_rx_indicate(device, serial_fops_rx_ind);
|
||||
if ((fd->flags & O_ACCMODE) != O_WRONLY)
|
||||
rt_device_set_rx_indicate(device, serial_fops_rx_ind);
|
||||
ret = rt_device_open(device, flags);
|
||||
if (ret == RT_EOK) return 0;
|
||||
|
||||
@@ -210,7 +211,7 @@ const static struct dfs_file_ops _serial_fops =
|
||||
serial_fops_poll,
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Serial poll routines
|
||||
*/
|
||||
@@ -993,7 +994,7 @@ rt_err_t rt_hw_serial_register(struct rt_serial_device *serial,
|
||||
/* register a character device */
|
||||
ret = rt_device_register(device, name, flag);
|
||||
|
||||
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_DEVFS)
|
||||
#if defined(RT_USING_POSIX)
|
||||
/* set fops */
|
||||
device->fops = &_serial_fops;
|
||||
#endif
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
*/
|
||||
#include <rthw.h>
|
||||
#include <rtdevice.h>
|
||||
#if defined(RT_USING_DFS)
|
||||
|
||||
#if defined(RT_USING_POSIX)
|
||||
#include <dfs_file.h>
|
||||
#include <dfs_posix.h>
|
||||
#endif
|
||||
#include <dfs_poll.h>
|
||||
|
||||
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_DEVFS)
|
||||
static int pipe_open(struct dfs_fd *fd)
|
||||
static int pipe_fops_open(struct dfs_fd *fd)
|
||||
{
|
||||
rt_device_t device;
|
||||
rt_pipe_t *pipe;
|
||||
@@ -65,7 +65,7 @@ static int pipe_open(struct dfs_fd *fd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pipe_close(struct dfs_fd *fd)
|
||||
static int pipe_fops_close(struct dfs_fd *fd)
|
||||
{
|
||||
rt_device_t device;
|
||||
rt_pipe_t *pipe;
|
||||
@@ -112,7 +112,7 @@ static int pipe_close(struct dfs_fd *fd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pipe_ioctl(struct dfs_fd *fd, int cmd, void *args)
|
||||
static int pipe_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
|
||||
{
|
||||
rt_pipe_t *pipe;
|
||||
int ret = 0;
|
||||
@@ -135,7 +135,7 @@ static int pipe_ioctl(struct dfs_fd *fd, int cmd, void *args)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int pipe_read(struct dfs_fd *fd, void *buf, size_t count)
|
||||
static int pipe_fops_read(struct dfs_fd *fd, void *buf, size_t count)
|
||||
{
|
||||
int len = 0;
|
||||
rt_pipe_t *pipe;
|
||||
@@ -185,7 +185,7 @@ out:
|
||||
return len;
|
||||
}
|
||||
|
||||
static int pipe_write(struct dfs_fd *fd, const void *buf, size_t count)
|
||||
static int pipe_fops_write(struct dfs_fd *fd, const void *buf, size_t count)
|
||||
{
|
||||
int len;
|
||||
rt_pipe_t *pipe;
|
||||
@@ -256,7 +256,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int pipe_poll(struct dfs_fd *fd, rt_pollreq_t *req)
|
||||
static int pipe_fops_poll(struct dfs_fd *fd, rt_pollreq_t *req)
|
||||
{
|
||||
int mask = 0;
|
||||
rt_pipe_t *pipe;
|
||||
@@ -308,15 +308,15 @@ static int pipe_poll(struct dfs_fd *fd, rt_pollreq_t *req)
|
||||
|
||||
static const struct dfs_file_ops pipe_fops =
|
||||
{
|
||||
pipe_open,
|
||||
pipe_close,
|
||||
pipe_ioctl,
|
||||
pipe_read,
|
||||
pipe_write,
|
||||
pipe_fops_open,
|
||||
pipe_fops_close,
|
||||
pipe_fops_ioctl,
|
||||
pipe_fops_read,
|
||||
pipe_fops_write,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
pipe_poll,
|
||||
pipe_fops_poll,
|
||||
};
|
||||
|
||||
rt_pipe_t *rt_pipe_create(const char *name)
|
||||
|
||||
Reference in New Issue
Block a user