diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2012-06-14 02:16:14 +0400 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2012-06-14 02:16:14 +0400 |
commit | 96ef3d84629ef72fb662d95abbab3de634921678 (patch) | |
tree | 1859c8ce4b577acce3c5561d7f749f5a23574d58 /src/amiga | |
parent | 2aeadb9c78df4b463ffb3293e242e19a7e0d17a9 (diff) |
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/amiga')
-rwxr-xr-x | src/amiga/map.c | 53 |
1 files changed, 53 insertions, 0 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 + |