Re: read() MAX_IO_SIZE bytes, more than SSIZE_MAX?
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Feb 8, 2015, 17:09 UTC
- Message-ID
- <CAPig+cTbLOV-0yFKp8wwVLSr4OJz7LUaLZgVGHUdFhj7xZEzrw@mail.gmail.com>
- In-Reply-To
- <loom.20150208T125055-287@post.gmane.org>
On Sun, Feb 8, 2015 at 7:05 AM, Joachim Schmitz <jojo@schmitz-digital.de> wrote:
Show 17 quoted lines
> Junio C Hamano <gitster <at> pobox.com> writes: >> (1) if Makefile gives one, use it without second-guessing with SSIZE_MAX. >> (2) if SSIZE_MAX is defined, and if it is smaller than our internal >> default, use it. >> (3) all other cases, us our internal default. > > oops, yes, of course > > /* allow overwriting from e.g. Makefile */ > #ifndef(MAX_IO_SIZE) > # define MAX_IO_SIZE (8*1024*1024) > /* for plattforms that have SSIZE and have it smaller */ > # if defined(SSIZE_MAX) && (SSIZE_MAX < MAX_IO_SIZE) > # undef MAX_IO_SIZE /* avoid warning */ > # define MAX_IO_SIZE SSIZE_MAX > # endif > #endif
A bit cleaner:
#ifndef(MAX_IO_SIZE) # define MAX_IO_SIZE_DEFAULT (8*1024*1024) # if defined(SSIZE_MAX) && (SSIZE_MAX < MAX_IO_SIZE_DEFAULT) # define MAX_IO_SIZE SSIZE_MAX # else # define MAX_IO_SIZE MAX_IO_SIZE_DEFAULT # endif #endif