git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* make gitfakemmap standalone to fix linking error in git.c
@ 2005-12-05 13:19 Alex Riesen
  2005-12-05 13:24 ` Alex Riesen
  0 siblings, 1 reply; 23+ messages in thread
From: Alex Riesen @ 2005-12-05 13:19 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 225 bytes --]

The patch is to fix linking error because of gitfakemmap referencing
die living in usage.c, and git.c not linking in the file. Instead of
hardcoding usage.o in git.c prerequisites, I separated mmap from the
main sources.

[-- Attachment #2: 0001-make-fakemmap-standalone-to-fix-linking-error-because-of-gitfakemmap.txt --]
[-- Type: text/plain, Size: 2720 bytes --]

Subject: [PATCH] make fakemmap standalone to fix linking error because of gitfakemmap
referencing die living in usage.c, and git.c not linking in the file.
Instead of hardcoding usage.o in git.c prerequisites, I separated mmap.

Signed-off-by: Alex Riesen <fork0@gmail.com>


---

 cache.h       |   18 +++---------------
 compat/mmap.c |   11 +++++++----
 compat/mmap.h |   15 +++++++++++++++
 3 files changed, 25 insertions(+), 19 deletions(-)
 create mode 100644 compat/mmap.h

e1e24d29b684d468a7be5d097ba3e1679170e7db
diff --git a/cache.h b/cache.h
index f9b367f..c70a467 100644
--- a/cache.h
+++ b/cache.h
@@ -11,7 +11,9 @@
 #include <string.h>
 #include <errno.h>
 #include <limits.h>
-#ifndef NO_MMAP
+#ifdef NO_MMAP
+#include "compat/mmap.h"
+#else
 #include <sys/mman.h>
 #endif
 #include <sys/param.h>
@@ -373,20 +375,6 @@ extern void packed_object_info_detail(st
 /* Dumb servers support */
 extern int update_server_info(int);
 
-#ifdef NO_MMAP
-
-#ifndef PROT_READ
-#define PROT_READ 1
-#define PROT_WRITE 2
-#define MAP_PRIVATE 1
-#define MAP_FAILED ((void*)-1)
-#endif
-
-extern void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset);
-extern int gitfakemunmap(void *start, size_t length);
-
-#endif
-
 typedef int (*config_fn_t)(const char *, const char *);
 extern int git_default_config(const char *, const char *);
 extern int git_config_from_file(config_fn_t fn, const char *);
diff --git a/compat/mmap.c b/compat/mmap.c
index a051c47..98cf3cb 100644
--- a/compat/mmap.c
+++ b/compat/mmap.c
@@ -2,21 +2,24 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
-#include "../cache.h"
+#include <string.h>
+#include "mmap.h"
 
 void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset)
 {
 	int n = 0;
 
-	if (start != NULL || !(flags & MAP_PRIVATE))
-		die("Invalid usage of gitfakemmap.");
+	if (!start || !(flags & MAP_PRIVATE)) {
+		fprintf(stderr, "Invalid usage of gitfakemmap.\n");
+		exit(128); /* see die() in ../usage.c */
+	}
 
 	if (lseek(fd, offset, SEEK_SET) < 0) {
 		errno = EINVAL;
 		return MAP_FAILED;
 	}
 
-	start = xmalloc(length);
+	start = malloc(length);
 	if (start == NULL) {
 		errno = ENOMEM;
 		return MAP_FAILED;
diff --git a/compat/mmap.h b/compat/mmap.h
new file mode 100644
index 0000000..08d7f99
--- /dev/null
+++ b/compat/mmap.h
@@ -0,0 +1,15 @@
+#ifndef MMAP_H
+#define MMAP_H
+
+#ifndef PROT_READ
+#define PROT_READ 1
+#define PROT_WRITE 2
+#define MAP_PRIVATE 1
+#define MAP_FAILED ((void*)-1)
+#endif
+
+extern void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset);
+extern int gitfakemunmap(void *start, size_t length);
+
+#endif
+
-- 
0.99.9.GIT

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2005-12-06  9:53 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-05 13:19 make gitfakemmap standalone to fix linking error in git.c Alex Riesen
2005-12-05 13:24 ` Alex Riesen
2005-12-05 14:11   ` Petr Baudis
2005-12-05 15:43     ` Alex Riesen
2005-12-05 17:40   ` Junio C Hamano
2005-12-05 20:22     ` [PATCH] Clean up compatibility definitions Junio C Hamano
2005-12-05 20:36       ` Johannes Schindelin
2005-12-05 20:51         ` Junio C Hamano
2005-12-05 21:39           ` Alex Riesen
2005-12-06  7:35             ` Alex Riesen
2005-12-06  7:58               ` Junio C Hamano
2005-12-05 21:50       ` Alex Riesen
2005-12-05 21:58         ` Junio C Hamano
2005-12-06  7:15           ` Alex Riesen
2005-12-06  7:31             ` Junio C Hamano
2005-12-06  8:07               ` Alex Riesen
2005-12-06  8:11                 ` Junio C Hamano
2005-12-05 23:12       ` Petr Baudis
2005-12-06  3:17         ` Junio C Hamano
2005-12-06  9:53           ` Petr Baudis
2005-12-05 21:36     ` make gitfakemmap standalone to fix linking error in git.c Alex Riesen
2005-12-05 21:49       ` Junio C Hamano
2005-12-06  7:49         ` Alex Riesen

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).