summaryrefslogtreecommitdiff
path: root/components/drivers/src/pipe.c
diff options
context:
space:
mode:
authorousugo <[email protected]>2021-12-14 10:42:18 +0800
committerousugo <[email protected]>2021-12-14 10:42:18 +0800
commit4820dbb0b3a15a62f4cd5f3e20fb4e02e4bfbb20 (patch)
tree27698aa9180b0c25dd9c4d9ced3320da10360b1d /components/drivers/src/pipe.c
parenta237f805b940db16ef0d0009e56eb183f5713c07 (diff)
parentc5208a7d19871573dcb719358d34d3effa0682e9 (diff)
Merge branch 'master' into addAnnotation
Diffstat (limited to 'components/drivers/src/pipe.c')
-rw-r--r--components/drivers/src/pipe.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c
index 62047e46d6..993f6f7616 100644
--- a/components/drivers/src/pipe.c
+++ b/components/drivers/src/pipe.c
@@ -13,7 +13,7 @@
#include <stdint.h>
#include <sys/errno.h>
-#ifdef RT_USING_POSIX_DEVIO
+#if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE)
#include <dfs_file.h>
#include <dfs_posix.h>
#include <poll.h>
@@ -392,7 +392,7 @@ static const struct dfs_file_ops pipe_fops =
RT_NULL,
pipe_fops_poll,
};
-#endif /* RT_USING_POSIX_DEVIO */
+#endif /* defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE) */
/**
* @brief This function will open the pipe and actually creates the pipe buffer.
@@ -406,7 +406,7 @@ static const struct dfs_file_ops pipe_fops =
* When the return value is -RT_EINVAL, it means the device handle is empty.
* When the return value is -RT_ENOMEM, it means insufficient memory allocation failed.
*/
-rt_err_t rt_pipe_open(rt_device_t device, rt_uint16_t oflag)
+static rt_err_t rt_pipe_open(rt_device_t device, rt_uint16_t oflag)
{
rt_pipe_t *pipe = (rt_pipe_t *)device;
rt_err_t ret = RT_EOK;
@@ -443,7 +443,7 @@ __exit:
* When the return value is RT_EOK, the operation is successful.
* When the return value is -RT_EINVAL, it means the device handle is empty.
*/
-rt_err_t rt_pipe_close(rt_device_t device)
+static rt_err_t rt_pipe_close(rt_device_t device)
{
rt_pipe_t *pipe = (rt_pipe_t *)device;
@@ -475,7 +475,7 @@ rt_err_t rt_pipe_close(rt_device_t device)
* @return Return the length of data read.
* When the return value is 0, it means the pipe device handle is empty or the count is 0.
*/
-rt_size_t rt_pipe_read(rt_device_t device, rt_off_t pos, void *buffer, rt_size_t count)
+static rt_size_t rt_pipe_read(rt_device_t device, rt_off_t pos, void *buffer, rt_size_t count)
{
uint8_t *pbuf;
rt_size_t read_bytes = 0;
@@ -517,7 +517,7 @@ rt_size_t rt_pipe_read(rt_device_t device, rt_off_t pos, void *buffer, rt_size_t
* @return Return the length of data written.
* When the return value is 0, it means the pipe device handle is empty or the count is 0.
*/
-rt_size_t rt_pipe_write(rt_device_t device, rt_off_t pos, const void *buffer, rt_size_t count)
+static rt_size_t rt_pipe_write(rt_device_t device, rt_off_t pos, const void *buffer, rt_size_t count)
{
uint8_t *pbuf;
rt_size_t write_bytes = 0;
@@ -556,7 +556,7 @@ rt_size_t rt_pipe_write(rt_device_t device, rt_off_t pos, const void *buffer, rt
*
* @return Always return RT_EOK yet.
*/
-rt_err_t rt_pipe_control(rt_device_t dev, int cmd, void *args)
+static rt_err_t rt_pipe_control(rt_device_t dev, int cmd, void *args)
{
return RT_EOK;
}
@@ -623,9 +623,9 @@ rt_pipe_t *rt_pipe_create(const char *name, int bufsz)
rt_free(pipe);
return RT_NULL;
}
-#ifdef RT_USING_POSIX_DEVIO
+#if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE)
dev->fops = (void*)&pipe_fops;
-#endif /* RT_USING_POSIX_DEVIO */
+#endif
return pipe;
}
@@ -683,7 +683,7 @@ int rt_pipe_delete(const char *name)
return result;
}
-#ifdef RT_USING_POSIX_DEVIO
+#if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE)
/**
* @brief This function will creat a anonymous pipe.
*
@@ -701,7 +701,7 @@ int pipe(int fildes[2])
rt_snprintf(dname, sizeof(dname), "pipe%d", pipeno++);
- pipe = rt_pipe_create(dname, PIPE_BUFSZ);
+ pipe = rt_pipe_create(dname, RT_USING_POSIX_PIPE_SIZE);
if (pipe == RT_NULL)
{
return -1;
@@ -738,7 +738,7 @@ int mkfifo(const char *path, mode_t mode)
{
rt_pipe_t *pipe;
- pipe = rt_pipe_create(path, PIPE_BUFSZ);
+ pipe = rt_pipe_create(path, RT_USING_POSIX_PIPE_SIZE);
if (pipe == RT_NULL)
{
return -1;
@@ -746,4 +746,4 @@ int mkfifo(const char *path, mode_t mode)
return 0;
}
-#endif /* RT_USING_POSIX_DEVIO */
+#endif /* defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_POSIX_PIPE) */