You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/04/28 05:40:29 UTC

[incubator-nuttx] branch master updated (2b938ed8f8 -> ded4fd33c1)

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

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


    from 2b938ed8f8 tools:minidumpserver.py support xtensa
     new d832df88a5 libc.csv: sort
     new ded4fd33c1 Implement preadv and pwritev

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 include/sys/uio.h                                 |  6 ++
 libs/libc/libc.csv                                | 26 +++----
 libs/libc/uio/Make.defs                           |  1 +
 libs/libc/uio/{lib_readv.c => lib_preadv.c}       | 42 +++--------
 libs/libc/{stdio/lib_puts.c => uio/lib_pwritev.c} | 85 +++++++++++------------
 5 files changed, 69 insertions(+), 91 deletions(-)
 copy libs/libc/uio/{lib_readv.c => lib_preadv.c} (61%)
 copy libs/libc/{stdio/lib_puts.c => uio/lib_pwritev.c} (57%)


[incubator-nuttx] 01/02: libc.csv: sort

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d832df88a56a3932fa720377cb86fe90aaabd333
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Apr 28 09:50:52 2022 +0900

    libc.csv: sort
---
 libs/libc/libc.csv | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/libs/libc/libc.csv b/libs/libc/libc.csv
index 5054e927c1..fde50b25d4 100644
--- a/libs/libc/libc.csv
+++ b/libs/libc/libc.csv
@@ -1,7 +1,7 @@
 "__errno","errno.h","defined(CONFIG_BUILD_FLAT)","FAR int *"
 "__stack_chk_fail","ssp/ssp.h","defined(CONFIG_STACK_CANARIES)","void","void"
-"_assert","assert.h","","void","FAR const char *","int"
 "_alert","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG_ERROR)","void","FAR const char *","..."
+"_assert","assert.h","","void","FAR const char *","int"
 "_err","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG_ERROR)","void","FAR const char *","..."
 "_info","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG_INFO)","void","FAR const char *","..."
 "_warn","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG_WARN)","void","FAR const char *","..."
@@ -91,21 +91,18 @@
 "inet_ntoa","arpa/inet.h","defined(CONFIG_NET_IPv4)","FAR char *","struct in_addr"
 "inet_ntop","arpa/inet.h","","FAR const char","int","FAR const void *","FAR char *","socklen_t"
 "inet_pton","arpa/inet.h","","int","int","FAR const char *","FAR void *"
-"isspace","ctype.h","","int","int"
-"isascii","ctype.h","","int","int"
-"isprint","ctype.h","","int","int"
-"isgraph","ctype.h","","int","int"
-"iscntrl","ctype.h","","int","int"
-"islower","ctype.h","","int","int"
-"isupper","ctype.h","","int","int"
+"isalnum","ctype.h","","int","int"
 "isalpha","ctype.h","","int","int"
+"isascii","ctype.h","","int","int"
 "isblank","ctype.h","","int","int"
+"iscntrl","ctype.h","","int","int"
 "isdigit","ctype.h","","int","int"
-"isalnum","ctype.h","","int","int"
+"isgraph","ctype.h","","int","int"
+"islower","ctype.h","","int","int"
+"isprint","ctype.h","","int","int"
 "ispunct","ctype.h","","int","int"
-"isxdigit","ctype.h","","int","int"
-"toupper","ctype.h","","int","int"
-"tolower","ctype.h","","int","int"
+"isspace","ctype.h","","int","int"
+"isupper","ctype.h","","int","int"
 "iswalnum","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t"
 "iswalpha","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t"
 "iswblank","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t"
@@ -119,6 +116,7 @@
 "iswspace","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t"
 "iswupper","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t"
 "iswxdigit","wctype.h","defined(CONFIG_LIBC_WCHAR)","int","wint_t"
+"isxdigit","ctype.h","","int","int"
 "labs","stdlib.h","","long int","long int"
 "lib_dumpbuffer","debug.h","","void","FAR const char *","FAR const uint8_t *","unsigned int"
 "lio_listio","aio.h","defined(CONFIG_FS_AIO)","int","int","FAR struct aiocb * const []|FAR struct aiocb * const *","int","FAR struct sigevent *"
@@ -257,6 +255,8 @@
 "tcsetattr","termios.h","defined(CONFIG_SERIAL_TERMIOS)","int","int","int","FAR const struct termios *"
 "telldir","dirent.h","","off_t","FAR DIR *"
 "time","time.h","","time_t","FAR time_t *"
+"tolower","ctype.h","","int","int"
+"toupper","ctype.h","","int","int"
 "towlower","wchar.h","defined(CONFIG_LIBC_WCHAR)","wint_t","wint_t"
 "towupper","wchar.h","defined(CONFIG_LIBC_WCHAR)","wint_t","wint_t"
 "truncate","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","FAR const char *","off_t"


[incubator-nuttx] 02/02: Implement preadv and pwritev

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ded4fd33c17753b6127970c1716ec9f751f5ce44
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Apr 28 09:26:17 2022 +0900

    Implement preadv and pwritev
---
 include/sys/uio.h           |  6 +++
 libs/libc/libc.csv          |  2 +
 libs/libc/uio/Make.defs     |  1 +
 libs/libc/uio/lib_preadv.c  | 97 +++++++++++++++++++++++++++++++++++++++++++++
 libs/libc/uio/lib_pwritev.c | 91 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 197 insertions(+)

diff --git a/include/sys/uio.h b/include/sys/uio.h
index 551cc5c26e..4555d5e044 100644
--- a/include/sys/uio.h
+++ b/include/sys/uio.h
@@ -156,6 +156,12 @@ ssize_t readv(int fildes, FAR const struct iovec *iov, int iovcnt);
 
 ssize_t writev(int fildes, FAR const struct iovec *iov, int iovcnt);
 
+ssize_t preadv(int fildes, FAR const struct iovec *iov, int iovcnt,
+               off_t offset);
+
+ssize_t pwritev(int fildes, FAR const struct iovec *iov, int iovcnt,
+                off_t offset);
+
 #undef EXTERN
 #if defined(__cplusplus)
 }
diff --git a/libs/libc/libc.csv b/libs/libc/libc.csv
index fde50b25d4..a746df93cb 100644
--- a/libs/libc/libc.csv
+++ b/libs/libc/libc.csv
@@ -147,6 +147,7 @@
 "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 *"
+"preadv","sys/uio.h","","ssize_t","int","FAR const struct iovec *","int","off_t"
 "printf","stdio.h","","int","FAR const IPTR char *","..."
 "pthread_attr_destroy","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR pthread_attr_t *"
 "pthread_attr_getinheritsched","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR const pthread_attr_t *","FAR int *"
@@ -183,6 +184,7 @@
 "pthread_setname_np","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t","const char *"
 "pthread_yield","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","void"
 "puts","stdio.h","defined(CONFIG_FILE_STREAM)","int","FAR const IPTR char *"
+"pwritev","sys/uio.h","","ssize_t","int","FAR const struct iovec *","int","off_t"
 "qsort","stdlib.h","","void","FAR void *","size_t","size_t","int(*)(FAR const void *","FAR const void *)"
 "rand","stdlib.h","","int"
 "readdir_r","dirent.h","","int","FAR DIR *","FAR struct dirent *","FAR struct dirent **"
diff --git a/libs/libc/uio/Make.defs b/libs/libc/uio/Make.defs
index 03cab6e236..eca08968bc 100644
--- a/libs/libc/uio/Make.defs
+++ b/libs/libc/uio/Make.defs
@@ -21,6 +21,7 @@
 # Add the uio.h C files to the build
 
 CSRCS += lib_readv.c lib_writev.c
+CSRCS += lib_preadv.c lib_pwritev.c
 
 # Add the uio.h directory to the build
 
diff --git a/libs/libc/uio/lib_preadv.c b/libs/libc/uio/lib_preadv.c
new file mode 100644
index 0000000000..427d5124fb
--- /dev/null
+++ b/libs/libc/uio/lib_preadv.c
@@ -0,0 +1,97 @@
+/****************************************************************************
+ * libs/libc/uio/lib_preadv.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 <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: preadv()
+ *
+ * Description:
+ *   The preadv() function is equivalent to pread(), except it takes
+ *   an iov array.
+ *
+ ****************************************************************************/
+
+ssize_t preadv(int fildes, FAR const struct iovec *iov, int iovcnt,
+               off_t offset)
+{
+  ssize_t ntotal;
+  ssize_t nread;
+  size_t remaining;
+  FAR uint8_t *buffer;
+  int i;
+
+  /* Process each entry in the struct iovec array */
+
+  for (i = 0, ntotal = 0; i < iovcnt; i++)
+    {
+      /* Ignore zero-length reads */
+
+      if (iov[i].iov_len > 0)
+        {
+          buffer    = iov[i].iov_base;
+          remaining = iov[i].iov_len;
+
+          /* Read repeatedly as necessary to fill buffer */
+
+          do
+            {
+              /* NOTE: pread() is a cancellation point */
+
+              nread = pread(fildes, buffer, remaining, offset + ntotal);
+
+              /* Check for a read error */
+
+              if (nread < 0)
+                {
+                  return nread;
+                }
+
+              /* Check for an end-of-file condition */
+
+              else if (nread == 0)
+                {
+                  return ntotal;
+                }
+
+              /* Update pointers and counts in order to handle partial
+               * buffer reads.
+               */
+
+              buffer    += nread;
+              remaining -= nread;
+              ntotal    += nread;
+            }
+          while (remaining > 0);
+        }
+    }
+
+  return ntotal;
+}
diff --git a/libs/libc/uio/lib_pwritev.c b/libs/libc/uio/lib_pwritev.c
new file mode 100644
index 0000000000..1203e20f0c
--- /dev/null
+++ b/libs/libc/uio/lib_pwritev.c
@@ -0,0 +1,91 @@
+/****************************************************************************
+ * libs/libc/uio/lib_pwritev.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 <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <errno.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: pwritev()
+ *
+ * Description:
+ *   The pwritev() function is equivalent to write(), except it takes
+ *   an iov array.
+ *
+ ****************************************************************************/
+
+ssize_t pwritev(int fildes, FAR const struct iovec *iov, int iovcnt,
+                off_t offset)
+{
+  ssize_t ntotal;
+  ssize_t nwritten;
+  size_t remaining;
+  FAR uint8_t *buffer;
+  int i;
+
+  /* Process each entry in the struct iovec array */
+
+  for (i = 0, ntotal = 0; i < iovcnt; i++)
+    {
+      /* Ignore zero-length writes */
+
+      if (iov[i].iov_len > 0)
+        {
+          buffer    = iov[i].iov_base;
+          remaining = iov[i].iov_len;
+
+          /* Write repeatedly as necessary to write the entire buffer */
+
+          do
+            {
+              /* NOTE: pwrite() is a cancellation point */
+
+              nwritten = pwrite(fildes, buffer, remaining, offset + ntotal);
+
+              /* Check for a write error */
+
+              if (nwritten < 0)
+                {
+                  return ntotal ? ntotal : ERROR;
+                }
+
+              /* Update pointers and counts in order to handle partial
+               * buffer writes.
+               */
+
+              buffer    += nwritten;
+              remaining -= nwritten;
+              ntotal    += nwritten;
+            }
+          while (remaining > 0);
+        }
+    }
+
+  return ntotal;
+}