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<--
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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 969a5e6..fdc103e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@
# Install:
# > cmake --build . --target install
-SET(CMAKE_SYSTEM_NAME "Generic")
+SET(CMAKE_SYSTEM_NAME "AmigaOS")
PROJECT(libgit2 C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
@@ -23,8 +23,10 @@ STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_V
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}")
SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}")
-# Uncomment out the line below to use PowerPC SHA1
-SET(SHA1_TYPE "ppc")
+IF (AMIGA)
+ # Default AmigaOS to use the PowerPC SHA1
+ SET(SHA1_TYPE "ppc")
+ENDIF()
# Find required dependencies
INCLUDE_DIRECTORIES(src include deps/http-parser)
@@ -33,15 +35,15 @@ FILE(GLOB SRC_HTTP deps/http-parser/*.c)
# Specify sha1 implementation
IF (SHA1_TYPE STREQUAL "ppc")
- ADD_DEFINITIONS(-DPPC_SHA1)
- FILE(GLOB SRC_SHA1 src/ppc/*.c src/ppc/*.S)
+ ADD_DEFINITIONS(-DPPC_SHA1)
+ FILE(GLOB SRC_SHA1 src/ppc/*.c src/ppc/*.S)
ELSE ()
SET (SRC_SHA1)
ENDIF()
IF (NOT WIN32)
FIND_PACKAGE(ZLIB)
- IF (CMAKE_SYSTEM_NAME MATCHES "Generic")
+ IF (CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
INCLUDE_DIRECTORIES(deps/regex)
SET(SRC_REGEX deps/regex/regex.c)
ENDIF()
@@ -68,7 +70,7 @@ SET(INSTALL_INC include CACHE PATH "Where to install headers to.")
# Build options
OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" OFF)
OPTION (THREADSAFE "Build libgit2 as threadsafe" OFF)
-OPTION (BUILD_CLAR "Build Tests using the Clar suite" ON)
+OPTION (BUILD_CLAR "Build Tests using the Clar suite" OFF)
OPTION (BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION (TAGS "Generate tags" OFF)
OPTION (PROFILE "Generate profiling information" OFF)
@@ -106,14 +108,11 @@ IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF ()
-IF (CMAKE_SYSTEM_NAME MATCHES "Generic")
-ELSE ()
- FIND_PACKAGE(OpenSSL)
- IF (OPENSSL_FOUND)
- ADD_DEFINITIONS(-DGIT_SSL)
- INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
- SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})
- ENDIF()
+FIND_PACKAGE(OpenSSL)
+IF (OPENSSL_FOUND)
+ ADD_DEFINITIONS(-DGIT_SSL)
+ INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
+ SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})
ENDIF()
IF (THREADSAFE)
@@ -133,8 +132,11 @@ FILE(GLOB SRC_H include/git2/*.h)
IF (WIN32 AND NOT CYGWIN)
ADD_DEFINITIONS(-DWIN32 -D_DEBUG -D_WIN32_WINNT=0x0501)
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/win32/*.c src/compat/*.c)
-ELSEIF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS|Generic)")
+ELSEIF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c src/compat/*.c)
+ELSEIF (AMIGA)
+ ADD_DEFINITIONS(-DNO_ADDRINFO -DNO_READDIR_R)
+ FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/amiga/*.c src/compat/*.c)
ELSE()
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c)
ENDIF ()
diff --git a/src/amiga/map.c b/src/amiga/map.c
new file mode 100755
index 0000000..d36bcbc
--- /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 6808c8e..11295c5 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 eb9bc06..596dad1 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 8e8b394..35118f9 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 b04e95a..9dcae58 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;
}