提交 c0f15a59 编写于 作者: armink_ztl's avatar armink_ztl

[component] Sync to master (366e28f4).

上级 1805aadb
......@@ -18,6 +18,10 @@
#include <lwp.h>
#endif
#ifdef RT_USING_DFS_DEVFS
#include <libc.h>
#endif
/* Global variables */
const struct dfs_filesystem_ops *filesystem_operation_table[DFS_FILESYSTEM_TYPES_MAX];
struct dfs_filesystem filesystem_table[DFS_FILESYSTEMS_MAX];
......@@ -212,6 +216,11 @@ struct dfs_fd *fd_get(int fd)
struct dfs_fd *d;
struct dfs_fdtable *fdt;
#ifdef RT_USING_DFS_DEVFS
if ((0 <= fd) && (fd <= 2))
fd = libc_stdio_get_console();
#endif
fdt = dfs_fdtable_get();
fd = fd - DFS_FD_OFFSET;
if (fd < 0 || fd >= fdt->maxfd)
......
......@@ -270,7 +270,10 @@ long _sys_flen(FILEHANDLE fh)
int _sys_istty(FILEHANDLE fh)
{
return 0;
if((STDIN <= fh) && (fh <= STDERR))
return 1;
else
return 0;
}
int remove(const char *filename)
......
......@@ -9,6 +9,8 @@
#include <reent.h>
#include <sys/errno.h>
#include <sys/time.h>
#include <stdio.h>
#include <rtthread.h>
#ifdef RT_USING_DFS
......@@ -218,7 +220,7 @@ _ssize_t
_write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
{
#ifndef RT_USING_DFS
if (fd == 0)
if (fileno(stdout) == fd)
{
rt_device_t console;
......
......@@ -572,10 +572,16 @@ __exit:
if (result < 0)
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
if (sock != RT_NULL)
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
}
at_do_event_changes(sock, AT_EVENT_SEND, RT_TRUE);
if (sock)
{
at_do_event_changes(sock, AT_EVENT_SEND, RT_TRUE);
}
return result;
}
......@@ -699,24 +705,27 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f
__exit:
if (recv_len > 0)
if (sock != RT_NULL)
{
result = recv_len;
at_do_event_changes(sock, AT_EVENT_RECV, RT_FALSE);
errno = 0;
if (!rt_slist_isempty(&sock->recvpkt_list))
if (recv_len > 0)
{
at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE);
result = recv_len;
at_do_event_changes(sock, AT_EVENT_RECV, RT_FALSE);
errno = 0;
if (!rt_slist_isempty(&sock->recvpkt_list))
{
at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE);
}
else
{
at_do_event_clean(sock, AT_EVENT_RECV);
}
}
else
{
at_do_event_clean(sock, AT_EVENT_RECV);
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
}
else
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
return result;
}
......@@ -807,7 +816,10 @@ __exit:
if (result < 0)
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
if (sock != RT_NULL)
{
at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE);
}
}
else
{
......
......@@ -45,12 +45,13 @@ void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level
int ulog_console_backend_init(void)
{
ulog_init();
console.output = ulog_console_backend_output;
ulog_backend_register(&console, "console", RT_TRUE);
return 0;
}
INIT_COMPONENT_EXPORT(ulog_console_backend_init);
INIT_PREV_EXPORT(ulog_console_backend_init);
#endif /* ULOG_BACKEND_USING_CONSOLE */
......@@ -149,7 +149,7 @@ size_t ulog_strcpy(size_t cur_len, char *dst, const char *src)
while (*src != 0)
{
/* make sure destination has enough space */
if (cur_len++ <= ULOG_LINE_BUF_SIZE)
if (cur_len++ < ULOG_LINE_BUF_SIZE)
{
*dst++ = *src++;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册