Basic mmap/munmap compatiblity
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
diff --git a/src/map.h b/src/map.h
index 96d8795..6ce6d36 100644
--- a/src/map.h
+++ b/src/map.h
@@ -23,6 +23,10 @@
#define GIT_MAP_TYPE 0xf
#define GIT_MAP_FIXED 0x10
+#ifdef __amigaos4__
+#define MAP_FAILED 0
+#endif
+
typedef struct { /* memory mapped buffer */
void *data; /* data bytes */
size_t len; /* data length */
diff --git a/src/pack.c b/src/pack.c
index 0db1069..85bc670 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -215,7 +215,7 @@ static int packfile_unpack_header1(
unsigned shift;
unsigned long size, c;
unsigned long used = 0;
-
+printf("[pack 218] buf = %lx, used = %ld, len = %ld\n", buf, used, len);
c = buf[used++];
*type = (c >> 4) & 7;
size = c & 15;
@@ -261,7 +261,7 @@ int git_packfile_unpack_header(
base = git_mwindow_open(mwf, w_curs, *curpos, 20, &left);
if (base == NULL)
return GIT_EBUFS;
-
+printf("[pack 264] base = %lx, mwf = %lx\n", base, mwf);
ret = packfile_unpack_header1(&used, size_p, type_p, base, left);
git_mwindow_close(w_curs);
if (ret == GIT_EBUFS)
diff --git a/src/unix/map.c b/src/unix/map.c
index 65f4ac9..8e853b9 100644
--- a/src/unix/map.c
+++ b/src/unix/map.c
@@ -16,7 +16,6 @@
int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
{
-#ifndef __amigaos4__
int mprot = 0;
int mflag = 0;
@@ -25,6 +24,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
out->data = NULL;
out->len = 0;
+#ifndef __amigaos4__
if (prot & GIT_PROT_WRITE)
mprot = PROT_WRITE;
else if (prot & GIT_PROT_READ)
@@ -36,21 +36,34 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
mflag = MAP_PRIVATE;
out->data = mmap(NULL, len, mprot, mflag, fd, offset);
+#else
+ if ((prot & GIT_PROT_WRITE) && ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)) {
+ printf("Trying to map shared-writeable file!!!\n");
+
+ if(out->data = malloc(len)) {
+ lseek(fd, offset, SEEK_SET);
+ p_read(fd, out->data, len);
+ }
+ }
+#endif
+
if (!out->data || out->data == MAP_FAILED) {
giterr_set(GITERR_OS, "Failed to mmap. Could not write data");
return -1;
}
out->len = len;
-#endif
+
return 0;
}
int p_munmap(git_map *map)
{
-#ifndef __amigaos4__
assert(map != NULL);
+#ifndef __amigaos4__
munmap(map->data, map->len);
+#else
+ free(map->data);
#endif
return 0;
}