Trivial updates from review of vecto I/O logic.

This commit is contained in:
Gregory Nutt
2018-06-23 09:01:42 -06:00
parent 706a6a2c19
commit 5db2f993f9
5 changed files with 76 additions and 33 deletions
+11 -2
View File
@@ -134,13 +134,19 @@
#ifdef CONFIG_SMALL_MEMORY #ifdef CONFIG_SMALL_MEMORY
#define _POSIX_SIZE_MAX 65535 /* See sys/types.h */
#define _POSIX_SIZE_MIN 0
#define _POSIX_SSIZE_MAX 32767 /* See sys/types.h */ #define _POSIX_SSIZE_MAX 32767 /* See sys/types.h */
#define _POSIX_SSIZE_MIN -32768 #define _POSIX_SSIZE_MIN -32768
#else /* CONFIG_SMALL_MEMORY */ #else /* CONFIG_SMALL_MEMORY */
#define _POSIX_SSIZE_MAX 2147483647 /* See sys/types.h */ #define _POSIX_SIZE_MAX 4294967295L /* See sys/types.h */
#define _POSIX_SSIZE_MIN -2147483648 #define _POSIX_SIZE_MIN 0
#define _POSIX_SSIZE_MAX 2147483647UL /* See sys/types.h */
#define _POSIX_SSIZE_MIN -2147483648UL
#endif /* CONFIG_SMALL_MEMORY */ #endif /* CONFIG_SMALL_MEMORY */
@@ -205,6 +211,8 @@
#define OPEN_MAX _POSIX_OPEN_MAX #define OPEN_MAX _POSIX_OPEN_MAX
#define PATH_MAX _POSIX_PATH_MAX #define PATH_MAX _POSIX_PATH_MAX
#define PIPE_BUF _POSIX_PIPE_BUF #define PIPE_BUF _POSIX_PIPE_BUF
#define SIZE_MAX _POSIX_SIZE_MAX
#define SIZE_MIN _POSIX_SIZE_MIN
#define SSIZE_MAX _POSIX_SSIZE_MAX #define SSIZE_MAX _POSIX_SSIZE_MAX
#define SSIZE_MIN _POSIX_SSIZE_MIN #define SSIZE_MIN _POSIX_SSIZE_MIN
#define STREAM_MAX _POSIX_STREAM_MAX #define STREAM_MAX _POSIX_STREAM_MAX
@@ -237,6 +245,7 @@
#define SEM_VALUE_MAX _POSIX_SEM_VALUE_MAX #define SEM_VALUE_MAX _POSIX_SEM_VALUE_MAX
/* Required for readv() and writev() */ /* Required for readv() and writev() */
/* There really is no upper limit on the number of vectors */
#define IOV_MAX INT_MAX #define IOV_MAX INT_MAX
+2
View File
@@ -132,6 +132,8 @@ typedef unsigned int mode_t;
/* size_t is used for sizes of memory objects. /* size_t is used for sizes of memory objects.
* ssize_t is used for a count of bytes or an error indication. * ssize_t is used for a count of bytes or an error indication.
* *
* See also definitions of SIZE_MAX et al in limits.h.
*
* REVISIT: size_t belongs in stddef.h * REVISIT: size_t belongs in stddef.h
*/ */
+34 -15
View File
@@ -38,14 +38,20 @@
#ifndef __INCLUDE_SYS_UIO_H #ifndef __INCLUDE_SYS_UIO_H
#define __INCLUDE_SYS_UIO_H #define __INCLUDE_SYS_UIO_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <sys/types.h>
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
struct iovec struct iovec
{ {
FAR void *iov_base; FAR void *iov_base; /* Base address of I/O memory region */
size_t iov_len; size_t iov_len; /* Size of the memory pointed to by iov_base */
}; };
/**************************************************************************** /****************************************************************************
@@ -57,17 +63,17 @@ struct iovec
* *
* Description: * Description:
* The readv() function is equivalent to read(), except as described below. * The readv() function is equivalent to read(), except as described below.
* The readv() function places the input data into the iovcnt buffers * The readv() function places the input data into the 'iovcnt' buffers
* specified by the members of the iov array: iov[0], iov[1], ..., * specified by the members of the 'iov' array: iov[0], iov[1], ...,
* iov[iovcnt-1]. The iovcnt argument is valid if greater than 0 and less * iov['iovcnt'-1]. The 'iovcnt' argument is valid if greater than 0 and
* than or equal to IOV_MAX as defined in limits.h. * less than or equal to IOV_MAX as defined in limits.h.
* *
* Each iovec entry specifies the base address and length of an area in * Each iovec entry specifies the base address and length of an area in
* memory where data should be placed. The readv() function will always * memory where data should be placed. The readv() function will always
* fill an area completely before proceeding to the next. * fill an area completely before proceeding to the next.
* *
* Upon successful completion, readv() will mark for update the st_atime * TODO: pon successful completion, readv() will mark for update the
* field of the file. * st_atime field of the file.
* *
* Input Parameters: * Input Parameters:
* filedes - The open file descriptor for the file to be read * filedes - The open file descriptor for the file to be read
@@ -77,7 +83,14 @@ struct iovec
* Returned Value: * Returned Value:
* Upon successful completion, readv() will return a non-negative integer * Upon successful completion, readv() will return a non-negative integer
* indicating the number of bytes actually read. Otherwise, the functions * indicating the number of bytes actually read. Otherwise, the functions
* will return -1 and set errno to indicate the error. See read(). * will return -1 and set errno to indicate the error. See read() for the
* list of returned errno values. In addition, the readv() function will
* fail if:
*
* EINVAL.
* The sum of the iov_len values in the iov array overflowed an ssize_t
* or The 'iovcnt' argument was less than or equal to 0, or greater than
* IOV_MAX (Not implemented).
* *
****************************************************************************/ ****************************************************************************/
@@ -88,20 +101,20 @@ ssize_t readv(int fildes, FAR const struct iovec *iov, int iovcnt);
* *
* Description: * Description:
* The writev() function is equivalent to write(), except as described * The writev() function is equivalent to write(), except as described
* below. The writev() function will gather output data from the iovcnt * below. The writev() function will gather output data from the 'iovcnt'
* buffers specified by the members of the iov array: iov[0], iov[1], ..., * buffers specified by the members of the 'iov' array: iov[0], iov[1], ...,
* iov[iovcnt-1]. The iovcnt argument is valid if greater than 0 and less * iov[iovcnt-1]. The 'iovcnt' argument is valid if greater than 0 and less
* than or equal to IOV_MAX, as defined in limits.h. * than or equal to IOV_MAX, as defined in limits.h.
* *
* Each iovec entry specifies the base address and length of an area in * Each iovec entry specifies the base address and length of an area in
* memory from which data should be written. The writev() function always * memory from which data should be written. The writev() function always
* writes a complete area before proceeding to the next. * writes a complete area before proceeding to the next.
* *
* If fildes refers to a regular file and all of the iov_len members in * If 'filedes' refers to a regular file and all of the iov_len members in
* the array pointed to by iov are 0, writev() will return 0 and have no * the array pointed to by iov are 0, writev() will return 0 and have no
* other effect. For other file types, the behavior is unspecified. * other effect. For other file types, the behavior is unspecified.
* *
* If the sum of the iov_len values is greater than SSIZE_MAX, the * TODO: If the sum of the iov_len values is greater than SSIZE_MAX, the
* operation will fail and no data will be transferred. * operation will fail and no data will be transferred.
* *
* Input Parameters: * Input Parameters:
@@ -113,7 +126,13 @@ ssize_t readv(int fildes, FAR const struct iovec *iov, int iovcnt);
* Upon successful completion, writev() shall return the number of bytes * Upon successful completion, writev() shall return the number of bytes
* actually written. Otherwise, it shall return a value of -1, the file- * actually written. Otherwise, it shall return a value of -1, the file-
* pointer shall remain unchanged, and errno shall be set to indicate an * pointer shall remain unchanged, and errno shall be set to indicate an
* error. * error. See write for the list of returned errno values. In addition,
* the readv() function will fail if:
*
* EINVAL.
* The sum of the iov_len values in the iov array overflowed an ssize_t
* or The 'iovcnt' argument was less than or equal to 0, or greater than
* IOV_MAX (Not implemented).
* *
****************************************************************************/ ****************************************************************************/
+15 -8
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* libs/libc/stdio/lib_readv.c * libs/libc/stdio/lib_readv.c
* *
* Copyright (C) 2017 Gregory Nutt. All rights reserved. * Copyright (C) 2017=-2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -50,17 +50,17 @@
* *
* Description: * Description:
* The readv() function is equivalent to read(), except as described below. * The readv() function is equivalent to read(), except as described below.
* The readv() function places the input data into the iovcnt buffers * The readv() function places the input data into the 'iovcnt' buffers
* specified by the members of the iov array: iov[0], iov[1], ..., * specified by the members of the 'iov' array: iov[0], iov[1], ...,
* iov[iovcnt-1]. The iovcnt argument is valid if greater than 0 and less * iov['iovcnt'-1]. The 'iovcnt' argument is valid if greater than 0 and
* than or equal to IOV_MAX as defined in limits.h. * less than or equal to IOV_MAX as defined in limits.h.
* *
* Each iovec entry specifies the base address and length of an area in * Each iovec entry specifies the base address and length of an area in
* memory where data should be placed. The readv() function will always * memory where data should be placed. The readv() function will always
* fill an area completely before proceeding to the next. * fill an area completely before proceeding to the next.
* *
* Upon successful completion, readv() will mark for update the st_atime * TODO: pon successful completion, readv() will mark for update the
* field of the file. * st_atime field of the file.
* *
* Input Parameters: * Input Parameters:
* filedes - The open file descriptor for the file to be read * filedes - The open file descriptor for the file to be read
@@ -70,7 +70,14 @@
* Returned Value: * Returned Value:
* Upon successful completion, readv() will return a non-negative integer * Upon successful completion, readv() will return a non-negative integer
* indicating the number of bytes actually read. Otherwise, the functions * indicating the number of bytes actually read. Otherwise, the functions
* will return -1 and set errno to indicate the error. See read(). * will return -1 and set errno to indicate the error. See read() for the
* list of returned errno values. In addition, the readv() function will
* fail if:
*
* EINVAL.
* The sum of the iov_len values in the iov array overflowed an ssize_t
* or The 'iovcnt' argument was less than or equal to 0, or greater than
* IOV_MAX (Not implemented).
* *
****************************************************************************/ ****************************************************************************/
+13 -7
View File
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* libs/libc/stdio/lib_writev.c * libs/libc/stdio/lib_writev.c
* *
* Copyright (C) 2017 Gregory Nutt. All rights reserved. * Copyright (C) 2017-2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -51,20 +51,20 @@
* *
* Description: * Description:
* The writev() function is equivalent to write(), except as described * The writev() function is equivalent to write(), except as described
* below. The writev() function will gather output data from the iovcnt * below. The writev() function will gather output data from the 'iovcnt'
* buffers specified by the members of the iov array: iov[0], iov[1], ..., * buffers specified by the members of the 'iov' array: iov[0], iov[1], ...,
* iov[iovcnt-1]. The iovcnt argument is valid if greater than 0 and less * iov[iovcnt-1]. The 'iovcnt' argument is valid if greater than 0 and less
* than or equal to IOV_MAX, as defined in limits.h. * than or equal to IOV_MAX, as defined in limits.h.
* *
* Each iovec entry specifies the base address and length of an area in * Each iovec entry specifies the base address and length of an area in
* memory from which data should be written. The writev() function always * memory from which data should be written. The writev() function always
* writes a complete area before proceeding to the next. * writes a complete area before proceeding to the next.
* *
* If fildes refers to a regular file and all of the iov_len members in * If 'filedes' refers to a regular file and all of the iov_len members in
* the array pointed to by iov are 0, writev() will return 0 and have no * the array pointed to by iov are 0, writev() will return 0 and have no
* other effect. For other file types, the behavior is unspecified. * other effect. For other file types, the behavior is unspecified.
* *
* If the sum of the iov_len values is greater than SSIZE_MAX, the * TODO: If the sum of the iov_len values is greater than SSIZE_MAX, the
* operation will fail and no data will be transferred. * operation will fail and no data will be transferred.
* *
* Input Parameters: * Input Parameters:
@@ -76,7 +76,13 @@
* Upon successful completion, writev() shall return the number of bytes * Upon successful completion, writev() shall return the number of bytes
* actually written. Otherwise, it shall return a value of -1, the file- * actually written. Otherwise, it shall return a value of -1, the file-
* pointer shall remain unchanged, and errno shall be set to indicate an * pointer shall remain unchanged, and errno shall be set to indicate an
* error. * error. See write for the list of returned errno values. In addition,
* the readv() function will fail if:
*
* EINVAL.
* The sum of the iov_len values in the iov array overflowed an ssize_t
* or The 'iovcnt' argument was less than or equal to 0, or greater than
* IOV_MAX (Not implemented).
* *
****************************************************************************/ ****************************************************************************/