git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jan 7, 2007, 11:24 UTC
Message-ID
<20070107112445.GE10351@spearce.org>
In-Reply-To
<20070107111712.GB9909@scotty.home>
"Stefan-W. Hahn" <stefan.hahn@s-hahn.de> 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.
Previous: Stefan-W. HahnNext: Stefan-W. Hahn
Message 5 of 12 in “problem with git clone on cygwin”
  1. Stefan-W. HahnJan 6, 2007
  2. Juergen RuehleJan 6, 2007
  3. Shawn O. PearceJan 7, 2007
  4. Replacing the system call pread() with real mmap().Stefan-W. Hahn, Jan 7, 2007
  5. Shawn O. PearceJan 7, 2007
  6. Stefan-W. HahnJan 7, 2007
  7. Johannes SchindelinJan 7, 2007
  8. Stefan-W. HahnJan 7, 2007
  9. Test for failing pread() on cygwin.Stefan-W. Hahn, Jan 7, 2007
  10. Stefan-W. HahnJan 7, 2007
  11. Juergen RuehleJan 7, 2007
  12. Stefan-W. HahnJan 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.