From 92c62a8fab541a89aa5d37d15d43864ca072dd13 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 11 Sep 2021 11:25:43 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=E6=A0=87=E5=87=86=E5=8C=96=20?= =?UTF-8?q?=E5=BC=B1=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/SConscript | 2 +- components/dfs/include/dfs_poll.h | 33 +-------------- components/dfs/src/{poll.c => dfs_poll.c} | 0 components/dfs/src/{select.c => dfs_select.c} | 0 components/libc/compilers/common/poll.h | 40 +++++++++++++++++++ components/libc/compilers/common/sys/time.h | 6 +-- 6 files changed, 45 insertions(+), 36 deletions(-) rename components/dfs/src/{poll.c => dfs_poll.c} (100%) rename components/dfs/src/{select.c => dfs_select.c} (100%) create mode 100644 components/libc/compilers/common/poll.h diff --git a/components/dfs/SConscript b/components/dfs/SConscript index 3ccaeb1080..e449c84911 100644 --- a/components/dfs/SConscript +++ b/components/dfs/SConscript @@ -11,7 +11,7 @@ cwd = GetCurrentDir() CPPPATH = [cwd + "/include"] if GetDepend('RT_USING_POSIX'): - src += ['src/poll.c', 'src/select.c'] + src += ['src/dfs_poll.c', 'src/dfs_select.c'] group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS'], CPPPATH = CPPPATH) diff --git a/components/dfs/include/dfs_poll.h b/components/dfs/include/dfs_poll.h index 096a5fe712..11d17cc1ff 100644 --- a/components/dfs/include/dfs_poll.h +++ b/components/dfs/include/dfs_poll.h @@ -10,37 +10,6 @@ #ifndef DFS_POLL_H__ #define DFS_POLL_H__ -#include - -#ifdef RT_USING_POSIX -#include /* for struct timeval */ - -#if !defined(POLLIN) && !defined(POLLOUT) -#define POLLIN (0x01) -#define POLLRDNORM (0x01) -#define POLLRDBAND (0x01) -#define POLLPRI (0x01) - -#define POLLOUT (0x02) -#define POLLWRNORM (0x02) -#define POLLWRBAND (0x02) - -#define POLLERR (0x04) -#define POLLHUP (0x08) -#define POLLNVAL (0x10) - -typedef unsigned int nfds_t; - -struct pollfd -{ - int fd; - short events; - short revents; -}; -#endif /* !defined(POLLIN) && !defined(POLLOUT) */ - -#define POLLMASK_DEFAULT (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM) -int poll(struct pollfd *fds, nfds_t nfds, int timeout); -#endif /* RT_USING_POSIX */ +#include #endif /* DFS_POLL_H__ */ diff --git a/components/dfs/src/poll.c b/components/dfs/src/dfs_poll.c similarity index 100% rename from components/dfs/src/poll.c rename to components/dfs/src/dfs_poll.c diff --git a/components/dfs/src/select.c b/components/dfs/src/dfs_select.c similarity index 100% rename from components/dfs/src/select.c rename to components/dfs/src/dfs_select.c diff --git a/components/libc/compilers/common/poll.h b/components/libc/compilers/common/poll.h new file mode 100644 index 0000000000..1862373559 --- /dev/null +++ b/components/libc/compilers/common/poll.h @@ -0,0 +1,40 @@ +#ifndef __POLL_H__ +#define __POLL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(POLLIN) && !defined(POLLOUT) +#define POLLIN (0x01) +#define POLLRDNORM (0x01) +#define POLLRDBAND (0x01) +#define POLLPRI (0x01) + +#define POLLOUT (0x02) +#define POLLWRNORM (0x02) +#define POLLWRBAND (0x02) + +#define POLLERR (0x04) +#define POLLHUP (0x08) +#define POLLNVAL (0x10) + +typedef unsigned int nfds_t; + +struct pollfd +{ + int fd; + short events; + short revents; +}; +#endif /* !defined(POLLIN) && !defined(POLLOUT) */ + +#define POLLMASK_DEFAULT (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM) + +int poll(struct pollfd *fds, nfds_t nfds, int timeout); + +#ifdef __cplusplus +} +#endif + +#endif /* __POLL_H__ */ diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index c2320429e0..9d4422e17a 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -8,8 +8,8 @@ * 2020-09-07 Meco Man combine gcc armcc iccarm * 2021-02-12 Meco Man move all definitions located in to this file */ -#ifndef _SYS_TIME_H_ -#define _SYS_TIME_H_ +#ifndef __SYS_TIME_H__ +#define __SYS_TIME_H__ #include #include @@ -73,7 +73,7 @@ struct timespec { }; #endif -/* posix clock and timer */ +/* POSIX clock and timer */ #define MILLISECOND_PER_SECOND 1000UL #define MICROSECOND_PER_SECOND 1000000UL #define NANOSECOND_PER_SECOND 1000000000UL From c360688714d3aaf1f2114c45afaa3ee2ddc64fdd Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 11 Sep 2021 11:48:14 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8poll.h=E4=BB=A3=E6=9B=BFd?= =?UTF-8?q?fs=5Fpoll.h?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/src/dfs_poll.c | 2 +- components/dfs/src/dfs_select.c | 2 +- components/drivers/serial/serial.c | 2 +- components/drivers/serial/serial_v2.c | 2 +- components/drivers/src/pipe.c | 2 +- components/libc/compilers/common/poll.h | 9 +++++++++ components/lwp/lwp_syscall.c | 2 +- components/net/at/at_socket/at_socket.c | 2 +- components/net/sal_socket/impl/af_inet_at.c | 2 +- components/net/sal_socket/impl/af_inet_lwip.c | 2 +- components/net/sal_socket/socket/net_sockets.c | 2 +- components/utilities/rt-link/src/rtlink_dev.c | 2 +- examples/rt-link/rtlink_dev_example.c | 2 +- 13 files changed, 21 insertions(+), 12 deletions(-) diff --git a/components/dfs/src/dfs_poll.c b/components/dfs/src/dfs_poll.c index d1e0372494..607b3487be 100644 --- a/components/dfs/src/dfs_poll.c +++ b/components/dfs/src/dfs_poll.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #ifdef RT_USING_POSIX diff --git a/components/dfs/src/dfs_select.c b/components/dfs/src/dfs_select.c index c9286ca97f..ca9c549259 100644 --- a/components/dfs/src/dfs_select.c +++ b/components/dfs/src/dfs_select.c @@ -11,7 +11,7 @@ #include #include -#include +#include #include #ifdef RT_USING_POSIX diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index c567e34b52..289d523bd2 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -38,7 +38,7 @@ #ifdef RT_USING_POSIX #include -#include +#include #include #ifdef RT_USING_POSIX_TERMIOS diff --git a/components/drivers/serial/serial_v2.c b/components/drivers/serial/serial_v2.c index 6e65457a5d..390dd31748 100644 --- a/components/drivers/serial/serial_v2.c +++ b/components/drivers/serial/serial_v2.c @@ -18,7 +18,7 @@ #ifdef RT_USING_POSIX #include -#include +#include #include #ifdef getc diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c index 7fa5eb067d..af90f13c6f 100644 --- a/components/drivers/src/pipe.c +++ b/components/drivers/src/pipe.c @@ -16,7 +16,7 @@ #ifdef RT_USING_POSIX #include #include -#include +#include #include static int pipe_fops_open(struct dfs_fd *fd) diff --git a/components/libc/compilers/common/poll.h b/components/libc/compilers/common/poll.h index 1862373559..aea73d6eaf 100644 --- a/components/libc/compilers/common/poll.h +++ b/components/libc/compilers/common/poll.h @@ -1,3 +1,12 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-11 Meco Man First version + */ #ifndef __POLL_H__ #define __POLL_H__ diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index 02915ab1cc..d9112eed3e 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -13,7 +13,7 @@ #include #include -#include +#include #include #if (defined(RT_USING_SAL) && defined(SAL_USING_POSIX)) diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index 8215dd4417..96ea053f9c 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -19,7 +19,7 @@ #include #ifdef SAL_USING_POSIX -#include +#include #endif #include diff --git a/components/net/sal_socket/impl/af_inet_at.c b/components/net/sal_socket/impl/af_inet_at.c index c85dfe9f06..07dff0018c 100644 --- a/components/net/sal_socket/impl/af_inet_at.c +++ b/components/net/sal_socket/impl/af_inet_at.c @@ -19,7 +19,7 @@ #include #ifdef SAL_USING_POSIX -#include +#include #endif #ifdef SAL_USING_AT diff --git a/components/net/sal_socket/impl/af_inet_lwip.c b/components/net/sal_socket/impl/af_inet_lwip.c index 2e19275b5d..2cf0958ee4 100644 --- a/components/net/sal_socket/impl/af_inet_lwip.c +++ b/components/net/sal_socket/impl/af_inet_lwip.c @@ -17,7 +17,7 @@ #include #ifdef SAL_USING_POSIX -#include +#include #endif #include diff --git a/components/net/sal_socket/socket/net_sockets.c b/components/net/sal_socket/socket/net_sockets.c index 7d4db34327..1b6db50e6d 100644 --- a/components/net/sal_socket/socket/net_sockets.c +++ b/components/net/sal_socket/socket/net_sockets.c @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include diff --git a/components/utilities/rt-link/src/rtlink_dev.c b/components/utilities/rt-link/src/rtlink_dev.c index 5eff1f9782..efebf37565 100644 --- a/components/utilities/rt-link/src/rtlink_dev.c +++ b/components/utilities/rt-link/src/rtlink_dev.c @@ -21,7 +21,7 @@ #ifdef RT_USING_POSIX #include -#include +#include int rtlink_fops_open(struct dfs_fd *fd) { diff --git a/examples/rt-link/rtlink_dev_example.c b/examples/rt-link/rtlink_dev_example.c index 0a026bcb3d..d00f916efd 100644 --- a/examples/rt-link/rtlink_dev_example.c +++ b/examples/rt-link/rtlink_dev_example.c @@ -47,7 +47,7 @@ static rt_err_t rtlink_dev_tx_done(rt_device_t dev, void *buffer) #ifdef RT_USING_POSIX #include -#include +#include #include #define RTLINK01_PATH "/dev/rtlink01"