Re: [PATCH] Replacing the system call pread() with real mmap().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Stefan-W. Hahn" <stefan.hahn@xxxxxxxxx> 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.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]