From 78022577001deadb3f32f00b74c69a75cfd2f7bd Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Mon, 11 Nov 2002 23:46:33 +0000 Subject: [PATCH] Portability fixes. committer: mfx 1037058393 +0000 --- src/Makefile | 13 ++++++++----- src/filter/sub.hh | 6 +++--- src/p_exe.cpp | 4 ++-- src/p_lx_elf.cpp | 6 +++--- src/p_lx_exc.cpp | 6 +++--- src/p_tmt.cpp | 4 ++-- src/p_unix.cpp | 8 ++++---- src/stdcxx.h | 1 + 8 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/Makefile b/src/Makefile index 870081fa..95c35271 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,7 +8,7 @@ # `make target=mingw32' # win32 - mingw32 # `make target=no-cygwin' # win32 - mingw32 as included in cygwin 1.3.x # `make target=bcc' # win32 - Borland C++ 5.5.1 -# `make target=dmc' # win32 - Digital Mars C++ 8.28 +# `make target=dmc' # win32 - Digital Mars C++ 8.30 # `make target=vc6' # win32 - Visual C++ 6.0 # `make target=wcc' # win32 - Watcom C++ 11.0c # `make target=cross-m68k-linux' # m68k-linux cross compiler @@ -314,6 +314,7 @@ endif # djgpp2 ifeq ($(target),cygwin) e = .exe CC += -march=i386 -mcpu=i586 +CXXLD = g++ ##CFLAGS_M += -mno-schedule-prologue endif @@ -321,6 +322,7 @@ ifeq ($(target),mingw32) e = .exe CC = gcc -mno-cygwin CC += -march=i386 -mcpu=i586 +CXXLD = g++ -mno-cygwin ##CFLAGS_M += -mno-schedule-prologue endif @@ -329,6 +331,7 @@ ifeq ($(target),no-cygwin) e = .exe CC = gcc -mno-cygwin CC += -march=i386 -mcpu=i586 +CXXLD = g++ -mno-cygwin ##CFLAGS_M += -mno-schedule-prologue endif @@ -356,7 +359,7 @@ CXXFLAGS1 = $(CFLAGS) CXXFLAGS2 = $(CFLAGS) -x- -xd- -RT- CFLAGS_OUTPUT = -o$@ LDFLAGS = -LDLIBS = $(DOS_LDLIBS) +LDLIBS = $(DOS_LDLIBS) zlib114.lib ifneq ($(strip $(DOS_LIBDIRS)),) LIB := $(DOS_LIBDIRS);$(LIB) @@ -375,14 +378,14 @@ endif # bcc ### -### Digital Mars C++ 8.28 +### Digital Mars C++ 8.30 ### ifeq ($(target),dmc) o = .obj a = .lib e = .exe -CC = sc -mn +CC = dmc -mn CFLAGS = -w- -wx CXXFLAGS1 = $(CFLAGS) -Aa -Ab -Ae -Ar CXXFLAGS2 = $(CFLAGS) -Aa -Ab @@ -433,7 +436,7 @@ ifeq (1,2) else # link against msvcrt.dll CC += -MD - LDLIBS = $(DOS_LDLIBS) setargv.obj + LDLIBS = $(DOS_LDLIBS) zlib114.lib setargv.obj endif ifeq ($(DEBUG),1) CFLAGS += -Od -ZI diff --git a/src/filter/sub.hh b/src/filter/sub.hh index 6cba3bd1..a8825ff0 100644 --- a/src/filter/sub.hh +++ b/src/filter/sub.hh @@ -41,9 +41,9 @@ \ i = N - 1; \ do { \ - T delta = get(b) - d[i]; \ + T delta = (T) (get(b) - d[i]); \ set(b, delta); \ - d[i] += delta; \ + d[i] = (T) (d[i] + delta); \ b += sizeof(T); \ if (--i < 0) \ i = N - 1; \ @@ -63,7 +63,7 @@ \ i = N - 1; \ do { \ - d[i] += get(b); \ + d[i] = (T) (d[i] + get(b)); \ set(b, d[i]); \ b += sizeof(T); \ if (--i < 0) \ diff --git a/src/p_exe.cpp b/src/p_exe.cpp index 8217599c..6d1149ce 100644 --- a/src/p_exe.cpp +++ b/src/p_exe.cpp @@ -657,7 +657,7 @@ void PackExe::unpack(OutputFile *fo) set_le32(wrkmem+4*relocn++,0); } - unsigned outputlen = sizeof(oh)+relocn*4+relocs-obuf; + unsigned outputlen = ptr_diff(relocs, obuf) + sizeof(oh) + relocn*4; oh.m512 = outputlen & 511; oh.p512 = (outputlen + 511) >> 9; oh.headsize16 = 2+relocn/4; @@ -689,7 +689,7 @@ void PackExe::unpack(OutputFile *fo) fo->write(&oh,sizeof(oh)); if (relocn) fo->write(wrkmem,relocn*4); - fo->write(obuf,relocs-obuf); + fo->write(obuf, ptr_diff(relocs, obuf)); // copy the overlay copyOverlay(fo, ih_overlay, &obuf); diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 64e07a19..7f7a1319 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -217,9 +217,9 @@ void PackLinuxI386elf::packExtent( set_native32(&tmp.sz_unc, ph.u_len); set_native32(&tmp.sz_cpr, ph.c_len); if (ph.c_len < ph.u_len) { - tmp.b_method = ph.method; + tmp.b_method = (unsigned char) ph.method; if (ft) { - tmp.b_ftid = ft->id; + tmp.b_ftid = (unsigned char) ft->id; tmp.b_cto8 = ft->cto; } } @@ -381,7 +381,7 @@ void PackLinuxI386elf::unpackExtent(unsigned wanted, OutputFile *fo, else if (ph.filter) { Filter ft(ph.level); ft.init(ph.filter, 0); - ft.cto = ph.filter_cto; + ft.cto = (unsigned char) ph.filter_cto; ft.unfilter(ibuf, sz_unc); } } diff --git a/src/p_lx_exc.cpp b/src/p_lx_exc.cpp index cb130f4b..a5156fe7 100644 --- a/src/p_lx_exc.cpp +++ b/src/p_lx_exc.cpp @@ -186,9 +186,9 @@ PackLinuxI386::buildLinuxLoader( hf->ehdr.e_phentsize * hf->ehdr.e_phnum + sizeof(l_info) ); struct b_info h; memset(&h, 0, sizeof(h)); h.sz_unc = szfold - fold_hdrlen; - h.b_method = ph.method; - h.b_ftid = ph.filter; - h.b_cto8 = ph.filter_cto; + h.b_method = (unsigned char) ph.method; + h.b_ftid = (unsigned char) ph.filter; + h.b_cto8 = (unsigned char) ph.filter_cto; unsigned char const *const uncLoader = fold_hdrlen + fold; unsigned char *const cprLoader = new unsigned char[sizeof(h) + h.sz_unc]; diff --git a/src/p_tmt.cpp b/src/p_tmt.cpp index 9dd4cf20..a1770cf3 100644 --- a/src/p_tmt.cpp +++ b/src/p_tmt.cpp @@ -211,7 +211,7 @@ void PackTmt::pack(OutputFile *fo) { for (unsigned ic=4; ic<=rsize; ic+=4) set_le32(wrkmem+ic,get_le32(wrkmem+ic)-4); - relocsize = optimizeReloc32(wrkmem+4,rsize/4,wrkmem,ibuf,1,&big_relocs)- wrkmem; + relocsize = ptr_diff(optimizeReloc32(wrkmem+4,rsize/4,wrkmem,ibuf,1,&big_relocs), wrkmem); } wrkmem[relocsize++] = 0; @@ -311,7 +311,7 @@ void PackTmt::unpack(OutputFile *fo) Filter ft(ph.level); ft.init(ph.filter, 0); ft.cto = (unsigned char) (ph.version < 11 ? (get_le32(obuf+ph.u_len-12) >> 24) : ph.filter_cto); - ft.unfilter(obuf, relocs-obuf); + ft.unfilter(obuf, ptr_diff(relocs, obuf)); } // decode relocations diff --git a/src/p_unix.cpp b/src/p_unix.cpp index 39fe70fc..857bc63b 100644 --- a/src/p_unix.cpp +++ b/src/p_unix.cpp @@ -115,7 +115,7 @@ bool PackUnix::checkCompressionRatio(unsigned, unsigned) const return true; } -void PackUnix::pack1(OutputFile */*fo*/, Filter &/*ft*/) +void PackUnix::pack1(OutputFile * /*fo*/, Filter & /*ft*/) { // derived class usually provides this } @@ -193,9 +193,9 @@ void PackUnix::pack2(OutputFile *fo, Filter &ft) set_native32(&blk_info.sz_unc, ph.u_len); set_native32(&blk_info.sz_cpr, ph.c_len); if (ph.c_len < ph.u_len) { - blk_info.b_method = ph.method; - blk_info.b_ftid = ph.filter; - blk_info.b_cto8 = ph.filter_cto; + blk_info.b_method = (unsigned char) ph.method; + blk_info.b_ftid = (unsigned char) ph.filter; + blk_info.b_cto8 = (unsigned char) ph.filter_cto; } fo->write(&blk_info, sizeof(blk_info)); b_len += sizeof(b_info); diff --git a/src/stdcxx.h b/src/stdcxx.h index 44325fcd..a955bd19 100644 --- a/src/stdcxx.h +++ b/src/stdcxx.h @@ -45,6 +45,7 @@ #include namespace std { +#undef type_info typedef ::Type_info type_info; class exception {