From: Shawn O. Pearce Date: Sun, 07 Jan 2007 11:24:45 GMT Subject: Re: [PATCH] Replacing the system call pread() with real mmap(). Message-ID: <20070107112445.GE10351@spearce.org> In-Reply-To: <20070107111712.GB9909@scotty.home> "Stefan-W. Hahn" wrote: > +# Define NO_PREAD if you have a problem with pread() system call (i.e. > +# cygwin.dll before v1.5.22). This needs NO_MMAP not to be set, because pread() > +# is emulated using mmap. Better to emulate pread using lseek/xread/lseek: off_t p = lseek(fd, offset, SEEK_SET); xread(fd, buf, count); lseek(fd, p, SEEK_SET); If you look at the history for contrib/mmap.c you will see an implementation like that before it was called git_mmap(). This works OK in Git as we only ever have one thread, therefore there is no race condition during the seek/read/seek calls. Its also usually faster on platforms like Mac OS X where mmap() is horrible. If the platform is lacking a good pread() it may also be the case that it lacks a good mmap(); in this case it would be desirable to set both NO_MMAP and NO_PREAD. -- Shawn.