summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2012-06-13 23:16:14 +0100
committerChris Young <chris@unsatisfactorysoftware.co.uk>2012-06-13 23:16:14 +0100
commit96ef3d84629ef72fb662d95abbab3de634921678 (patch)
tree1859c8ce4b577acce3c5561d7f749f5a23574d58 /src
parent2aeadb9c78df4b463ffb3293e242e19a7e0d17a9 (diff)
downloadlibgit2-96ef3d84629ef72fb662d95abbab3de634921678.tar.gz
Make this more generic and mergeable.
Needs AmigaOS.cmake now from CMake package at OS4Depot, or contents below: --8<-- SET(AMIGA 1) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") --8<--
Diffstat (limited to 'src')
-rwxr-xr-xsrc/amiga/map.c53
-rw-r--r--src/netops.c12
-rw-r--r--src/path.c2
-rw-r--r--src/posix.h2
-rw-r--r--src/unix/map.c18
5 files changed, 62 insertions, 25 deletions
diff --git a/src/amiga/map.c b/src/amiga/map.c
new file mode 100755
index 000000000..d36bcbc9c
--- /dev/null
+++ b/src/amiga/map.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009-2012 the libgit2 contributors
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+#include <git2/common.h>
+
+#ifndef GIT_WIN32
+
+#include "posix.h"
+#include "map.h"
+#include <errno.h>
+
+int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
+{
+ int mprot = 0;
+ int mflag = 0;
+
+ GIT_MMAP_VALIDATE(out, len, prot, flags);
+
+ out->data = NULL;
+ out->len = 0;
+
+ 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)) {
+ p_lseek(fd, offset, SEEK_SET);
+ p_read(fd, out->data, len);
+ }
+
+ if (!out->data || out->data == MAP_FAILED) {
+ giterr_set(GITERR_OS, "Failed to mmap. Could not write data");
+ return -1;
+ }
+
+ out->len = len;
+
+ return 0;
+}
+
+int p_munmap(git_map *map)
+{
+ assert(map != NULL);
+ free(map->data);
+
+ return 0;
+}
+
+#endif
+
diff --git a/src/netops.c b/src/netops.c
index 6808c8ee7..11295c5cd 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -376,7 +376,7 @@ static int ssl_setup(git_transport *t, const char *host)
int gitno_connect(git_transport *t, const char *host, const char *port)
{
-#ifndef __amigaos4__
+#ifndef NO_ADDRINFO
struct addrinfo *info = NULL, *p;
struct addrinfo hints;
#else
@@ -388,7 +388,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
#endif
int ret;
GIT_SOCKET s = INVALID_SOCKET;
-#ifndef __amigaos4__
+#ifndef NO_ADDRINFO
memset(&hints, 0x0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
@@ -407,7 +407,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
port_num = atol(port);
#endif
-#ifndef __amigaos4__
+#ifndef NO_ADDRINFO
for (p = info; p != NULL; p = p->ai_next) {
s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
#else
@@ -418,7 +418,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
net_set_error("error creating socket");
break;
}
-#ifndef __amigaos4__
+#ifndef NO_ADDRINFO
if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0)
#else
memcpy(&saddr.sin_addr, hent->h_addr_list[p], hent->h_length);
@@ -435,7 +435,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
/* Oops, we couldn't connect to any address */
if (s == INVALID_SOCKET &&
-#ifndef __amigaos4__
+#ifndef NO_ADDRINFO
p == NULL) {
#else
hent->h_addr_list[p] == NULL) {
@@ -445,7 +445,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
}
t->socket = s;
-#ifndef __amigaos4__
+#ifndef NO_ADDRINFO
freeaddrinfo(info);
#endif
if (t->encrypt && ssl_setup(t, host) < 0)
diff --git a/src/path.c b/src/path.c
index eb9bc06f3..596dad164 100644
--- a/src/path.c
+++ b/src/path.c
@@ -517,7 +517,7 @@ int git_path_direach(
de_buf = git__malloc(sizeof(struct dirent));
#endif
-#ifdef __amigaos4__
+#ifdef NO_READDIR_R
while (de = readdir(dir)) {
#else
while (p_readdir_r(dir, de_buf, de) == 0 && de != NULL) {
diff --git a/src/posix.h b/src/posix.h
index 8e8b394c8..35118f968 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -74,7 +74,7 @@ typedef SOCKET GIT_SOCKET;
# include "unix/posix.h"
#endif
-#ifndef __amigaos4__
+#ifndef NO_READDIR_R
#define p_readdir_r(d,e,r) readdir_r(d,e,&r)
#else
#define p_readdir_r(d,e,r) r = readdir(d)
diff --git a/src/unix/map.c b/src/unix/map.c
index b04e95a76..9dcae5845 100644
--- a/src/unix/map.c
+++ b/src/unix/map.c
@@ -9,9 +9,7 @@
#ifndef GIT_WIN32
#include "map.h"
-#ifndef __amigaos4__
#include <sys/mman.h>
-#endif
#include <errno.h>
int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
@@ -24,7 +22,6 @@ 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,16 +33,6 @@ 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");
@@ -60,11 +47,8 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs
int p_munmap(git_map *map)
{
assert(map != NULL);
-#ifndef __amigaos4__
munmap(map->data, map->len);
-#else
- free(map->data);
-#endif
+
return 0;
}