From a5549b565393be1f529efd7e500dff225e67b33a Mon Sep 17 00:00:00 2001 From: Phillip Susi Date: Thu, 31 Jan 2002 20:26:25 +0000 Subject: [PATCH] Build unbzip2.sys as export driver, instead of unbzip2.dll svn path=/trunk/; revision=2587 --- reactos/drivers/lib/bzip2/Makefile | 11 +++++---- reactos/drivers/lib/bzip2/bzlib.c | 33 ++++++++++++++++++--------- reactos/drivers/lib/bzip2/bzlib.h | 1 + reactos/drivers/lib/bzip2/dllmain.c | 8 ++++++- reactos/drivers/lib/bzip2/unbzip2.def | 2 -- reactos/drivers/lib/bzip2/unbzip2.edf | 3 +-- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/reactos/drivers/lib/bzip2/Makefile b/reactos/drivers/lib/bzip2/Makefile index 33e85a7011a..764cf5d8334 100644 --- a/reactos/drivers/lib/bzip2/Makefile +++ b/reactos/drivers/lib/bzip2/Makefile @@ -1,17 +1,18 @@ PATH_TO_TOP = ../.. -TARGET_TYPE = dynlink +TARGET_TYPE = export_driver TARGET_NAME = unbzip2 TARGET_NORC = yes -TARGET_LFLAGS = -nostartfiles -ffreestanding -TARGET_CFLAGS=-Wall -Winline -Os -fomit-frame-pointer -fno-strength-reduce -DBZ_NO_STDIO -DBZ_DECOMPRESS_ONLY $(BIGFILES) +TARGET_CFLAGS=-Wall -Winline -Os -fomit-frame-pointer -fno-strength-reduce -DBZ_NO_STDIO -DBZ_DECOMPRESS_ONLY $(BIGFILES) -g TARGET_OBJECTS = bzlib.o randtable.o crctable.o decompress.o huffman.o dllmain.o +TARGET_GCCLIBS = gcc + include $(PATH_TO_TOP)/rules.mak include $(TOOLS_PATH)/helper.mk test.exe: test.o ../../dk/w32/lib/unbzip2.a - $(CC) -g -o test.exe test.o ../../dk/w32/lib/unbzip2.a + $(CC) -s -Os -o test.exe test.o ../../dk/w32/lib/unbzip2.a test.o: test.c - $(CC) -g -c test.c + $(CC) -s -Os -c test.c diff --git a/reactos/drivers/lib/bzip2/bzlib.c b/reactos/drivers/lib/bzip2/bzlib.c index 3e5c8d0d40a..e43de27683a 100644 --- a/reactos/drivers/lib/bzip2/bzlib.c +++ b/reactos/drivers/lib/bzip2/bzlib.c @@ -73,6 +73,12 @@ bzBuffToBuffDecompress. Fixed. --*/ +#ifdef BZ_DECOMPRESS_ONLY +#define __NTDRIVER__ +#include +#include +#endif + #include "bzlib_private.h" @@ -112,26 +118,19 @@ int bz_config_ok ( void ) return 1; } - -_stdcall void *(*BZ2_malloc)( unsigned long size ); -_stdcall void (*BZ2_free)( void *ptr ); - - /*---------------------------------------------------*/ static void* default_bzalloc ( void* opaque, Int32 items, Int32 size ) { - void* v = BZ2_malloc ( items * size ); - return v; + return ExAllocatePool( PagedPool, items * size ); } static void default_bzfree ( void* opaque, void* addr ) { - if (addr != NULL) BZ2_free ( addr ); + ExFreePool( addr ); } - #ifndef BZ_DECOMPRESS_ONLY /*---------------------------------------------------*/ @@ -550,6 +549,8 @@ int BZ_API(BZ2_bzDecompressInit) return BZ_OK; } +#ifndef BZ_DECOMPRESS_ONLY + /*---------------------------------------------------*/ static void unRLE_obuf_to_output_FAST ( DState* s ) @@ -691,6 +692,8 @@ void unRLE_obuf_to_output_FAST ( DState* s ) } } +#endif // BZ_DECOMPRESS_ONLY + /*---------------------------------------------------*/ __inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab ) { @@ -812,9 +815,13 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) while (True) { if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR; if (s->state == BZ_X_OUTPUT) { +#ifndef BZ_DECOMPRESS_ONLY if (s->smallDecompress) unRLE_obuf_to_output_SMALL ( s ); else unRLE_obuf_to_output_FAST ( s ); +#else + unRLE_obuf_to_output_SMALL ( s ); +#endif if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { BZ_FINALISE_CRC ( s->calculatedBlockCRC ); if (s->verbosity >= 3) @@ -1250,7 +1257,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress) { bz_stream strm; int ret; - + CHECKPOINT; if (dest == NULL || destLen == NULL || source == NULL || blockSize100k < 1 || blockSize100k > 9 || @@ -1262,10 +1269,11 @@ int BZ_API(BZ2_bzBuffToBuffCompress) strm.bzalloc = NULL; strm.bzfree = NULL; strm.opaque = NULL; + CHECKPOINT; ret = BZ2_bzCompressInit ( &strm, blockSize100k, verbosity, workFactor ); if (ret != BZ_OK) return ret; - + CHECKPOINT; strm.next_in = source; strm.next_out = dest; strm.avail_in = sourceLen; @@ -1277,14 +1285,17 @@ int BZ_API(BZ2_bzBuffToBuffCompress) /* normal termination */ *destLen -= strm.avail_out; + CHECKPOINT; BZ2_bzCompressEnd ( &strm ); return BZ_OK; output_overflow: + CHECKPOINT; BZ2_bzCompressEnd ( &strm ); return BZ_OUTBUFF_FULL; errhandler: + CHECKPOINT; BZ2_bzCompressEnd ( &strm ); return ret; } diff --git a/reactos/drivers/lib/bzip2/bzlib.h b/reactos/drivers/lib/bzip2/bzlib.h index 96350796ffc..41a155d3983 100644 --- a/reactos/drivers/lib/bzip2/bzlib.h +++ b/reactos/drivers/lib/bzip2/bzlib.h @@ -310,6 +310,7 @@ BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( extern _stdcall void *(*BZ2_malloc)( unsigned long size ); extern _stdcall void (*BZ2_free)( void *ptr ); +_stdcall void BZ2_set_malloc_free( _stdcall void *(*malloc)(unsigned long size), _stdcall void (*free)(void *ptr) ); #ifdef __cplusplus } diff --git a/reactos/drivers/lib/bzip2/dllmain.c b/reactos/drivers/lib/bzip2/dllmain.c index e0702326e19..99d048c9d41 100644 --- a/reactos/drivers/lib/bzip2/dllmain.c +++ b/reactos/drivers/lib/bzip2/dllmain.c @@ -1,9 +1,15 @@ +#ifdef BZ_DECOMPRESS_ONLY +int _stdcall DriverEntry( void *a, void *b ) +{ + return 1; +} +#else int _stdcall DllMain( unsigned long a, unsigned long b, unsigned long c ) { return 1; } - +#endif void bz_internal_error ( int errcode ) { return; diff --git a/reactos/drivers/lib/bzip2/unbzip2.def b/reactos/drivers/lib/bzip2/unbzip2.def index 64fc93f7af1..181a120518a 100644 --- a/reactos/drivers/lib/bzip2/unbzip2.def +++ b/reactos/drivers/lib/bzip2/unbzip2.def @@ -2,5 +2,3 @@ LIBRARY unbzip2.dll EXPORTS BZ2_bzBuffToBuffDecompress@24 -BZ2_malloc -BZ2_free diff --git a/reactos/drivers/lib/bzip2/unbzip2.edf b/reactos/drivers/lib/bzip2/unbzip2.edf index fd43af83c19..2eca816d1c1 100644 --- a/reactos/drivers/lib/bzip2/unbzip2.edf +++ b/reactos/drivers/lib/bzip2/unbzip2.edf @@ -2,5 +2,4 @@ LIBRARY unbzip2.dll EXPORTS BZ2_bzBuffToBuffDecompress=BZ2_bzBuffToBuffDecompress@24 -BZ2_malloc -BZ2_free +