delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/01/23/01:36:57

Date: Thu, 23 Jan 2003 08:31:19 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
cc: djgpp-workers AT delorie DOT com
Subject: Re: readv, writev [PATCH]
In-Reply-To: <E18bKL9-0000WW-00@phekda.freeserve.co.uk>
Message-ID: <Pine.SUN.3.91.1030123082200.15630D@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 22 Jan 2003, Richard Dawe wrote:

> The calls allocate a buffer big enough to store all the data
> for the I/O vector, so that a single read or write call can be used.
> This seemed like the simplest and most robust way of doing it, since
> there are no readv or writev system calls.

This design worries me a bit.  The buffer you allocate can be quite 
large, in which case we are talking some major heap exercising.  The 
function could even unjustly fail (for lack of enough memory) in some 
borderline cases, like if the file is much smaller than what you tell 
the function about the buffers' length.

What exactly are the problems in doing this straightforwardly, i.e. read 
into the buffers directly one by one?  What am I missing?

> +   /* Read in the data. */
> +   ret = read(fd, buf, maxbytes);

Can't you use _read instead?  Is readv supposed to handle text files and 
do CRLF->NL conversions?

The same holds for _write in writev.

> + @subheading Syntax
> + 
> + @example
> + #include <sys/uio.h>
> + 
> + ssize_t readv(int fd, const struct iovec *iov, int iovcnt);
> + @end example
[...]
> + @code{struct iovec} is defined as follows:

Since we are about to add index entries to the manual, how about having 
@findex at the beginning of the node and @tindex for `struct iovec'?

> + Otherwise, a value of -1 is returned and @var{errno} is set appropriately.

`errno' is the actual name of a variable, it does not stand for something 
else.  So it should be in @code, not in @var.

And please don't forget an entry in wc204.txi.

Last but not least, thanks for working on this.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019