Build unbzip2.sys as export driver, instead of unbzip2.dll

svn path=/trunk/; revision=2587
This commit is contained in:
Phillip Susi 2002-01-31 20:26:25 +00:00
parent f17ca2d3d9
commit a5549b5653
6 changed files with 37 additions and 21 deletions

View file

@ -1,17 +1,18 @@
PATH_TO_TOP = ../.. PATH_TO_TOP = ../..
TARGET_TYPE = dynlink TARGET_TYPE = export_driver
TARGET_NAME = unbzip2 TARGET_NAME = unbzip2
TARGET_NORC = yes 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_OBJECTS = bzlib.o randtable.o crctable.o decompress.o huffman.o dllmain.o
TARGET_GCCLIBS = gcc
include $(PATH_TO_TOP)/rules.mak include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk include $(TOOLS_PATH)/helper.mk
test.exe: test.o ../../dk/w32/lib/unbzip2.a 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 test.o: test.c
$(CC) -g -c test.c $(CC) -s -Os -c test.c

View file

@ -73,6 +73,12 @@
bzBuffToBuffDecompress. Fixed. bzBuffToBuffDecompress. Fixed.
--*/ --*/
#ifdef BZ_DECOMPRESS_ONLY
#define __NTDRIVER__
#include <ntddk.h>
#include <debug.h>
#endif
#include "bzlib_private.h" #include "bzlib_private.h"
@ -112,26 +118,19 @@ int bz_config_ok ( void )
return 1; return 1;
} }
_stdcall void *(*BZ2_malloc)( unsigned long size );
_stdcall void (*BZ2_free)( void *ptr );
/*---------------------------------------------------*/ /*---------------------------------------------------*/
static static
void* default_bzalloc ( void* opaque, Int32 items, Int32 size ) void* default_bzalloc ( void* opaque, Int32 items, Int32 size )
{ {
void* v = BZ2_malloc ( items * size ); return ExAllocatePool( PagedPool, items * size );
return v;
} }
static static
void default_bzfree ( void* opaque, void* addr ) void default_bzfree ( void* opaque, void* addr )
{ {
if (addr != NULL) BZ2_free ( addr ); ExFreePool( addr );
} }
#ifndef BZ_DECOMPRESS_ONLY #ifndef BZ_DECOMPRESS_ONLY
/*---------------------------------------------------*/ /*---------------------------------------------------*/
@ -550,6 +549,8 @@ int BZ_API(BZ2_bzDecompressInit)
return BZ_OK; return BZ_OK;
} }
#ifndef BZ_DECOMPRESS_ONLY
/*---------------------------------------------------*/ /*---------------------------------------------------*/
static static
void unRLE_obuf_to_output_FAST ( DState* s ) 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 ) __inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
{ {
@ -812,9 +815,13 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
while (True) { while (True) {
if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR; if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR;
if (s->state == BZ_X_OUTPUT) { if (s->state == BZ_X_OUTPUT) {
#ifndef BZ_DECOMPRESS_ONLY
if (s->smallDecompress) if (s->smallDecompress)
unRLE_obuf_to_output_SMALL ( s ); else unRLE_obuf_to_output_SMALL ( s ); else
unRLE_obuf_to_output_FAST ( s ); 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) { if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
BZ_FINALISE_CRC ( s->calculatedBlockCRC ); BZ_FINALISE_CRC ( s->calculatedBlockCRC );
if (s->verbosity >= 3) if (s->verbosity >= 3)
@ -1250,7 +1257,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress)
{ {
bz_stream strm; bz_stream strm;
int ret; int ret;
CHECKPOINT;
if (dest == NULL || destLen == NULL || if (dest == NULL || destLen == NULL ||
source == NULL || source == NULL ||
blockSize100k < 1 || blockSize100k > 9 || blockSize100k < 1 || blockSize100k > 9 ||
@ -1262,10 +1269,11 @@ int BZ_API(BZ2_bzBuffToBuffCompress)
strm.bzalloc = NULL; strm.bzalloc = NULL;
strm.bzfree = NULL; strm.bzfree = NULL;
strm.opaque = NULL; strm.opaque = NULL;
CHECKPOINT;
ret = BZ2_bzCompressInit ( &strm, blockSize100k, ret = BZ2_bzCompressInit ( &strm, blockSize100k,
verbosity, workFactor ); verbosity, workFactor );
if (ret != BZ_OK) return ret; if (ret != BZ_OK) return ret;
CHECKPOINT;
strm.next_in = source; strm.next_in = source;
strm.next_out = dest; strm.next_out = dest;
strm.avail_in = sourceLen; strm.avail_in = sourceLen;
@ -1277,14 +1285,17 @@ int BZ_API(BZ2_bzBuffToBuffCompress)
/* normal termination */ /* normal termination */
*destLen -= strm.avail_out; *destLen -= strm.avail_out;
CHECKPOINT;
BZ2_bzCompressEnd ( &strm ); BZ2_bzCompressEnd ( &strm );
return BZ_OK; return BZ_OK;
output_overflow: output_overflow:
CHECKPOINT;
BZ2_bzCompressEnd ( &strm ); BZ2_bzCompressEnd ( &strm );
return BZ_OUTBUFF_FULL; return BZ_OUTBUFF_FULL;
errhandler: errhandler:
CHECKPOINT;
BZ2_bzCompressEnd ( &strm ); BZ2_bzCompressEnd ( &strm );
return ret; return ret;
} }

View file

@ -310,6 +310,7 @@ BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
extern _stdcall void *(*BZ2_malloc)( unsigned long size ); extern _stdcall void *(*BZ2_malloc)( unsigned long size );
extern _stdcall void (*BZ2_free)( void *ptr ); 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 #ifdef __cplusplus
} }

View file

@ -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 ) int _stdcall DllMain( unsigned long a, unsigned long b, unsigned long c )
{ {
return 1; return 1;
} }
#endif
void bz_internal_error ( int errcode ) void bz_internal_error ( int errcode )
{ {
return; return;

View file

@ -2,5 +2,3 @@ LIBRARY unbzip2.dll
EXPORTS EXPORTS
BZ2_bzBuffToBuffDecompress@24 BZ2_bzBuffToBuffDecompress@24
BZ2_malloc
BZ2_free

View file

@ -2,5 +2,4 @@ LIBRARY unbzip2.dll
EXPORTS EXPORTS
BZ2_bzBuffToBuffDecompress=BZ2_bzBuffToBuffDecompress@24 BZ2_bzBuffToBuffDecompress=BZ2_bzBuffToBuffDecompress@24
BZ2_malloc
BZ2_free