From: Jonathan Nieder <jrnieder@gmail.com>
To: git@vger.kernel.org
Cc: Ramkumar Ramachandra <artagnon@gmail.com>,
David Barr <david.barr@cordelta.com>
Subject: [PATCH 1/8] wrapper: move xmmap() to sha1_file.c
Date: Sat, 6 Nov 2010 06:44:11 -0500 [thread overview]
Message-ID: <20101106114411.GA27641@burratino> (raw)
In-Reply-To: <20101106113905.GA27405@burratino>
wrapper.o depends on sha1_file.o for a number of reasons. One is
release_pack_memory().
xmmap function calls mmap, discarding unused pack windows when
necessary to relieve memory pressure. Simple git programs using
wrapper.o as a friendly libc do not need this functionality.
So move xmmap to sha1_file.o, where release_pack_memory() is.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
sha1_file.c | 15 +++++++++++++++
wrapper.c | 15 ---------------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 0cd9435..8e299ae 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -576,6 +576,21 @@ void release_pack_memory(size_t need, int fd)
; /* nothing */
}
+void *xmmap(void *start, size_t length,
+ int prot, int flags, int fd, off_t offset)
+{
+ void *ret = mmap(start, length, prot, flags, fd, offset);
+ if (ret == MAP_FAILED) {
+ if (!length)
+ return NULL;
+ release_pack_memory(length, fd);
+ ret = mmap(start, length, prot, flags, fd, offset);
+ if (ret == MAP_FAILED)
+ die_errno("Out of memory? mmap failed");
+ }
+ return ret;
+}
+
void close_pack_windows(struct packed_git *p)
{
while (p->windows) {
diff --git a/wrapper.c b/wrapper.c
index fd8ead3..3195ef3 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -108,21 +108,6 @@ void *xcalloc(size_t nmemb, size_t size)
return ret;
}
-void *xmmap(void *start, size_t length,
- int prot, int flags, int fd, off_t offset)
-{
- void *ret = mmap(start, length, prot, flags, fd, offset);
- if (ret == MAP_FAILED) {
- if (!length)
- return NULL;
- release_pack_memory(length, fd);
- ret = mmap(start, length, prot, flags, fd, offset);
- if (ret == MAP_FAILED)
- die_errno("Out of memory? mmap failed");
- }
- return ret;
-}
-
/*
* xread() is the same a read(), but it automatically restarts read()
* operations with a recoverable error (EAGAIN and EINTR). xread()
--
1.7.2.3.557.gab647.dirty
next prev parent reply other threads:[~2010-11-06 11:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-06 11:39 [PATCH/RFC 0/8] Remove various dependencies from wrapper.o Jonathan Nieder
2010-11-06 11:44 ` Jonathan Nieder [this message]
2010-11-06 11:45 ` [PATCH 2/8] wrapper: move odb_* to environment.c Jonathan Nieder
2010-11-06 11:46 ` [PATCH 3/8] path helpers: move git_mkstemp* to wrapper.c Jonathan Nieder
2010-11-06 11:46 ` [PATCH 4/8] strbuf: move strbuf_branchname to sha1_name.c Jonathan Nieder
2010-11-06 11:47 ` [PATCH 5/8] wrapper: give zlib wrappers their own translation unit Jonathan Nieder
2010-11-06 11:47 ` [PATCH 6/8] pack-objects: mark file-local variable static Jonathan Nieder
2010-11-06 11:48 ` [PATCH 7/8] wrapper: expose try_to_free_pack_memory() Jonathan Nieder
2010-11-06 11:52 ` [PATCH 8/8] Remove pack file handling dependency from wrapper.o Jonathan Nieder
2010-11-06 18:07 ` René Scharfe
2010-11-06 18:42 ` Jonathan Nieder
2010-11-07 16:10 ` René Scharfe
2010-11-07 18:23 ` Jonathan Nieder
2010-11-06 19:00 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101106114411.GA27641@burratino \
--to=jrnieder@gmail.com \
--cc=artagnon@gmail.com \
--cc=david.barr@cordelta.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).