diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2019-06-23 17:09:22 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2019-11-25 13:18:28 +1100 |
commit | 8be12026a158f0836c73f6b9f33abab640d9a115 (patch) | |
tree | 0734a3249ccedec73dd3c3c599b00453b7bb5687 | |
parent | 7e1cc296e4c89c35b38d3637176aab2bdc4efab6 (diff) | |
download | libgit2-8be12026a158f0836c73f6b9f33abab640d9a115.tar.gz |
mmap: use a 64-bit signed type `off64_t` for mmap
Prefer `off64_t` to `git_off_t` for internal visibility.
-rw-r--r-- | src/futils.c | 2 | ||||
-rw-r--r-- | src/futils.h | 2 | ||||
-rw-r--r-- | src/map.h | 2 | ||||
-rw-r--r-- | src/posix.c | 2 | ||||
-rw-r--r-- | src/posix.h | 12 | ||||
-rw-r--r-- | src/win32/map.c | 6 |
6 files changed, 19 insertions, 7 deletions
diff --git a/src/futils.c b/src/futils.c index 7e100a930..a7c360a1c 100644 --- a/src/futils.c +++ b/src/futils.c @@ -307,7 +307,7 @@ int git_futils_mv_withpath(const char *from, const char *to, const mode_t dirmod return 0; } -int git_futils_mmap_ro(git_map *out, git_file fd, git_off_t begin, size_t len) +int git_futils_mmap_ro(git_map *out, git_file fd, off64_t begin, size_t len) { return p_mmap(out, len, GIT_PROT_READ, GIT_MAP_SHARED, fd, begin); } diff --git a/src/futils.h b/src/futils.h index f97b15602..3d5664679 100644 --- a/src/futils.h +++ b/src/futils.h @@ -290,7 +290,7 @@ extern mode_t git_futils_canonical_mode(mode_t raw_mode); extern int git_futils_mmap_ro( git_map *out, git_file fd, - git_off_t begin, + off64_t begin, size_t len); /** @@ -40,7 +40,7 @@ typedef struct { /* memory mapped buffer */ assert((prot & GIT_PROT_WRITE) || (prot & GIT_PROT_READ)); \ assert((flags & GIT_MAP_FIXED) == 0); } while (0) -extern int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset); +extern int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset); extern int p_munmap(git_map *map); #endif diff --git a/src/posix.c b/src/posix.c index 1ea2ce54b..fbaa7c3ca 100644 --- a/src/posix.c +++ b/src/posix.c @@ -235,7 +235,7 @@ int git__mmap_alignment(size_t *alignment) } -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, off64_t offset) { GIT_MMAP_VALIDATE(out, len, prot, flags); diff --git a/src/posix.h b/src/posix.h index 170ff2606..eef667762 100644 --- a/src/posix.h +++ b/src/posix.h @@ -89,6 +89,18 @@ #define EAFNOSUPPORT (INT_MAX-1) #endif +/* Provide a 64-bit size for offsets. */ + +#if defined(_MSC_VER) +typedef __int64 off64_t; +#elif defined(__HAIKU__) +typedef __haiku_std_int64 off64_t; +#elif defined(__APPLE__) +typedef __int64_t off64_t; +#else +typedef int64_t off64_t; +#endif + typedef int git_file; /** diff --git a/src/win32/map.c b/src/win32/map.c index dff0695d2..e2ce737de 100644 --- a/src/win32/map.c +++ b/src/win32/map.c @@ -50,7 +50,7 @@ int git__mmap_alignment(size_t *page_size) return 0; } -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, off64_t offset) { HANDLE fh = (HANDLE)_get_osfhandle(fd); DWORD alignment = get_allocation_granularity(); @@ -58,8 +58,8 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offs DWORD view_prot = 0; DWORD off_low = 0; DWORD off_hi = 0; - git_off_t page_start; - git_off_t page_offset; + off64_t page_start; + off64_t page_offset; GIT_MMAP_VALIDATE(out, len, prot, flags); |