From df99698aa15f6b0b5a83c860b2a36cb69bad6c6c Mon Sep 17 00:00:00 2001 From: "josh.macdonald" Date: Sat, 15 Dec 2007 00:36:21 +0000 Subject: Patches for mingw. --- xdelta3/Makefile.mingw | 303 +++++++++++++++++++++++++++++++++++++++++++++++++ xdelta3/xdelta3-main.h | 21 ++++ xdelta3/xdelta3.h | 28 ++++- 3 files changed, 347 insertions(+), 5 deletions(-) create mode 100644 xdelta3/Makefile.mingw diff --git a/xdelta3/Makefile.mingw b/xdelta3/Makefile.mingw new file mode 100644 index 0000000..b91c4e7 --- /dev/null +++ b/xdelta3/Makefile.mingw @@ -0,0 +1,303 @@ +# xdelta 3 - delta compression tools and library +# Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007. Joshua P. MacDonald + +UNAME = $(shell uname) +CYGWIN = $(findstring CYGWIN, $(UNAME)) +PYVER = 2.5 + +ifeq ("$(CYGWIN)", "") +SWIGTGT = xdelta3module.so +PYTGT = build/lib.linux-i686-$(PYVER)/xdelta3main.so +else +SWIGTGT = xdelta3module.dll +PYTGT = build/lib.cygwin-1.5.24-i686-$(PYVER)/xdelta3main.dll +endif + +SOURCES = xdelta3-cfgs.h \ + xdelta3-decode.h \ + xdelta3-djw.h \ + xdelta3-fgk.h \ + xdelta3-hash.h \ + xdelta3-list.h \ + xdelta3-main.h \ + xdelta3-python.h \ + xdelta3-second.h \ + xdelta3-test.h \ + xdelta3.c \ + xdelta3.h + +TARGETS = xdelta3-debug \ + xdelta3 \ + xdelta3-debug2 \ + xdelta3-debug3 \ + xdelta3.o \ + xdelta3_wrap.o \ + xdelta3-32 \ + xdelta3-64 \ + xdelta3-everything \ + xdelta3-Opg \ + xdelta3-64-O \ + xdelta3-Op \ + xdelta3-decoder xdelta3-decoder-nomain.o \ + xdelta3-nosec.o xdelta3-all.o xdelta3-fgk.o \ + xdelta3-noext xdelta3-tools \ + xdelta3-notools \ + xdelta3_wrap.c xdelta3.py \ + $(PYTGT) $(SWIGTGT) + +PYTHON = python + +WIXDIR = "/cygdrive/c/Program Files/wix2.0.4820" + +CFLAGS= -Wall -Wshadow -fno-builtin + +# $Format: "REL=$Xdelta3Version$" $ +REL=3.0t + +RELDIR = xdelta$(REL) + +EXTRA = Makefile COPYING linkxd3lib.c badcopy.c xdelta3.swig \ + draft-korn-vcdiff.txt xdelta3.vcproj badcopy.vcproj \ + xdelta3-regtest.py xdelta3-test.py setup.py \ + examples/Makefile examples/small_page_test.c \ + examples/README examples/encode_decode_test.c \ + examples/compare_test.c examples/speed_test.c \ + examples/test.h examples/checksum_test.cc \ + xdelta3.py xdelta3_wrap.c xdelta3.wxs xdelta3.wxi \ + README readme.txt + +SWIG_FLAGS = -DXD3_DEBUG=0 \ + -DEXTERNAL_COMPRESSION=0 \ + -DXD3_USE_LARGEFILE64=1 \ + -DGENERIC_ENCODE_TABLES=1 \ + -DSECONDARY_DJW=1 \ + -DVCDIFF_TOOLS=1 \ + -DSWIG_MODULE=1 + +all: xdelta3-debug xdelta3 + +all-py: all $(PYTGT) $(SWIGTGT) + +all-targets: $(TARGETS) + +all-targets-test: all-targets test + +pytgt: $(PYTGT) +swigtgt: $(SWIGTGT) + +test: + ./xdelta3-debug test + +tar: + tar --exclude ".svn" -czf /tmp/$(RELDIR)-tmp.tar.gz $(SOURCES) $(EXTRA) + rm -rf /tmp/$(RELDIR) + mkdir /tmp/$(RELDIR) + (cd /tmp/$(RELDIR) && tar -xzf ../$(RELDIR)-tmp.tar.gz) + tar -czf ./$(RELDIR).tar.gz -C /tmp $(RELDIR) + +tar -tzf ./$(RELDIR).tar.gz + rm -rf /tmp/$(RELDIR) + +zip: + tar --exclude ".svn" -czf /tmp/$(RELDIR)-tmp.tar.gz $(SOURCES) $(EXTRA) + rm -rf /tmp/$(RELDIR) + mkdir /tmp/$(RELDIR) + (cd /tmp/$(RELDIR) && tar -xzf ../$(RELDIR)-tmp.tar.gz) + tar -czf ./$(RELDIR).tar.gz -C /tmp $(RELDIR) + +zip -r $(RELDIR).zip /tmp/$(RELDIR) + rm -rf /tmp/$(RELDIR) + +clean: + rm -f $(TARGETS) + rm -rf build Debug Release core cifs* *.stackdump *.exe \ + xdelta3.ncb xdelta3.suo xdelta3.sln xdelta3.wixobj xdelta3.msi + +wix: xdelta3.wxs xdelta3.wxi readme.txt Release\xdelta3.exe + $(WIXDIR)/candle.exe xdelta3.wxs -out xdelta3.wixobj + $(WIXDIR)/light.exe xdelta3.wixobj -out xdelta3.msi + +xdelta3: $(SOURCES) + $(CC) $(CFLAGS) -O3 xdelta3.c -lm -o xdelta3 \ + -DGENERIC_ENCODE_TABLES=0 \ + -DREGRESSION_TEST=1 \ + -DEXTERNAL_COMPRESSION=0 \ + -DSECONDARY_DJW=1 \ + -DSECONDARY_FGK=1 \ + -DXD3_DEBUG=0 \ + -DXD3_MAIN=1 \ + -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 \ + -DXD3_USE_LARGEFILE64=1 + +xdelta3-debug: $(SOURCES) + $(CC) -g $(CFLAGS) xdelta3.c -lm -o xdelta3-debug \ + -DGENERIC_ENCODE_TABLES=1 \ + -DREGRESSION_TEST=1 \ + -DEXTERNAL_COMPRESSION=0 \ + -DSECONDARY_DJW=1 \ + -DSECONDARY_FGK=1 \ + -DXD3_DEBUG=1 \ + -DXD3_MAIN=1 \ + -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 \ + -DXD3_USE_LARGEFILE64=1 + +xdelta3-32: $(SOURCES) + $(CC) -O3 $(CFLAGS) xdelta3.c -lm -o xdelta3-32 \ + -DXD3_DEBUG=1 \ + -DXD3_USE_LARGEFILE64=0 \ + -DREGRESSION_TEST=1 \ + -DEXTERNAL_COMPRESSION=0 \ + -DSECONDARY_DJW=1 \ + -DSECONDARY_FGK=1 \ + -DXD3_MAIN=1 \ + -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 + +xdelta3-debug2: $(SOURCES) + $(CC) -g $(CFLAGS) \ + xdelta3.c -o xdelta3-debug2 \ + -DXD3_DEBUG=2 \ + -DXD3_MAIN=1 \ + -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 \ + -DXD3_USE_LARGEFILE64=1 \ + -DGENERIC_ENCODE_TABLES=1 \ + -DREGRESSION_TEST=1 \ + -DEXTERNAL_COMPRESSION=0 \ + -DSECONDARY_DJW=1 \ + -DSECONDARY_FGK=1 \ + -lm + +xdelta3-debug3: $(SOURCES) + $(CC) -g $(CFLAGS) xdelta3.c -o xdelta3-debug3 \ + -DXD3_MAIN=1 \ + -DGENERIC_ENCODE_TABLES=1 \ + -DXD3_USE_LARGEFILE64=1 \ + -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 \ + -DREGRESSION_TEST=1 \ + -DXD3_DEBUG=3 \ + -DEXTERNAL_COMPRESSION=0 \ + -DSECONDARY_DJW=1 \ + -DSECONDARY_FGK=1 \ + -lm + +$(PYTGT): $(SOURCES) setup.py + $(PYTHON) setup.py install --verbose --compile --force + +xdelta3_wrap.c xdelta3.py: xdelta3.swig + swig -python xdelta3.swig + +xdelta3.o: $(SOURCES) + $(CC) -O3 $(CFLAGS) -c xdelta3.c $(SWIG_FLAGS) -o xdelta3.o + +xdelta3_wrap.o: xdelta3_wrap.c + $(CC) -O3 $(CFLAGS) $(SWIG_FLAGS) \ + -DHAVE_CONFIG_H \ + -I/usr/include/python$(PYVER) \ + -I/usr/lib/python$(PYVER)/config \ + -fpic \ + -c xdelta3_wrap.c + +xdelta3module.dll: xdelta3_wrap.o xdelta3.o + gcc -shared -Wl,--enable-auto-image-base \ + xdelta3.o \ + xdelta3_wrap.o \ + -L/usr/lib/python$(PYVER)/config \ + -lpython$(PYVER) \ + -o xdelta3module.dll + cp $(SWIGTGT) /usr/lib/python$(PYVER)/site-packages + +xdelta3module.so: xdelta3_wrap.o xdelta3.o + ld -shared xdelta3.o xdelta3_wrap.o \ + -o xdelta3module.so \ + /usr/lib/libpython$(PYVER).so \ + -lc + +xdelta3-decoder: $(SOURCES) + $(CC) -O3 -Wall -Wshadow xdelta3.c \ + -DXD3_ENCODER=0 -DXD3_MAIN=1 -DSECONDARY_FGK=0 -DSECONDARY_DJW=0 \ + -DXD3_STDIO=0 -DXD3_POSIX=0 -DXD3_WIN32=1 -DEXTERNAL_COMPRESSION=0 -DVCDIFF_TOOLS=0 \ + -o xdelta3-decoder + +xdelta3-decoder-nomain.o: $(SOURCES) linkxd3lib.c + $(CC) -O3 -Wall -Wshadow xdelta3.c linkxd3lib.c \ + -DXD3_ENCODER=0 -DSECONDARY_FGK=0 -DSECONDARY_DJW=0 \ + -o xdelta3-decoder-nomain.o + strip xdelta3-decoder-nomain.o + +xdelta3-O++: $(SOURCES) + $(CXX) -g -O3 $(CFLAGS) xdelta3.c \ + -o xdelta3-O++ \ + -DXD3_MAIN=1 \ + -DSECONDARY_DJW=1 \ + -DREGRESSION_TEST=1 \ + -lm + +xdelta3-Op: $(SOURCES) + $(CC) -g -O3 $(CFLAGS) xdelta3.c \ + -o xdelta3-Op \ + -DXD3_POSIX=1 \ + -DXD3_MAIN=1 \ + -DREGRESSION_TEST=1 \ + -lm + +xdelta3-64: $(SOURCES) + $(CC) -g $(CFLAGS) \ + xdelta3.c \ + -o xdelta3-64 \ + -DXD3_POSIX=1 \ + -DXD3_MAIN=1 \ + -DREGRESSION_TEST=1 \ + -DXD3_DEBUG=0 \ + -DXD3_USE_LARGEFILE64=1 \ + -lm + +xdelta3-64-O: $(SOURCES) + $(CC) -O3 $(CFLAGS) \ + xdelta3.c \ + -o xdelta3-64-O \ + -DXD3_POSIX=1 \ + -DXD3_MAIN=1 \ + -DXD3_USE_LARGEFILE64=1 \ + -lm + +xdelta3-everything: $(SOURCES) + $(CC) -g $(CFLAGS) \ + xdelta3.c \ + -o xdelta3-everything \ + -DXD3_MAIN=1 \ + -DVCDIFF_TOOLS=1 \ + -DREGRESSION_TEST=1 \ + -DSECONDARY_FGK=1 \ + -DSECONDARY_DJW=1 \ + -DGENERIC_ENCODE_TABLES=1 \ + -DGENERIC_ENCODE_TABLES_COMPUTE=1 \ + -DXD3_POSIX=1 \ + -DEXTERNAL_COMPRESSION=1 \ + -DXD3_DEBUG=1 \ + -lm + +xdelta3-Opg: $(SOURCES) + $(CC) -pg -g -O3 $(CFLAGS) \ + xdelta3.c \ + -o xdelta3-Opg \ + -DXD3_MAIN=1 \ + -DSECONDARY_DJW=1 \ + -DSECONDARY_FGK=1 \ + -DXD3_POSIX=1 \ + -DXD3_USE_LARGEFILE64=1 \ + -DREGRESSION_TEST=1 + +xdelta3-nosec.o: $(SOURCES) + $(CC) -O3 $(CFLAGS) -c xdelta3.c -DSECONDARY_FGK=0 -DSECONDARY_DJW=0 -o xdelta3-nosec.o + +xdelta3-all.o: $(SOURCES) + $(CC) -O3 $(CFLAGS) -c xdelta3.c -DSECONDARY_FGK=1 -DSECONDARY_DJW=1 -o xdelta3-all.o + +xdelta3-fgk.o: $(SOURCES) + $(CC) -O3 $(CFLAGS) -c xdelta3.c -DSECONDARY_FGK=1 -DSECONDARY_DJW=0 -o xdelta3-fgk.o + +xdelta3-noext: $(SOURCES) + $(CC) -O3 $(CFLAGS) xdelta3.c -DXD3_MAIN=1 -DEXTERNAL_COMPRESSION=0 -o xdelta3-noext + +xdelta3-tools: $(SOURCES) + $(CC) -O3 $(CFLAGS) xdelta3.c -DXD3_MAIN=1 -o xdelta3-tools + +xdelta3-notools: $(SOURCES) + $(CC) -O3 $(CFLAGS) xdelta3.c -DXD3_MAIN=1 -DVCDIFF_TOOLS=0 -o xdelta3-notools diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index cfff0fc..d0f90fe 100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h @@ -106,7 +106,9 @@ const char* xd3_mainerror(int err_num); #include /* gettimeofday() */ #include /* stat() and fstat() */ #else +#if defined(_MSC_VER) #define strtoll _strtoi64 +#endif #include #include #ifndef WIFEXITED @@ -841,6 +843,7 @@ main_file_stat (main_file *xfile, xoff_t *size, int err_ifnoseek) { int ret = 0; #if XD3_WIN32 +# if (_WIN32_WINNT >= 0x0500) LARGE_INTEGER li; if (GetFileSizeEx(xfile->file, &li) == 0) { @@ -850,6 +853,16 @@ main_file_stat (main_file *xfile, xoff_t *size, int err_ifnoseek) { *size = li.QuadPart; } +# else + DWORD filesize = GetFileSize(xfile->file, NULL); + if (filesize == INVALID_FILE_SIZE) + { + ret = GetLastError(); + if (ret != NO_ERROR) + return ret; + } + *size = filesize; +# endif #else struct stat sbuf; if (fstat (XFNO (xfile), & sbuf) < 0) @@ -1024,11 +1037,19 @@ main_file_seek (main_file *xfile, xoff_t pos) { ret = get_errno (); } #elif XD3_WIN32 +# if (_WIN32_WINNT >= 0x0500) LARGE_INTEGER move, out; move.QuadPart = pos; if (SetFilePointerEx(xfile->file, move, &out, FILE_BEGIN) == 0) { ret = get_errno (); } +# else + if (SetFilePointer(xfile->file, (LONG)pos, NULL, FILE_BEGIN) == + INVALID_SET_FILE_POINTER) + { + ret = get_errno (); + } +# endif #endif if (ret) diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h index adc78c9..0cf6d6b 100644 --- a/xdelta3/xdelta3.h +++ b/xdelta3/xdelta3.h @@ -84,6 +84,10 @@ #define XD3_DEFAULT_SECONDARY_LEVEL 6 #endif +#ifndef XD3_USE_LARGEFILE64 +#define XD3_USE_LARGEFILE64 1 +#endif + /* Sizes and addresses within VCDIFF windows are represented as usize_t * * For source-file offsets and total file sizes, total input and @@ -96,19 +100,33 @@ typedef unsigned int usize_t; #else #define WIN32_LEAN_AND_MEAN +#if XD3_USE_LARGEFILE64 +/* 64 bit file offsets: uses GetFileSizeEx and + * SetFilePointerEx. requires WinME, or Win2000 + * and or newer version of WinNT */ +#define WINVER 0x0500 +#define _WIN32_WINNT 0x0500 +#else +/* 32 bit (DWORD) file offsets: uses GetFileSize + * and SetFilePointer. compatible with win95-98 + * and WinNT4 */ +#define WINVER 0x0400 +#define _WIN32_WINNT 0x0400 +#endif #include +typedef unsigned int usize_t; +#ifdef _MSC_VER #define inline -typedef unsigned int uint; typedef signed int ssize_t; -typedef unsigned int usize_t; typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned long uint32_t; typedef ULONGLONG uint64_t; +#else +/* mingw32, lcc and watcom + * provide a proper header */ +#include #endif - -#ifndef XD3_USE_LARGEFILE64 -#define XD3_USE_LARGEFILE64 1 #endif /* TODO: note that SIZEOF_USIZE_T is never set to 8, although it should be for -- cgit v1.2.3