1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

zlib: patches for mswin64

* cast to suppress C4267 warnings; no possible loss of data as
  following the comparison.

* shift base address to suppress LNK4281; although /DYNAMICBASE is
  preferable, not sure from which version of link.exe supports it.
This commit is contained in:
Nobuyoshi Nakada 2020-11-24 08:27:08 +09:00
parent 78c40e6588
commit 48d1e8682c
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
3 changed files with 101 additions and 1 deletions

View file

@ -31,9 +31,12 @@ else
$extso << dll
$cleanfiles << "$(topdir)/#{dll}" << "$(ZIMPLIB)"
zmk = "\t$(MAKE) -f $(ZMKFILE) TOP=$(ZSRC)"
zopts = []
if $nmake
zmkfile = "$(ZSRC)/win32/Makefile.msc"
m = "#{zsrc}/win32/Makefile.msc"
# zopts << "USE_ASM=1"
zopts << "ARCH=#{RbConfig::CONFIG['target_cpu']}"
else
zmkfile = "$(ZSRC)/win32/Makefile.gcc"
m = "#{zsrc}/win32/Makefile.gcc"
@ -55,9 +58,10 @@ else
addconf.push(
"ZMKFILE = #{zmkfile}\n",
"ZIMPLIB = #{zimplib}\n",
"ZOPTS = #{zopts.join(' ')}\n",
"$(TARGET_SO): $(ZIMPLIB)\n",
"$(ZIMPLIB):\n",
"#{zmk} $@\n",
"#{zmk} $(ZOPTS) $@\n",
"install-so: $(topdir)/#{dll}",
"$(topdir)/#{dll}: $(ZIMPLIB)\n",
"\t$(Q) $(COPY) #{dll} $(@D)\n",

View file

@ -5,3 +5,4 @@ https://zlib.net/$(pkg).tar.gz \
md5:1c9f62f0778697a09d36121ead88e08e \
sha512:73fd3fff4adeccd4894084c15ddac89890cd10ef105dd5e1835e1e9bbb6a49ff229713bd197d203edfa17c2727700fce65a2a235f07568212d820dca88b528ae \
#
win32/$(pkg)-mswin.patch -p0

View file

@ -0,0 +1,95 @@
diff -ru zlib-1.2.11/gzread.c zlib-1.2.11/gzread.c
--- zlib-1.2.11/gzread.c 2016-12-31 23:37:10.000000000 +0900
+++ zlib-1.2.11/gzread.c 2020-11-23 19:35:00.550987184 +0900
@@ -316,7 +316,7 @@
/* set n to the maximum amount of len that fits in an unsigned int */
n = -1;
if (n > len)
- n = len;
+ n = (unsigned)len;
/* first just try copying data from the output buffer */
if (state->x.have) {
@@ -397,7 +397,7 @@
}
/* read len or fewer bytes to buf */
- len = gz_read(state, buf, len);
+ len = (unsigned)gz_read(state, buf, len);
/* check for an error */
if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
@@ -469,7 +469,7 @@
}
/* nothing there -- try gz_read() */
- ret = gz_read(state, buf, 1);
+ ret = (int)gz_read(state, buf, 1);
return ret < 1 ? -1 : buf[0];
}
diff -ru zlib-1.2.11/gzwrite.c zlib-1.2.11/gzwrite.c
--- zlib-1.2.11/gzwrite.c 2017-01-15 09:29:40.000000000 +0900
+++ zlib-1.2.11/gzwrite.c 2020-11-23 19:35:41.530494030 +0900
@@ -209,7 +209,7 @@
state->in);
copy = state->size - have;
if (copy > len)
- copy = len;
+ copy = (unsigned)len;
memcpy(state->in + have, buf, copy);
state->strm.avail_in += copy;
state->x.pos += copy;
@@ -229,7 +229,7 @@
do {
unsigned n = (unsigned)-1;
if (n > len)
- n = len;
+ n = (unsigned)len;
state->strm.avail_in = n;
state->x.pos += n;
if (gz_comp(state, Z_NO_FLUSH) == -1)
@@ -368,7 +368,7 @@
/* write string */
len = strlen(str);
- ret = gz_write(state, str, len);
+ ret = (int)gz_write(state, str, len);
return ret == 0 && len != 0 ? -1 : ret;
}
diff -ru zlib-1.2.11/win32/Makefile.msc zlib-1.2.11/win32/Makefile.msc
--- zlib-1.2.11/win32/Makefile.msc 2017-01-15 09:07:08.000000000 +0900
+++ zlib-1.2.11/win32/Makefile.msc 2020-11-23 22:37:19.746500208 +0900
@@ -37,6 +37,22 @@
gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj
OBJA =
+!ifdef USE_ASM
+LOC = -DASMV -DASMINF
+!if "$(ARCH)" == "i386"
+OBJA = inffas32.obj match686.obj
+!else if "$(ARCH)" == "x64"
+AS = ml64
+LOC = $(LOC) -I.
+OBJA = inffasx64.obj gvmat64.obj inffas8664.obj
+!endif
+!endif
+
+!if "$(ARCH)" == "x64"
+ZBASE = 0x5A4C000000
+!else
+ZBASE = 0x5A4C0000
+!endif
# targets
all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \
@@ -49,7 +65,7 @@
$(SHAREDLIB): $(TOP)/win32/zlib.def $(OBJS) $(OBJA) zlib1.res
$(LD) $(LDFLAGS) -def:$(TOP)/win32/zlib.def -dll -implib:$(IMPLIB) \
- -out:$@ -base:0x5A4C0000 $(OBJS) $(OBJA) zlib1.res
+ -out:$@ -base:$(ZBASE) $(OBJS) $(OBJA) zlib1.res
if exist $@.manifest \
mt -nologo -manifest $@.manifest -outputresource:$@;2