* import patches to use dllimport/export instead of def file

* added version info
* add a modern DLL makefile
This commit is contained in:
Gabi Davar 2014-06-04 15:28:59 +03:00
parent faaacf5bed
commit 7ebc7596d4
6 changed files with 364 additions and 12 deletions

239
.gitignore vendored Normal file
View File

@ -0,0 +1,239 @@
# Created by http://www.gitignore.io
*.rb2
*.tst
### VisualStudio ###
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
build/
bld/
[Bb]in/
[Oo]bj/
# Roslyn cache directories
*.ide/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
#NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
*.manifest
*.res
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding addin-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
## TODO: Comment the next line if you want to checkin your
## web deploy settings but do note that will include unencrypted
## passwords
*.pubxml
# NuGet Packages Directory
packages/*
## TODO: If the tool you use requires repositories.config
## uncomment the next line
#!packages/repositories.config
# Enable "build/" folder in the NuGet Packages folder since
# NuGet packages use it for MSBuild targets.
# This line needs to be after the ignore of the build folder
# (and the packages folder if the line above has been uncommented)
!packages/build/
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
### C ###
# Object files
*.o
*.ko
*.obj
*.elf
# Libraries
*.lib
*.a
*.exp
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

View File

@ -128,7 +128,7 @@
#if BZ_LCCWIN32
# include <io.h>
# include <fcntl.h>
# include <sys\stat.h>
# include <sys/stat.h>
# define NORETURN /**/
# define PATH_SEP '\\'

View File

@ -309,7 +309,8 @@ Int32 main ( Int32 argc, Char** argv )
UInt32 buffHi, buffLo, blockCRC;
Char* p;
strcpy ( progName, argv[0] );
strncpy ( progName, argv[0], BZ_MAX_FILENAME-1);
progName[BZ_MAX_FILENAME-1]='\0';
inFileName[0] = outFileName[0] = 0;
fprintf ( stderr,

54
bzlib.h
View File

@ -81,18 +81,52 @@ typedef
/* windows.h define small to char */
# undef small
# endif
# ifdef BZ_EXPORT
# define BZ_API(func) WINAPI func
# define BZ_EXTERN extern
# else
/* import windows dll dynamically */
# define BZ_API(func) (WINAPI * func)
# define BZ_EXTERN
//# ifdef BZ_EXPORT
//# define BZ_API(func) WINAPI func
//# define BZ_EXTERN extern
//# else
// /* import windows dll dynamically */
//# define BZ_API(func) (WINAPI * func)
//# define BZ_EXTERN
//# endif
//#else
//# define BZ_API(func) func
//# define BZ_EXTERN extern
# include <stdio.h>
# include <io.h>
# include <sys/utime.h>
# define fdopen _fdopen
# define isatty _isatty
# define setmode _setmode
# define utime _utime
# endif
#else
# define BZ_API(func) func
# define BZ_EXTERN extern
#ifndef __GNUC__
# define __DLL_IMPORT__ __declspec(dllimport)
# define __DLL_EXPORT__ __declspec(dllexport)
# else
# define __DLL_IMPORT__ __attribute__((dllimport)) extern
# define __DLL_EXPORT__ __attribute__((dllexport)) extern
# endif
#if (defined __WIN32__) || (defined _WIN32)
# if defined BUILD_BZIP2_DLL || defined BZ_EXPORT
# define BZIP2_DLL_IMPEXP __DLL_EXPORT__
# elif defined(BZIP2_STATIC)
# define BZIP2_DLL_IMPEXP
# elif defined (USE_BZIP2_DLL) || defined BZ_IMPORT
# define BZIP2_DLL_IMPEXP __DLL_IMPORT__
# elif defined (USE_BZIP2_STATIC)
# define BZIP2_DLL_IMPEXP
# else /* assume USE_BZIP2_DLL */
# define BZIP2_DLL_IMPEXP __DLL_IMPORT__
#endif
#else /* __WIN32__ */
# define BZIP2_DLL_IMPEXP
#endif
#define BZ_API(func) func
#define BZ_EXTERN BZIP2_DLL_IMPEXP
/*-- Core (low-level) library functions --*/

BIN
libbz2.rc Normal file

Binary file not shown.

78
makefile.vc Normal file
View File

@ -0,0 +1,78 @@
# Makefile for Microsoft Visual C++ 2008+
# usage: nmake -f makefile.msc
# Gabi Davar (grizzly.nyo@gmail.com)
# Fixed up by JRS for bzip2-0.9.5d release.
#CC:=icl
#CFLAGS= -DWIN32 -MD -Ox -D_FILE_OFFSET_BITS=64 -nologo
#CFLAGS= -Qopenmp -Qmkl:parallel -nologo -MP -MD -Qvc9 -fp:precise -arch:SSSE3 -QaxAVX -O3 -D _CRT_SECURE_NO_WARNINGS -D WIN32 -D _UNICODE -D UNICODE -D __INTEL_COMPILER=1300
#CC=cl
CFLAGS= -nologo -MP -Z7 -DBUILD_BZIP2_DLL -DWIN32 -MD -Ox -D_FILE_OFFSET_BITS=64 -D_CRT_SECURE_NO_WARNINGS
EXECFLAGS= -nologo -MP -Z7 -MD -Ox -D_CRT_SECURE_NO_WARNINGS
RFLAGS= /nologo /d _UNICODE /d UNICODE /l"0x0409" /d ARCH=\"$(ARCH)\" /d MSVCVER=\"$(MSVCVER)\"
#COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
#INTEL_LIBS := mkl_intel_c_dll.lib mkl_intel_thread_dll.lib mkl_core_dll.lib libiomp5md.lib
INTEL_LIBS =
OBJS= blocksort.obj \
huffman.obj \
crctable.obj \
randtable.obj \
compress.obj \
decompress.obj \
bzlib.obj
DLLNAME = libbz2-vc$(MSVCVER)-mt-$(ARCH).dll
IMPLIB = libbz2.lib
all: libbz2-static.lib $(DLLNAME) bzip2.exe bzip2recover.exe test
bzip2.exe: libbz2-static.lib
$(CC) $(EXECFLAGS) /Fe$@ bzip2.c $**
bzip2recover.exe:
$(CC) $(EXECFLAGS) /Fe$@ bzip2recover.c
libbz2-static.lib: $(OBJS)
lib -nologo -out:$@ $(OBJS)
$(DLLNAME): $(OBJS) libbz2.res
link -NOLOGO -NXCOMPAT -IMPLIB:libbz2.lib -RELEASE -DLL $** $(INTEL_LIBS) -OUT:$@ -MANIFEST -MANIFESTFILE:"$@.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
mt.exe /nologo /verbose /outputresource:"$@;#2" /manifest $@.intermediate.manifest
test: bzip2.exe
type words1
bzip2 -1 < sample1.ref > sample1.rb2
bzip2 -2 < sample2.ref > sample2.rb2
bzip2 -3 < sample3.ref > sample3.rb2
bzip2 -d < sample1.bz2 > sample1.tst
bzip2 -d < sample2.bz2 > sample2.tst
bzip2 -ds < sample3.bz2 > sample3.tst
@echo All six of the fc's should find no differences.
@echo If fc finds an error on sample3.bz2, this could be
@echo because WinZip's 'TAR file smart CR/LF conversion'
@echo is too clever for its own good. Disable this option.
@echo The correct size for sample3.ref is 120,244. If it
@echo is 150,251, WinZip has messed it up.
fc sample1.bz2 sample1.rb2
fc sample2.bz2 sample2.rb2
fc sample3.bz2 sample3.rb2
fc sample1.tst sample1.ref
fc sample2.tst sample2.ref
fc sample3.tst sample3.ref
clean:
del *.obj
del *.dll
del *.lib
del *.exe
del sample1.rb2
del sample2.rb2
del sample3.rb2
del sample1.tst
del sample2.tst
del sample3.tst