Commit 96ef3d84 by Chris Young

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<--
parent 2aeadb9c
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# Install: # Install:
# > cmake --build . --target install # > cmake --build . --target install
SET(CMAKE_SYSTEM_NAME "Generic") SET(CMAKE_SYSTEM_NAME "AmigaOS")
PROJECT(libgit2 C) PROJECT(libgit2 C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
...@@ -23,8 +23,10 @@ STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_V ...@@ -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}") 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}") SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}")
# Uncomment out the line below to use PowerPC SHA1 IF (AMIGA)
SET(SHA1_TYPE "ppc") # Default AmigaOS to use the PowerPC SHA1
SET(SHA1_TYPE "ppc")
ENDIF()
# Find required dependencies # Find required dependencies
INCLUDE_DIRECTORIES(src include deps/http-parser) INCLUDE_DIRECTORIES(src include deps/http-parser)
...@@ -33,15 +35,15 @@ FILE(GLOB SRC_HTTP deps/http-parser/*.c) ...@@ -33,15 +35,15 @@ FILE(GLOB SRC_HTTP deps/http-parser/*.c)
# Specify sha1 implementation # Specify sha1 implementation
IF (SHA1_TYPE STREQUAL "ppc") IF (SHA1_TYPE STREQUAL "ppc")
ADD_DEFINITIONS(-DPPC_SHA1) ADD_DEFINITIONS(-DPPC_SHA1)
FILE(GLOB SRC_SHA1 src/ppc/*.c src/ppc/*.S) FILE(GLOB SRC_SHA1 src/ppc/*.c src/ppc/*.S)
ELSE () ELSE ()
SET (SRC_SHA1) SET (SRC_SHA1)
ENDIF() ENDIF()
IF (NOT WIN32) IF (NOT WIN32)
FIND_PACKAGE(ZLIB) FIND_PACKAGE(ZLIB)
IF (CMAKE_SYSTEM_NAME MATCHES "Generic") IF (CMAKE_SYSTEM_NAME STREQUAL "AmigaOS")
INCLUDE_DIRECTORIES(deps/regex) INCLUDE_DIRECTORIES(deps/regex)
SET(SRC_REGEX deps/regex/regex.c) SET(SRC_REGEX deps/regex/regex.c)
ENDIF() ENDIF()
...@@ -68,7 +70,7 @@ SET(INSTALL_INC include CACHE PATH "Where to install headers to.") ...@@ -68,7 +70,7 @@ SET(INSTALL_INC include CACHE PATH "Where to install headers to.")
# Build options # Build options
OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" OFF) OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" OFF)
OPTION (THREADSAFE "Build libgit2 as threadsafe" 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 (BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION (TAGS "Generate tags" OFF) OPTION (TAGS "Generate tags" OFF)
OPTION (PROFILE "Generate profiling information" OFF) OPTION (PROFILE "Generate profiling information" OFF)
...@@ -106,14 +108,11 @@ IF (NOT CMAKE_BUILD_TYPE) ...@@ -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) SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF () ENDIF ()
IF (CMAKE_SYSTEM_NAME MATCHES "Generic") FIND_PACKAGE(OpenSSL)
ELSE () IF (OPENSSL_FOUND)
FIND_PACKAGE(OpenSSL) ADD_DEFINITIONS(-DGIT_SSL)
IF (OPENSSL_FOUND) INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
ADD_DEFINITIONS(-DGIT_SSL) SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})
ENDIF()
ENDIF() ENDIF()
IF (THREADSAFE) IF (THREADSAFE)
...@@ -133,8 +132,11 @@ FILE(GLOB SRC_H include/git2/*.h) ...@@ -133,8 +132,11 @@ FILE(GLOB SRC_H include/git2/*.h)
IF (WIN32 AND NOT CYGWIN) IF (WIN32 AND NOT CYGWIN)
ADD_DEFINITIONS(-DWIN32 -D_DEBUG -D_WIN32_WINNT=0x0501) 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) 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) 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() ELSE()
FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c) FILE(GLOB SRC src/*.c src/transports/*.c src/xdiff/*.c src/unix/*.c)
ENDIF () ENDIF ()
......
/*
* 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
...@@ -376,7 +376,7 @@ static int ssl_setup(git_transport *t, const char *host) ...@@ -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) int gitno_connect(git_transport *t, const char *host, const char *port)
{ {
#ifndef __amigaos4__ #ifndef NO_ADDRINFO
struct addrinfo *info = NULL, *p; struct addrinfo *info = NULL, *p;
struct addrinfo hints; struct addrinfo hints;
#else #else
...@@ -388,7 +388,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port) ...@@ -388,7 +388,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
#endif #endif
int ret; int ret;
GIT_SOCKET s = INVALID_SOCKET; GIT_SOCKET s = INVALID_SOCKET;
#ifndef __amigaos4__ #ifndef NO_ADDRINFO
memset(&hints, 0x0, sizeof(struct addrinfo)); memset(&hints, 0x0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
...@@ -407,7 +407,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port) ...@@ -407,7 +407,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
port_num = atol(port); port_num = atol(port);
#endif #endif
#ifndef __amigaos4__ #ifndef NO_ADDRINFO
for (p = info; p != NULL; p = p->ai_next) { for (p = info; p != NULL; p = p->ai_next) {
s = socket(p->ai_family, p->ai_socktype, p->ai_protocol); s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
#else #else
...@@ -418,7 +418,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port) ...@@ -418,7 +418,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
net_set_error("error creating socket"); net_set_error("error creating socket");
break; break;
} }
#ifndef __amigaos4__ #ifndef NO_ADDRINFO
if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0) if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0)
#else #else
memcpy(&saddr.sin_addr, hent->h_addr_list[p], hent->h_length); 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) ...@@ -435,7 +435,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
/* Oops, we couldn't connect to any address */ /* Oops, we couldn't connect to any address */
if (s == INVALID_SOCKET && if (s == INVALID_SOCKET &&
#ifndef __amigaos4__ #ifndef NO_ADDRINFO
p == NULL) { p == NULL) {
#else #else
hent->h_addr_list[p] == NULL) { hent->h_addr_list[p] == NULL) {
...@@ -445,7 +445,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port) ...@@ -445,7 +445,7 @@ int gitno_connect(git_transport *t, const char *host, const char *port)
} }
t->socket = s; t->socket = s;
#ifndef __amigaos4__ #ifndef NO_ADDRINFO
freeaddrinfo(info); freeaddrinfo(info);
#endif #endif
if (t->encrypt && ssl_setup(t, host) < 0) if (t->encrypt && ssl_setup(t, host) < 0)
......
...@@ -517,7 +517,7 @@ int git_path_direach( ...@@ -517,7 +517,7 @@ int git_path_direach(
de_buf = git__malloc(sizeof(struct dirent)); de_buf = git__malloc(sizeof(struct dirent));
#endif #endif
#ifdef __amigaos4__ #ifdef NO_READDIR_R
while (de = readdir(dir)) { while (de = readdir(dir)) {
#else #else
while (p_readdir_r(dir, de_buf, de) == 0 && de != NULL) { while (p_readdir_r(dir, de_buf, de) == 0 && de != NULL) {
......
...@@ -74,7 +74,7 @@ typedef SOCKET GIT_SOCKET; ...@@ -74,7 +74,7 @@ typedef SOCKET GIT_SOCKET;
# include "unix/posix.h" # include "unix/posix.h"
#endif #endif
#ifndef __amigaos4__ #ifndef NO_READDIR_R
#define p_readdir_r(d,e,r) readdir_r(d,e,&r) #define p_readdir_r(d,e,r) readdir_r(d,e,&r)
#else #else
#define p_readdir_r(d,e,r) r = readdir(d) #define p_readdir_r(d,e,r) r = readdir(d)
......
...@@ -9,9 +9,7 @@ ...@@ -9,9 +9,7 @@
#ifndef GIT_WIN32 #ifndef GIT_WIN32
#include "map.h" #include "map.h"
#ifndef __amigaos4__
#include <sys/mman.h> #include <sys/mman.h>
#endif
#include <errno.h> #include <errno.h>
int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset) 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 ...@@ -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->data = NULL;
out->len = 0; out->len = 0;
#ifndef __amigaos4__
if (prot & GIT_PROT_WRITE) if (prot & GIT_PROT_WRITE)
mprot = PROT_WRITE; mprot = PROT_WRITE;
else if (prot & GIT_PROT_READ) 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 ...@@ -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; mflag = MAP_PRIVATE;
out->data = mmap(NULL, len, mprot, mflag, fd, offset); 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) { if (!out->data || out->data == MAP_FAILED) {
giterr_set(GITERR_OS, "Failed to mmap. Could not write data"); 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 ...@@ -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) int p_munmap(git_map *map)
{ {
assert(map != NULL); assert(map != NULL);
#ifndef __amigaos4__
munmap(map->data, map->len); munmap(map->data, map->len);
#else
free(map->data);
#endif
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment