1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
diff -ur zziplib-0.13.68.orig/zzip/__fnmatch.h zziplib-0.13.68/zzip/__fnmatch.h
--- zziplib-0.13.68.orig/zzip/__fnmatch.h Tue Feb 06 05:00:56 2018
+++ zziplib-0.13.68/zzip/__fnmatch.h Tue Feb 06 10:35:33 2018
@@ -20,13 +20,7 @@
#else
# define _zzip_FNM_CASEFOLD 0
/* if your system does not have fnmatch, we fall back to strcmp: */
-static int _zzip_fnmatch(char* pattern, char* string, int flags)
-{
-# ifdef DBG2
- DBG1("<zzip:mmapped:strcmp>");
-# endif
- return strcmp (pattern, string);
-}
+#define _zzip_fnmatch(x,y,z) strcmp ((x),(y))
#endif
#endif
diff -ur zziplib-0.13.68.orig/zzip/__mmap.h zziplib-0.13.68/zzip/__mmap.h
--- zziplib-0.13.68.orig/zzip/__mmap.h Tue Feb 06 05:00:56 2018
+++ zziplib-0.13.68/zzip/__mmap.h Tue Feb 06 08:37:50 2018
@@ -45,43 +45,61 @@
#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;
p = MapViewOfFile(*(HANDLE*)user, FILE_MAP_READ, 0, offs, len);
- if (p) return p + offs;
+ if (p) return p;
CloseHandle (*(HANDLE*)user); *user = 1;
}
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.68.orig/zzip/mmapped.h zziplib-0.13.68/zzip/mmapped.h
--- zziplib-0.13.68.orig/zzip/mmapped.h Tue Feb 06 05:00:56 2018
+++ zziplib-0.13.68/zzip/mmapped.h Tue Feb 06 08:39:00 2018
@@ -37,7 +37,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.68.orig/zzip/plugin.c zziplib-0.13.68/zzip/plugin.c
--- zziplib-0.13.68.orig/zzip/plugin.c Tue Feb 06 05:00:56 2018
+++ zziplib-0.13.68/zzip/plugin.c Tue Feb 06 08:40:30 2018
@@ -38,7 +38,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.68.orig/zzip/plugin.h zziplib-0.13.68/zzip/plugin.h
--- zziplib-0.13.68.orig/zzip/plugin.h Tue Feb 06 05:00:56 2018
+++ zziplib-0.13.68/zzip/plugin.h Tue Feb 06 08:41:43 2018
@@ -42,7 +42,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);
};
|