X-Spam-Check-By: sourceware.org
Date: Fri, 1 Sep 2006 10:47:13 -0700
From: clayne@anodized.com
To: cygwin@cygwin.com
Subject: Re: cygwin fork()
Message-ID: <20060901174713.GE30633@ns1.anodized.com>
References: <20060901100138.GA7444@ns1.anodized.com> <Pine.GSO.4.63.0609011023420.13719@access1.cims.nyu.edu> <20060901153709.GC7663@ns1.anodized.com> <20060901155403.GE5926@trixie.casa.cgf.cx> <20060901160911.GA30633@ns1.anodized.com> <20060901163415.GB30633@ns1.anodized.com> <20060901170451.GC30633@ns1.anodized.com> <20060901172457.GA10511@trixie.casa.cgf.cx>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20060901172457.GA10511@trixie.casa.cgf.cx>
User-Agent: Mutt/1.5.11
X-Assp-Spam-Prob: 0.00000
X-Assp-Whitelisted: Yes
X-Assp-Envelope-From: clayne@ns1.anodized.com
X-Assp-Intended-For: cygwin@cygwin.com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Fri, Sep 01, 2006 at 01:24:57PM -0400, Christopher Faylor wrote:
> >In regards to setting the fd to textmode as a way of stripping CRs.
> >Only problem is that it's making 213,110 syscalls for a 213k libtool
> >script.  That cannot be an efficient way to remove CRs from input.
> 
> Opening a file with O_TEXT should not, AFAIK, cause a bunch of one-byte
> reads.
> 
> A simple test case (tm) seems to confirm that.
> 
> cgf

You're right. I also verified this.

I found the real culprit, which I had also ifdef'd out because it looked
bogus and crufty:

/* Return 1 if a seek on FD will succeed. */
#ifndef __CYGWIN__
#  define fd_is_seekable(fd) (lseek ((fd), 0L, SEEK_CUR) >= 0)
#else
#  define fd_is_seekable(fd) 0
#endif /* __CYGWIN__ */

/* Take FD, a file descriptor, and create and return a buffered stream
   corresponding to it.  If something is wrong and the file descriptor
   is invalid, return a NULL stream. */
BUFFERED_STREAM *
fd_to_buffered_stream (fd)
     int fd;
{
  char *buffer;
  size_t size;
  struct stat sb;

  if (fstat (fd, &sb) < 0)
    {
      close (fd);
      return ((BUFFERED_STREAM *)NULL);
    }

  size = (fd_is_seekable (fd)) ? min (sb.st_size, MAX_INPUT_BUFFER_SIZE) : 1;
  if (size == 0)
    size = 1;
  buffer = (char *)xmalloc (size);

  return (make_buffered_stream (fd, buffer, size));
}



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

