summaryrefslogtreecommitdiff
path: root/Build/source/libs/zziplib
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2014-07-14 10:04:07 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2014-07-14 10:04:07 +0000
commit4f919c611cf0d93c4e4a9234e5d3eca1883343bc (patch)
tree9df54b112a0306759b75bb0b3b97a7a87dbcdfd9 /Build/source/libs/zziplib
parent2d1ceac8dad55545f652aa69af318f5e262b7d71 (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')
-rw-r--r--Build/source/libs/zziplib/ChangeLog4
-rwxr-xr-xBuild/source/libs/zziplib/configure7
-rw-r--r--Build/source/libs/zziplib/configure.ac5
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.62-PATCHES/ChangeLog4
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.62-PATCHES/patch-02-bugfix107
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.62/zzip/__mmap.h25
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.62/zzip/mmapped.h4
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.62/zzip/plugin.c2
-rw-r--r--Build/source/libs/zziplib/zziplib-0.13.62/zzip/plugin.h4
9 files changed, 147 insertions, 15 deletions
diff --git a/Build/source/libs/zziplib/ChangeLog b/Build/source/libs/zziplib/ChangeLog
index c64a7e39bb8..995e618e337 100644
--- a/Build/source/libs/zziplib/ChangeLog
+++ b/Build/source/libs/zziplib/ChangeLog
@@ -1,3 +1,7 @@
+2014-07-11 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * configure.ac: Reenable mmap for 32- and 64-bit Windows.
+
2014-07-10 Peter Breitenlohner <peb@mppmu.mpg.de>
* configure.ac: Bug fix for MinGW: do not use mmap.
diff --git a/Build/source/libs/zziplib/configure b/Build/source/libs/zziplib/configure
index bd3f30e5a2a..83933ff36ea 100755
--- a/Build/source/libs/zziplib/configure
+++ b/Build/source/libs/zziplib/configure
@@ -5728,18 +5728,13 @@ done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether can use mmap for file scanning" >&5
$as_echo_n "checking whether can use mmap for file scanning... " >&6; }
enable_mmap='no (just a bit slower)'
-case $host_os in #(
- mingw*) :
- ;; #(
- *) :
- test "x$ac_cv_header_winbase_h" = xyes && enable_mmap="yes, winbase.h"
+test "x$ac_cv_header_winbase_h" = xyes && enable_mmap="yes, winbase.h"
test "x$ac_cv_header_sys_mman_h" = xyes && enable_mmap="yes, sys/mman.h"
case $enable_mmap in #(
yes*) :
ZZIPLIB_DEFINES='-D_USE_MMAP' ;; #(
*) :
;;
-esac ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_mmap" >&5
$as_echo "$enable_mmap" >&6; }
diff --git a/Build/source/libs/zziplib/configure.ac b/Build/source/libs/zziplib/configure.ac
index 52cebfedd7d..b6c13707c3f 100644
--- a/Build/source/libs/zziplib/configure.ac
+++ b/Build/source/libs/zziplib/configure.ac
@@ -37,13 +37,10 @@ AC_CHECK_HEADERS([fnmatch.h])
# ---------------------------------------------------------------
AC_MSG_CHECKING([whether can use mmap for file scanning])
enable_mmap='no (just a bit slower)'
-AS_CASE([$host_os],
- [mingw*], [],
- [dnl
test "x$ac_cv_header_winbase_h" = xyes && enable_mmap="yes, winbase.h"
test "x$ac_cv_header_sys_mman_h" = xyes && enable_mmap="yes, sys/mman.h"
AS_CASE([$enable_mmap],
- [yes*], [ZZIPLIB_DEFINES='-D_USE_MMAP'])])
+ [yes*], [ZZIPLIB_DEFINES='-D_USE_MMAP'])
AC_MSG_RESULT([$enable_mmap])
AC_SUBST([ZZIPLIB_DEFINES])
diff --git a/Build/source/libs/zziplib/zziplib-0.13.62-PATCHES/ChangeLog b/Build/source/libs/zziplib/zziplib-0.13.62-PATCHES/ChangeLog
index 3526fac6463..72ad27ac1a0 100644
--- a/Build/source/libs/zziplib/zziplib-0.13.62-PATCHES/ChangeLog
+++ b/Build/source/libs/zziplib/zziplib-0.13.62-PATCHES/ChangeLog
@@ -1,3 +1,7 @@
+2014-07-14 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * patch-02-bugfix (new): Fix mmap for WIN32/WIN64, from Akira.
+
2014-07-11 Peter Breitenlohner <peb@mppmu.mpg.de>
* patch-01-binary (new): Do not convert NL => CRLF (required
diff --git a/Build/source/libs/zziplib/zziplib-0.13.62-PATCHES/patch-02-bugfix b/Build/source/libs/zziplib/zziplib-0.13.62-PATCHES/patch-02-bugfix
new file mode 100644
index 00000000000..5885b3c7f5f
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-0.13.62-PATCHES/patch-02-bugfix
@@ -0,0 +1,107 @@
+diff -ur zziplib-0.13.62.orig/zzip/__mmap.h zziplib-0.13.62/zzip/__mmap.h
+--- zziplib-0.13.62.orig/zzip/__mmap.h 2009-08-23 13:38:22.000000000 +0200
++++ zziplib-0.13.62/zzip/__mmap.h 2014-07-14 11:27:20.000000000 +0200
+@@ -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 @@
+ 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 -ur zziplib-0.13.62.orig/zzip/mmapped.h zziplib-0.13.62/zzip/mmapped.h
+--- zziplib-0.13.62.orig/zzip/mmapped.h 2009-08-23 13:38:22.000000000 +0200
++++ zziplib-0.13.62/zzip/mmapped.h 2014-07-14 11:25:47.000000000 +0200
+@@ -42,7 +42,11 @@
+ 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 -ur zziplib-0.13.62.orig/zzip/plugin.c zziplib-0.13.62/zzip/plugin.c
+--- zziplib-0.13.62.orig/zzip/plugin.c 2010-12-27 02:14:27.000000000 +0100
++++ zziplib-0.13.62/zzip/plugin.c 2014-07-14 11:23:23.000000000 +0200
+@@ -43,7 +43,7 @@
+ return st.st_size;
+ }
+
+-static const struct zzip_plugin_io default_io = {
++static struct zzip_plugin_io default_io = {
+ &open,
+ &close,
+ &_zzip_read,
+diff -ur zziplib-0.13.62.orig/zzip/plugin.h zziplib-0.13.62/zzip/plugin.h
+--- zziplib-0.13.62.orig/zzip/plugin.h 2010-12-27 02:12:54.000000000 +0100
++++ zziplib-0.13.62/zzip/plugin.h 2014-07-14 11:23:23.000000000 +0200
+@@ -47,7 +47,11 @@
+ 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);
+ };
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);
};