This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 19bded4738374413863103f803f14b16bb50a63a
Author: Xiang Xiao <xiaoxi...@xiaomi.com>
AuthorDate: Thu Oct 27 02:02:09 2022 +0800

    fs: Remove the unused nx_pipe to prefer file_pipe for kernel
    
    Signed-off-by: Xiang Xiao <xiaoxi...@xiaomi.com>
---
 drivers/pipes/pipe.c         | 28 +++++++----------
 include/nuttx/fs/fs.h        | 15 ++++------
 include/sys/syscall_lookup.h |  2 +-
 include/unistd.h             |  2 +-
 libs/libc/libc.csv           |  2 --
 libs/libc/unistd/Make.defs   |  4 ---
 libs/libc/unistd/lib_pipe.c  | 70 -------------------------------------------
 libs/libc/unistd/lib_pipe2.c | 71 --------------------------------------------
 syscall/syscall.csv          |  2 +-
 9 files changed, 19 insertions(+), 177 deletions(-)

diff --git a/drivers/pipes/pipe.c b/drivers/pipes/pipe.c
index 43bc3be2d6..999a55a7f3 100644
--- a/drivers/pipes/pipe.c
+++ b/drivers/pipes/pipe.c
@@ -167,26 +167,21 @@ static int pipe_register(size_t bufsize, int flags,
  ****************************************************************************/
 
 /****************************************************************************
- * Name: nx_pipe
+ * Name: pipe2
  *
  * Description:
- *   nx_pipe() creates a pair of file descriptors, pointing to a pipe inode,
+ *   pipe2() creates a pair of file descriptors, pointing to a pipe inode,
  *   and  places them in the array pointed to by 'fd'. fd[0] is for reading,
  *   fd[1] is for writing.
  *
- *   NOTE: nx_pipe is a special, non-standard, NuttX-only interface.  Since
- *   the NuttX FIFOs are based in in-memory, circular buffers, the ability
- *   to control the size of those buffers is critical for system tuning.
- *
  * Input Parameters:
  *   fd[2] - The user provided array in which to catch the pipe file
  *   descriptors
- *   bufsize - The size of the in-memory, circular buffer in bytes.
  *   flags - The file status flags.
  *
  * Returned Value:
- *   0 is returned on success; a negated errno value is returned on a
- *   failure.
+ *   0 is returned on success; -1 (ERROR) is returned on a failure
+ *   with the errno value set appropriately.
  *
  ****************************************************************************/
 
@@ -232,34 +227,33 @@ errout_with_driver:
   return ret;
 }
 
-int nx_pipe(int fd[2], size_t bufsize, int flags)
+int pipe2(int fd[2], int flags)
 {
   char devname[32];
   int ret;
 
   /* Register a new pipe device */
 
-  ret = pipe_register(bufsize, flags, devname, sizeof(devname));
+  ret = pipe_register(CONFIG_DEV_PIPE_SIZE, flags, devname, sizeof(devname));
   if (ret < 0)
     {
-      return ret;
+      set_errno(-ret);
+      return ERROR;
     }
 
   /* Get a write file descriptor */
 
-  fd[1] = nx_open(devname, O_WRONLY | flags);
+  fd[1] = open(devname, O_WRONLY | flags);
   if (fd[1] < 0)
     {
-      ret = fd[1];
       goto errout_with_driver;
     }
 
   /* Get a read file descriptor */
 
-  fd[0] = nx_open(devname, O_RDONLY | flags);
+  fd[0] = open(devname, O_RDONLY | flags);
   if (fd[0] < 0)
     {
-      ret = fd[0];
       goto errout_with_wrfd;
     }
 
@@ -273,7 +267,7 @@ errout_with_wrfd:
 
 errout_with_driver:
   unregister_driver(devname);
-  return ret;
+  return ERROR;
 }
 
 #endif /* CONFIG_DEV_PIPE_SIZE > 0 */
diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h
index dfaaa5c2c8..e0293527fd 100644
--- a/include/nuttx/fs/fs.h
+++ b/include/nuttx/fs/fs.h
@@ -1402,19 +1402,15 @@ int file_fchstat(FAR struct file *filep, FAR struct 
stat *buf, int flags);
 int nx_unlink(FAR const char *pathname);
 
 /****************************************************************************
- * Name: nx_pipe
+ * Name: file_pipe
  *
  * Description:
- *   nx_pipe() creates a pair of file descriptors, pointing to a pipe inode,
- *   and  places them in the array pointed to by 'fd'. fd[0] is for reading,
- *   fd[1] is for writing.
- *
- *   NOTE: nx_pipe is a special, non-standard, NuttX-only interface.  Since
- *   the NuttX FIFOs are based in in-memory, circular buffers, the ability
- *   to control the size of those buffers is critical for system tuning.
+ *   file_pipe() creates a pair of file descriptors, pointing to a pipe
+ *   inode, and places them in the array pointed to by 'filep'. filep[0]
+ *   is for reading, filep[1] is for writing.
  *
  * Input Parameters:
- *   fd[2] - The user provided array in which to catch the pipe file
+ *   filep[2] - The user provided array in which to catch the pipe file
  *   descriptors
  *   bufsize - The size of the in-memory, circular buffer in bytes.
  *   flags - The file status flags.
@@ -1427,7 +1423,6 @@ int nx_unlink(FAR const char *pathname);
 
 #if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0
 int file_pipe(FAR struct file *filep[2], size_t bufsize, int flags);
-int nx_pipe(int fd[2], size_t bufsize, int flags);
 #endif
 
 /****************************************************************************
diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h
index a61a82c88a..057a4395dd 100644
--- a/include/sys/syscall_lookup.h
+++ b/include/sys/syscall_lookup.h
@@ -258,7 +258,7 @@ SYSCALL_LOOKUP(futimens,                   2)
 #endif
 
 #if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0
-  SYSCALL_LOOKUP(nx_pipe,                  3)
+  SYSCALL_LOOKUP(pipe2,                    2)
 #endif
 
 #if defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 0
diff --git a/include/unistd.h b/include/unistd.h
index 9a43b23f05..c0c8d487c1 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -352,7 +352,7 @@ FAR void *sbrk(intptr_t incr);
 
 /* Special devices */
 
-int     pipe(int fd[2]);
+#define pipe(fd) pipe2(fd, 0)
 int     pipe2(int pipefd[2], int flags);
 
 /* Schedule an alarm */
diff --git a/libs/libc/libc.csv b/libs/libc/libc.csv
index 41b53621ba..a6403a2ad0 100644
--- a/libs/libc/libc.csv
+++ b/libs/libc/libc.csv
@@ -151,8 +151,6 @@
 "ntohl","arpa/inet.h","","uint32_t","uint32_t"
 "ntohs","arpa/inet.h","","uint16_t","uint16_t"
 "perror","stdio.h","defined(CONFIG_FILE_STREAM)","void","FAR const char *"
-"pipe","unistd.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 
0","int","int [2]|FAR int *"
-"pipe2","unistd.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 
0","int","int [2]|FAR int *","int"
 "posix_fallocate","fcntl.h","","int","off_t","off_t"
 "preadv","sys/uio.h","","ssize_t","int","FAR const struct iovec 
*","int","off_t"
 "printf","stdio.h","","int","FAR const IPTR char *","..."
diff --git a/libs/libc/unistd/Make.defs b/libs/libc/unistd/Make.defs
index f182d8346e..1bd870eefb 100644
--- a/libs/libc/unistd/Make.defs
+++ b/libs/libc/unistd/Make.defs
@@ -46,10 +46,6 @@ ifneq ($(CONFIG_DISABLE_MOUNTPOINTS),y)
 CSRCS += lib_truncate.c lib_posix_fallocate.c
 endif
 
-ifeq ($(CONFIG_PIPES),y)
-CSRCS += lib_pipe.c lib_pipe2.c
-endif
-
 # Add the unistd directory to the build
 
 DEPPATH += --dep-path unistd
diff --git a/libs/libc/unistd/lib_pipe.c b/libs/libc/unistd/lib_pipe.c
deleted file mode 100644
index d7655cf9be..0000000000
--- a/libs/libc/unistd/lib_pipe.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
- * libs/libc/unistd/lib_pipe.c
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.  The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <errno.h>
-#include <unistd.h>
-
-#include <nuttx/fs/fs.h>
-
-#if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: pipe
- *
- * Description:
- *   pipe() creates a pair of file descriptors, pointing to a pipe inode,
- *   and  places them in the array pointed to by 'fd'. fd[0] is for reading,
- *   fd[1] is for writing.
- *
- * Input Parameters:
- *   fd[2] - The user provided array in which to catch the pipe file
- *   descriptors
- *
- * Returned Value:
- *   0 is returned on success; otherwise, -1 is returned with errno set
- *   appropriately.
- *
- ****************************************************************************/
-
-int pipe(int fd[2])
-{
-  int ret;
-
-  ret = nx_pipe(fd, CONFIG_DEV_PIPE_SIZE, 0);
-  if (ret < 0)
-    {
-      set_errno(-ret);
-      ret = ERROR;
-    }
-
-  return ret;
-}
-
-#endif /* CONFIG_PIPES && CONFIG_DEV_PIPE_SIZE > 0 */
diff --git a/libs/libc/unistd/lib_pipe2.c b/libs/libc/unistd/lib_pipe2.c
deleted file mode 100644
index 04af09e8d5..0000000000
--- a/libs/libc/unistd/lib_pipe2.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
- * libs/libc/unistd/lib_pipe2.c
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.  The
- * ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the
- * License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations
- * under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <errno.h>
-#include <unistd.h>
-
-#include <nuttx/fs/fs.h>
-
-#if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: pipe2
- *
- * Description:
- *   pipe2() creates a pair of file descriptors, pointing to a pipe inode,
- *   and  places them in the array pointed to by 'fd'. fd[0] is for reading,
- *   fd[1] is for writing. If flags is 0, then pipe2() is the same as pipe().
- *
- * Input Parameters:
- *   fd[2] - The user provided array in which to catch the pipe file
- *   descriptors
- *   flags - The file status flags.
- *
- * Returned Value:
- *   0 is returned on success; otherwise, -1 is returned with errno set
- *   appropriately.
- *
- ****************************************************************************/
-
-int pipe2(int fd[2], int flags)
-{
-  int ret;
-
-  ret = nx_pipe(fd, CONFIG_DEV_PIPE_SIZE, flags);
-  if (ret < 0)
-    {
-      set_errno(-ret);
-      ret = ERROR;
-    }
-
-  return ret;
-}
-
-#endif /* CONFIG_PIPES && CONFIG_DEV_PIPE_SIZE > 0 */
diff --git a/syscall/syscall.csv b/syscall/syscall.csv
index 434cd9acbf..4ae54a2de4 100644
--- a/syscall/syscall.csv
+++ b/syscall/syscall.csv
@@ -69,7 +69,6 @@
 "mq_unlink","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","FAR const char 
*"
 "munmap","sys/mman.h","defined(CONFIG_FS_RAMMAP)","int","FAR void *","size_t"
 "nx_mkfifo","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_FIFO_SIZE > 
0","int","FAR const char *","mode_t","size_t"
-"nx_pipe","nuttx/fs/fs.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 
0","int","int [2]|FAR int *","size_t","int"
 
"nx_pthread_create","nuttx/pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_trampoline_t","FAR
 pthread_t *","FAR const pthread_attr_t 
*","pthread_startroutine_t","pthread_addr_t"
 
"nx_pthread_exit","nuttx/pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","noreturn","pthread_addr_t"
 "nx_vsyslog","nuttx/syslog/syslog.h","","int","int","FAR const IPTR char 
*","FAR va_list *"
@@ -77,6 +76,7 @@
 "nxsched_get_streams","nuttx/sched.h","defined(CONFIG_FILE_STREAM)","FAR 
struct streamlist *"
 "open","fcntl.h","","int","FAR const char *","int","...","mode_t"
 "pgalloc", "nuttx/arch.h", "defined(CONFIG_BUILD_KERNEL)", "uintptr_t", 
"uintptr_t", "unsigned int"
+"pipe2","unistd.h","defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 
0","int","int [2]|FAR int *","int"
 "poll","poll.h","","int","FAR struct pollfd *","nfds_t","int"
 "posix_spawn","spawn.h","!defined(CONFIG_BINFMT_DISABLE) && 
defined(CONFIG_LIBC_EXECFUNCS)","int","FAR pid_t *","FAR const char *","FAR 
const posix_spawn_file_actions_t *","FAR const posix_spawnattr_t *","FAR char * 
const []|FAR char * const *","FAR char * const []|FAR char * const *"
 "ppoll","poll.h","","int","FAR struct pollfd *","nfds_t","FAR const struct 
timespec *","FAR const sigset_t *"

Reply via email to