diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-07-14 10:04:07 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-07-14 10:04:07 +0000 |
commit | 4f919c611cf0d93c4e4a9234e5d3eca1883343bc (patch) | |
tree | 9df54b112a0306759b75bb0b3b97a7a87dbcdfd9 /Build/source/libs/zziplib/zziplib-0.13.62 | |
parent | 2d1ceac8dad55545f652aa69af318f5e262b7d71 (diff) |
libs/zziplib: Reenable use of mmap() for WIN32 and WIN64 (patch from Akira)
git-svn-id: svn://tug.org/texlive/trunk@34602 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/zziplib/zziplib-0.13.62')
4 files changed, 30 insertions, 5 deletions
diff --git a/Build/source/libs/zziplib/zziplib-0.13.62/zzip/__mmap.h b/Build/source/libs/zziplib/zziplib-0.13.62/zzip/__mmap.h index d70419dcb02..b57324c4b90 100644 --- a/Build/source/libs/zziplib/zziplib-0.13.62/zzip/__mmap.h +++ b/Build/source/libs/zziplib/zziplib-0.13.62/zzip/__mmap.h @@ -50,21 +50,29 @@ #define MAP_FAILED 0 #endif /* we (ab)use the "*user" variable to store the FileMapping handle */ - /* which assumes (sizeof(long) == sizeof(HANDLE)) */ + /* and make sure (sizeof(*user) == sizeof(HANDLE)) */ static size_t win32_getpagesize (void) { SYSTEM_INFO si; GetSystemInfo (&si); return si.dwAllocationGranularity; } +#ifdef _WIN64 +static void* win32_mmap (__int64* user, int fd, zzip_off_t offs, size_t len) +#else static void* win32_mmap (long* user, int fd, zzip_off_t offs, size_t len) +#endif { if (! user || *user != 1) /* || offs % getpagesize() */ return 0; { HANDLE hFile = (HANDLE)_get_osfhandle(fd); if (hFile) - *user = (int) CreateFileMapping (hFile, 0, PAGE_READONLY, 0, 0, NULL); +#ifdef _WIN64 + *user = (__int64) CreateFileMapping (hFile, 0, PAGE_READONLY, 0, 0, NULL); +#else + *user = (long) CreateFileMapping (hFile, 0, PAGE_READONLY, 0, 0, NULL); +#endif if (*user) { char* p = 0; @@ -75,18 +83,27 @@ static void* win32_mmap (long* user, int fd, zzip_off_t offs, size_t len) return MAP_FAILED; } } +#ifdef _WIN64 +static void win32_munmap (__int64* user, char* fd_map, size_t len) +#else static void win32_munmap (long* user, char* fd_map, size_t len) +#endif { UnmapViewOfFile (fd_map); CloseHandle (*(HANDLE*)user); *user = 1; } - +#ifdef _WIN64 +#define _zzip_mmap(user, fd, offs, len) \ + win32_mmap ((__int64*) &(user), fd, offs, len) +#define _zzip_munmap(user, ptr, len) \ + win32_munmap ((__int64*) &(user), ptr, len) +#else #define _zzip_mmap(user, fd, offs, len) \ win32_mmap ((long*) &(user), fd, offs, len) #define _zzip_munmap(user, ptr, len) \ win32_munmap ((long*) &(user), ptr, len) +#endif #define _zzip_getpagesize(user) win32_getpagesize() - #else /* disable */ #define USE_MMAP 0 /* USE_MAP is intentional: we expect the compiler to do some "code removal" diff --git a/Build/source/libs/zziplib/zziplib-0.13.62/zzip/mmapped.h b/Build/source/libs/zziplib/zziplib-0.13.62/zzip/mmapped.h index ee2ba5ad8b6..18fbabadb40 100644 --- a/Build/source/libs/zziplib/zziplib-0.13.62/zzip/mmapped.h +++ b/Build/source/libs/zziplib/zziplib-0.13.62/zzip/mmapped.h @@ -42,7 +42,11 @@ struct zzip_disk void* reserved; /* - for later extensions (might be renamed) */ void* user; /* - free for applications (use this!) */ long flags; /* bit 0: findfile searches case-insensitive */ +#ifdef _WIN64 + __int64 mapped; +#else long mapped; /* used for mmap() wrappers of zzip/__mmap.h */ +#endif long unused; /* - for later extensions (might be renamed) */ long code; /* - free for applications (use this!) */ }; diff --git a/Build/source/libs/zziplib/zziplib-0.13.62/zzip/plugin.c b/Build/source/libs/zziplib/zziplib-0.13.62/zzip/plugin.c index ee578f41f55..2909df86687 100644 --- a/Build/source/libs/zziplib/zziplib-0.13.62/zzip/plugin.c +++ b/Build/source/libs/zziplib/zziplib-0.13.62/zzip/plugin.c @@ -43,7 +43,7 @@ zzip_filesize(int fd) return st.st_size; } -static const struct zzip_plugin_io default_io = { +static struct zzip_plugin_io default_io = { &open, &close, &_zzip_read, diff --git a/Build/source/libs/zziplib/zziplib-0.13.62/zzip/plugin.h b/Build/source/libs/zziplib/zziplib-0.13.62/zzip/plugin.h index 8282193440c..db563d2dcec 100644 --- a/Build/source/libs/zziplib/zziplib-0.13.62/zzip/plugin.h +++ b/Build/source/libs/zziplib/zziplib-0.13.62/zzip/plugin.h @@ -47,7 +47,11 @@ struct zzip_plugin_io { /* use "zzip_plugin_io_handlers" in applications !! */ zzip_ssize_t (*read)(int fd, void* buf, zzip_size_t len); zzip_off_t (*seeks)(int fd, zzip_off_t offset, int whence); zzip_off_t (*filesize)(int fd); +#ifdef _WIN64 + __int64 sys; +#else long sys; +#endif long type; zzip_ssize_t (*write)(int fd, _zzip_const void* buf, zzip_size_t len); }; |