* Fix last commit

This commit is contained in:
Phillip Stephens 2015-05-20 22:41:29 -07:00
commit 6a611ef2cc
166 changed files with 11744 additions and 7790 deletions

View File

@ -51,14 +51,14 @@ extern "C" {
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1_compress ( const lzo_bytep src, lzo_uint src_len, lzo1_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1_decompress ( const lzo_bytep src, lzo_uint src_len, lzo1_decompress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/*********************************************************************** /***********************************************************************
@ -68,9 +68,9 @@ lzo1_decompress ( const lzo_bytep src, lzo_uint src_len,
#define LZO1_99_MEM_COMPRESS ((lzo_uint32_t) (65536L * lzo_sizeof_dict_t)) #define LZO1_99_MEM_COMPRESS ((lzo_uint32_t) (65536L * lzo_sizeof_dict_t))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1_99_compress ( const lzo_bytep src, lzo_uint src_len, lzo1_99_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);

View File

@ -51,14 +51,14 @@ extern "C" {
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1a_compress ( const lzo_bytep src, lzo_uint src_len, lzo1a_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1a_decompress ( const lzo_bytep src, lzo_uint src_len, lzo1a_decompress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/*********************************************************************** /***********************************************************************
@ -68,9 +68,9 @@ lzo1a_decompress ( const lzo_bytep src, lzo_uint src_len,
#define LZO1A_99_MEM_COMPRESS ((lzo_uint32_t) (65536L * lzo_sizeof_dict_t)) #define LZO1A_99_MEM_COMPRESS ((lzo_uint32_t) (65536L * lzo_sizeof_dict_t))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1a_99_compress ( const lzo_bytep src, lzo_uint src_len, lzo1a_99_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);

View File

@ -57,22 +57,22 @@ extern "C" {
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
int compression_level ); int compression_level);
/* decompression */ /* decompression */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_decompress ( const lzo_bytep src, lzo_uint src_len, lzo1b_decompress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/* safe decompression with overrun testing */ /* safe decompression with overrun testing */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_decompress_safe ( const lzo_bytep src, lzo_uint src_len, lzo1b_decompress_safe(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/*********************************************************************** /***********************************************************************
@ -80,41 +80,41 @@ lzo1b_decompress_safe ( const lzo_bytep src, lzo_uint src_len,
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_1_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_1_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_2_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_2_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_3_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_3_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_4_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_4_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_5_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_5_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_6_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_6_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_7_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_7_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_8_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_8_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_9_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_9_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
/*********************************************************************** /***********************************************************************
@ -124,17 +124,17 @@ lzo1b_9_compress ( const lzo_bytep src, lzo_uint src_len,
#define LZO1B_99_MEM_COMPRESS ((lzo_uint32_t) (65536L * lzo_sizeof_dict_t)) #define LZO1B_99_MEM_COMPRESS ((lzo_uint32_t) (65536L * lzo_sizeof_dict_t))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_99_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_99_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
#define LZO1B_999_MEM_COMPRESS ((lzo_uint32_t) (3 * 65536L * sizeof(lzo_xint))) #define LZO1B_999_MEM_COMPRESS ((lzo_uint32_t) (3 * 65536L * sizeof(lzo_xint)))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_999_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_999_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);

View File

@ -57,22 +57,22 @@ extern "C" {
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
int compression_level ); int compression_level);
/* decompression */ /* decompression */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_decompress ( const lzo_bytep src, lzo_uint src_len, lzo1c_decompress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/* safe decompression with overrun testing */ /* safe decompression with overrun testing */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_decompress_safe ( const lzo_bytep src, lzo_uint src_len, lzo1c_decompress_safe(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/*********************************************************************** /***********************************************************************
@ -80,41 +80,41 @@ lzo1c_decompress_safe ( const lzo_bytep src, lzo_uint src_len,
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_1_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_1_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_2_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_2_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_3_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_3_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_4_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_4_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_5_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_5_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_6_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_6_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_7_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_7_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_8_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_8_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_9_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_9_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
/*********************************************************************** /***********************************************************************
@ -124,17 +124,17 @@ lzo1c_9_compress ( const lzo_bytep src, lzo_uint src_len,
#define LZO1C_99_MEM_COMPRESS ((lzo_uint32_t) (65536L * lzo_sizeof_dict_t)) #define LZO1C_99_MEM_COMPRESS ((lzo_uint32_t) (65536L * lzo_sizeof_dict_t))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_99_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_99_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
#define LZO1C_999_MEM_COMPRESS ((lzo_uint32_t) (5 * 16384L * sizeof(short))) #define LZO1C_999_MEM_COMPRESS ((lzo_uint32_t) (5 * 16384L * sizeof(short)))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_999_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_999_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);

View File

@ -52,15 +52,15 @@ extern "C" {
/* decompression */ /* decompression */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1f_decompress ( const lzo_bytep src, lzo_uint src_len, lzo1f_decompress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/* safe decompression with overrun testing */ /* safe decompression with overrun testing */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1f_decompress_safe ( const lzo_bytep src, lzo_uint src_len, lzo1f_decompress_safe(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/*********************************************************************** /***********************************************************************
@ -68,9 +68,9 @@ lzo1f_decompress_safe ( const lzo_bytep src, lzo_uint src_len,
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1f_1_compress ( const lzo_bytep src, lzo_uint src_len, lzo1f_1_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
/*********************************************************************** /***********************************************************************
@ -80,9 +80,9 @@ lzo1f_1_compress ( const lzo_bytep src, lzo_uint src_len,
#define LZO1F_999_MEM_COMPRESS ((lzo_uint32_t) (5 * 16384L * sizeof(short))) #define LZO1F_999_MEM_COMPRESS ((lzo_uint32_t) (5 * 16384L * sizeof(short)))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1f_999_compress ( const lzo_bytep src, lzo_uint src_len, lzo1f_999_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);

View File

@ -53,15 +53,15 @@ extern "C" {
/* decompression */ /* decompression */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len, lzo1x_decompress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/* safe decompression with overrun testing */ /* safe decompression with overrun testing */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len, lzo1x_decompress_safe(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/*********************************************************************** /***********************************************************************
@ -71,9 +71,9 @@ lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len,
#define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t)) #define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len, lzo1x_1_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
/*********************************************************************** /***********************************************************************
@ -84,27 +84,27 @@ lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len,
#define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32_t) (2048L * lzo_sizeof_dict_t)) #define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32_t) (2048L * lzo_sizeof_dict_t))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_1_11_compress ( const lzo_bytep src, lzo_uint src_len, lzo1x_1_11_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
/* this version needs 16 KiB work memory */ /* this version needs 16 KiB work memory */
#define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32_t) (4096L * lzo_sizeof_dict_t)) #define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32_t) (4096L * lzo_sizeof_dict_t))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_1_12_compress ( const lzo_bytep src, lzo_uint src_len, lzo1x_1_12_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
/* use this version if you need a little more compression speed */ /* use this version if you need a little more compression speed */
#define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32_t) (32768L * lzo_sizeof_dict_t)) #define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32_t) (32768L * lzo_sizeof_dict_t))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_1_15_compress ( const lzo_bytep src, lzo_uint src_len, lzo1x_1_15_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
/*********************************************************************** /***********************************************************************
@ -114,9 +114,9 @@ lzo1x_1_15_compress ( const lzo_bytep src, lzo_uint src_len,
#define LZO1X_999_MEM_COMPRESS ((lzo_uint32_t) (14 * 16384L * sizeof(short))) #define LZO1X_999_MEM_COMPRESS ((lzo_uint32_t) (14 * 16384L * sizeof(short)))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_999_compress ( const lzo_bytep src, lzo_uint src_len, lzo1x_999_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
/*********************************************************************** /***********************************************************************
@ -124,24 +124,24 @@ lzo1x_999_compress ( const lzo_bytep src, lzo_uint src_len,
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_999_compress_dict ( const lzo_bytep src, lzo_uint src_len, lzo1x_999_compress_dict(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len ); const lzo_bytep dict, lzo_uint dict_len);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_999_compress_level ( const lzo_bytep src, lzo_uint src_len, lzo1x_999_compress_level(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len, const lzo_bytep dict, lzo_uint dict_len,
lzo_callback_p cb, lzo_callback_p cb,
int compression_level ); int compression_level);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_decompress_dict_safe ( const lzo_bytep src, lzo_uint src_len, lzo1x_decompress_dict_safe(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */, lzo_voidp wrkmem /* NOT USED */,
const lzo_bytep dict, lzo_uint dict_len ); const lzo_bytep dict, lzo_uint dict_len);
/*********************************************************************** /***********************************************************************
@ -149,9 +149,9 @@ lzo1x_decompress_dict_safe ( const lzo_bytep src, lzo_uint src_len,
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_optimize ( lzo_bytep src, lzo_uint src_len, lzo1x_optimize(lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);

View File

@ -53,15 +53,15 @@ extern "C" {
/* decompression */ /* decompression */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1y_decompress ( const lzo_bytep src, lzo_uint src_len, lzo1y_decompress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/* safe decompression with overrun testing */ /* safe decompression with overrun testing */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1y_decompress_safe ( const lzo_bytep src, lzo_uint src_len, lzo1y_decompress_safe(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/*********************************************************************** /***********************************************************************
@ -69,9 +69,9 @@ lzo1y_decompress_safe ( const lzo_bytep src, lzo_uint src_len,
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1y_1_compress ( const lzo_bytep src, lzo_uint src_len, lzo1y_1_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
/*********************************************************************** /***********************************************************************
@ -81,9 +81,9 @@ lzo1y_1_compress ( const lzo_bytep src, lzo_uint src_len,
#define LZO1Y_999_MEM_COMPRESS ((lzo_uint32_t) (14 * 16384L * sizeof(short))) #define LZO1Y_999_MEM_COMPRESS ((lzo_uint32_t) (14 * 16384L * sizeof(short)))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1y_999_compress ( const lzo_bytep src, lzo_uint src_len, lzo1y_999_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
@ -92,24 +92,24 @@ lzo1y_999_compress ( const lzo_bytep src, lzo_uint src_len,
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1y_999_compress_dict ( const lzo_bytep src, lzo_uint src_len, lzo1y_999_compress_dict(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len ); const lzo_bytep dict, lzo_uint dict_len);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1y_999_compress_level ( const lzo_bytep src, lzo_uint src_len, lzo1y_999_compress_level(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len, const lzo_bytep dict, lzo_uint dict_len,
lzo_callback_p cb, lzo_callback_p cb,
int compression_level ); int compression_level);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1y_decompress_dict_safe ( const lzo_bytep src, lzo_uint src_len, lzo1y_decompress_dict_safe(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */, lzo_voidp wrkmem /* NOT USED */,
const lzo_bytep dict, lzo_uint dict_len ); const lzo_bytep dict, lzo_uint dict_len);
/*********************************************************************** /***********************************************************************
@ -117,9 +117,9 @@ lzo1y_decompress_dict_safe ( const lzo_bytep src, lzo_uint src_len,
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1y_optimize ( lzo_bytep src, lzo_uint src_len, lzo1y_optimize(lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);

View File

@ -51,15 +51,15 @@ extern "C" {
/* decompression */ /* decompression */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1z_decompress ( const lzo_bytep src, lzo_uint src_len, lzo1z_decompress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/* safe decompression with overrun testing */ /* safe decompression with overrun testing */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1z_decompress_safe ( const lzo_bytep src, lzo_uint src_len, lzo1z_decompress_safe(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/*********************************************************************** /***********************************************************************
@ -69,9 +69,9 @@ lzo1z_decompress_safe ( const lzo_bytep src, lzo_uint src_len,
#define LZO1Z_999_MEM_COMPRESS ((lzo_uint32_t) (14 * 16384L * sizeof(short))) #define LZO1Z_999_MEM_COMPRESS ((lzo_uint32_t) (14 * 16384L * sizeof(short)))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1z_999_compress ( const lzo_bytep src, lzo_uint src_len, lzo1z_999_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
/*********************************************************************** /***********************************************************************
@ -79,24 +79,24 @@ lzo1z_999_compress ( const lzo_bytep src, lzo_uint src_len,
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1z_999_compress_dict ( const lzo_bytep src, lzo_uint src_len, lzo1z_999_compress_dict(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len ); const lzo_bytep dict, lzo_uint dict_len);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1z_999_compress_level ( const lzo_bytep src, lzo_uint src_len, lzo1z_999_compress_level(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len, const lzo_bytep dict, lzo_uint dict_len,
lzo_callback_p cb, lzo_callback_p cb,
int compression_level ); int compression_level);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1z_decompress_dict_safe ( const lzo_bytep src, lzo_uint src_len, lzo1z_decompress_dict_safe(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */, lzo_voidp wrkmem /* NOT USED */,
const lzo_bytep dict, lzo_uint dict_len ); const lzo_bytep dict, lzo_uint dict_len);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -46,15 +46,15 @@ extern "C" {
/* decompression */ /* decompression */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo2a_decompress ( const lzo_bytep src, lzo_uint src_len, lzo2a_decompress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/* safe decompression with overrun testing */ /* safe decompression with overrun testing */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo2a_decompress_safe ( const lzo_bytep src, lzo_uint src_len, lzo2a_decompress_safe(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ ); lzo_voidp wrkmem /* NOT USED */);
/*********************************************************************** /***********************************************************************
@ -64,9 +64,9 @@ lzo2a_decompress_safe ( const lzo_bytep src, lzo_uint src_len,
#define LZO2A_999_MEM_COMPRESS ((lzo_uint32_t) (8 * 16384L * sizeof(short))) #define LZO2A_999_MEM_COMPRESS ((lzo_uint32_t) (8 * 16384L * sizeof(short)))
LZO_EXTERN(int) LZO_EXTERN(int)
lzo2a_999_compress ( const lzo_bytep src, lzo_uint src_len, lzo2a_999_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);

View File

@ -56,56 +56,56 @@ extern "C" {
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) lzo1c_decompress_asm LZO_EXTERN(int) lzo1c_decompress_asm
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_EXTERN(int) lzo1c_decompress_asm_safe LZO_EXTERN(int) lzo1c_decompress_asm_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_EXTERN(int) lzo1f_decompress_asm_fast LZO_EXTERN(int) lzo1f_decompress_asm_fast
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_EXTERN(int) lzo1f_decompress_asm_fast_safe LZO_EXTERN(int) lzo1f_decompress_asm_fast_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_EXTERN(int) lzo1x_decompress_asm LZO_EXTERN(int) lzo1x_decompress_asm
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_EXTERN(int) lzo1x_decompress_asm_safe LZO_EXTERN(int) lzo1x_decompress_asm_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_EXTERN(int) lzo1x_decompress_asm_fast LZO_EXTERN(int) lzo1x_decompress_asm_fast
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_EXTERN(int) lzo1x_decompress_asm_fast_safe LZO_EXTERN(int) lzo1x_decompress_asm_fast_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_EXTERN(int) lzo1y_decompress_asm LZO_EXTERN(int) lzo1y_decompress_asm
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_EXTERN(int) lzo1y_decompress_asm_safe LZO_EXTERN(int) lzo1y_decompress_asm_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_EXTERN(int) lzo1y_decompress_asm_fast LZO_EXTERN(int) lzo1y_decompress_asm_fast
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_EXTERN(int) lzo1y_decompress_asm_fast_safe LZO_EXTERN(int) lzo1y_decompress_asm_fast_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
/*********************************************************************** /***********************************************************************
@ -122,10 +122,10 @@ LZO_EXTERN(lzo_uint32_t)
lzo_crc32_asm_small(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); lzo_crc32_asm_small(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
LZO_EXTERN(int) LZO_EXTERN(int)
lzo_cpuid_asm(lzo_uint32_tp /* lzo_uint32_t info[16] */ ); lzo_cpuid_asm(lzo_uint32_tp /* lzo_uint32_t info[16] */);
LZO_EXTERN(lzo_uint32_t) LZO_EXTERN(lzo_uint32_t)
lzo_rdtsc_asm(lzo_uint32_tp /* lzo_uint32_t ticks[2] */ ); lzo_rdtsc_asm(lzo_uint32_tp /* lzo_uint32_t ticks[2] */);
#endif #endif

View File

@ -92,12 +92,12 @@ extern "C" {
#if !defined(LZO_UINT_MAX) #if !defined(LZO_UINT_MAX)
# if (LZO_ABI_LLP64) # if (LZO_ABI_LLP64)
# if (LZO_OS_WIN64) # if (LZO_OS_WIN64)
typedef unsigned __int64 lzo_uint; typedef unsigned __int64 lzo_uint;
typedef __int64 lzo_int; typedef __int64 lzo_int;
# define LZO_TYPEOF_LZO_INT LZO_TYPEOF___INT64 # define LZO_TYPEOF_LZO_INT LZO_TYPEOF___INT64
# else # else
typedef lzo_ullong_t lzo_uint; typedef lzo_ullong_t lzo_uint;
typedef lzo_llong_t lzo_int; typedef lzo_llong_t lzo_int;
# define LZO_TYPEOF_LZO_INT LZO_TYPEOF_LONG_LONG # define LZO_TYPEOF_LZO_INT LZO_TYPEOF_LONG_LONG
# endif # endif
# define LZO_SIZEOF_LZO_INT 8 # define LZO_SIZEOF_LZO_INT 8
@ -105,16 +105,16 @@ extern "C" {
# define LZO_INT_MAX 9223372036854775807LL # define LZO_INT_MAX 9223372036854775807LL
# define LZO_INT_MIN (-1LL - LZO_INT_MAX) # define LZO_INT_MIN (-1LL - LZO_INT_MAX)
# elif (LZO_ABI_IP32L64) /* MIPS R5900 */ # elif (LZO_ABI_IP32L64) /* MIPS R5900 */
typedef unsigned int lzo_uint; typedef unsigned int lzo_uint;
typedef int lzo_int; typedef int lzo_int;
# define LZO_SIZEOF_LZO_INT LZO_SIZEOF_INT # define LZO_SIZEOF_LZO_INT LZO_SIZEOF_INT
# define LZO_TYPEOF_LZO_INT LZO_TYPEOF_INT # define LZO_TYPEOF_LZO_INT LZO_TYPEOF_INT
# define LZO_UINT_MAX UINT_MAX # define LZO_UINT_MAX UINT_MAX
# define LZO_INT_MAX INT_MAX # define LZO_INT_MAX INT_MAX
# define LZO_INT_MIN INT_MIN # define LZO_INT_MIN INT_MIN
# elif (ULONG_MAX >= LZO_0xffffffffL) # elif (ULONG_MAX >= LZO_0xffffffffL)
typedef unsigned long lzo_uint; typedef unsigned long lzo_uint;
typedef long lzo_int; typedef long lzo_int;
# define LZO_SIZEOF_LZO_INT LZO_SIZEOF_LONG # define LZO_SIZEOF_LZO_INT LZO_SIZEOF_LONG
# define LZO_TYPEOF_LZO_INT LZO_TYPEOF_LONG # define LZO_TYPEOF_LZO_INT LZO_TYPEOF_LONG
# define LZO_UINT_MAX ULONG_MAX # define LZO_UINT_MAX ULONG_MAX
@ -191,11 +191,11 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) >= 4)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(size_t))
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(ptrdiff_t))
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint) == sizeof(lzo_uintptr_t))
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_uintptr_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void*) == sizeof(lzo_uintptr_t))
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_uintptr_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char*) == sizeof(lzo_uintptr_t))
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long *) == sizeof(lzo_uintptr_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long*) == sizeof(lzo_uintptr_t))
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void *) == sizeof(lzo_voidp)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(void*) == sizeof(lzo_voidp))
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char*) == sizeof(lzo_bytep))
/*********************************************************************** /***********************************************************************
@ -237,31 +237,31 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(char *) == sizeof(lzo_bytep))
/* function types */ /* function types */
typedef int typedef int
(__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len, (__LZO_CDECL* lzo_compress_t)(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
typedef int typedef int
(__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len, (__LZO_CDECL* lzo_decompress_t)(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
typedef int typedef int
(__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len, (__LZO_CDECL* lzo_optimize_t)(lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem ); lzo_voidp wrkmem);
typedef int typedef int
(__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len, (__LZO_CDECL* lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len ); const lzo_bytep dict, lzo_uint dict_len);
typedef int typedef int
(__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len, (__LZO_CDECL* lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len ); const lzo_bytep dict, lzo_uint dict_len);
/* Callback interface. Currently only the progress indicator ("nprogress") /* Callback interface. Currently only the progress indicator ("nprogress")
@ -272,14 +272,14 @@ typedef struct lzo_callback_t lzo_callback_t;
#define lzo_callback_p lzo_callback_t __LZO_MMODEL * #define lzo_callback_p lzo_callback_t __LZO_MMODEL *
/* malloc & free function types */ /* malloc & free function types */
typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t) typedef lzo_voidp(__LZO_CDECL* lzo_alloc_func_t)
(lzo_callback_p self, lzo_uint items, lzo_uint size); (lzo_callback_p self, lzo_uint items, lzo_uint size);
typedef void (__LZO_CDECL *lzo_free_func_t) typedef void (__LZO_CDECL* lzo_free_func_t)
(lzo_callback_p self, lzo_voidp ptr); (lzo_callback_p self, lzo_voidp ptr);
/* a progress indicator callback function */ /* a progress indicator callback function */
typedef void (__LZO_CDECL *lzo_progress_func_t) typedef void (__LZO_CDECL* lzo_progress_func_t)
(lzo_callback_p, lzo_uint, lzo_uint, int); (lzo_callback_p, lzo_uint, lzo_uint, int);
struct lzo_callback_t struct lzo_callback_t
{ {
@ -337,38 +337,47 @@ struct lzo_callback_t
(int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\ (int)sizeof(long),(int)sizeof(lzo_uint32_t),(int)sizeof(lzo_uint),\
(int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
(int)sizeof(lzo_callback_t)) (int)sizeof(lzo_callback_t))
LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); LZO_EXTERN(int) __lzo_init_v2(unsigned, int, int, int, int, int, int, int, int, int);
/* version functions (useful for shared libraries) */ /* version functions (useful for shared libraries) */
LZO_EXTERN(unsigned) lzo_version(void); LZO_EXTERN(unsigned) lzo_version(void);
LZO_EXTERN(const char *) lzo_version_string(void); LZO_EXTERN(const char*) lzo_version_string(void);
LZO_EXTERN(const char *) lzo_version_date(void); LZO_EXTERN(const char*) lzo_version_date(void);
LZO_EXTERN(const lzo_charp) _lzo_version_string(void); LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
LZO_EXTERN(const lzo_charp) _lzo_version_date(void); LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
/* string functions */ /* string functions */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len); lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len);
LZO_EXTERN(lzo_voidp) LZO_EXTERN(lzo_voidp)
lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len); lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
LZO_EXTERN(lzo_voidp) LZO_EXTERN(lzo_voidp)
lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len); lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len);
LZO_EXTERN(lzo_voidp) LZO_EXTERN(lzo_voidp)
lzo_memset(lzo_voidp buf, int c, lzo_uint len); lzo_memset(lzo_voidp buf, int c, lzo_uint len);
/* checksum functions */ /* checksum functions */
LZO_EXTERN(lzo_uint32_t) LZO_EXTERN(lzo_uint32_t)
lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); lzo_adler32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
LZO_EXTERN(lzo_uint32_t) LZO_EXTERN(lzo_uint32_t)
lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len); lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len);
LZO_EXTERN(const lzo_uint32_tp) LZO_EXTERN(const lzo_uint32_tp)
lzo_get_crc32_table(void); lzo_get_crc32_table(void);
/* misc. */ /* misc. */
LZO_EXTERN(int) _lzo_config_check(void); LZO_EXTERN(int) _lzo_config_check(void);
typedef union { typedef union
lzo_voidp a00; lzo_bytep a01; lzo_uint a02; lzo_xint a03; lzo_uintptr_t a04; {
void *a05; unsigned char *a06; unsigned long a07; size_t a08; ptrdiff_t a09; lzo_voidp a00;
lzo_bytep a01;
lzo_uint a02;
lzo_xint a03;
lzo_uintptr_t a04;
void* a05;
unsigned char* a06;
unsigned long a07;
size_t a08;
ptrdiff_t a09;
#if defined(lzo_int64_t) #if defined(lzo_int64_t)
lzo_uint64_t a10; lzo_uint64_t a10;
#endif #endif

View File

@ -1114,21 +1114,21 @@
extern "C" { extern "C" {
#endif #endif
#if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200))
extern void __near __cdecl _AHSHIFT(void); extern void __near __cdecl _AHSHIFT(void);
# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
#elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
extern void __near __cdecl _AHSHIFT(void); extern void __near __cdecl _AHSHIFT(void);
# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
#elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC) #elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC)
extern void __near __cdecl _AHSHIFT(void); extern void __near __cdecl _AHSHIFT(void);
# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
#elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295)) #elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295))
extern void __near __cdecl _AHSHIFT(void); extern void __near __cdecl _AHSHIFT(void);
# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
#elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16) #elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16)
# define LZO_MM_AHSHIFT 12 # define LZO_MM_AHSHIFT 12
#elif (LZO_CC_WATCOMC) #elif (LZO_CC_WATCOMC)
extern unsigned char _HShift; extern unsigned char _HShift;
# define LZO_MM_AHSHIFT ((unsigned) _HShift) # define LZO_MM_AHSHIFT ((unsigned) _HShift)
#else #else
# error "FIXME - implement LZO_MM_AHSHIFT" # error "FIXME - implement LZO_MM_AHSHIFT"
@ -2317,7 +2317,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8)
#if !defined(LZO_SIZEOF_VOID_P) #if !defined(LZO_SIZEOF_VOID_P)
# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
#endif #endif
LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *)) LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void*))
#if !defined(LZO_SIZEOF_SIZE_T) #if !defined(LZO_SIZEOF_SIZE_T)
#if (LZO_ARCH_I086 || LZO_ARCH_M16C) #if (LZO_ARCH_I086 || LZO_ARCH_M16C)
# define LZO_SIZEOF_SIZE_T 2 # define LZO_SIZEOF_SIZE_T 2
@ -2741,8 +2741,8 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
# define lzo_uint16e_t unsigned short int # define lzo_uint16e_t unsigned short int
# define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF_SHORT # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF_SHORT
#elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) #elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM)
typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__))); typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__)));
typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__))); typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__)));
# define lzo_int16e_t lzo_int16e_hi_t__ # define lzo_int16e_t lzo_int16e_hi_t__
# define lzo_uint16e_t lzo_uint16e_hi_t__ # define lzo_uint16e_t lzo_uint16e_hi_t__
# define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF___MODE_HI # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF___MODE_HI
@ -2755,8 +2755,8 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
#endif #endif
#if defined(lzo_int16e_t) #if defined(lzo_int16e_t)
# define LZO_SIZEOF_LZO_INT16E_T 2 # define LZO_SIZEOF_LZO_INT16E_T 2
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T)
#endif #endif
#if !defined(lzo_int32e_t) #if !defined(lzo_int32e_t)
#if (LZO_SIZEOF_LONG == 4) #if (LZO_SIZEOF_LONG == 4)
@ -2776,14 +2776,14 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
# define lzo_uint32e_t lzo_ullong_t # define lzo_uint32e_t lzo_ullong_t
# define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_LONG_LONG # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_LONG_LONG
#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L) #elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L)
typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__)));
typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
# define lzo_int32e_t lzo_int32e_si_t__ # define lzo_int32e_t lzo_int32e_si_t__
# define lzo_uint32e_t lzo_uint32e_si_t__ # define lzo_uint32e_t lzo_uint32e_si_t__
# define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF___MODE_SI # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF___MODE_SI
#elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L) #elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L)
typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__))); typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__)));
typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__))); typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
# define lzo_int32e_t lzo_int32e_si_t__ # define lzo_int32e_t lzo_int32e_si_t__
# define lzo_uint32e_t lzo_uint32e_si_t__ # define lzo_uint32e_t lzo_uint32e_si_t__
# define LZO_INT32_C(c) (c##LL) # define LZO_INT32_C(c) (c##LL)
@ -2798,8 +2798,8 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
#endif #endif
#if defined(lzo_int32e_t) #if defined(lzo_int32e_t)
# define LZO_SIZEOF_LZO_INT32E_T 4 # define LZO_SIZEOF_LZO_INT32E_T 4
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T)
#endif #endif
#if !defined(lzo_int64e_t) #if !defined(lzo_int64e_t)
#if (LZO_SIZEOF___INT64 == 8) #if (LZO_SIZEOF___INT64 == 8)
@ -2845,8 +2845,8 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
#endif #endif
#if defined(lzo_int64e_t) #if defined(lzo_int64e_t)
# define LZO_SIZEOF_LZO_INT64E_T 8 # define LZO_SIZEOF_LZO_INT64E_T 8
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T)
#endif #endif
#if !defined(lzo_int32l_t) #if !defined(lzo_int32l_t)
#if defined(lzo_int32e_t) #if defined(lzo_int32e_t)
@ -2869,8 +2869,8 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
#endif #endif
#endif #endif
#if 1 #if 1
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T)
#endif #endif
#if !defined(lzo_int64l_t) #if !defined(lzo_int64l_t)
#if defined(lzo_int64e_t) #if defined(lzo_int64e_t)
@ -2882,8 +2882,8 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
#endif #endif
#endif #endif
#if defined(lzo_int64l_t) #if defined(lzo_int64l_t)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T)
#endif #endif
#if !defined(lzo_int32f_t) #if !defined(lzo_int32f_t)
#if (LZO_SIZEOF_SIZE_T >= 8) #if (LZO_SIZEOF_SIZE_T >= 8)
@ -2899,8 +2899,8 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
#endif #endif
#endif #endif
#if 1 #if 1
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T)
#endif #endif
#if !defined(lzo_int64f_t) #if !defined(lzo_int64f_t)
#if defined(lzo_int64l_t) #if defined(lzo_int64l_t)
@ -2912,21 +2912,21 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
#endif #endif
#endif #endif
#if defined(lzo_int64f_t) #if defined(lzo_int64f_t)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T)
#endif #endif
#if !defined(lzo_intptr_t) #if !defined(lzo_intptr_t)
#if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16)) #if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16))
# define __LZO_INTPTR_T_IS_POINTER 1 # define __LZO_INTPTR_T_IS_POINTER 1
typedef char * lzo_intptr_t; typedef char* lzo_intptr_t;
typedef char * lzo_uintptr_t; typedef char* lzo_uintptr_t;
# define lzo_intptr_t lzo_intptr_t # define lzo_intptr_t lzo_intptr_t
# define lzo_uintptr_t lzo_uintptr_t # define lzo_uintptr_t lzo_uintptr_t
# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P
# define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_CHAR_P # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_CHAR_P
#elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4)) #elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4))
typedef __w64 int lzo_intptr_t; typedef __w64 int lzo_intptr_t;
typedef __w64 unsigned int lzo_uintptr_t; typedef __w64 unsigned int lzo_uintptr_t;
# define lzo_intptr_t lzo_intptr_t # define lzo_intptr_t lzo_intptr_t
# define lzo_uintptr_t lzo_uintptr_t # define lzo_uintptr_t lzo_uintptr_t
# define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT
@ -2956,8 +2956,8 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
#endif #endif
#endif #endif
#if 1 #if 1
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void*))
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t)) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t))
#endif #endif
#if !defined(lzo_word_t) #if !defined(lzo_word_t)
#if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0) #if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0)
@ -2993,8 +2993,8 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
# define LZO_TYPEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T # define LZO_TYPEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T
#elif (LZO_ARCH_SPU) && (LZO_CC_GNUC) #elif (LZO_ARCH_SPU) && (LZO_CC_GNUC)
#if 0 #if 0
typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__))); typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__)));
typedef int lzo_sword_t __attribute__((__mode__(__V16QI__))); typedef int lzo_sword_t __attribute__((__mode__(__V16QI__)));
# define lzo_word_t lzo_word_t # define lzo_word_t lzo_word_t
# define lzo_sword_t lzo_sword_t # define lzo_sword_t lzo_sword_t
# define LZO_SIZEOF_LZO_WORD_T 16 # define LZO_SIZEOF_LZO_WORD_T 16
@ -3006,8 +3006,8 @@ __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
#endif #endif
#endif #endif
#if 1 && defined(lzo_word_t) #if 1 && defined(lzo_word_t)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE)
#endif #endif
#if 1 #if 1
#define lzo_int8_t signed char #define lzo_int8_t signed char

View File

@ -57,11 +57,11 @@
const lzo_compress_t LZO_COMPRESS_FUNC = do_compress; const lzo_compress_t LZO_COMPRESS_FUNC = do_compress;
LZO_PUBLIC(int) LZO_PUBLIC(int)
LZO_COMPRESS ( const lzo_bytep in, lzo_uint in_len, LZO_COMPRESS(const lzo_bytep in, lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
return _lzo1b_do_compress(in,in_len,out,out_len,wrkmem,do_compress); return _lzo1b_do_compress(in, in_len, out, out_len, wrkmem, do_compress);
} }

View File

@ -57,11 +57,11 @@
const lzo_compress_t LZO_COMPRESS_FUNC = do_compress; const lzo_compress_t LZO_COMPRESS_FUNC = do_compress;
LZO_PUBLIC(int) LZO_PUBLIC(int)
LZO_COMPRESS ( const lzo_bytep in, lzo_uint in_len, LZO_COMPRESS(const lzo_bytep in, lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
return _lzo1c_do_compress(in,in_len,out,out_len,wrkmem,do_compress); return _lzo1c_do_compress(in, in_len, out, out_len, wrkmem, do_compress);
} }

218
extern/lzo/src/lzo1.c vendored
View File

@ -153,15 +153,17 @@ RBITS | MBITS MIN THR. MSIZE MAXS MINL MAXL MAXO R0MAX R0FAST
// get algorithm info, return memory required for compression // get algorithm info, return memory required for compression
************************************************************************/ ************************************************************************/
LZO_EXTERN(lzo_uint) lzo1_info ( int *rbits, int *clevel ); LZO_EXTERN(lzo_uint) lzo1_info(int* rbits, int* clevel);
LZO_PUBLIC(lzo_uint) LZO_PUBLIC(lzo_uint)
lzo1_info ( int *rbits, int *clevel ) lzo1_info(int* rbits, int* clevel)
{ {
if (rbits) if (rbits)
*rbits = RBITS; *rbits = RBITS;
if (clevel) if (clevel)
*clevel = CLEVEL; *clevel = CLEVEL;
return D_SIZE * lzo_sizeof(lzo_bytep); return D_SIZE * lzo_sizeof(lzo_bytep);
} }
@ -190,9 +192,9 @@ lzo1_info ( int *rbits, int *clevel )
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1_decompress ( const lzo_bytep in , lzo_uint in_len, lzo1_decompress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
lzo_bytep op; lzo_bytep op;
const lzo_bytep ip; const lzo_bytep ip;
@ -203,6 +205,7 @@ lzo1_decompress ( const lzo_bytep in , lzo_uint in_len,
op = out; op = out;
ip = in; ip = in;
while (ip < ip_end) while (ip < ip_end)
{ {
t = *ip++; /* get marker */ t = *ip++; /* get marker */
@ -212,9 +215,11 @@ lzo1_decompress ( const lzo_bytep in , lzo_uint in_len,
if (t == 0) /* a R0 literal run */ if (t == 0) /* a R0 literal run */
{ {
t = *ip++; t = *ip++;
if (t >= R0FAST - R0MIN) /* a long R0 run */ if (t >= R0FAST - R0MIN) /* a long R0 run */
{ {
t -= R0FAST - R0MIN; t -= R0FAST - R0MIN;
if (t == 0) if (t == 0)
t = R0FAST; t = R0FAST;
else else
@ -224,23 +229,30 @@ lzo1_decompress ( const lzo_bytep in , lzo_uint in_len,
#else #else
/* help the optimizer */ /* help the optimizer */
lzo_uint tt = 256; lzo_uint tt = 256;
do tt <<= 1; while (--t > 0);
do tt <<= 1;
while (--t > 0);
t = tt; t = tt;
#endif #endif
} }
MEMCPY8_DS(op,ip,t);
MEMCPY8_DS(op, ip, t);
continue; continue;
} }
t += R0MIN; t += R0MIN;
} }
MEMCPY_DS(op,ip,t);
MEMCPY_DS(op, ip, t);
} }
else /* a match */ else /* a match */
{ {
lzo_uint tt; lzo_uint tt;
/* get match offset */ /* get match offset */
const lzo_bytep m_pos = op - 1; const lzo_bytep m_pos = op - 1;
m_pos -= (lzo_uint)(t & OMASK) | (((lzo_uint) *ip++) << OBITS); m_pos -= (lzo_uint)(t & OMASK) | (((lzo_uint) * ip++) << OBITS);
/* get match len */ /* get match len */
if (t >= ((MSIZE - 1) << OBITS)) /* all m-bits set */ if (t >= ((MSIZE - 1) << OBITS)) /* all m-bits set */
@ -253,7 +265,7 @@ lzo1_decompress ( const lzo_bytep in , lzo_uint in_len,
/* a half unrolled loop */ /* a half unrolled loop */
*op++ = *m_pos++; *op++ = *m_pos++;
*op++ = *m_pos++; *op++ = *m_pos++;
MEMCPY_DS(op,m_pos,tt); MEMCPY_DS(op, m_pos, tt);
} }
} }
@ -261,7 +273,7 @@ lzo1_decompress ( const lzo_bytep in , lzo_uint in_len,
/* the next line is the only check in the decompressor ! */ /* the next line is the only check in the decompressor ! */
return (ip == ip_end ? LZO_E_OK : return (ip == ip_end ? LZO_E_OK :
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
} }
@ -282,26 +294,33 @@ store_run(lzo_bytep op, const lzo_bytep ii, lzo_uint r_len)
if (r_len >= 512) if (r_len >= 512)
{ {
unsigned r_bits = 7; /* 256 << 7 == 32768 */ unsigned r_bits = 7; /* 256 << 7 == 32768 */
do {
do
{
while (r_len >= (256u << r_bits)) while (r_len >= (256u << r_bits))
{ {
r_len -= (256u << r_bits); r_len -= (256u << r_bits);
*op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits); *op++ = 0;
*op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
MEMCPY8_DS(op, ii, (256u << r_bits)); MEMCPY8_DS(op, ii, (256u << r_bits));
} }
} while (--r_bits > 0); }
while (--r_bits > 0);
} }
while (r_len >= R0FAST) while (r_len >= R0FAST)
{ {
r_len -= R0FAST; r_len -= R0FAST;
*op++ = 0; *op++ = R0FAST - R0MIN; *op++ = 0;
*op++ = R0FAST - R0MIN;
MEMCPY8_DS(op, ii, R0FAST); MEMCPY8_DS(op, ii, R0FAST);
} }
if (r_len >= R0MIN) if (r_len >= R0MIN)
{ {
/* code a short R0 run */ /* code a short R0 run */
*op++ = 0; *op++ = LZO_BYTE(r_len - R0MIN); *op++ = 0;
*op++ = LZO_BYTE(r_len - R0MIN);
MEMCPY_DS(op, ii, r_len); MEMCPY_DS(op, ii, r_len);
} }
else if (r_len > 0) else if (r_len > 0)
@ -326,9 +345,9 @@ store_run(lzo_bytep op, const lzo_bytep ii, lzo_uint r_len)
************************************************************************/ ************************************************************************/
static int static int
do_compress ( const lzo_bytep in , lzo_uint in_len, do_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
const lzo_bytep ip; const lzo_bytep ip;
#if defined(__LZO_HASH_INCREMENTAL) #if defined(__LZO_HASH_INCREMENTAL)
@ -336,8 +355,8 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
#endif #endif
lzo_bytep op; lzo_bytep op;
const lzo_bytep m_pos; const lzo_bytep m_pos;
const lzo_bytep const ip_end = in+in_len - DVAL_LEN - MIN_MATCH_LONG; const lzo_bytep const ip_end = in + in_len - DVAL_LEN - MIN_MATCH_LONG;
const lzo_bytep const in_end = in+in_len - DVAL_LEN; const lzo_bytep const in_end = in + in_len - DVAL_LEN;
const lzo_bytep ii; const lzo_bytep ii;
lzo_dict_p const dict = (lzo_dict_p) wrkmem; lzo_dict_p const dict = (lzo_dict_p) wrkmem;
@ -348,60 +367,72 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
op = out; op = out;
ip = in; ip = in;
ii = ip; /* point to start of literal run */ ii = ip; /* point to start of literal run */
if (in_len <= MIN_MATCH_LONG + DVAL_LEN + 1) if (in_len <= MIN_MATCH_LONG + DVAL_LEN + 1)
goto the_end; goto the_end;
/* init dictionary */ /* init dictionary */
#if (LZO_DETERMINISTIC) #if (LZO_DETERMINISTIC)
BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); BZERO8_PTR(wrkmem, sizeof(lzo_dict_t), D_SIZE);
#endif #endif
DVAL_FIRST(dv,ip); DVAL_FIRST(dv, ip);
UPDATE_D(dict,0,dv,ip,in); UPDATE_D(dict, 0, dv, ip, in);
ip++; ip++;
DVAL_NEXT(dv,ip); DVAL_NEXT(dv, ip);
do { do
{
LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
lzo_uint dindex; lzo_uint dindex;
DINDEX1(dindex,ip); DINDEX1(dindex, ip);
GINDEX(m_pos,m_off,dict,dindex,in); GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS(m_pos,m_off,in,ip,MAX_OFFSET))
if (LZO_CHECK_MPOS(m_pos, m_off, in, ip, MAX_OFFSET))
goto literal; goto literal;
if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2]) if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2])
goto match; goto match;
DINDEX2(dindex,ip);
GINDEX(m_pos,m_off,dict,dindex,in); DINDEX2(dindex, ip);
if (LZO_CHECK_MPOS(m_pos,m_off,in,ip,MAX_OFFSET)) GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS(m_pos, m_off, in, ip, MAX_OFFSET))
goto literal; goto literal;
if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2]) if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2])
goto match; goto match;
goto literal; goto literal;
literal: literal:
UPDATE_I(dict,0,dindex,ip,in); UPDATE_I(dict, 0, dindex, ip, in);
if (++ip >= ip_end) if (++ip >= ip_end)
break; break;
continue; continue;
match: match:
UPDATE_I(dict,0,dindex,ip,in); UPDATE_I(dict, 0, dindex, ip, in);
#if !defined(NDEBUG) && (LZO_DICT_USE_PTR) #if !defined(NDEBUG) && (LZO_DICT_USE_PTR)
m_pos_sav = m_pos; m_pos_sav = m_pos;
#endif #endif
m_pos += 3; m_pos += 3;
{ {
/* we have found a match (of at least length 3) */ /* we have found a match (of at least length 3) */
#if !defined(NDEBUG) && !(LZO_DICT_USE_PTR) #if !defined(NDEBUG) && !(LZO_DICT_USE_PTR)
assert((m_pos_sav = ip - m_off) == (m_pos - 3)); assert((m_pos_sav = ip - m_off) == (m_pos - 3));
#endif #endif
/* 1) store the current literal run */ /* 1) store the current literal run */
if (pd(ip,ii) > 0) if (pd(ip, ii) > 0)
{ {
lzo_uint t = pd(ip,ii); lzo_uint t = pd(ip, ii);
#if 1 #if 1
/* OPTIMIZED: inline the copying of a short run */ /* OPTIMIZED: inline the copying of a short run */
if (t < R0MIN) if (t < R0MIN)
{ {
@ -410,7 +441,7 @@ match:
} }
else else
#endif #endif
op = store_run(op,ii,t); op = store_run(op, ii, t);
} }
/* 2a) compute match len */ /* 2a) compute match len */
@ -427,33 +458,34 @@ match:
#define PS *m_pos++ != *ip++ #define PS *m_pos++ != *ip++
#if (MIN_MATCH_LONG - MIN_MATCH == 2) /* MBITS == 2 */ #if (MIN_MATCH_LONG - MIN_MATCH == 2) /* MBITS == 2 */
if (PS || PS) if (PS || PS)
#elif (MIN_MATCH_LONG - MIN_MATCH == 6) /* MBITS == 3 */ #elif (MIN_MATCH_LONG - MIN_MATCH == 6) /* MBITS == 3 */
if (PS || PS || PS || PS || PS || PS) if (PS || PS || PS || PS || PS || PS)
#elif (MIN_MATCH_LONG - MIN_MATCH == 14) /* MBITS == 4 */ #elif (MIN_MATCH_LONG - MIN_MATCH == 14) /* MBITS == 4 */
if (PS || PS || PS || PS || PS || PS || PS || if (PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS || PS) PS || PS || PS || PS || PS || PS || PS)
#elif (MIN_MATCH_LONG - MIN_MATCH == 30) /* MBITS == 5 */ #elif (MIN_MATCH_LONG - MIN_MATCH == 30) /* MBITS == 5 */
if (PS || PS || PS || PS || PS || PS || PS || PS || if (PS || PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS) PS || PS || PS || PS || PS || PS)
#else #else
# error "MBITS not yet implemented" # error "MBITS not yet implemented"
#endif #endif
{ {
lzo_uint m_len; lzo_uint m_len;
/* 2b) code a short match */ /* 2b) code a short match */
assert(pd(ip,m_pos) == m_off); assert(pd(ip, m_pos) == m_off);
--ip; /* ran one too far, point back to non-match */ --ip; /* ran one too far, point back to non-match */
m_len = pd(ip, ii); m_len = pd(ip, ii);
assert(m_len >= MIN_MATCH_SHORT); assert(m_len >= MIN_MATCH_SHORT);
assert(m_len <= MAX_MATCH_SHORT); assert(m_len <= MAX_MATCH_SHORT);
assert(m_off > 0); assert(m_off > 0);
assert(m_off <= MAX_OFFSET); assert(m_off <= MAX_OFFSET);
assert(ii-m_off == m_pos_sav); assert(ii - m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0); assert(lzo_memcmp(m_pos_sav, ii, m_len) == 0);
--m_off; --m_off;
/* code short match len + low offset bits */ /* code short match len + low offset bits */
*op++ = LZO_BYTE(((m_len - THRESHOLD) << OBITS) | *op++ = LZO_BYTE(((m_len - THRESHOLD) << OBITS) |
@ -462,41 +494,45 @@ match:
*op++ = LZO_BYTE(m_off >> OBITS); *op++ = LZO_BYTE(m_off >> OBITS);
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */ /* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
#define SI /* nothing */ #define SI /* nothing */
#define DI ++ii; DVAL_NEXT(dv,ii); UPDATE_D(dict,0,dv,ii,in); #define DI ++ii; DVAL_NEXT(dv,ii); UPDATE_D(dict,0,dv,ii,in);
#define XI assert(ii < ip); ii = ip; DVAL_FIRST(dv,(ip)); #define XI assert(ii < ip); ii = ip; DVAL_FIRST(dv,(ip));
#if (CLEVEL == 9) || (CLEVEL >= 7 && MBITS <= 4) || (CLEVEL >= 5 && MBITS <= 3) #if (CLEVEL == 9) || (CLEVEL >= 7 && MBITS <= 4) || (CLEVEL >= 5 && MBITS <= 3)
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */ /* Insert the whole match (ii+1)..(ip-1) into dictionary. */
++ii; ++ii;
do {
DVAL_NEXT(dv,ii); do
UPDATE_D(dict,0,dv,ii,in); {
} while (++ii < ip); DVAL_NEXT(dv, ii);
DVAL_NEXT(dv,ii); UPDATE_D(dict, 0, dv, ii, in);
}
while (++ii < ip);
DVAL_NEXT(dv, ii);
assert(ii == ip); assert(ii == ip);
DVAL_ASSERT(dv,ip); DVAL_ASSERT(dv, ip);
#elif (CLEVEL >= 3) #elif (CLEVEL >= 3)
SI DI DI XI SI DI DI XI
#elif (CLEVEL >= 2) #elif (CLEVEL >= 2)
SI DI XI SI DI XI
#else #else
XI XI
#endif #endif
} }
else else
{ {
/* we've found a long match - see how far we can still go */ /* we've found a long match - see how far we can still go */
const lzo_bytep end; const lzo_bytep end;
lzo_uint m_len; lzo_uint m_len;
assert(ip <= in_end); assert(ip <= in_end);
assert(ii == ip - MIN_MATCH_LONG); assert(ii == ip - MIN_MATCH_LONG);
if (pd(in_end,ip) <= (MAX_MATCH_LONG - MIN_MATCH_LONG)) if (pd(in_end, ip) <= (MAX_MATCH_LONG - MIN_MATCH_LONG))
end = in_end; end = in_end;
else else
{ {
@ -506,17 +542,18 @@ match:
while (ip < end && *m_pos == *ip) while (ip < end && *m_pos == *ip)
m_pos++, ip++; m_pos++, ip++;
assert(ip <= in_end); assert(ip <= in_end);
/* 2b) code the long match */ /* 2b) code the long match */
m_len = pd(ip, ii); m_len = pd(ip, ii);
assert(m_len >= MIN_MATCH_LONG); assert(m_len >= MIN_MATCH_LONG);
assert(m_len <= MAX_MATCH_LONG); assert(m_len <= MAX_MATCH_LONG);
assert(m_off > 0); assert(m_off > 0);
assert(m_off <= MAX_OFFSET); assert(m_off <= MAX_OFFSET);
assert(ii-m_off == m_pos_sav); assert(ii - m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0); assert(lzo_memcmp(m_pos_sav, ii, m_len) == 0);
assert(pd(ip,m_pos) == m_off); assert(pd(ip, m_pos) == m_off);
--m_off; --m_off;
/* code long match flag + low offset bits */ /* code long match flag + low offset bits */
*op++ = LZO_BYTE(((MSIZE - 1) << OBITS) | (m_off & OMASK)); *op++ = LZO_BYTE(((MSIZE - 1) << OBITS) | (m_off & OMASK));
@ -526,18 +563,22 @@ match:
*op++ = LZO_BYTE(m_len - MIN_MATCH_LONG); *op++ = LZO_BYTE(m_len - MIN_MATCH_LONG);
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */ /* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
#if (CLEVEL == 9) #if (CLEVEL == 9)
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */ /* Insert the whole match (ii+1)..(ip-1) into dictionary. */
/* This is not recommended because it is slow. */ /* This is not recommended because it is slow. */
++ii; ++ii;
do {
DVAL_NEXT(dv,ii); do
UPDATE_D(dict,0,dv,ii,in); {
} while (++ii < ip); DVAL_NEXT(dv, ii);
DVAL_NEXT(dv,ii); UPDATE_D(dict, 0, dv, ii, in);
}
while (++ii < ip);
DVAL_NEXT(dv, ii);
assert(ii == ip); assert(ii == ip);
DVAL_ASSERT(dv,ip); DVAL_ASSERT(dv, ip);
#elif (CLEVEL >= 8) #elif (CLEVEL >= 8)
SI DI DI DI DI DI DI DI DI XI SI DI DI DI DI DI DI DI DI XI
#elif (CLEVEL >= 7) #elif (CLEVEL >= 7)
@ -553,14 +594,15 @@ match:
#elif (CLEVEL >= 2) #elif (CLEVEL >= 2)
SI DI XI SI DI XI
#else #else
XI XI
#endif #endif
} }
/* ii now points to the start of next literal run */ /* ii now points to the start of next literal run */
assert(ii == ip); assert(ii == ip);
} }
} while (ip < ip_end); }
while (ip < ip_end);
@ -569,6 +611,7 @@ the_end:
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
/* return -1 if op == out to indicate that we /* return -1 if op == out to indicate that we
* couldn't compress and didn't copy anything. * couldn't compress and didn't copy anything.
*/ */
@ -577,12 +620,13 @@ the_end:
*out_len = 0; *out_len = 0;
return LZO_E_NOT_COMPRESSIBLE; return LZO_E_NOT_COMPRESSIBLE;
} }
#endif #endif
/* store the final literal run */ /* store the final literal run */
if (pd(in_end+DVAL_LEN,ii) > 0) if (pd(in_end + DVAL_LEN, ii) > 0)
op = store_run(op,ii,pd(in_end+DVAL_LEN,ii)); op = store_run(op, ii, pd(in_end + DVAL_LEN, ii));
*out_len = pd(op, out); *out_len = pd(op, out);
return 0; /* compression went ok */ return 0; /* compression went ok */
@ -594,9 +638,9 @@ the_end:
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1_compress ( const lzo_bytep in , lzo_uint in_len, lzo1_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
int r = LZO_E_OK; int r = LZO_E_OK;
@ -608,11 +652,11 @@ lzo1_compress ( const lzo_bytep in , lzo_uint in_len,
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
r = LZO_E_NOT_COMPRESSIBLE; r = LZO_E_NOT_COMPRESSIBLE;
#else #else
*out_len = pd(store_run(out,in,in_len), out); *out_len = pd(store_run(out, in, in_len), out);
#endif #endif
} }
else else
r = do_compress(in,in_len,out,out_len,wrkmem); r = do_compress(in, in_len, out, out_len, wrkmem);
return r; return r;
} }

View File

@ -46,10 +46,10 @@
************************************************************************/ ************************************************************************/
static int static int
_lzo1_do_compress ( const lzo_bytep in, lzo_uint in_len, _lzo1_do_compress(const lzo_bytep in, lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_compress_t func ) lzo_compress_t func)
{ {
int r; int r;
@ -65,12 +65,12 @@ _lzo1_do_compress ( const lzo_bytep in, lzo_uint in_len,
*out_len = 0; *out_len = 0;
r = LZO_E_NOT_COMPRESSIBLE; r = LZO_E_NOT_COMPRESSIBLE;
#else #else
*out_len = pd(STORE_RUN(out,in,in_len), out); *out_len = pd(STORE_RUN(out, in, in_len), out);
r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR; r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR;
#endif #endif
} }
else else
r = func(in,in_len,out,out_len,wrkmem); r = func(in, in_len, out, out_len, wrkmem);
return r; return r;
} }
@ -105,11 +105,11 @@ _lzo1_do_compress ( const lzo_bytep in, lzo_uint in_len,
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
LZO_COMPRESS ( const lzo_bytep in, lzo_uint in_len, LZO_COMPRESS(const lzo_bytep in, lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
return _lzo1_do_compress(in,in_len,out,out_len,wrkmem,do_compress); return _lzo1_do_compress(in, in_len, out, out_len, wrkmem, do_compress);
} }

View File

@ -105,7 +105,7 @@
#if !defined(LZO_EOF_CODE) && !defined(TEST_IP) #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
/* if we have no EOF code, we have to test for the end of the input */ /* if we have no EOF code, we have to test for the end of the input */
# define TEST_IP (ip < ip_end) # define TEST_IP (ip < ip_end)
#endif #endif

267
extern/lzo/src/lzo1a.c vendored
View File

@ -91,8 +91,8 @@
#if (LZO_COLLECT_STATS) #if (LZO_COLLECT_STATS)
static lzo1a_stats_t lzo_statistics; static lzo1a_stats_t lzo_statistics;
lzo1a_stats_t *lzo1a_stats = &lzo_statistics; lzo1a_stats_t* lzo1a_stats = &lzo_statistics;
# define lzo_stats lzo1a_stats # define lzo_stats lzo1a_stats
#endif #endif
@ -101,15 +101,17 @@
// get algorithm info, return memory required for compression // get algorithm info, return memory required for compression
************************************************************************/ ************************************************************************/
LZO_EXTERN(lzo_uint) lzo1a_info ( int *rbits, int *clevel ); LZO_EXTERN(lzo_uint) lzo1a_info(int* rbits, int* clevel);
LZO_PUBLIC(lzo_uint) LZO_PUBLIC(lzo_uint)
lzo1a_info ( int *rbits, int *clevel ) lzo1a_info(int* rbits, int* clevel)
{ {
if (rbits) if (rbits)
*rbits = RBITS; *rbits = RBITS;
if (clevel) if (clevel)
*clevel = CLEVEL; *clevel = CLEVEL;
return D_SIZE * lzo_sizeof(lzo_bytep); return D_SIZE * lzo_sizeof(lzo_bytep);
} }
@ -121,9 +123,9 @@ lzo1a_info ( int *rbits, int *clevel )
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1a_decompress ( const lzo_bytep in , lzo_uint in_len, lzo1a_decompress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
lzo_bytep op; lzo_bytep op;
const lzo_bytep ip; const lzo_bytep ip;
@ -135,6 +137,7 @@ lzo1a_decompress ( const lzo_bytep in , lzo_uint in_len,
op = out; op = out;
ip = in; ip = in;
while (ip < ip_end) while (ip < ip_end)
{ {
t = *ip++; /* get marker */ t = *ip++; /* get marker */
@ -143,9 +146,11 @@ lzo1a_decompress ( const lzo_bytep in , lzo_uint in_len,
if (t == 0) /* a R0 literal run */ if (t == 0) /* a R0 literal run */
{ {
t = *ip++; t = *ip++;
if (t >= R0FAST - R0MIN) /* a long R0 run */ if (t >= R0FAST - R0MIN) /* a long R0 run */
{ {
t -= R0FAST - R0MIN; t -= R0FAST - R0MIN;
if (t == 0) if (t == 0)
t = R0FAST; t = R0FAST;
else else
@ -155,33 +160,41 @@ lzo1a_decompress ( const lzo_bytep in , lzo_uint in_len,
#else #else
/* help the optimizer */ /* help the optimizer */
lzo_uint tt = 256; lzo_uint tt = 256;
do tt <<= 1; while (--t > 0);
do tt <<= 1;
while (--t > 0);
t = tt; t = tt;
#endif #endif
} }
MEMCPY8_DS(op,ip,t);
MEMCPY8_DS(op, ip, t);
continue; continue;
} }
t += R0MIN; t += R0MIN;
goto literal; goto literal;
} }
else if (t < R0MIN) /* a short literal run */ else if (t < R0MIN) /* a short literal run */
{ {
literal: literal:
MEMCPY_DS(op,ip,t); MEMCPY_DS(op, ip, t);
/* after a literal a match must follow */ /* after a literal a match must follow */
while (ip < ip_end) while (ip < ip_end)
{ {
t = *ip++; /* get R1 marker */ t = *ip++; /* get R1 marker */
if (t >= R0MIN) if (t >= R0MIN)
goto match; goto match;
/* R1 match - a context sensitive 3 byte match + 1 byte literal */ /* R1 match - a context sensitive 3 byte match + 1 byte literal */
assert((t & OMASK) == t); assert((t & OMASK) == t);
m_pos = op - MIN_OFFSET; m_pos = op - MIN_OFFSET;
m_pos -= t | (((lzo_uint) *ip++) << OBITS); m_pos -= t | (((lzo_uint) * ip++) << OBITS);
assert(m_pos >= out); assert(m_pos < op); assert(m_pos >= out);
assert(m_pos < op);
*op++ = m_pos[0]; *op++ = m_pos[0];
*op++ = m_pos[1]; *op++ = m_pos[1];
*op++ = m_pos[2]; *op++ = m_pos[2];
@ -193,8 +206,9 @@ literal:
match: match:
/* get match offset */ /* get match offset */
m_pos = op - MIN_OFFSET; m_pos = op - MIN_OFFSET;
m_pos -= (t & OMASK) | (((lzo_uint) *ip++) << OBITS); m_pos -= (t & OMASK) | (((lzo_uint) * ip++) << OBITS);
assert(m_pos >= out); assert(m_pos < op); assert(m_pos >= out);
assert(m_pos < op);
/* get match len */ /* get match len */
if (t < ((MSIZE - 1) << OBITS)) /* a short match */ if (t < ((MSIZE - 1) << OBITS)) /* a short match */
@ -202,7 +216,7 @@ match:
t >>= OBITS; t >>= OBITS;
*op++ = *m_pos++; *op++ = *m_pos++;
*op++ = *m_pos++; *op++ = *m_pos++;
MEMCPY_DS(op,m_pos,t); MEMCPY_DS(op, m_pos, t);
} }
else /* a long match */ else /* a long match */
{ {
@ -213,13 +227,16 @@ match:
#endif #endif
*op++ = *m_pos++; *op++ = *m_pos++;
*op++ = *m_pos++; *op++ = *m_pos++;
MEMCPY_DS(op,m_pos,t); MEMCPY_DS(op, m_pos, t);
#if (LBITS < 8) #if (LBITS < 8)
/* a very short literal following a long match */ /* a very short literal following a long match */
t = ip[-1] >> LBITS; t = ip[-1] >> LBITS;
if (t) do if (t) do
*op++ = *ip++; *op++ = *ip++;
while (--t);
while (--t);
#endif #endif
} }
} }
@ -229,7 +246,7 @@ match:
/* the next line is the only check in the decompressor */ /* the next line is the only check in the decompressor */
return (ip == ip_end ? LZO_E_OK : return (ip == ip_end ? LZO_E_OK :
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
} }
@ -243,9 +260,9 @@ match:
#include "lzo1a_cr.ch" #include "lzo1a_cr.ch"
static int static int
do_compress ( const lzo_bytep in , lzo_uint in_len, do_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
const lzo_bytep ip; const lzo_bytep ip;
#if defined(__LZO_HASH_INCREMENTAL) #if defined(__LZO_HASH_INCREMENTAL)
@ -253,8 +270,8 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
#endif #endif
const lzo_bytep m_pos; const lzo_bytep m_pos;
lzo_bytep op; lzo_bytep op;
const lzo_bytep const ip_end = in+in_len - DVAL_LEN - MIN_MATCH_LONG; const lzo_bytep const ip_end = in + in_len - DVAL_LEN - MIN_MATCH_LONG;
const lzo_bytep const in_end = in+in_len - DVAL_LEN; const lzo_bytep const in_end = in + in_len - DVAL_LEN;
const lzo_bytep ii; const lzo_bytep ii;
lzo_dict_p const dict = (lzo_dict_p) wrkmem; lzo_dict_p const dict = (lzo_dict_p) wrkmem;
const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */ const lzo_bytep r1 = ip_end; /* pointer for R1 match (none yet) */
@ -272,45 +289,56 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
/* init dictionary */ /* init dictionary */
#if (LZO_DETERMINISTIC) #if (LZO_DETERMINISTIC)
BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); BZERO8_PTR(wrkmem, sizeof(lzo_dict_t), D_SIZE);
#endif #endif
DVAL_FIRST(dv,ip); UPDATE_D(dict,0,dv,ip,in); ip++; DVAL_FIRST(dv, ip);
DVAL_NEXT(dv,ip); UPDATE_D(dict, 0, dv, ip, in);
ip++;
DVAL_NEXT(dv, ip);
do { do
{
LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0); LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
lzo_uint dindex; lzo_uint dindex;
DINDEX1(dindex,ip); DINDEX1(dindex, ip);
GINDEX(m_pos,m_off,dict,dindex,in); GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,MAX_OFFSET))
if (LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, MAX_OFFSET))
goto literal; goto literal;
if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2]) if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2])
goto match; goto match;
DINDEX2(dindex,ip);
GINDEX(m_pos,m_off,dict,dindex,in); DINDEX2(dindex, ip);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,MAX_OFFSET)) GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, MAX_OFFSET))
goto literal; goto literal;
if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2]) if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2])
goto match; goto match;
goto literal; goto literal;
literal: literal:
UPDATE_I(dict,0,dindex,ip,in); UPDATE_I(dict, 0, dindex, ip, in);
if (++ip >= ip_end) if (++ip >= ip_end)
break; break;
continue; continue;
match: match:
UPDATE_I(dict,0,dindex,ip,in); UPDATE_I(dict, 0, dindex, ip, in);
#if !defined(NDEBUG) && (LZO_DICT_USE_PTR) #if !defined(NDEBUG) && (LZO_DICT_USE_PTR)
assert(m_pos == NULL || m_pos >= in); assert(m_pos == NULL || m_pos >= in);
m_pos_sav = m_pos; m_pos_sav = m_pos;
#endif #endif
m_pos += 3; m_pos += 3;
{ {
/* we have found a match (of at least length 3) */ /* we have found a match (of at least length 3) */
#if !defined(NDEBUG) && !(LZO_DICT_USE_PTR) #if !defined(NDEBUG) && !(LZO_DICT_USE_PTR)
assert((m_pos_sav = ip - m_off) == (m_pos - 3)); assert((m_pos_sav = ip - m_off) == (m_pos - 3));
@ -320,22 +348,22 @@ match:
assert(ip < ip_end); assert(ip < ip_end);
/* 1) store the current literal run */ /* 1) store the current literal run */
if (pd(ip,ii) > 0) if (pd(ip, ii) > 0)
{ {
lzo_uint t = pd(ip,ii); lzo_uint t = pd(ip, ii);
if (ip - r1 == MIN_MATCH + 1) if (ip - r1 == MIN_MATCH + 1)
{ {
/* Code a context sensitive R1 match. /* Code a context sensitive R1 match.
* This is tricky and somewhat difficult to explain: * This is tricky and somewhat difficult to explain:
* multiplex a literal run of length 1 into the previous * multiplex a literal run of length 1 into the previous
* short match of length MIN_MATCH. * short match of length MIN_MATCH.
* The key idea is: * The key idea is:
* - after a short run a match MUST follow * - after a short run a match MUST follow
* - therefore the value m = 000 in the mmmooooo marker is free * - therefore the value m = 000 in the mmmooooo marker is free
* - use 000ooooo to indicate a MIN_MATCH match (this * - use 000ooooo to indicate a MIN_MATCH match (this
* is already coded) plus a 1 byte literal * is already coded) plus a 1 byte literal
*/ */
assert(t == 1); assert(t == 1);
/* modify marker byte */ /* modify marker byte */
assert((op[-2] >> OBITS) == (MIN_MATCH - THRESHOLD)); assert((op[-2] >> OBITS) == (MIN_MATCH - THRESHOLD));
@ -350,11 +378,11 @@ match:
{ {
/* inline the copying of a short run */ /* inline the copying of a short run */
#if (LBITS < 8) #if (LBITS < 8)
if (t < (1 << (8-LBITS)) && ii - im >= MIN_MATCH_LONG) if (t < (1 << (8 - LBITS)) && ii - im >= MIN_MATCH_LONG)
{ {
/* Code a very short literal run into the /* Code a very short literal run into the
* previous long match length byte. * previous long match length byte.
*/ */
LZO_STATS(lzo_stats->lit_runs_after_long_match++); LZO_STATS(lzo_stats->lit_runs_after_long_match++);
LZO_STATS(lzo_stats->lit_run_after_long_match[t]++); LZO_STATS(lzo_stats->lit_run_after_long_match[t]++);
assert(ii - im <= MAX_MATCH_LONG); assert(ii - im <= MAX_MATCH_LONG);
@ -376,13 +404,15 @@ match:
{ {
/* inline the copying of a short R0 run */ /* inline the copying of a short R0 run */
LZO_STATS(lzo_stats->r0short_runs++); LZO_STATS(lzo_stats->r0short_runs++);
*op++ = 0; *op++ = LZO_BYTE(t - R0MIN); *op++ = 0;
*op++ = LZO_BYTE(t - R0MIN);
MEMCPY_DS(op, ii, t); MEMCPY_DS(op, ii, t);
r1 = ip; /* set new R1 pointer */ r1 = ip; /* set new R1 pointer */
} }
else else
op = store_run(op,ii,t); op = store_run(op, ii, t);
} }
#if (LBITS < 8) #if (LBITS < 8)
im = ip; im = ip;
#endif #endif
@ -402,37 +432,38 @@ match:
#define PS *m_pos++ != *ip++ #define PS *m_pos++ != *ip++
#if (MIN_MATCH_LONG - MIN_MATCH == 2) /* MBITS == 2 */ #if (MIN_MATCH_LONG - MIN_MATCH == 2) /* MBITS == 2 */
if (PS || PS) if (PS || PS)
#elif (MIN_MATCH_LONG - MIN_MATCH == 6) /* MBITS == 3 */ #elif (MIN_MATCH_LONG - MIN_MATCH == 6) /* MBITS == 3 */
if (PS || PS || PS || PS || PS || PS) if (PS || PS || PS || PS || PS || PS)
#elif (MIN_MATCH_LONG - MIN_MATCH == 14) /* MBITS == 4 */ #elif (MIN_MATCH_LONG - MIN_MATCH == 14) /* MBITS == 4 */
if (PS || PS || PS || PS || PS || PS || PS || if (PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS || PS) PS || PS || PS || PS || PS || PS || PS)
#elif (MIN_MATCH_LONG - MIN_MATCH == 30) /* MBITS == 5 */ #elif (MIN_MATCH_LONG - MIN_MATCH == 30) /* MBITS == 5 */
if (PS || PS || PS || PS || PS || PS || PS || PS || if (PS || PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS || PS ||
PS || PS || PS || PS || PS || PS) PS || PS || PS || PS || PS || PS)
#else #else
# error "MBITS not yet implemented" # error "MBITS not yet implemented"
#endif #endif
{ {
/* we've found a short match */ /* we've found a short match */
lzo_uint m_len; lzo_uint m_len;
/* 2a) compute match parameters */ /* 2a) compute match parameters */
assert(ip-m_pos == (int)m_off); assert(ip - m_pos == (int)m_off);
--ip; /* ran one too far, point back to non-match */ --ip; /* ran one too far, point back to non-match */
m_len = pd(ip, ii); m_len = pd(ip, ii);
assert(m_len >= MIN_MATCH_SHORT); assert(m_len >= MIN_MATCH_SHORT);
assert(m_len <= MAX_MATCH_SHORT); assert(m_len <= MAX_MATCH_SHORT);
assert(m_off >= MIN_OFFSET); assert(m_off >= MIN_OFFSET);
assert(m_off <= MAX_OFFSET); assert(m_off <= MAX_OFFSET);
assert(ii-m_off == m_pos_sav); assert(ii - m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0); assert(lzo_memcmp(m_pos_sav, ii, m_len) == 0);
m_off -= MIN_OFFSET; m_off -= MIN_OFFSET;
/* 2b) code a short match */ /* 2b) code a short match */
/* code short match len + low offset bits */ /* code short match len + low offset bits */
*op++ = LZO_BYTE(((m_len - THRESHOLD) << OBITS) | *op++ = LZO_BYTE(((m_len - THRESHOLD) << OBITS) |
(m_off & OMASK)); (m_off & OMASK));
@ -443,50 +474,58 @@ match:
#if (LZO_COLLECT_STATS) #if (LZO_COLLECT_STATS)
lzo_stats->short_matches++; lzo_stats->short_matches++;
lzo_stats->short_match[m_len]++; lzo_stats->short_match[m_len]++;
if (m_off < OSIZE) if (m_off < OSIZE)
lzo_stats->short_match_offset_osize[m_len]++; lzo_stats->short_match_offset_osize[m_len]++;
if (m_off < 256) if (m_off < 256)
lzo_stats->short_match_offset_256[m_len]++; lzo_stats->short_match_offset_256[m_len]++;
if (m_off < 1024) if (m_off < 1024)
lzo_stats->short_match_offset_1024[m_len]++; lzo_stats->short_match_offset_1024[m_len]++;
#endif #endif
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */ /* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
#define SI /* nothing */ #define SI /* nothing */
#define DI ++ii; DVAL_NEXT(dv,ii); UPDATE_D(dict,0,dv,ii,in); #define DI ++ii; DVAL_NEXT(dv,ii); UPDATE_D(dict,0,dv,ii,in);
#define XI assert(ii < ip); ii = ip; DVAL_FIRST(dv,(ip)); #define XI assert(ii < ip); ii = ip; DVAL_FIRST(dv,(ip));
#if (CLEVEL == 9) || (CLEVEL >= 7 && MBITS <= 4) || (CLEVEL >= 5 && MBITS <= 3) #if (CLEVEL == 9) || (CLEVEL >= 7 && MBITS <= 4) || (CLEVEL >= 5 && MBITS <= 3)
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */ /* Insert the whole match (ii+1)..(ip-1) into dictionary. */
++ii; ++ii;
do {
DVAL_NEXT(dv,ii); do
UPDATE_D(dict,0,dv,ii,in); {
} while (++ii < ip); DVAL_NEXT(dv, ii);
DVAL_NEXT(dv,ii); UPDATE_D(dict, 0, dv, ii, in);
}
while (++ii < ip);
DVAL_NEXT(dv, ii);
assert(ii == ip); assert(ii == ip);
DVAL_ASSERT(dv,ip); DVAL_ASSERT(dv, ip);
#elif (CLEVEL >= 3) #elif (CLEVEL >= 3)
SI DI DI XI SI DI DI XI
#elif (CLEVEL >= 2) #elif (CLEVEL >= 2)
SI DI XI SI DI XI
#else #else
XI XI
#endif #endif
} }
else else
{ {
/* we've found a long match - see how far we can still go */ /* we've found a long match - see how far we can still go */
const lzo_bytep end; const lzo_bytep end;
lzo_uint m_len; lzo_uint m_len;
assert(ip <= in_end); assert(ip <= in_end);
assert(ii == ip - MIN_MATCH_LONG); assert(ii == ip - MIN_MATCH_LONG);
if (pd(in_end,ip) <= (MAX_MATCH_LONG - MIN_MATCH_LONG)) if (pd(in_end, ip) <= (MAX_MATCH_LONG - MIN_MATCH_LONG))
end = in_end; end = in_end;
else else
{ {
@ -496,20 +535,21 @@ match:
while (ip < end && *m_pos == *ip) while (ip < end && *m_pos == *ip)
m_pos++, ip++; m_pos++, ip++;
assert(ip <= in_end); assert(ip <= in_end);
/* 2a) compute match parameters */ /* 2a) compute match parameters */
m_len = pd(ip, ii); m_len = pd(ip, ii);
assert(m_len >= MIN_MATCH_LONG); assert(m_len >= MIN_MATCH_LONG);
assert(m_len <= MAX_MATCH_LONG); assert(m_len <= MAX_MATCH_LONG);
assert(m_off >= MIN_OFFSET); assert(m_off >= MIN_OFFSET);
assert(m_off <= MAX_OFFSET); assert(m_off <= MAX_OFFSET);
assert(ii-m_off == m_pos_sav); assert(ii - m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0); assert(lzo_memcmp(m_pos_sav, ii, m_len) == 0);
assert(pd(ip,m_pos) == m_off); assert(pd(ip, m_pos) == m_off);
m_off -= MIN_OFFSET; m_off -= MIN_OFFSET;
/* 2b) code the long match */ /* 2b) code the long match */
/* code long match flag + low offset bits */ /* code long match flag + low offset bits */
*op++ = LZO_BYTE(((MSIZE - 1) << OBITS) | (m_off & OMASK)); *op++ = LZO_BYTE(((MSIZE - 1) << OBITS) | (m_off & OMASK));
/* code high offset bits */ /* code high offset bits */
@ -524,18 +564,22 @@ match:
#endif #endif
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */ /* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
#if (CLEVEL == 9) #if (CLEVEL == 9)
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */ /* Insert the whole match (ii+1)..(ip-1) into dictionary. */
/* This is not recommended because it is slow. */ /* This is not recommended because it is slow. */
++ii; ++ii;
do {
DVAL_NEXT(dv,ii); do
UPDATE_D(dict,0,dv,ii,in); {
} while (++ii < ip); DVAL_NEXT(dv, ii);
DVAL_NEXT(dv,ii); UPDATE_D(dict, 0, dv, ii, in);
}
while (++ii < ip);
DVAL_NEXT(dv, ii);
assert(ii == ip); assert(ii == ip);
DVAL_ASSERT(dv,ip); DVAL_ASSERT(dv, ip);
#elif (CLEVEL >= 8) #elif (CLEVEL >= 8)
SI DI DI DI DI DI DI DI DI XI SI DI DI DI DI DI DI DI DI XI
#elif (CLEVEL >= 7) #elif (CLEVEL >= 7)
@ -551,7 +595,7 @@ match:
#elif (CLEVEL >= 2) #elif (CLEVEL >= 2)
SI DI XI SI DI XI
#else #else
XI XI
#endif #endif
} }
@ -559,12 +603,14 @@ match:
assert(ii == ip); assert(ii == ip);
} }
} while (ip < ip_end); }
while (ip < ip_end);
assert(ip <= in_end); assert(ip <= in_end);
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
/* return -1 if op == out to indicate that we /* return -1 if op == out to indicate that we
* couldn't compress and didn't copy anything. * couldn't compress and didn't copy anything.
*/ */
@ -573,11 +619,12 @@ match:
*out_len = 0; *out_len = 0;
return LZO_E_NOT_COMPRESSIBLE; return LZO_E_NOT_COMPRESSIBLE;
} }
#endif #endif
/* store the final literal run */ /* store the final literal run */
if (pd(in_end+DVAL_LEN,ii) > 0) if (pd(in_end + DVAL_LEN, ii) > 0)
op = store_run(op,ii,pd(in_end+DVAL_LEN,ii)); op = store_run(op, ii, pd(in_end + DVAL_LEN, ii));
*out_len = pd(op, out); *out_len = pd(op, out);
return 0; /* compression went ok */ return 0; /* compression went ok */
@ -589,15 +636,15 @@ match:
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1a_compress ( const lzo_bytep in , lzo_uint in_len, lzo1a_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
int r = LZO_E_OK; int r = LZO_E_OK;
#if (LZO_COLLECT_STATS) #if (LZO_COLLECT_STATS)
lzo_memset(lzo_stats,0,sizeof(*lzo_stats)); lzo_memset(lzo_stats, 0, sizeof(*lzo_stats));
lzo_stats->rbits = RBITS; lzo_stats->rbits = RBITS;
lzo_stats->clevel = CLEVEL; lzo_stats->clevel = CLEVEL;
lzo_stats->dbits = DBITS; lzo_stats->dbits = DBITS;
@ -623,11 +670,11 @@ lzo1a_compress ( const lzo_bytep in , lzo_uint in_len,
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
r = LZO_E_NOT_COMPRESSIBLE; r = LZO_E_NOT_COMPRESSIBLE;
#else #else
*out_len = pd(store_run(out,in,in_len), out); *out_len = pd(store_run(out, in, in_len), out);
#endif #endif
} }
else else
r = do_compress(in,in_len,out,out_len,wrkmem); r = do_compress(in, in_len, out, out_len, wrkmem);
#if (LZO_COLLECT_STATS) #if (LZO_COLLECT_STATS)

View File

@ -46,10 +46,10 @@
************************************************************************/ ************************************************************************/
static int static int
_lzo1a_do_compress ( const lzo_bytep in, lzo_uint in_len, _lzo1a_do_compress(const lzo_bytep in, lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_compress_t func ) lzo_compress_t func)
{ {
int r; int r;
@ -65,12 +65,12 @@ _lzo1a_do_compress ( const lzo_bytep in, lzo_uint in_len,
*out_len = 0; *out_len = 0;
r = LZO_E_NOT_COMPRESSIBLE; r = LZO_E_NOT_COMPRESSIBLE;
#else #else
*out_len = pd(STORE_RUN(out,in,in_len), out); *out_len = pd(STORE_RUN(out, in, in_len), out);
r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR; r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR;
#endif #endif
} }
else else
r = func(in,in_len,out,out_len,wrkmem); r = func(in, in_len, out, out_len, wrkmem);
return r; return r;
} }
@ -105,11 +105,11 @@ _lzo1a_do_compress ( const lzo_bytep in, lzo_uint in_len,
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
LZO_COMPRESS ( const lzo_bytep in, lzo_uint in_len, LZO_COMPRESS(const lzo_bytep in, lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
return _lzo1a_do_compress(in,in_len,out,out_len,wrkmem,do_compress); return _lzo1a_do_compress(in, in_len, out, out_len, wrkmem, do_compress);
} }

View File

@ -47,182 +47,191 @@
#if (DD_BITS == 0) #if (DD_BITS == 0)
/* we already matched M2_MIN_LEN bytes, /* we already matched M2_MIN_LEN bytes,
* m_pos also already advanced M2_MIN_LEN bytes */ * m_pos also already advanced M2_MIN_LEN bytes */
ip += M2_MIN_LEN; ip += M2_MIN_LEN;
assert(m_pos < ip); assert(m_pos < ip);
/* try to match another M2_MAX_LEN + 1 - M2_MIN_LEN bytes /* try to match another M2_MAX_LEN + 1 - M2_MIN_LEN bytes
* to see if we get more than a M2 match */ * to see if we get more than a M2 match */
#define M2_OR_M3 (MATCH_M2) #define M2_OR_M3 (MATCH_M2)
#else /* (DD_BITS == 0) */ #else /* (DD_BITS == 0) */
/* we already matched m_len bytes */ /* we already matched m_len bytes */
assert(m_len >= M2_MIN_LEN); assert(m_len >= M2_MIN_LEN);
ip += m_len; ip += m_len;
assert(ip <= in_end); assert(ip <= in_end);
#define M2_OR_M3 (m_len <= M2_MAX_LEN) #define M2_OR_M3 (m_len <= M2_MAX_LEN)
#endif /* (DD_BITS == 0) */ #endif /* (DD_BITS == 0) */
if (M2_OR_M3) if (M2_OR_M3)
{ {
/* we've found a short match */ /* we've found a short match */
assert(ip <= in_end); assert(ip <= in_end);
/* 2a) compute match parameters */ /* 2a) compute match parameters */
#if (DD_BITS == 0) #if (DD_BITS == 0)
assert(pd(ip,m_pos) == m_off); assert(pd(ip, m_pos) == m_off);
--ip; /* ran one too far, point back to non-match */ --ip; /* ran one too far, point back to non-match */
m_len = ip - ii; m_len = ip - ii;
#endif #endif
assert(m_len >= M2_MIN_LEN); assert(m_len >= M2_MIN_LEN);
assert(m_len <= M2_MAX_LEN); assert(m_len <= M2_MAX_LEN);
assert(m_off >= M2_MIN_OFFSET); assert(m_off >= M2_MIN_OFFSET);
assert(m_off <= M2_MAX_OFFSET); assert(m_off <= M2_MAX_OFFSET);
assert(ii-m_off == m_pos_sav); assert(ii - m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0); assert(lzo_memcmp(m_pos_sav, ii, m_len) == 0);
/* 2b) code the match */ /* 2b) code the match */
m_off -= M2_MIN_OFFSET; m_off -= M2_MIN_OFFSET;
/* code short match len + low offset bits */ /* code short match len + low offset bits */
*op++ = LZO_BYTE(((m_len - THRESHOLD) << M2O_BITS) | *op++ = LZO_BYTE(((m_len - THRESHOLD) << M2O_BITS) |
(m_off & M2O_MASK)); (m_off & M2O_MASK));
/* code high offset bits */ /* code high offset bits */
*op++ = LZO_BYTE(m_off >> M2O_BITS); *op++ = LZO_BYTE(m_off >> M2O_BITS);
if (ip >= ip_end) if (ip >= ip_end)
{ {
ii = ip; ii = ip;
break; break;
} }
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */ /* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
#if (CLEVEL == 9) || (CLEVEL >= 7 && M2L_BITS <= 4) || (CLEVEL >= 5 && M2L_BITS <= 3) #if (CLEVEL == 9) || (CLEVEL >= 7 && M2L_BITS <= 4) || (CLEVEL >= 5 && M2L_BITS <= 3)
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */ /* Insert the whole match (ii+1)..(ip-1) into dictionary. */
++ii; ++ii;
do {
DVAL_NEXT(dv,ii); do
{
DVAL_NEXT(dv, ii);
#if 0 #if 0
UPDATE_D(dict,drun,dv,ii,in); UPDATE_D(dict, drun, dv, ii, in);
#else #else
dict[ DINDEX(dv,ii) ] = DENTRY(ii,in); dict[ DINDEX(dv, ii) ] = DENTRY(ii, in);
#endif #endif
MI MI
} while (++ii < ip); }
DVAL_NEXT(dv,ii); while (++ii < ip);
assert(ii == ip);
DVAL_ASSERT(dv,ip); DVAL_NEXT(dv, ii);
assert(ii == ip);
DVAL_ASSERT(dv, ip);
#elif (CLEVEL >= 3) #elif (CLEVEL >= 3)
SI DI DI XI SI DI DI XI
#elif (CLEVEL >= 2) #elif (CLEVEL >= 2)
SI DI XI SI DI XI
#else #else
XI XI
#endif #endif
} }
else else
{ {
/* we've found a long match - see how far we can still go */ /* we've found a long match - see how far we can still go */
const lzo_bytep end; const lzo_bytep end;
assert(ip <= in_end); assert(ip <= in_end);
assert(ii == ip - (M2_MAX_LEN + 1)); assert(ii == ip - (M2_MAX_LEN + 1));
assert(lzo_memcmp(m_pos_sav,ii,(lzo_uint)(ip-ii)) == 0); assert(lzo_memcmp(m_pos_sav, ii, (lzo_uint)(ip - ii)) == 0);
#if (DD_BITS > 0) #if (DD_BITS > 0)
assert(m_len == (lzo_uint)(ip-ii)); assert(m_len == (lzo_uint)(ip - ii));
m_pos = ip - m_off; m_pos = ip - m_off;
assert(m_pos == m_pos_sav + m_len); assert(m_pos == m_pos_sav + m_len);
#endif #endif
if (pd(in_end,ip) <= (M3_MAX_LEN - M3_MIN_LEN)) if (pd(in_end, ip) <= (M3_MAX_LEN - M3_MIN_LEN))
end = in_end; end = in_end;
else else
{ {
end = ip + (M3_MAX_LEN - M3_MIN_LEN); end = ip + (M3_MAX_LEN - M3_MIN_LEN);
assert(end < in_end); assert(end < in_end);
} }
while (ip < end && *m_pos == *ip) while (ip < end && *m_pos == *ip)
m_pos++, ip++; m_pos++, ip++;
assert(ip <= in_end);
/* 2a) compute match parameters */ assert(ip <= in_end);
m_len = pd(ip, ii);
assert(m_len >= M3_MIN_LEN);
assert(m_len <= M3_MAX_LEN);
assert(m_off >= M3_MIN_OFFSET); /* 2a) compute match parameters */
assert(m_off <= M3_MAX_OFFSET); m_len = pd(ip, ii);
assert(ii-m_off == m_pos_sav); assert(m_len >= M3_MIN_LEN);
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0); assert(m_len <= M3_MAX_LEN);
assert(pd(ip,m_pos) == m_off);
/* 2b) code the match */ assert(m_off >= M3_MIN_OFFSET);
m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET; assert(m_off <= M3_MAX_OFFSET);
/* code long match flag + low offset bits */ assert(ii - m_off == m_pos_sav);
*op++ = LZO_BYTE(((MSIZE - 1) << M3O_BITS) | (m_off & M3O_MASK)); assert(lzo_memcmp(m_pos_sav, ii, m_len) == 0);
/* code high offset bits */ assert(pd(ip, m_pos) == m_off);
*op++ = LZO_BYTE(m_off >> M3O_BITS);
/* code match len */ /* 2b) code the match */
*op++ = LZO_BYTE(m_len - M3_MIN_LEN); m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET;
/* code long match flag + low offset bits */
*op++ = LZO_BYTE(((MSIZE - 1) << M3O_BITS) | (m_off & M3O_MASK));
/* code high offset bits */
*op++ = LZO_BYTE(m_off >> M3O_BITS);
/* code match len */
*op++ = LZO_BYTE(m_len - M3_MIN_LEN);
if (ip >= ip_end) if (ip >= ip_end)
{ {
ii = ip; ii = ip;
break; break;
} }
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */ /* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
#if (CLEVEL == 9) #if (CLEVEL == 9)
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */ /* Insert the whole match (ii+1)..(ip-1) into dictionary. */
/* This is not recommended because it can be slow. */ /* This is not recommended because it can be slow. */
++ii; ++ii;
do {
DVAL_NEXT(dv,ii);
#if 0
UPDATE_D(dict,drun,dv,ii,in);
#else
dict[ DINDEX(dv,ii) ] = DENTRY(ii,in);
#endif
MI
} while (++ii < ip);
DVAL_NEXT(dv,ii);
assert(ii == ip);
DVAL_ASSERT(dv,ip);
#elif (CLEVEL >= 8)
SI DI DI DI DI DI DI DI DI XI
#elif (CLEVEL >= 7)
SI DI DI DI DI DI DI DI XI
#elif (CLEVEL >= 6)
SI DI DI DI DI DI DI XI
#elif (CLEVEL >= 5)
SI DI DI DI DI XI
#elif (CLEVEL >= 4)
SI DI DI DI XI
#elif (CLEVEL >= 3)
SI DI DI XI
#elif (CLEVEL >= 2)
SI DI XI
#else
XI
#endif
}
/* ii now points to the start of the next literal run */ do
assert(ii == ip); {
DVAL_NEXT(dv, ii);
#if 0
UPDATE_D(dict, drun, dv, ii, in);
#else
dict[ DINDEX(dv, ii) ] = DENTRY(ii, in);
#endif
MI
}
while (++ii < ip);
DVAL_NEXT(dv, ii);
assert(ii == ip);
DVAL_ASSERT(dv, ip);
#elif (CLEVEL >= 8)
SI DI DI DI DI DI DI DI DI XI
#elif (CLEVEL >= 7)
SI DI DI DI DI DI DI DI XI
#elif (CLEVEL >= 6)
SI DI DI DI DI DI DI XI
#elif (CLEVEL >= 5)
SI DI DI DI DI XI
#elif (CLEVEL >= 4)
SI DI DI DI XI
#elif (CLEVEL >= 3)
SI DI DI XI
#elif (CLEVEL >= 2)
SI DI XI
#else
XI
#endif
}
/* ii now points to the start of the next literal run */
assert(ii == ip);
/* vim:set ts=4 sw=4 et: */ /* vim:set ts=4 sw=4 et: */

View File

@ -60,37 +60,48 @@ store_run(lzo_bytep const oo, const lzo_bytep const ii, lzo_uint r_len)
while (r_len >= (t = tt)) while (r_len >= (t = tt))
{ {
r_len -= t; r_len -= t;
*op++ = 0; *op++ = (R0MAX - R0MIN); *op++ = 0;
*op++ = (R0MAX - R0MIN);
MEMCPY8_DS(op, ip, t); MEMCPY8_DS(op, ip, t);
LZO_STATS(lzo_stats->r0long_runs++); LZO_STATS(lzo_stats->r0long_runs++);
} }
tt >>= 1; tt >>= 1;
do {
do
{
if (r_len >= (t = tt)) if (r_len >= (t = tt))
{ {
r_len -= t; r_len -= t;
*op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits); *op++ = 0;
*op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
MEMCPY8_DS(op, ip, t); MEMCPY8_DS(op, ip, t);
LZO_STATS(lzo_stats->r0long_runs++); LZO_STATS(lzo_stats->r0long_runs++);
} }
tt >>= 1; tt >>= 1;
} while (--r_bits > 0); }
while (--r_bits > 0);
} }
assert(r_len < 512); assert(r_len < 512);
while (r_len >= (t = R0FAST)) while (r_len >= (t = R0FAST))
{ {
r_len -= t; r_len -= t;
*op++ = 0; *op++ = (R0FAST - R0MIN); *op++ = 0;
*op++ = (R0FAST - R0MIN);
MEMCPY8_DS(op, ip, t); MEMCPY8_DS(op, ip, t);
LZO_STATS(lzo_stats->r0fast_runs++); LZO_STATS(lzo_stats->r0fast_runs++);
} }
t = r_len; t = r_len;
if (t >= R0MIN) if (t >= R0MIN)
{ {
/* code a short R0 run */ /* code a short R0 run */
*op++ = 0; *op++ = LZO_BYTE(t - R0MIN); *op++ = 0;
*op++ = LZO_BYTE(t - R0MIN);
MEMCPY_DS(op, ip, t); MEMCPY_DS(op, ip, t);
LZO_STATS(lzo_stats->r0short_runs++); LZO_STATS(lzo_stats->r0short_runs++);
} }

View File

@ -50,7 +50,7 @@
************************************************************************/ ************************************************************************/
static lzo_bytep static lzo_bytep
code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off ) code_match(LZO_COMPRESS_T* c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off)
{ {
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET)
{ {
@ -60,7 +60,7 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
m_off -= M2_MIN_OFFSET; m_off -= M2_MIN_OFFSET;
/* code match len + low offset bits */ /* code match len + low offset bits */
*op++ = LZO_BYTE(((m_len - (M2_MIN_LEN - 2)) << M2O_BITS) | *op++ = LZO_BYTE(((m_len - (M2_MIN_LEN - 2)) << M2O_BITS) |
(m_off & M2O_MASK)); (m_off & M2O_MASK));
/* code high offset bits */ /* code high offset bits */
*op++ = LZO_BYTE(m_off >> M2O_BITS); *op++ = LZO_BYTE(m_off >> M2O_BITS);
c->m2_m++; c->m2_m++;
@ -71,6 +71,7 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
assert(m_off <= M3_MAX_OFFSET); assert(m_off <= M3_MAX_OFFSET);
m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET; m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET;
/* code match len */ /* code match len */
if (m_len <= M3_MAX_LEN) if (m_len <= M3_MAX_LEN)
*op++ = LZO_BYTE(M3_MARKER | (m_len - (M3_MIN_LEN - 1))); *op++ = LZO_BYTE(M3_MARKER | (m_len - (M3_MIN_LEN - 1)));
@ -81,14 +82,17 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
*op++ = M4_MARKER; *op++ = M4_MARKER;
/* code match len */ /* code match len */
m_len -= M4_MIN_LEN - 1; m_len -= M4_MIN_LEN - 1;
while (m_len > 255) while (m_len > 255)
{ {
m_len -= 255; m_len -= 255;
*op++ = 0; *op++ = 0;
} }
assert(m_len > 0); assert(m_len > 0);
*op++ = LZO_BYTE(m_len); *op++ = LZO_BYTE(m_len);
} }
/* code low offset bits */ /* code low offset bits */
*op++ = LZO_BYTE(m_off & M3O_MASK); *op++ = LZO_BYTE(m_off & M3O_MASK);
/* code high offset bits */ /* code high offset bits */
@ -97,6 +101,7 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
c->r1_m_len = 0; c->r1_m_len = 0;
c->m3_m++; c->m3_m++;
} }
return op; return op;
} }
@ -106,25 +111,25 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len, lzo1b_999_compress_callback(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_callback_p cb, lzo_callback_p cb,
lzo_uint max_chain ); lzo_uint max_chain);
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len, lzo1b_999_compress_callback(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_callback_p cb, lzo_callback_p cb,
lzo_uint max_chain ) lzo_uint max_chain)
{ {
lzo_bytep op; lzo_bytep op;
const lzo_bytep ii; const lzo_bytep ii;
lzo_uint lit; lzo_uint lit;
lzo_uint m_len, m_off; lzo_uint m_len, m_off;
LZO_COMPRESS_T cc; LZO_COMPRESS_T cc;
LZO_COMPRESS_T * const c = &cc; LZO_COMPRESS_T* const c = &cc;
lzo_swd_p const swd = (lzo_swd_p) wrkmem; lzo_swd_p const swd = (lzo_swd_p) wrkmem;
int r; int r;
@ -142,15 +147,19 @@ lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
lit = 0; lit = 0;
c->r1_m_len = 0; c->r1_m_len = 0;
r = init_match(c,swd,NULL,0,0); r = init_match(c, swd, NULL, 0, 0);
if (r != 0) if (r != 0)
return r; return r;
if (max_chain > 0) if (max_chain > 0)
swd->max_chain = max_chain; swd->max_chain = max_chain;
r = find_match(c,swd,0,0); r = find_match(c, swd, 0, 0);
if (r != 0) if (r != 0)
return r; return r;
while (c->look > 0) while (c->look > 0)
{ {
int lazy_match_min_gain = -1; int lazy_match_min_gain = -1;
@ -160,18 +169,20 @@ lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
m_off = c->m_off; m_off = c->m_off;
#if 0 #if 0
printf("%5ld: %5d len:%3d off:%5d\n", (c->ip-c->look)-in, c->look, printf("%5ld: %5d len:%3d off:%5d\n", (c->ip - c->look) - in, c->look,
m_len, m_off); m_len, m_off);
#endif #endif
assert(c->ip - c->look >= in); assert(c->ip - c->look >= in);
if (lit == 0) if (lit == 0)
ii = c->ip - c->look; ii = c->ip - c->look;
assert(ii + lit == c->ip - c->look); assert(ii + lit == c->ip - c->look);
assert(swd->b_char == *(c->ip - c->look)); assert(swd->b_char == *(c->ip - c->look));
if ((m_len < M2_MIN_LEN) || if ((m_len < M2_MIN_LEN) ||
(m_len < M3_MIN_LEN && m_off > M2_MAX_OFFSET)) (m_len < M3_MIN_LEN && m_off > M2_MAX_OFFSET))
{ {
m_len = 0; m_len = 0;
} }
@ -192,20 +203,24 @@ lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
lazy_match_min_gain = 1; lazy_match_min_gain = 1;
#if (M2_MIN_LEN == 2) #if (M2_MIN_LEN == 2)
if (m_len == 2) if (m_len == 2)
{ {
/* don't code a match of len 2 if we have to /* don't code a match of len 2 if we have to
code a literal run. Code a literal instead. */ code a literal run. Code a literal instead. */
m_len = 0; m_len = 0;
} }
#endif #endif
#if (M2_MIN_LEN == M3_MIN_LEN) #if (M2_MIN_LEN == M3_MIN_LEN)
if (m_len == M2_MIN_LEN && m_off > M2_MAX_OFFSET) if (m_len == M2_MIN_LEN && m_off > M2_MAX_OFFSET)
{ {
/* don't code a M3 match of len 3 if we have to /* don't code a M3 match of len 3 if we have to
code a literal run. Code a literal instead. */ code a literal run. Code a literal instead. */
m_len = 0; m_len = 0;
} }
#endif #endif
} }
else else
@ -223,16 +238,18 @@ lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
/* try a lazy match */ /* try a lazy match */
if (m_len == 0) if (m_len == 0)
lazy_match_min_gain = -1; lazy_match_min_gain = -1;
if (lazy_match_min_gain >= 0 && c->look > m_len) if (lazy_match_min_gain >= 0 && c->look > m_len)
{ {
assert(m_len > 0); assert(m_len > 0);
r = find_match(c,swd,1,0); r = find_match(c, swd, 1, 0);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
assert(c->look > 0); assert(c->look > 0);
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET && if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET &&
c->m_off > M2_MAX_OFFSET) c->m_off > M2_MAX_OFFSET)
lazy_match_min_gain += 1; lazy_match_min_gain += 1;
if (c->m_len >= m_len + lazy_match_min_gain) if (c->m_len >= m_len + lazy_match_min_gain)
@ -253,8 +270,10 @@ lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
ahead = 1; ahead = 1;
assert(ii + lit + 1 == c->ip - c->look); assert(ii + lit + 1 == c->ip - c->look);
} }
assert(m_len > 0); assert(m_len > 0);
} }
assert(ii + lit + ahead == c->ip - c->look); assert(ii + lit + ahead == c->ip - c->look);
@ -262,8 +281,9 @@ lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
{ {
/* a literal */ /* a literal */
lit++; lit++;
r = find_match(c,swd,1,0); r = find_match(c, swd, 1, 0);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
} }
else else
{ {
@ -284,21 +304,24 @@ lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
} }
else else
{ {
op = STORE_RUN(op,ii,lit); op = STORE_RUN(op, ii, lit);
} }
if (lit < R0FAST) if (lit < R0FAST)
c->r1_m_len = m_len; c->r1_m_len = m_len;
else else
c->r1_m_len = 0; c->r1_m_len = 0;
lit = 0; lit = 0;
} }
else else
c->r1_m_len = 0; c->r1_m_len = 0;
/* 2 - code match */ /* 2 - code match */
op = code_match(c,op,m_len,m_off); op = code_match(c, op, m_len, m_off);
r = find_match(c,swd,m_len,1+ahead); r = find_match(c, swd, m_len, 1 + ahead);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
} }
c->codesize = pd(op, out); c->codesize = pd(op, out);
@ -307,7 +330,7 @@ lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
/* store final run */ /* store final run */
if (lit > 0) if (lit > 0)
op = STORE_RUN(op,ii,lit); op = STORE_RUN(op, ii, lit);
#if defined(LZO_EOF_CODE) #if defined(LZO_EOF_CODE)
*op++ = M3_MARKER | 1; *op++ = M3_MARKER | 1;
@ -325,8 +348,8 @@ lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
#if 0 #if 0
printf("%ld %ld -> %ld: %ld %ld %ld %ld %ld\n", printf("%ld %ld -> %ld: %ld %ld %ld %ld %ld\n",
(long) c->textsize, (long)in_len, (long) c->codesize, (long) c->textsize, (long)in_len, (long) c->codesize,
c->r1_r, c->m3_r, c->m2_m, c->m3_m, c->lazy); c->r1_r, c->m3_r, c->m2_m, c->m3_m, c->lazy);
#endif #endif
return LZO_E_OK; return LZO_E_OK;
} }
@ -338,11 +361,11 @@ lzo1b_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1b_999_compress ( const lzo_bytep in , lzo_uint in_len, lzo1b_999_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
return lzo1b_999_compress_callback(in,in_len,out,out_len,wrkmem, return lzo1b_999_compress_callback(in, in_len, out, out_len, wrkmem,
(lzo_callback_p) 0, 0); (lzo_callback_p) 0, 0);
} }

View File

@ -63,9 +63,9 @@
extern "C" { extern "C" {
#endif #endif
LZO_PRIVATE(int) LZO_PRIVATE(int)
do_compress ( const lzo_bytep in , lzo_uint in_len, do_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
const lzo_bytep ip; const lzo_bytep ip;
#if (DD_BITS > 0) #if (DD_BITS > 0)
@ -101,7 +101,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
/* init dictionary */ /* init dictionary */
#if (LZO_DETERMINISTIC) #if (LZO_DETERMINISTIC)
BZERO8_PTR(wrkmem,sizeof(lzo_dict_t),D_SIZE); BZERO8_PTR(wrkmem, sizeof(lzo_dict_t), D_SIZE);
#endif #endif
@ -111,15 +111,16 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
#if (DD_BITS > 0) #if (DD_BITS > 0)
DVAL_FIRST(dv,ip); DVAL_FIRST(dv, ip);
UPDATE_D(dict,drun,dv,ip,in); UPDATE_D(dict, drun, dv, ip, in);
ip++; ip++;
DVAL_NEXT(dv,ip); DVAL_NEXT(dv, ip);
#else #else
ip++; ip++;
#endif #endif
assert(ip < ip_end); assert(ip < ip_end);
for (;;) for (;;)
{ {
const lzo_bytep m_pos; const lzo_bytep m_pos;
@ -133,9 +134,9 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
lzo_uint m_len; lzo_uint m_len;
/*********************************************************************** /***********************************************************************
// search for a match // search for a match
************************************************************************/ ************************************************************************/
#if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE) #if !defined(LZO_SEARCH_MATCH_INCLUDE_FILE)
# define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch" # define LZO_SEARCH_MATCH_INCLUDE_FILE "lzo1b_sm.ch"
@ -152,32 +153,34 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
/*********************************************************************** /***********************************************************************
// found a literal // found a literal
************************************************************************/ ************************************************************************/
/* a literal */ /* a literal */
literal: literal:
#if (DD_BITS == 0) #if (DD_BITS == 0)
UPDATE_I(dict,0,dindex,ip,in); UPDATE_I(dict, 0, dindex, ip, in);
#endif #endif
if (++ip >= ip_end) if (++ip >= ip_end)
break; break;
#if (DD_BITS > 0) #if (DD_BITS > 0)
DVAL_NEXT(dv,ip); DVAL_NEXT(dv, ip);
#endif #endif
continue; continue;
/*********************************************************************** /***********************************************************************
// found a match // found a match
************************************************************************/ ************************************************************************/
match: match:
#if (DD_BITS == 0) #if (DD_BITS == 0)
UPDATE_I(dict,0,dindex,ip,in); UPDATE_I(dict, 0, dindex, ip, in);
#endif #endif
/* we have found a match of at least M2_MIN_LEN */ /* we have found a match of at least M2_MIN_LEN */
@ -193,9 +196,9 @@ match:
assert(ii == ip); assert(ii == ip);
/*********************************************************************** /***********************************************************************
// code the match // code the match
************************************************************************/ ************************************************************************/
#if !defined(LZO_CODE_MATCH_INCLUDE_FILE) #if !defined(LZO_CODE_MATCH_INCLUDE_FILE)
# define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch" # define LZO_CODE_MATCH_INCLUDE_FILE "lzo1b_cm.ch"
@ -210,9 +213,9 @@ match:
} }
/*********************************************************************** /***********************************************************************
// end of block // end of block
************************************************************************/ ************************************************************************/
assert(ip <= in_end); assert(ip <= in_end);
@ -224,9 +227,11 @@ match:
for (i = 0; i < D_SIZE; i++) for (i = 0; i < D_SIZE; i++)
{ {
p = dict[i]; p = dict[i];
if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end)) if (BOUNDS_CHECKING_OFF_IN_EXPR(p == NULL || p < in || p > in_end))
lzo_stats->unused_dict_entries++; lzo_stats->unused_dict_entries++;
} }
lzo_stats->unused_dict_entries_percent = lzo_stats->unused_dict_entries_percent =
100.0 * lzo_stats->unused_dict_entries / D_SIZE; 100.0 * lzo_stats->unused_dict_entries / D_SIZE;
} }
@ -234,6 +239,7 @@ match:
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE) #if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
/* return if op == out to indicate that we /* return if op == out to indicate that we
* couldn't compress and didn't copy anything. * couldn't compress and didn't copy anything.
*/ */
@ -242,13 +248,14 @@ match:
*out_len = 0; *out_len = 0;
return LZO_E_NOT_COMPRESSIBLE; return LZO_E_NOT_COMPRESSIBLE;
} }
#endif #endif
/* store the final literal run */ /* store the final literal run */
if (pd(in_end,ii) > 0) if (pd(in_end, ii) > 0)
{ {
lzo_uint t = pd(in_end,ii); lzo_uint t = pd(in_end, ii);
op = STORE_RUN(op,ii,t); op = STORE_RUN(op, ii, t);
} }
*out_len = pd(op, out); *out_len = pd(op, out);

View File

@ -35,10 +35,10 @@
************************************************************************/ ************************************************************************/
LZO_LOCAL_IMPL(int) LZO_LOCAL_IMPL(int)
_lzo1b_do_compress ( const lzo_bytep in, lzo_uint in_len, _lzo1b_do_compress(const lzo_bytep in, lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_compress_t func ) lzo_compress_t func)
{ {
int r; int r;
#if defined(LZO_TEST_COMPRESS_OVERRUN) #if defined(LZO_TEST_COMPRESS_OVERRUN)
@ -64,19 +64,22 @@ _lzo1b_do_compress ( const lzo_bytep in, lzo_uint in_len,
*out_len = 0; *out_len = 0;
r = LZO_E_NOT_COMPRESSIBLE; r = LZO_E_NOT_COMPRESSIBLE;
#else #else
*out_len = pd(STORE_RUN(out,in,in_len), out); *out_len = pd(STORE_RUN(out, in, in_len), out);
r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR; r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR;
#endif #endif
} }
else else
r = func(in,in_len,out,out_len,wrkmem); r = func(in, in_len, out, out_len, wrkmem);
#if defined(LZO_EOF_CODE) #if defined(LZO_EOF_CODE)
#if defined(LZO_TEST_COMPRESS_OVERRUN) #if defined(LZO_TEST_COMPRESS_OVERRUN)
if (r == LZO_E_OK && avail_out - *out_len < 3) if (r == LZO_E_OK && avail_out - *out_len < 3)
r = LZO_E_COMPRESS_OVERRUN; r = LZO_E_COMPRESS_OVERRUN;
#endif #endif
if (r == LZO_E_OK) if (r == LZO_E_OK)
{ {
lzo_bytep op = out + *out_len; lzo_bytep op = out + *out_len;
@ -85,14 +88,15 @@ _lzo1b_do_compress ( const lzo_bytep in, lzo_uint in_len,
op[2] = 0; op[2] = 0;
*out_len += 3; *out_len += 3;
} }
#endif #endif
#if (LZO_COLLECT_STATS) #if (LZO_COLLECT_STATS)
lzo_stats->out_len = *out_len; lzo_stats->out_len = *out_len;
lzo_stats->match_bytes = lzo_stats->match_bytes =
1 * lzo_stats->m1_matches + 2 * lzo_stats->m2_matches + 1 * lzo_stats->m1_matches + 2 * lzo_stats->m2_matches +
3 * lzo_stats->m3_matches + 4 * lzo_stats->m4_matches; 3 * lzo_stats->m3_matches + 4 * lzo_stats->m4_matches;
_lzo1b_stats_calc(lzo_stats); _lzo1b_stats_calc(lzo_stats);
#endif #endif
@ -112,30 +116,30 @@ _lzo1b_do_compress ( const lzo_bytep in, lzo_uint in_len,
#if (LZO_COLLECT_STATS) #if (LZO_COLLECT_STATS)
static lzo_stats_t lzo_statistics; static lzo_stats_t lzo_statistics;
lzo_stats_t * const lzo1b_stats = &lzo_statistics; lzo_stats_t* const lzo1b_stats = &lzo_statistics;
void _lzo1b_stats_init(lzo_stats_t *lzo_stats) void _lzo1b_stats_init(lzo_stats_t* lzo_stats)
{ {
lzo_memset(lzo_stats,0,sizeof(*lzo_stats)); lzo_memset(lzo_stats, 0, sizeof(*lzo_stats));
} }
void _lzo1b_stats_calc(lzo_stats_t *lzo_stats) void _lzo1b_stats_calc(lzo_stats_t* lzo_stats)
{ {
lzo_stats->matches = lzo_stats->matches =
lzo_stats->m1_matches + lzo_stats->m2_matches + lzo_stats->m1_matches + lzo_stats->m2_matches +
lzo_stats->m3_matches + lzo_stats->m4_matches; lzo_stats->m3_matches + lzo_stats->m4_matches;
lzo_stats->literal_overhead = lzo_stats->lit_runs + lzo_stats->literal_overhead = lzo_stats->lit_runs +
2 * (lzo_stats->r0short_runs + lzo_stats->r0fast_runs + 2 * (lzo_stats->r0short_runs + lzo_stats->r0fast_runs +
lzo_stats->r0long_runs); lzo_stats->r0long_runs);
lzo_stats->literal_bytes = lzo_stats->literals + lzo_stats->literal_bytes = lzo_stats->literals +
lzo_stats->literal_overhead; lzo_stats->literal_overhead;
#if 0 #if 0
assert(lzo_stats->match_bytes + lzo_stats->literal_bytes == assert(lzo_stats->match_bytes + lzo_stats->literal_bytes ==
lzo_stats->out_len); lzo_stats->out_len);
#endif #endif
lzo_stats->m2_matches -= lzo_stats->r1_matches; lzo_stats->m2_matches -= lzo_stats->r1_matches;
@ -143,7 +147,7 @@ void _lzo1b_stats_calc(lzo_stats_t *lzo_stats)
if (lzo_stats->literals > 0) if (lzo_stats->literals > 0)
lzo_stats->literal_overhead_percent = lzo_stats->literal_overhead_percent =
100.0 * lzo_stats->literal_overhead / lzo_stats->literals; 100.0 * lzo_stats->literal_overhead / lzo_stats->literals;
} }

View File

@ -57,18 +57,18 @@ extern const lzo_compress_t _lzo1b_99_compress_func;
// //
************************************************************************/ ************************************************************************/
LZO_LOCAL_DECL(lzo_bytep ) LZO_LOCAL_DECL(lzo_bytep)
_lzo1b_store_run ( lzo_bytep const oo, const lzo_bytep const ii, _lzo1b_store_run(lzo_bytep const oo, const lzo_bytep const ii,
lzo_uint r_len); lzo_uint r_len);
#define STORE_RUN _lzo1b_store_run #define STORE_RUN _lzo1b_store_run
LZO_LOCAL_DECL(int) LZO_LOCAL_DECL(int)
_lzo1b_do_compress ( const lzo_bytep in, lzo_uint in_len, _lzo1b_do_compress(const lzo_bytep in, lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_compress_t func ); lzo_compress_t func);
#endif /* already included */ #endif /* already included */

View File

@ -39,21 +39,21 @@
#if (DD_BITS == 0) #if (DD_BITS == 0)
/* we already matched M2_MIN_LEN bytes, /* we already matched M2_MIN_LEN bytes,
* m_pos also already advanced M2_MIN_LEN bytes */ * m_pos also already advanced M2_MIN_LEN bytes */
ip += M2_MIN_LEN; ip += M2_MIN_LEN;
assert(m_pos < ip); assert(m_pos < ip);
/* try to match another M2_MAX_LEN + 1 - M2_MIN_LEN bytes /* try to match another M2_MAX_LEN + 1 - M2_MIN_LEN bytes
* to see if we get more than a M2 match */ * to see if we get more than a M2 match */
#define M2_OR_M3 (MATCH_M2) #define M2_OR_M3 (MATCH_M2)
#else /* (DD_BITS == 0) */ #else /* (DD_BITS == 0) */
/* we already matched m_len bytes */ /* we already matched m_len bytes */
assert(m_len >= M2_MIN_LEN); assert(m_len >= M2_MIN_LEN);
ip += m_len; ip += m_len;
assert(ip <= in_end); assert(ip <= in_end);
#define M2_OR_M3 (m_len <= M2_MAX_LEN) #define M2_OR_M3 (m_len <= M2_MAX_LEN)
@ -61,220 +61,234 @@
if (M2_OR_M3) if (M2_OR_M3)
{ {
/* we've found a M2 or M3 match */ /* we've found a M2 or M3 match */
assert(ip <= in_end); assert(ip <= in_end);
/* 2a) compute match parameters */ /* 2a) compute match parameters */
#if (DD_BITS == 0) #if (DD_BITS == 0)
assert(pd(ip,m_pos) == m_off); assert(pd(ip, m_pos) == m_off);
--ip; /* ran one too far, point back to non-match */ --ip; /* ran one too far, point back to non-match */
m_len = pd(ip, ii); m_len = pd(ip, ii);
#endif #endif
/* 2a2) verify match parameters */ /* 2a2) verify match parameters */
assert(m_len >= M2_MIN_LEN); assert(m_len >= M2_MIN_LEN);
assert(m_len <= M2_MAX_LEN); assert(m_len <= M2_MAX_LEN);
assert(m_len <= M3_MAX_LEN); assert(m_len <= M3_MAX_LEN);
assert(m_off >= M2_MIN_OFFSET); assert(m_off >= M2_MIN_OFFSET);
assert(m_off >= M3_MIN_OFFSET); assert(m_off >= M3_MIN_OFFSET);
assert(m_off <= M3_MAX_OFFSET); assert(m_off <= M3_MAX_OFFSET);
assert(ii-m_off == m_pos_sav); assert(ii - m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0); assert(lzo_memcmp(m_pos_sav, ii, m_len) == 0);
/* 2b) code the match */ /* 2b) code the match */
#if (_M2_MAX_OFFSET != _M3_MAX_OFFSET) #if (_M2_MAX_OFFSET != _M3_MAX_OFFSET)
if (m_off <= M2_MAX_OFFSET)
{ if (m_off <= M2_MAX_OFFSET)
{
#else #else
assert(m_off <= M2_MAX_OFFSET); assert(m_off <= M2_MAX_OFFSET);
#endif #endif
m_off -= M2_MIN_OFFSET; m_off -= M2_MIN_OFFSET;
/* code match len + low offset bits */ /* code match len + low offset bits */
*op++ = LZO_BYTE(((m_len - (M2_MIN_LEN - 2)) << M2O_BITS) | *op++ = LZO_BYTE(((m_len - (M2_MIN_LEN - 2)) << M2O_BITS) |
(m_off & M2O_MASK)); (m_off & M2O_MASK));
/* code high offset bits */ /* code high offset bits */
*op++ = LZO_BYTE(m_off >> M2O_BITS); *op++ = LZO_BYTE(m_off >> M2O_BITS);
LZO_STATS(lzo_stats->m2_matches++); LZO_STATS(lzo_stats->m2_matches++);
LZO_STATS(lzo_stats->m2_match[m_len]++); LZO_STATS(lzo_stats->m2_match[m_len]++);
#if (_M2_MAX_OFFSET != _M3_MAX_OFFSET) #if (_M2_MAX_OFFSET != _M3_MAX_OFFSET)
} }
else else
{ {
#if defined(LZO_HAVE_R1) #if defined(LZO_HAVE_R1)
#if (M3_MIN_LEN == M2_MIN_LEN) #if (M3_MIN_LEN == M2_MIN_LEN)
r1 = ip_end; /* invalidate R1 pointer */ r1 = ip_end; /* invalidate R1 pointer */
#endif #endif
#endif #endif
assert(m_len >= M3_MIN_LEN); assert(m_len >= M3_MIN_LEN);
m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET; m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET;
/* code match len */ /* code match len */
*op++ = LZO_BYTE(M3_MARKER | (m_len - (M3_MIN_LEN - 1))); *op++ = LZO_BYTE(M3_MARKER | (m_len - (M3_MIN_LEN - 1)));
/* code low offset bits */ /* code low offset bits */
*op++ = LZO_BYTE(m_off & M3O_MASK); *op++ = LZO_BYTE(m_off & M3O_MASK);
/* code high offset bits */ /* code high offset bits */
*op++ = LZO_BYTE(m_off >> M3O_BITS); *op++ = LZO_BYTE(m_off >> M3O_BITS);
LZO_STATS(lzo_stats->m3_matches++); LZO_STATS(lzo_stats->m3_matches++);
LZO_STATS(lzo_stats->m3_match[m_len]++); LZO_STATS(lzo_stats->m3_match[m_len]++);
#if defined(LZO_HAVE_M3) #if defined(LZO_HAVE_M3)
m3 = op; /* set M3 pointer */ m3 = op; /* set M3 pointer */
#endif #endif
} }
#endif /* (_M2_MAX_OFFSET != _M3_MAX_OFFSET) */ #endif /* (_M2_MAX_OFFSET != _M3_MAX_OFFSET) */
if (ip >= ip_end) if (ip >= ip_end)
{ {
ii = ip; ii = ip;
break; break;
} }
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */ /* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
#if (CLEVEL == 9) || (CLEVEL >= 7 && M2L_BITS <= 4) || (CLEVEL >= 5 && M2L_BITS <= 3) #if (CLEVEL == 9) || (CLEVEL >= 7 && M2L_BITS <= 4) || (CLEVEL >= 5 && M2L_BITS <= 3)
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */ /* Insert the whole match (ii+1)..(ip-1) into dictionary. */
++ii; ++ii;
do {
DVAL_NEXT(dv,ii); do
{
DVAL_NEXT(dv, ii);
#if 0 #if 0
UPDATE_D(dict,drun,dv,ii,in); UPDATE_D(dict, drun, dv, ii, in);
#else #else
dict[ DINDEX(dv,ii) ] = DENTRY(ii,in); dict[ DINDEX(dv, ii) ] = DENTRY(ii, in);
#endif #endif
MI MI
} while (++ii < ip); }
DVAL_NEXT(dv,ii); while (++ii < ip);
assert(ii == ip);
DVAL_ASSERT(dv,ip); DVAL_NEXT(dv, ii);
assert(ii == ip);
DVAL_ASSERT(dv, ip);
#elif (CLEVEL >= 3) #elif (CLEVEL >= 3)
SI DI DI XI SI DI DI XI
#elif (CLEVEL >= 2) #elif (CLEVEL >= 2)
SI DI XI SI DI XI
#else #else
XI XI
#endif #endif
}
else
{
/* we've found a M3 or M4 match - see how far we can still go */
assert(ip <= in_end);
assert(lzo_memcmp(m_pos_sav, ii, (lzo_uint)(ip - ii)) == 0);
/* 2a) compute match parameters */
#if !defined(MATCH_IP_END)
assert(ii == ip - (M2_MAX_LEN + 1));
#if (DD_BITS > 0)
assert(m_len == (lzo_uint)(ip - ii));
m_pos = ip - m_off;
assert(m_pos == m_pos_sav + m_len);
#endif
{
const lzo_bytep end;
end = in_end;
while (ip < end && *m_pos == *ip)
m_pos++, ip++;
assert(ip <= in_end);
m_len = pd(ip, ii);
}
assert(pd(ip, m_pos) == m_off);
#endif
/* 2a2) verify match parameters */
assert(m_len >= M3_MIN_LEN);
assert(m_off >= M3_MIN_OFFSET);
assert(m_off >= M4_MIN_OFFSET);
assert(m_off <= M3_MAX_OFFSET);
assert(m_off <= M4_MAX_OFFSET);
assert(ii - m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav, ii, m_len) == 0);
/* 2b) code the match */
if (m_len <= M3_MAX_LEN)
{
/* code match len */
*op++ = LZO_BYTE(M3_MARKER | (m_len - (M3_MIN_LEN - 1)));
LZO_STATS(lzo_stats->m3_matches++);
LZO_STATS(lzo_stats->m3_match[m_len]++);
}
else
{
assert(m_len >= M4_MIN_LEN);
/* code M4 match len flag */
*op++ = M4_MARKER;
/* code match len */
m_len -= M4_MIN_LEN - 1;
while (m_len > 255)
{
m_len -= 255;
*op++ = 0;
} }
else assert(m_len > 0);
*op++ = LZO_BYTE(m_len);
LZO_STATS(lzo_stats->m4_matches++);
}
{ m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET;
/* we've found a M3 or M4 match - see how far we can still go */ /* code low offset bits */
assert(ip <= in_end); *op++ = LZO_BYTE(m_off & M3O_MASK);
assert(lzo_memcmp(m_pos_sav,ii,(lzo_uint)(ip-ii)) == 0); /* code high offset bits */
*op++ = LZO_BYTE(m_off >> M3O_BITS);
/* 2a) compute match parameters */
#if !defined(MATCH_IP_END)
assert(ii == ip - (M2_MAX_LEN + 1));
#if (DD_BITS > 0)
assert(m_len == (lzo_uint)(ip-ii));
m_pos = ip - m_off;
assert(m_pos == m_pos_sav + m_len);
#endif
{
const lzo_bytep end;
end = in_end;
while (ip < end && *m_pos == *ip)
m_pos++, ip++;
assert(ip <= in_end);
m_len = pd(ip, ii);
}
assert(pd(ip,m_pos) == m_off);
#endif
/* 2a2) verify match parameters */
assert(m_len >= M3_MIN_LEN);
assert(m_off >= M3_MIN_OFFSET);
assert(m_off >= M4_MIN_OFFSET);
assert(m_off <= M3_MAX_OFFSET);
assert(m_off <= M4_MAX_OFFSET);
assert(ii-m_off == m_pos_sav);
assert(lzo_memcmp(m_pos_sav,ii,m_len) == 0);
/* 2b) code the match */
if (m_len <= M3_MAX_LEN)
{
/* code match len */
*op++ = LZO_BYTE(M3_MARKER | (m_len - (M3_MIN_LEN - 1)));
LZO_STATS(lzo_stats->m3_matches++);
LZO_STATS(lzo_stats->m3_match[m_len]++);
}
else
{
assert(m_len >= M4_MIN_LEN);
/* code M4 match len flag */
*op++ = M4_MARKER;
/* code match len */
m_len -= M4_MIN_LEN - 1;
while (m_len > 255)
{
m_len -= 255;
*op++ = 0;
}
assert(m_len > 0);
*op++ = LZO_BYTE(m_len);
LZO_STATS(lzo_stats->m4_matches++);
}
m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET;
/* code low offset bits */
*op++ = LZO_BYTE(m_off & M3O_MASK);
/* code high offset bits */
*op++ = LZO_BYTE(m_off >> M3O_BITS);
#if defined(LZO_HAVE_M3) #if defined(LZO_HAVE_M3)
m3 = op; /* set M3 pointer */ m3 = op; /* set M3 pointer */
#endif #endif
if (ip >= ip_end) if (ip >= ip_end)
{ {
ii = ip; ii = ip;
break; break;
} }
/* 2c) Insert phrases (beginning with ii+1) into the dictionary. */ /* 2c) Insert phrases (beginning with ii+1) into the dictionary. */
#if (CLEVEL == 9) #if (CLEVEL == 9)
/* Insert the whole match (ii+1)..(ip-1) into dictionary. */ /* Insert the whole match (ii+1)..(ip-1) into dictionary. */
/* This is not recommended because it can be slow. */ /* This is not recommended because it can be slow. */
++ii; ++ii;
do {
DVAL_NEXT(dv,ii);
#if 0
UPDATE_D(dict,drun,dv,ii,in);
#else
dict[ DINDEX(dv,ii) ] = DENTRY(ii,in);
#endif
MI
} while (++ii < ip);
DVAL_NEXT(dv,ii);
assert(ii == ip);
DVAL_ASSERT(dv,ip);
#elif (CLEVEL >= 8)
SI DI DI DI DI DI DI DI DI XI
#elif (CLEVEL >= 7)
SI DI DI DI DI DI DI DI XI
#elif (CLEVEL >= 6)
SI DI DI DI DI DI DI XI
#elif (CLEVEL >= 5)
SI DI DI DI DI XI
#elif (CLEVEL >= 4)
SI DI DI DI XI
#elif (CLEVEL >= 3)
SI DI DI XI
#elif (CLEVEL >= 2)
SI DI XI
#else
XI
#endif
}
/* ii now points to the start of the next literal run */ do
assert(ii == ip); {
DVAL_NEXT(dv, ii);
#if 0
UPDATE_D(dict, drun, dv, ii, in);
#else
dict[ DINDEX(dv, ii) ] = DENTRY(ii, in);
#endif
MI
}
while (++ii < ip);
DVAL_NEXT(dv, ii);
assert(ii == ip);
DVAL_ASSERT(dv, ip);
#elif (CLEVEL >= 8)
SI DI DI DI DI DI DI DI DI XI
#elif (CLEVEL >= 7)
SI DI DI DI DI DI DI DI XI
#elif (CLEVEL >= 6)
SI DI DI DI DI DI DI XI
#elif (CLEVEL >= 5)
SI DI DI DI DI XI
#elif (CLEVEL >= 4)
SI DI DI DI XI
#elif (CLEVEL >= 3)
SI DI DI XI
#elif (CLEVEL >= 2)
SI DI XI
#else
XI
#endif
}
/* ii now points to the start of the next literal run */
assert(ii == ip);
/* vim:set ts=4 sw=4 et: */ /* vim:set ts=4 sw=4 et: */

View File

@ -37,76 +37,81 @@
// store the current literal run // store the current literal run
************************************************************************/ ************************************************************************/
assert(ip < ip_end); assert(ip < ip_end);
if (pd(ip,ii) > 0)
{ if (pd(ip, ii) > 0)
lzo_uint t = pd(ip,ii); {
lzo_uint t = pd(ip, ii);
#if defined(LZO_HAVE_R1) #if defined(LZO_HAVE_R1)
if (ip == r1)
{ if (ip == r1)
/* Code a context sensitive R1 match. */ {
LZO_STATS(lzo_stats->literals += t); /* Code a context sensitive R1 match. */
LZO_STATS(lzo_stats->r1_matches++); LZO_STATS(lzo_stats->literals += t);
assert(t == 1); LZO_STATS(lzo_stats->r1_matches++);
/* modify marker byte */ assert(t == 1);
assert((op[-2] >> M2O_BITS) == (M2_MARKER >> M2O_BITS)); /* modify marker byte */
op[-2] &= M2O_MASK; assert((op[-2] >> M2O_BITS) == (M2_MARKER >> M2O_BITS));
assert((op[-2] >> M2O_BITS) == 0); op[-2] &= M2O_MASK;
/* copy 1 literal */ assert((op[-2] >> M2O_BITS) == 0);
*op++ = *ii++; /* copy 1 literal */
r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */ *op++ = *ii++;
} r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */
else }
else
#endif #endif
if (t < R0MIN) if (t < R0MIN)
{ {
/* inline the copying of a short run */ /* inline the copying of a short run */
LZO_STATS(lzo_stats->literals += t); LZO_STATS(lzo_stats->literals += t);
LZO_STATS(lzo_stats->lit_runs++); LZO_STATS(lzo_stats->lit_runs++);
LZO_STATS(lzo_stats->lit_run[t]++); LZO_STATS(lzo_stats->lit_run[t]++);
#if defined(LZO_HAVE_M3) #if defined(LZO_HAVE_M3)
if (t < LZO_SIZE(8-M3O_BITS) && op == m3)
{ if (t < LZO_SIZE(8 - M3O_BITS) && op == m3)
{
/* Code a very short literal run into the low offset bits /* Code a very short literal run into the low offset bits
* of the previous M3/M4 match. * of the previous M3/M4 match.
*/ */
LZO_STATS(lzo_stats->lit_runs_after_m3_match++); LZO_STATS(lzo_stats->lit_runs_after_m3_match++);
LZO_STATS(lzo_stats->lit_run_after_m3_match[t]++); LZO_STATS(lzo_stats->lit_run_after_m3_match[t]++);
assert((m3[-2] >> M3O_BITS) == 0); assert((m3[-2] >> M3O_BITS) == 0);
m3[-2] = LZO_BYTE(m3[-2] | (t << M3O_BITS)); m3[-2] = LZO_BYTE(m3[-2] | (t << M3O_BITS));
}
else
#endif
{
*op++ = LZO_BYTE(t);
}
MEMCPY_DS(op, ii, t);
#if defined(LZO_HAVE_R1)
r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */
#endif
}
else if (t < R0FAST)
{
/* inline the copying of a short R0 run */
LZO_STATS(lzo_stats->literals += t);
LZO_STATS(lzo_stats->r0short_runs++);
*op++ = 0; *op++ = LZO_BYTE(t - R0MIN);
MEMCPY_DS(op, ii, t);
#if defined(LZO_HAVE_R1)
r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */
#endif
} }
else else
#endif
{ {
op = STORE_RUN(op,ii,t); *op++ = LZO_BYTE(t);
ii = ip;
} }
MEMCPY_DS(op, ii, t);
#if defined(LZO_HAVE_R1)
r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */
#endif
} }
else if (t < R0FAST)
{
/* inline the copying of a short R0 run */
LZO_STATS(lzo_stats->literals += t);
LZO_STATS(lzo_stats->r0short_runs++);
*op++ = 0;
*op++ = LZO_BYTE(t - R0MIN);
MEMCPY_DS(op, ii, t);
#if defined(LZO_HAVE_R1)
r1 = ip + (M2_MIN_LEN + 1); /* set new R1 pointer */
#endif
}
else
{
op = STORE_RUN(op, ii, t);
ii = ip;
}
}
/* ii now points to the start of the current match */ /* ii now points to the start of the current match */
assert(ii == ip); assert(ii == ip);
/* vim:set ts=4 sw=4 et: */ /* vim:set ts=4 sw=4 et: */

View File

@ -34,9 +34,9 @@
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, DO_DECOMPRESS(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
lzo_bytep op; lzo_bytep op;
const lzo_bytep ip; const lzo_bytep ip;
@ -63,9 +63,11 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
{ {
NEED_IP(1); NEED_IP(1);
t = *ip++; t = *ip++;
if (t >= R0FAST - R0MIN) /* a long R0 run */ if (t >= R0FAST - R0MIN) /* a long R0 run */
{ {
t -= R0FAST - R0MIN; t -= R0FAST - R0MIN;
if (t == 0) if (t == 0)
t = R0FAST; t = R0FAST;
else else
@ -75,37 +77,57 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
#else #else
/* help the optimizer */ /* help the optimizer */
lzo_uint tt = 256; lzo_uint tt = 256;
do tt <<= 1; while (--t > 0);
do tt <<= 1;
while (--t > 0);
t = tt; t = tt;
#endif #endif
} }
NEED_IP(t); NEED_OP(t); NEED_IP(t);
NEED_OP(t);
#if 1 && (LZO_OPT_UNALIGNED32) #if 1 && (LZO_OPT_UNALIGNED32)
do {
UA_COPY4(op+0, ip+0); do
UA_COPY4(op+4, ip+4); {
op += 8; ip += 8; UA_COPY4(op + 0, ip + 0);
UA_COPY4(op + 4, ip + 4);
op += 8;
ip += 8;
t -= 8; t -= 8;
} while (t > 0); }
while (t > 0);
#else #else
MEMCPY8_DS(op,ip,t); MEMCPY8_DS(op, ip, t);
#endif #endif
continue; continue;
} }
t += R0MIN; /* a short R0 run */ t += R0MIN; /* a short R0 run */
} }
NEED_IP(t); NEED_OP(t); NEED_IP(t);
NEED_OP(t);
/* copy literal run */ /* copy literal run */
#if 1 && (LZO_OPT_UNALIGNED32) #if 1 && (LZO_OPT_UNALIGNED32)
if (t >= 4) if (t >= 4)
{ {
do { do
{
UA_COPY4(op, ip); UA_COPY4(op, ip);
op += 4; ip += 4; t -= 4; op += 4;
} while (t >= 4); ip += 4;
if (t > 0) do *op++ = *ip++; while (--t > 0); t -= 4;
}
while (t >= 4);
if (t > 0) do* op++ = *ip++;
while (--t > 0);
} }
else else
#endif #endif
@ -113,7 +135,10 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
#if (M3O_BITS < 7) #if (M3O_BITS < 7)
literal1: literal1:
#endif #endif
do *op++ = *ip++; while (--t > 0);
do* op++ = *ip++;
while (--t > 0);
} }
#if (M3O_BITS == 7) #if (M3O_BITS == 7)
@ -124,16 +149,19 @@ literal2:
while (TEST_IP_AND_TEST_OP) while (TEST_IP_AND_TEST_OP)
{ {
t = *ip++; /* get R1 marker */ t = *ip++; /* get R1 marker */
if (t >= R0MIN) if (t >= R0MIN)
goto match; goto match;
NEED_IP(2); NEED_OP(M2_MIN_LEN + 1); NEED_IP(2);
NEED_OP(M2_MIN_LEN + 1);
/* R1 match - a M2_MIN_LEN match + 1 byte literal */ /* R1 match - a M2_MIN_LEN match + 1 byte literal */
assert((t & M2O_MASK) == t); assert((t & M2O_MASK) == t);
m_pos = op - M2_MIN_OFFSET; m_pos = op - M2_MIN_OFFSET;
m_pos -= t | (((lzo_uint) *ip++) << M2O_BITS); m_pos -= t | (((lzo_uint) * ip++) << M2O_BITS);
assert(m_pos >= out); assert(m_pos < op); assert(m_pos >= out);
assert(m_pos < op);
TEST_LB(m_pos); TEST_LB(m_pos);
COPY_M2; COPY_M2;
*op++ = *ip++; *op++ = *ip++;
@ -151,23 +179,26 @@ match:
/* get match offset */ /* get match offset */
NEED_IP(1); NEED_IP(1);
m_pos = op - M2_MIN_OFFSET; m_pos = op - M2_MIN_OFFSET;
m_pos -= (t & M2O_MASK) | (((lzo_uint) *ip++) << M2O_BITS); m_pos -= (t & M2O_MASK) | (((lzo_uint) * ip++) << M2O_BITS);
assert(m_pos >= out); assert(m_pos < op); assert(m_pos >= out);
assert(m_pos < op);
TEST_LB(m_pos); TEST_LB(m_pos);
/* get match len */ /* get match len */
t = (t >> M2O_BITS) - 1; t = (t >> M2O_BITS) - 1;
NEED_OP(t + M2_MIN_LEN - 1); NEED_OP(t + M2_MIN_LEN - 1);
COPY_M2X; COPY_M2X;
MEMCPY_DS(op,m_pos,t); MEMCPY_DS(op, m_pos, t);
} }
else /* a M3 or M4 match */ else /* a M3 or M4 match */
{ {
/* get match len */ /* get match len */
t &= M3L_MASK; t &= M3L_MASK;
if (t == 0) /* a M4 match */ if (t == 0) /* a M4 match */
{ {
NEED_IP(1); NEED_IP(1);
while (*ip == 0) while (*ip == 0)
{ {
t += 255; t += 255;
@ -175,6 +206,7 @@ match:
TEST_OV(t); TEST_OV(t);
NEED_IP(1); NEED_IP(1);
} }
t += (M4_MIN_LEN - M3_MIN_LEN) + *ip++; t += (M4_MIN_LEN - M3_MIN_LEN) + *ip++;
} }
@ -184,47 +216,68 @@ match:
m_pos -= *ip++ & M3O_MASK; m_pos -= *ip++ & M3O_MASK;
m_pos -= (lzo_uint)(*ip++) << M3O_BITS; m_pos -= (lzo_uint)(*ip++) << M3O_BITS;
#if defined(LZO_EOF_CODE) #if defined(LZO_EOF_CODE)
if (m_pos == op) if (m_pos == op)
goto eof_found; goto eof_found;
#endif #endif
/* copy match */ /* copy match */
assert(m_pos >= out); assert(m_pos < op); assert(m_pos >= out);
TEST_LB(m_pos); NEED_OP(t + M3_MIN_LEN - 1); assert(m_pos < op);
TEST_LB(m_pos);
NEED_OP(t + M3_MIN_LEN - 1);
#if (LZO_OPT_UNALIGNED32) #if (LZO_OPT_UNALIGNED32)
if (t >= 2 * 4 - (M3_MIN_LEN - 1) && (op - m_pos) >= 4) if (t >= 2 * 4 - (M3_MIN_LEN - 1) && (op - m_pos) >= 4)
{ {
UA_COPY4(op, m_pos); UA_COPY4(op, m_pos);
op += 4; m_pos += 4; t -= 4 - (M3_MIN_LEN - 1); op += 4;
do { m_pos += 4;
t -= 4 - (M3_MIN_LEN - 1);
do
{
UA_COPY4(op, m_pos); UA_COPY4(op, m_pos);
op += 4; m_pos += 4; t -= 4; op += 4;
} while (t >= 4); m_pos += 4;
if (t > 0) do *op++ = *m_pos++; while (--t > 0); t -= 4;
}
while (t >= 4);
if (t > 0) do* op++ = *m_pos++;
while (--t > 0);
} }
else else
#endif #endif
{ {
COPY_M3X; COPY_M3X;
MEMCPY_DS(op,m_pos,t); MEMCPY_DS(op, m_pos, t);
} }
#if (M3O_BITS < 7) #if (M3O_BITS < 7)
t = ip[-2] >> M3O_BITS; t = ip[-2] >> M3O_BITS;
if (t) if (t)
{ {
NEED_IP(t); NEED_OP(t); NEED_IP(t);
NEED_OP(t);
goto literal1; goto literal1;
} }
#elif (M3O_BITS == 7) #elif (M3O_BITS == 7)
/* optimized version */ /* optimized version */
if (ip[-2] & (1 << M3O_BITS)) if (ip[-2] & (1 << M3O_BITS))
{ {
NEED_IP(1); NEED_OP(1); NEED_IP(1);
NEED_OP(1);
*op++ = *ip++; *op++ = *ip++;
goto literal2; goto literal2;
} }
#endif #endif
} }
} }
@ -242,7 +295,7 @@ eof_found:
#endif #endif
*out_len = pd(op, out); *out_len = pd(op, out);
return (ip == ip_end ? LZO_E_OK : return (ip == ip_end ? LZO_E_OK :
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
#if defined(HAVE_NEED_IP) #if defined(HAVE_NEED_IP)

View File

@ -30,8 +30,8 @@
// store a literal run (internal) // store a literal run (internal)
************************************************************************/ ************************************************************************/
LZO_LOCAL_IMPL(lzo_bytep ) LZO_LOCAL_IMPL(lzo_bytep)
STORE_RUN ( lzo_bytep const oo, const lzo_bytep const ii, lzo_uint r_len) STORE_RUN(lzo_bytep const oo, const lzo_bytep const ii, lzo_uint r_len)
{ {
lzo_bytep op; lzo_bytep op;
const lzo_bytep ip; const lzo_bytep ip;
@ -52,37 +52,48 @@ STORE_RUN ( lzo_bytep const oo, const lzo_bytep const ii, lzo_uint r_len)
while (r_len >= (t = tt)) while (r_len >= (t = tt))
{ {
r_len -= t; r_len -= t;
*op++ = 0; *op++ = (R0FAST - R0MIN) + 7; *op++ = 0;
*op++ = (R0FAST - R0MIN) + 7;
MEMCPY8_DS(op, ip, t); MEMCPY8_DS(op, ip, t);
LZO_STATS(lzo_stats->r0long_runs++); LZO_STATS(lzo_stats->r0long_runs++);
} }
tt >>= 1; tt >>= 1;
do {
do
{
if (r_len >= (t = tt)) if (r_len >= (t = tt))
{ {
r_len -= t; r_len -= t;
*op++ = 0; *op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits); *op++ = 0;
*op++ = LZO_BYTE((R0FAST - R0MIN) + r_bits);
MEMCPY8_DS(op, ip, t); MEMCPY8_DS(op, ip, t);
LZO_STATS(lzo_stats->r0long_runs++); LZO_STATS(lzo_stats->r0long_runs++);
} }
tt >>= 1; tt >>= 1;
} while (--r_bits > 0); }
while (--r_bits > 0);
} }
assert(r_len < 512); assert(r_len < 512);
while (r_len >= (t = R0FAST)) while (r_len >= (t = R0FAST))
{ {
r_len -= t; r_len -= t;
*op++ = 0; *op++ = (R0FAST - R0MIN); *op++ = 0;
*op++ = (R0FAST - R0MIN);
MEMCPY8_DS(op, ip, t); MEMCPY8_DS(op, ip, t);
LZO_STATS(lzo_stats->r0fast_runs++); LZO_STATS(lzo_stats->r0fast_runs++);
} }
t = r_len; t = r_len;
if (t >= R0MIN) if (t >= R0MIN)
{ {
/* code a short R0 run */ /* code a short R0 run */
*op++ = 0; *op++ = LZO_BYTE(t - R0MIN); *op++ = 0;
*op++ = LZO_BYTE(t - R0MIN);
MEMCPY_DS(op, ip, t); MEMCPY_DS(op, ip, t);
LZO_STATS(lzo_stats->r0short_runs++); LZO_STATS(lzo_stats->r0short_runs++);
} }

View File

@ -39,156 +39,181 @@
#if (DD_BITS == 0) #if (DD_BITS == 0)
/* search ip in the dictionary */ /* search ip in the dictionary */
DINDEX1(dindex,ip); DINDEX1(dindex, ip);
GINDEX(m_pos,m_off,dict,dindex,in); GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M3_MAX_OFFSET))
goto literal; if (LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, M3_MAX_OFFSET))
goto literal;
#if 1 #if 1
if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
goto try_match; if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
DINDEX2(dindex,ip); goto try_match;
DINDEX2(dindex, ip);
#endif #endif
GINDEX(m_pos,m_off,dict,dindex,in); GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M3_MAX_OFFSET))
goto literal; if (LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, M3_MAX_OFFSET))
if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) goto literal;
goto try_match;
goto literal; if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
goto try_match;
goto literal;
#else /* (DD_BITS == 0) */ #else /* (DD_BITS == 0) */
/* search ip in the deepened dictionary */ /* search ip in the deepened dictionary */
{ {
lzo_dict_p d = &dict [ DINDEX(dv,ip) ]; lzo_dict_p d = &dict [ DINDEX(dv, ip) ];
const lzo_bytep ip_sav; const lzo_bytep ip_sav;
unsigned j = DD_SIZE; unsigned j = DD_SIZE;
lzo_uint x_len; lzo_uint x_len;
LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, x_off, 0); LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, x_off, 0);
DVAL_ASSERT(dv,ip); DVAL_ASSERT(dv, ip);
ip_sav = ip; ip_sav = ip;
m_len = 0; m_len = 0;
do {
do
{
#if !defined(NDEBUG) #if !defined(NDEBUG)
const lzo_bytep z_pos = NULL; const lzo_bytep z_pos = NULL;
#endif #endif
#if (LZO_DICT_USE_PTR) #if (LZO_DICT_USE_PTR)
m_pos = *d; m_pos = *d;
assert((z_pos = m_pos) == *d); assert((z_pos = m_pos) == *d);
#if (LZO_DETERMINISTIC) #if (LZO_DETERMINISTIC)
assert(m_pos == NULL || m_pos >= in); assert(m_pos == NULL || m_pos >= in);
assert(m_pos == NULL || m_pos < ip); assert(m_pos == NULL || m_pos < ip);
#endif #endif
#else #else
x_off = *d; x_off = *d;
#endif #endif
assert(ip == ip_sav); assert(ip == ip_sav);
if (LZO_CHECK_MPOS(m_pos,x_off,in,ip,MAX_OFFSET)) if (LZO_CHECK_MPOS(m_pos, x_off, in, ip, MAX_OFFSET))
#if (CLEVEL == 9) #if (CLEVEL == 9)
*d = DENTRY(ip,in); *d = DENTRY(ip, in);
#else #else
((void)(0)); ((void)(0));
#endif #endif
else if (m_pos[m_len] != ip[m_len]) else if (m_pos[m_len] != ip[m_len])
((void)(0)); ((void)(0));
else if (*m_pos++ == *ip++ && *m_pos++ == *ip++ && *m_pos++ == *ip++) else if (*m_pos++ == *ip++ && *m_pos++ == *ip++ && *m_pos++ == *ip++)
{ {
#if !(LZO_DICT_USE_PTR) #if !(LZO_DICT_USE_PTR)
assert((z_pos = ip - 3 - x_off) == (m_pos - 3)); assert((z_pos = ip - 3 - x_off) == (m_pos - 3));
#endif #endif
/* a match */
if (MATCH_M2) /* a match */
{ if (MATCH_M2)
x_len = pd((ip - 1), ip_sav); {
if (x_len > m_len) x_len = pd((ip - 1), ip_sav);
{
m_len = x_len; if (x_len > m_len)
m_off = x_off; {
assert((m_pos_sav = z_pos) != NULL); m_len = x_len;
} m_off = x_off;
assert((m_pos_sav = z_pos) != NULL);
}
#if (CLEVEL == 9) #if (CLEVEL == 9)
/* try to find a closer match */ /* try to find a closer match */
else if (x_len == m_len && x_off < m_off) else if (x_len == m_len && x_off < m_off)
{ {
m_off = x_off; m_off = x_off;
assert((m_pos_sav = z_pos) != NULL); assert((m_pos_sav = z_pos) != NULL);
} }
#endif #endif
} }
else else
{ {
assert((ip - ip_sav) == M2_MAX_LEN + 1); assert((ip - ip_sav) == M2_MAX_LEN + 1);
#if (CLEVEL == 9) #if (CLEVEL == 9)
#if defined(MATCH_IP_END) #if defined(MATCH_IP_END)
{ {
const lzo_bytep end; const lzo_bytep end;
end = MATCH_IP_END; end = MATCH_IP_END;
while (ip < end && *m_pos == *ip)
m_pos++, ip++;
assert(ip <= in_end);
x_len = pd(ip, ip_sav);
}
if (x_len > m_len)
{
m_len = x_len;
m_off = x_off;
assert((m_pos_sav = z_pos) != NULL);
if (ip >= MATCH_IP_END)
{
ip = ip_sav;
#if 0
/* not needed - we are at the end */
d -= DD_SIZE - j;
assert(d == &dict [ DINDEX(dv,ip) ]);
UPDATE_P(d,drun,ip,in);
#endif
goto match;
}
}
else if (x_len == m_len && x_off < m_off)
{
m_off = x_off;
assert((m_pos_sav = z_pos) != NULL);
}
#else
/* try to find a closer match */
if (m_len < M2_MAX_LEN + 1 || x_off < m_off)
{
m_len = M2_MAX_LEN + 1;
m_off = x_off;
assert((m_pos_sav = z_pos) != NULL);
}
#endif
#else
/* don't search for a longer/closer match */
m_len = M2_MAX_LEN + 1;
m_off = x_off;
assert((m_pos_sav = z_pos) != NULL);
ip = ip_sav;
d -= DD_SIZE - j;
assert(d == &dict [ DINDEX(dv,ip) ]);
UPDATE_P(d,drun,ip,in);
goto match;
#endif
}
ip = ip_sav;
}
else
ip = ip_sav;
d++;
} while (--j > 0);
assert(ip == ip_sav);
d -= DD_SIZE; while (ip < end && *m_pos == *ip)
assert(d == &dict [ DINDEX(dv,ip) ]); m_pos++, ip++;
UPDATE_P(d,drun,ip,in);
assert(ip <= in_end);
x_len = pd(ip, ip_sav);
}
if (x_len > m_len)
{
m_len = x_len;
m_off = x_off;
assert((m_pos_sav = z_pos) != NULL);
if (ip >= MATCH_IP_END)
{
ip = ip_sav;
#if 0
/* not needed - we are at the end */
d -= DD_SIZE - j;
assert(d == &dict [ DINDEX(dv, ip) ]);
UPDATE_P(d, drun, ip, in);
#endif
goto match;
}
}
else if (x_len == m_len && x_off < m_off)
{
m_off = x_off;
assert((m_pos_sav = z_pos) != NULL);
}
#else
/* try to find a closer match */
if (m_len < M2_MAX_LEN + 1 || x_off < m_off)
{
m_len = M2_MAX_LEN + 1;
m_off = x_off;
assert((m_pos_sav = z_pos) != NULL);
}
#endif
#else
/* don't search for a longer/closer match */
m_len = M2_MAX_LEN + 1;
m_off = x_off;
assert((m_pos_sav = z_pos) != NULL);
ip = ip_sav;
d -= DD_SIZE - j;
assert(d == &dict [ DINDEX(dv, ip) ]);
UPDATE_P(d, drun, ip, in);
goto match;
#endif
}
ip = ip_sav;
} }
else
ip = ip_sav;
d++;
}
while (--j > 0);
assert(ip == ip_sav);
d -= DD_SIZE;
assert(d == &dict [ DINDEX(dv, ip) ]);
UPDATE_P(d, drun, ip, in);
}
#endif /* (DD_BITS == 0) */ #endif /* (DD_BITS == 0) */

View File

@ -43,39 +43,46 @@
try_match: try_match:
#if !defined(NDEBUG) && (LZO_DICT_USE_PTR) #if !defined(NDEBUG) && (LZO_DICT_USE_PTR)
#if (LZO_DETERMINISTIC) #if (LZO_DETERMINISTIC)
assert(m_pos == NULL || m_pos >= in); assert(m_pos == NULL || m_pos >= in);
assert(m_pos == NULL || m_pos < ip); assert(m_pos == NULL || m_pos < ip);
#endif #endif
m_pos_sav = m_pos; m_pos_sav = m_pos;
#endif #endif
if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2])
{ if (m_pos[0] == ip[0] && m_pos[1] == ip[1] && m_pos[2] == ip[2])
m_pos += 3; {
goto match; m_pos += 3;
} goto match;
}
#else /* (DD_BITS == 0) */ #else /* (DD_BITS == 0) */
/* test potential match */ /* test potential match */
if (m_len > M2_MIN_LEN) if (m_len > M2_MIN_LEN)
goto match; goto match;
if (m_len == M2_MIN_LEN)
{ if (m_len == M2_MIN_LEN)
{
#if (_MAX_OFFSET == _M2_MAX_OFFSET) #if (_MAX_OFFSET == _M2_MAX_OFFSET)
goto match; goto match;
#else #else
if (m_off <= M2_MAX_OFFSET)
goto match; if (m_off <= M2_MAX_OFFSET)
goto match;
#if 0 && (M3_MIN_LEN == M2_MIN_LEN) #if 0 && (M3_MIN_LEN == M2_MIN_LEN)
if (ip == ii)
goto match; if (ip == ii)
goto match;
#endif #endif
#endif #endif
} }
goto literal;
goto literal;
#endif /* (DD_BITS == 0) */ #endif /* (DD_BITS == 0) */

View File

@ -33,7 +33,7 @@
// //
************************************************************************/ ************************************************************************/
static const lzo_compress_t * const c_funcs [9] = static const lzo_compress_t* const c_funcs [9] =
{ {
&_lzo1b_1_compress_func, &_lzo1b_1_compress_func,
&_lzo1b_2_compress_func, &_lzo1b_2_compress_func,
@ -49,7 +49,7 @@ static const lzo_compress_t * const c_funcs [9] =
static lzo_compress_t lzo1b_get_compress_func(int clevel) static lzo_compress_t lzo1b_get_compress_func(int clevel)
{ {
const lzo_compress_t *f; const lzo_compress_t* f;
if (clevel < LZO1B_BEST_SPEED || clevel > LZO1B_BEST_COMPRESSION) if (clevel < LZO1B_BEST_SPEED || clevel > LZO1B_BEST_COMPRESSION)
{ {
@ -58,24 +58,27 @@ static lzo_compress_t lzo1b_get_compress_func(int clevel)
else else
return (lzo_compress_t) 0; return (lzo_compress_t) 0;
} }
f = c_funcs[clevel-1];
f = c_funcs[clevel - 1];
assert(f && *f); assert(f && *f);
return *f; return *f;
} }
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1b_compress ( const lzo_bytep src, lzo_uint src_len, lzo1b_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
int clevel ) int clevel)
{ {
lzo_compress_t f; lzo_compress_t f;
f = lzo1b_get_compress_func(clevel); f = lzo1b_get_compress_func(clevel);
if (!f) if (!f)
return LZO_E_ERROR; return LZO_E_ERROR;
return _lzo1b_do_compress(src,src_len,dst,dst_len,wrkmem,f);
return _lzo1b_do_compress(src, src_len, dst, dst_len, wrkmem, f);
} }

View File

@ -50,7 +50,7 @@
************************************************************************/ ************************************************************************/
static lzo_bytep static lzo_bytep
code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off ) code_match(LZO_COMPRESS_T* c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off)
{ {
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET)
{ {
@ -60,7 +60,7 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
m_off -= M2_MIN_OFFSET; m_off -= M2_MIN_OFFSET;
/* code match len + low offset bits */ /* code match len + low offset bits */
*op++ = LZO_BYTE(((m_len - (M2_MIN_LEN - 2)) << M2O_BITS) | *op++ = LZO_BYTE(((m_len - (M2_MIN_LEN - 2)) << M2O_BITS) |
(m_off & M2O_MASK)); (m_off & M2O_MASK));
/* code high offset bits */ /* code high offset bits */
*op++ = LZO_BYTE(m_off >> M2O_BITS); *op++ = LZO_BYTE(m_off >> M2O_BITS);
c->m2_m++; c->m2_m++;
@ -71,6 +71,7 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
assert(m_off <= M3_MAX_OFFSET); assert(m_off <= M3_MAX_OFFSET);
m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET; m_off -= M3_MIN_OFFSET - M3_EOF_OFFSET;
/* code match len */ /* code match len */
if (m_len <= M3_MAX_LEN) if (m_len <= M3_MAX_LEN)
*op++ = LZO_BYTE(M3_MARKER | (m_len - (M3_MIN_LEN - 1))); *op++ = LZO_BYTE(M3_MARKER | (m_len - (M3_MIN_LEN - 1)));
@ -81,14 +82,17 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
*op++ = M4_MARKER; *op++ = M4_MARKER;
/* code match len */ /* code match len */
m_len -= M4_MIN_LEN - 1; m_len -= M4_MIN_LEN - 1;
while (m_len > 255) while (m_len > 255)
{ {
m_len -= 255; m_len -= 255;
*op++ = 0; *op++ = 0;
} }
assert(m_len > 0); assert(m_len > 0);
*op++ = LZO_BYTE(m_len); *op++ = LZO_BYTE(m_len);
} }
/* code low offset bits */ /* code low offset bits */
*op++ = LZO_BYTE(m_off & M3O_MASK); *op++ = LZO_BYTE(m_off & M3O_MASK);
/* code high offset bits */ /* code high offset bits */
@ -98,6 +102,7 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
c->m3 = op; c->m3 = op;
c->m3_m++; c->m3_m++;
} }
return op; return op;
} }
@ -107,25 +112,25 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len, lzo1c_999_compress_callback(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_callback_p cb, lzo_callback_p cb,
lzo_uint max_chain ); lzo_uint max_chain);
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len, lzo1c_999_compress_callback(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_callback_p cb, lzo_callback_p cb,
lzo_uint max_chain ) lzo_uint max_chain)
{ {
lzo_bytep op; lzo_bytep op;
const lzo_bytep ii; const lzo_bytep ii;
lzo_uint lit; lzo_uint lit;
lzo_uint m_len, m_off; lzo_uint m_len, m_off;
LZO_COMPRESS_T cc; LZO_COMPRESS_T cc;
LZO_COMPRESS_T * const c = &cc; LZO_COMPRESS_T* const c = &cc;
lzo_swd_p const swd = (lzo_swd_p) wrkmem; lzo_swd_p const swd = (lzo_swd_p) wrkmem;
int r; int r;
@ -144,15 +149,19 @@ lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
c->r1_m_len = 0; c->r1_m_len = 0;
c->m3 = out + 1; /* pointer after last m3/m4 match */ c->m3 = out + 1; /* pointer after last m3/m4 match */
r = init_match(c,swd,NULL,0,0); r = init_match(c, swd, NULL, 0, 0);
if (r != 0) if (r != 0)
return r; return r;
if (max_chain > 0) if (max_chain > 0)
swd->max_chain = max_chain; swd->max_chain = max_chain;
r = find_match(c,swd,0,0); r = find_match(c, swd, 0, 0);
if (r != 0) if (r != 0)
return r; return r;
while (c->look > 0) while (c->look > 0)
{ {
int lazy_match_min_gain = -1; int lazy_match_min_gain = -1;
@ -162,18 +171,20 @@ lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
m_off = c->m_off; m_off = c->m_off;
#if 0 #if 0
printf("%5ld: %5d len:%3d off:%5d\n", (c->ip-c->look)-in, c->look, printf("%5ld: %5d len:%3d off:%5d\n", (c->ip - c->look) - in, c->look,
m_len, m_off); m_len, m_off);
#endif #endif
assert(c->ip - c->look >= in); assert(c->ip - c->look >= in);
if (lit == 0) if (lit == 0)
ii = c->ip - c->look; ii = c->ip - c->look;
assert(ii + lit == c->ip - c->look); assert(ii + lit == c->ip - c->look);
assert(swd->b_char == *(c->ip - c->look)); assert(swd->b_char == *(c->ip - c->look));
if ((m_len < M2_MIN_LEN) || if ((m_len < M2_MIN_LEN) ||
(m_len < M3_MIN_LEN && m_off > M2_MAX_OFFSET)) (m_len < M3_MIN_LEN && m_off > M2_MAX_OFFSET))
{ {
m_len = 0; m_len = 0;
} }
@ -198,20 +209,24 @@ lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
lazy_match_min_gain = 1; lazy_match_min_gain = 1;
#if (M2_MIN_LEN == 2) #if (M2_MIN_LEN == 2)
if (m_len == 2) if (m_len == 2)
{ {
/* don't code a match of len 2 if we have to /* don't code a match of len 2 if we have to
code a literal run. Code a literal instead. */ code a literal run. Code a literal instead. */
m_len = 0; m_len = 0;
} }
#endif #endif
#if (M2_MIN_LEN == M3_MIN_LEN) #if (M2_MIN_LEN == M3_MIN_LEN)
if (m_len == M2_MIN_LEN && m_off > M2_MAX_OFFSET) if (m_len == M2_MIN_LEN && m_off > M2_MAX_OFFSET)
{ {
/* don't code a M3 match of len 3 if we have to /* don't code a M3 match of len 3 if we have to
code a literal run. Code a literal instead. */ code a literal run. Code a literal instead. */
m_len = 0; m_len = 0;
} }
#endif #endif
} }
else else
@ -229,16 +244,18 @@ lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
/* try a lazy match */ /* try a lazy match */
if (m_len == 0) if (m_len == 0)
lazy_match_min_gain = -1; lazy_match_min_gain = -1;
if (lazy_match_min_gain >= 0 && c->look > m_len) if (lazy_match_min_gain >= 0 && c->look > m_len)
{ {
assert(m_len > 0); assert(m_len > 0);
r = find_match(c,swd,1,0); r = find_match(c, swd, 1, 0);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
assert(c->look > 0); assert(c->look > 0);
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET && if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET &&
c->m_off > M2_MAX_OFFSET) c->m_off > M2_MAX_OFFSET)
lazy_match_min_gain += 1; lazy_match_min_gain += 1;
if (c->m_len >= m_len + lazy_match_min_gain) if (c->m_len >= m_len + lazy_match_min_gain)
@ -259,8 +276,10 @@ lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
ahead = 1; ahead = 1;
assert(ii + lit + 1 == c->ip - c->look); assert(ii + lit + 1 == c->ip - c->look);
} }
assert(m_len > 0); assert(m_len > 0);
} }
assert(ii + lit + ahead == c->ip - c->look); assert(ii + lit + ahead == c->ip - c->look);
@ -268,8 +287,9 @@ lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
{ {
/* a literal */ /* a literal */
lit++; lit++;
r = find_match(c,swd,1,0); r = find_match(c, swd, 1, 0);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
} }
else else
{ {
@ -298,21 +318,24 @@ lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
} }
else else
{ {
op = STORE_RUN(op,ii,lit); op = STORE_RUN(op, ii, lit);
} }
if (lit < R0FAST) if (lit < R0FAST)
c->r1_m_len = m_len; c->r1_m_len = m_len;
else else
c->r1_m_len = 0; c->r1_m_len = 0;
lit = 0; lit = 0;
} }
else else
c->r1_m_len = 0; c->r1_m_len = 0;
/* 2 - code match */ /* 2 - code match */
op = code_match(c,op,m_len,m_off); op = code_match(c, op, m_len, m_off);
r = find_match(c,swd,m_len,1+ahead); r = find_match(c, swd, m_len, 1 + ahead);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
} }
c->codesize = pd(op, out); c->codesize = pd(op, out);
@ -321,7 +344,7 @@ lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
/* store final run */ /* store final run */
if (lit > 0) if (lit > 0)
op = STORE_RUN(op,ii,lit); op = STORE_RUN(op, ii, lit);
#if defined(LZO_EOF_CODE) #if defined(LZO_EOF_CODE)
*op++ = M3_MARKER | 1; *op++ = M3_MARKER | 1;
@ -339,8 +362,8 @@ lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
#if 0 #if 0
printf("%ld %ld -> %ld: %ld %ld %ld %ld %ld\n", printf("%ld %ld -> %ld: %ld %ld %ld %ld %ld\n",
(long) c->textsize, (long)in_len, (long) c->codesize, (long) c->textsize, (long)in_len, (long) c->codesize,
c->r1_r, c->m3_r, c->m2_m, c->m3_m, c->lazy); c->r1_r, c->m3_r, c->m2_m, c->m3_m, c->lazy);
#endif #endif
return LZO_E_OK; return LZO_E_OK;
} }
@ -352,11 +375,11 @@ lzo1c_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1c_999_compress ( const lzo_bytep in , lzo_uint in_len, lzo1c_999_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
return lzo1c_999_compress_callback(in,in_len,out,out_len,wrkmem, return lzo1c_999_compress_callback(in, in_len, out, out_len, wrkmem,
(lzo_callback_p) 0, 0); (lzo_callback_p) 0, 0);
} }

View File

@ -35,10 +35,10 @@
************************************************************************/ ************************************************************************/
LZO_LOCAL_IMPL(int) LZO_LOCAL_IMPL(int)
_lzo1c_do_compress ( const lzo_bytep in, lzo_uint in_len, _lzo1c_do_compress(const lzo_bytep in, lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_compress_t func ) lzo_compress_t func)
{ {
int r; int r;
#if defined(LZO_TEST_COMPRESS_OVERRUN) #if defined(LZO_TEST_COMPRESS_OVERRUN)
@ -64,19 +64,22 @@ _lzo1c_do_compress ( const lzo_bytep in, lzo_uint in_len,
*out_len = 0; *out_len = 0;
r = LZO_E_NOT_COMPRESSIBLE; r = LZO_E_NOT_COMPRESSIBLE;
#else #else
*out_len = pd(STORE_RUN(out,in,in_len), out); *out_len = pd(STORE_RUN(out, in, in_len), out);
r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR; r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR;
#endif #endif
} }
else else
r = func(in,in_len,out,out_len,wrkmem); r = func(in, in_len, out, out_len, wrkmem);
#if defined(LZO_EOF_CODE) #if defined(LZO_EOF_CODE)
#if defined(LZO_TEST_COMPRESS_OVERRUN) #if defined(LZO_TEST_COMPRESS_OVERRUN)
if (r == LZO_E_OK && avail_out - *out_len < 3) if (r == LZO_E_OK && avail_out - *out_len < 3)
r = LZO_E_COMPRESS_OVERRUN; r = LZO_E_COMPRESS_OVERRUN;
#endif #endif
if (r == LZO_E_OK) if (r == LZO_E_OK)
{ {
lzo_bytep op = out + *out_len; lzo_bytep op = out + *out_len;
@ -85,14 +88,15 @@ _lzo1c_do_compress ( const lzo_bytep in, lzo_uint in_len,
op[2] = 0; op[2] = 0;
*out_len += 3; *out_len += 3;
} }
#endif #endif
#if (LZO_COLLECT_STATS) #if (LZO_COLLECT_STATS)
lzo_stats->out_len = *out_len; lzo_stats->out_len = *out_len;
lzo_stats->match_bytes = lzo_stats->match_bytes =
1 * lzo_stats->m1_matches + 2 * lzo_stats->m2_matches + 1 * lzo_stats->m1_matches + 2 * lzo_stats->m2_matches +
3 * lzo_stats->m3_matches + 4 * lzo_stats->m4_matches; 3 * lzo_stats->m3_matches + 4 * lzo_stats->m4_matches;
_lzo1c_stats_calc(lzo_stats); _lzo1c_stats_calc(lzo_stats);
#endif #endif
@ -112,30 +116,30 @@ _lzo1c_do_compress ( const lzo_bytep in, lzo_uint in_len,
#if (LZO_COLLECT_STATS) #if (LZO_COLLECT_STATS)
static lzo_stats_t lzo_statistics; static lzo_stats_t lzo_statistics;
lzo_stats_t * const lzo1c_stats = &lzo_statistics; lzo_stats_t* const lzo1c_stats = &lzo_statistics;
void _lzo1c_stats_init(lzo_stats_t *lzo_stats) void _lzo1c_stats_init(lzo_stats_t* lzo_stats)
{ {
lzo_memset(lzo_stats,0,sizeof(*lzo_stats)); lzo_memset(lzo_stats, 0, sizeof(*lzo_stats));
} }
void _lzo1c_stats_calc(lzo_stats_t *lzo_stats) void _lzo1c_stats_calc(lzo_stats_t* lzo_stats)
{ {
lzo_stats->matches = lzo_stats->matches =
lzo_stats->m1_matches + lzo_stats->m2_matches + lzo_stats->m1_matches + lzo_stats->m2_matches +
lzo_stats->m3_matches + lzo_stats->m4_matches; lzo_stats->m3_matches + lzo_stats->m4_matches;
lzo_stats->literal_overhead = lzo_stats->lit_runs + lzo_stats->literal_overhead = lzo_stats->lit_runs +
2 * (lzo_stats->r0short_runs + lzo_stats->r0fast_runs + 2 * (lzo_stats->r0short_runs + lzo_stats->r0fast_runs +
lzo_stats->r0long_runs); lzo_stats->r0long_runs);
lzo_stats->literal_bytes = lzo_stats->literals + lzo_stats->literal_bytes = lzo_stats->literals +
lzo_stats->literal_overhead; lzo_stats->literal_overhead;
#if 0 #if 0
assert(lzo_stats->match_bytes + lzo_stats->literal_bytes == assert(lzo_stats->match_bytes + lzo_stats->literal_bytes ==
lzo_stats->out_len); lzo_stats->out_len);
#endif #endif
lzo_stats->m2_matches -= lzo_stats->r1_matches; lzo_stats->m2_matches -= lzo_stats->r1_matches;
@ -143,7 +147,7 @@ void _lzo1c_stats_calc(lzo_stats_t *lzo_stats)
if (lzo_stats->literals > 0) if (lzo_stats->literals > 0)
lzo_stats->literal_overhead_percent = lzo_stats->literal_overhead_percent =
100.0 * lzo_stats->literal_overhead / lzo_stats->literals; 100.0 * lzo_stats->literal_overhead / lzo_stats->literals;
} }

View File

@ -57,18 +57,18 @@ extern const lzo_compress_t _lzo1c_99_compress_func;
// //
************************************************************************/ ************************************************************************/
LZO_LOCAL_DECL(lzo_bytep ) LZO_LOCAL_DECL(lzo_bytep)
_lzo1c_store_run ( lzo_bytep const oo, const lzo_bytep const ii, _lzo1c_store_run(lzo_bytep const oo, const lzo_bytep const ii,
lzo_uint r_len); lzo_uint r_len);
#define STORE_RUN _lzo1c_store_run #define STORE_RUN _lzo1c_store_run
LZO_LOCAL_DECL(int) LZO_LOCAL_DECL(int)
_lzo1c_do_compress ( const lzo_bytep in, lzo_uint in_len, _lzo1c_do_compress(const lzo_bytep in, lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_compress_t func ); lzo_compress_t func);
#endif /* already included */ #endif /* already included */

View File

@ -35,13 +35,13 @@
#if defined(LZO_ARCH_I386) && defined(LZO_USE_ASM) #if defined(LZO_ARCH_I386) && defined(LZO_USE_ASM)
LZO_EXTERN(int) lzo1c_decompress_asm_safe LZO_EXTERN(int) lzo1c_decompress_asm_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_PUBLIC(int) lzo1c_decompress_asm_safe LZO_PUBLIC(int) lzo1c_decompress_asm_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem) lzo_voidp wrkmem)
{ {
return lzo1c_decompress_safe(src, src_len, dst, dst_len, wrkmem); return lzo1c_decompress_safe(src, src_len, dst, dst_len, wrkmem);
} }

View File

@ -33,7 +33,7 @@
// //
************************************************************************/ ************************************************************************/
static const lzo_compress_t * const c_funcs [9] = static const lzo_compress_t* const c_funcs [9] =
{ {
&_lzo1c_1_compress_func, &_lzo1c_1_compress_func,
&_lzo1c_2_compress_func, &_lzo1c_2_compress_func,
@ -49,7 +49,7 @@ static const lzo_compress_t * const c_funcs [9] =
static lzo_compress_t lzo1c_get_compress_func(int clevel) static lzo_compress_t lzo1c_get_compress_func(int clevel)
{ {
const lzo_compress_t *f; const lzo_compress_t* f;
if (clevel < LZO1C_BEST_SPEED || clevel > LZO1C_BEST_COMPRESSION) if (clevel < LZO1C_BEST_SPEED || clevel > LZO1C_BEST_COMPRESSION)
{ {
@ -58,24 +58,27 @@ static lzo_compress_t lzo1c_get_compress_func(int clevel)
else else
return (lzo_compress_t) 0; return (lzo_compress_t) 0;
} }
f = c_funcs[clevel-1];
f = c_funcs[clevel - 1];
assert(f && *f); assert(f && *f);
return *f; return *f;
} }
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1c_compress ( const lzo_bytep src, lzo_uint src_len, lzo1c_compress(const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
int clevel ) int clevel)
{ {
lzo_compress_t f; lzo_compress_t f;
f = lzo1c_get_compress_func(clevel); f = lzo1c_get_compress_func(clevel);
if (!f) if (!f)
return LZO_E_ERROR; return LZO_E_ERROR;
return _lzo1c_do_compress(src,src_len,dst,dst_len,wrkmem,f);
return _lzo1c_do_compress(src, src_len, dst, dst_len, wrkmem, f);
} }

View File

@ -53,9 +53,9 @@
************************************************************************/ ************************************************************************/
static __lzo_noinline static __lzo_noinline
int do_compress ( const lzo_bytep in , lzo_uint in_len, int do_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
const lzo_bytep ip; const lzo_bytep ip;
lzo_bytep op; lzo_bytep op;
@ -69,6 +69,7 @@ int do_compress ( const lzo_bytep in , lzo_uint in_len,
ii = ip; ii = ip;
ip++; ip++;
for (;;) for (;;)
{ {
const lzo_bytep m_pos; const lzo_bytep m_pos;
@ -77,25 +78,33 @@ int do_compress ( const lzo_bytep in , lzo_uint in_len,
lzo_uint dindex; lzo_uint dindex;
lzo_uint lit; lzo_uint lit;
DINDEX1(dindex,ip); DINDEX1(dindex, ip);
GINDEX(m_pos,m_off,dict,dindex,in); GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M3_MAX_OFFSET))
if (LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, M3_MAX_OFFSET))
goto literal; goto literal;
#if 1 #if 1
if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
goto try_match; goto try_match;
DINDEX2(dindex,ip);
DINDEX2(dindex, ip);
#endif #endif
GINDEX(m_pos,m_off,dict,dindex,in); GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M3_MAX_OFFSET))
if (LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, M3_MAX_OFFSET))
goto literal; goto literal;
if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
goto try_match; goto try_match;
goto literal; goto literal;
try_match: try_match:
#if 0 && (LZO_OPT_UNALIGNED16) #if 0 && (LZO_OPT_UNALIGNED16)
if (UA_GET_NE16(m_pos) != UA_GET_NE16(ip)) if (UA_GET_NE16(m_pos) != UA_GET_NE16(ip))
#else #else
if (m_pos[0] != ip[0] || m_pos[1] != ip[1]) if (m_pos[0] != ip[0] || m_pos[1] != ip[1])
@ -108,16 +117,23 @@ try_match:
{ {
m_pos += 3; m_pos += 3;
#if 0 #if 0
if (m_off <= M2_MAX_OFFSET) if (m_off <= M2_MAX_OFFSET)
goto match; goto match;
if (lit <= 3) if (lit <= 3)
goto match; goto match;
if (lit == 3) /* better compression, but slower */ if (lit == 3) /* better compression, but slower */
{ {
assert(op - 2 > out); op[-2] |= LZO_BYTE(3); assert(op - 2 > out);
*op++ = *ii++; *op++ = *ii++; *op++ = *ii++; op[-2] |= LZO_BYTE(3);
*op++ = *ii++;
*op++ = *ii++;
*op++ = *ii++;
goto code_match; goto code_match;
} }
if (*m_pos == ip[3]) if (*m_pos == ip[3])
#endif #endif
goto match; goto match;
@ -125,19 +141,22 @@ try_match:
} }
/* a literal */ /* a literal */
literal: literal:
UPDATE_I(dict,0,dindex,ip,in); UPDATE_I(dict, 0, dindex, ip, in);
if (++ip >= ip_end) if (++ip >= ip_end)
break; break;
continue; continue;
/* a match */ /* a match */
match: match:
UPDATE_I(dict,0,dindex,ip,in); UPDATE_I(dict, 0, dindex, ip, in);
/* store current literal run */ /* store current literal run */
lit = pd(ip,ii); lit = pd(ip, ii);
if (lit > 0) if (lit > 0)
{ {
lzo_uint t = lit; lzo_uint t = lit;
@ -151,28 +170,36 @@ match:
lzo_uint tt = t - 31; lzo_uint tt = t - 31;
*op++ = 0; *op++ = 0;
while (tt > 255) while (tt > 255)
{ {
tt -= 255; tt -= 255;
UA_SET1(op, 0); UA_SET1(op, 0);
op++; op++;
} }
assert(tt > 0); assert(tt > 0);
*op++ = LZO_BYTE(tt); *op++ = LZO_BYTE(tt);
} }
do *op++ = *ii++; while (--t > 0);
do* op++ = *ii++;
while (--t > 0);
} }
assert(ii == ip); assert(ii == ip);
/* code the match */ /* code the match */
ip += 3; ip += 3;
if (*m_pos++ != *ip++ || *m_pos++ != *ip++ || *m_pos++ != *ip++ || if (*m_pos++ != *ip++ || *m_pos++ != *ip++ || *m_pos++ != *ip++ ||
*m_pos++ != *ip++ || *m_pos++ != *ip++ || *m_pos++ != *ip++) *m_pos++ != *ip++ || *m_pos++ != *ip++ || *m_pos++ != *ip++)
{ {
--ip; --ip;
m_len = pd(ip, ii); m_len = pd(ip, ii);
assert(m_len >= 3); assert(m_len <= 8); assert(m_len >= 3);
assert(m_len <= 8);
if (m_off <= M2_MAX_OFFSET) if (m_off <= M2_MAX_OFFSET)
{ {
@ -180,7 +207,7 @@ match:
*op++ = LZO_BYTE(((m_len - 2) << 5) | ((m_off & 7) << 2)); *op++ = LZO_BYTE(((m_len - 2) << 5) | ((m_off & 7) << 2));
*op++ = LZO_BYTE(m_off >> 3); *op++ = LZO_BYTE(m_off >> 3);
} }
else if (m_len == 3 && m_off <= 2*M2_MAX_OFFSET && lit > 0) else if (m_len == 3 && m_off <= 2 * M2_MAX_OFFSET && lit > 0)
{ {
m_off -= 1; m_off -= 1;
/* m_off -= M2_MAX_OFFSET; */ /* m_off -= M2_MAX_OFFSET; */
@ -199,8 +226,10 @@ match:
{ {
const lzo_bytep end; const lzo_bytep end;
end = in_end; end = in_end;
while (ip < end && *m_pos == *ip) while (ip < end && *m_pos == *ip)
m_pos++, ip++; m_pos++, ip++;
m_len = pd(ip, ii); m_len = pd(ip, ii);
} }
assert(m_len >= 3); assert(m_len >= 3);
@ -211,29 +240,33 @@ match:
{ {
m_len -= 33; m_len -= 33;
*op++ = M3_MARKER | 0; *op++ = M3_MARKER | 0;
while (m_len > 255) while (m_len > 255)
{ {
m_len -= 255; m_len -= 255;
UA_SET1(op, 0); UA_SET1(op, 0);
op++; op++;
} }
assert(m_len > 0); assert(m_len > 0);
*op++ = LZO_BYTE(m_len); *op++ = LZO_BYTE(m_len);
} }
*op++ = LZO_BYTE((m_off & 63) << 2); *op++ = LZO_BYTE((m_off & 63) << 2);
*op++ = LZO_BYTE(m_off >> 6); *op++ = LZO_BYTE(m_off >> 6);
} }
ii = ip; ii = ip;
if (ip >= ip_end) if (ip >= ip_end)
break; break;
} }
/* store final literal run */ /* store final literal run */
if (pd(in_end,ii) > 0) if (pd(in_end, ii) > 0)
{ {
lzo_uint t = pd(in_end,ii); lzo_uint t = pd(in_end, ii);
if (t < 4 && op > out) if (t < 4 && op > out)
op[-2] = LZO_BYTE(op[-2] | t); op[-2] = LZO_BYTE(op[-2] | t);
@ -244,15 +277,18 @@ match:
lzo_uint tt = t - 31; lzo_uint tt = t - 31;
*op++ = 0; *op++ = 0;
while (tt > 255) while (tt > 255)
{ {
tt -= 255; tt -= 255;
UA_SET1(op, 0); UA_SET1(op, 0);
op++; op++;
} }
assert(tt > 0); assert(tt > 0);
*op++ = LZO_BYTE(tt); *op++ = LZO_BYTE(tt);
} }
UA_COPYN(op, ii, t); UA_COPYN(op, ii, t);
op += t; op += t;
} }
@ -267,9 +303,9 @@ match:
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1f_1_compress ( const lzo_bytep in , lzo_uint in_len, lzo1f_1_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
lzo_bytep op = out; lzo_bytep op = out;
int r = LZO_E_OK; int r = LZO_E_OK;
@ -279,11 +315,15 @@ lzo1f_1_compress ( const lzo_bytep in , lzo_uint in_len,
else if (in_len <= 10) else if (in_len <= 10)
{ {
*op++ = LZO_BYTE(in_len); *op++ = LZO_BYTE(in_len);
do *op++ = *in++; while (--in_len > 0);
do* op++ = *in++;
while (--in_len > 0);
*out_len = pd(op, out); *out_len = pd(op, out);
} }
else else
r = do_compress(in,in_len,out,out_len,wrkmem); r = do_compress(in, in_len, out, out_len, wrkmem);
if (r == LZO_E_OK) if (r == LZO_E_OK)
{ {

View File

@ -50,7 +50,7 @@
************************************************************************/ ************************************************************************/
static lzo_bytep static lzo_bytep
code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off ) code_match(LZO_COMPRESS_T* c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off)
{ {
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET)
{ {
@ -76,14 +76,17 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
{ {
m_len -= M3_MAX_LEN; m_len -= M3_MAX_LEN;
*op++ = M3_MARKER | 0; *op++ = M3_MARKER | 0;
while (m_len > 255) while (m_len > 255)
{ {
m_len -= 255; m_len -= 255;
*op++ = 0; *op++ = 0;
} }
assert(m_len > 0); assert(m_len > 0);
*op++ = LZO_BYTE(m_len); *op++ = LZO_BYTE(m_len);
} }
*op++ = LZO_BYTE((m_off & 63) << 2); *op++ = LZO_BYTE((m_off & 63) << 2);
*op++ = LZO_BYTE(m_off >> 6); *op++ = LZO_BYTE(m_off >> 6);
c->m3_m++; c->m3_m++;
@ -94,7 +97,7 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
static lzo_bytep static lzo_bytep
STORE_RUN ( lzo_bytep op, const lzo_bytep ii, lzo_uint t, lzo_bytep out ) STORE_RUN(lzo_bytep op, const lzo_bytep ii, lzo_uint t, lzo_bytep out)
{ {
if (t < 4 && op > out) if (t < 4 && op > out)
op[-2] = LZO_BYTE(op[-2] | t); op[-2] = LZO_BYTE(op[-2] | t);
@ -105,15 +108,20 @@ STORE_RUN ( lzo_bytep op, const lzo_bytep ii, lzo_uint t, lzo_bytep out )
lzo_uint tt = t - 31; lzo_uint tt = t - 31;
*op++ = 0; *op++ = 0;
while (tt > 255) while (tt > 255)
{ {
tt -= 255; tt -= 255;
*op++ = 0; *op++ = 0;
} }
assert(tt > 0); assert(tt > 0);
*op++ = LZO_BYTE(tt); *op++ = LZO_BYTE(tt);
} }
do *op++ = *ii++; while (--t > 0);
do* op++ = *ii++;
while (--t > 0);
return op; return op;
} }
@ -124,25 +132,25 @@ STORE_RUN ( lzo_bytep op, const lzo_bytep ii, lzo_uint t, lzo_bytep out )
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1f_999_compress_callback ( const lzo_bytep in , lzo_uint in_len, lzo1f_999_compress_callback(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_callback_p cb, lzo_callback_p cb,
lzo_uint max_chain ); lzo_uint max_chain);
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1f_999_compress_callback ( const lzo_bytep in , lzo_uint in_len, lzo1f_999_compress_callback(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_callback_p cb, lzo_callback_p cb,
lzo_uint max_chain ) lzo_uint max_chain)
{ {
lzo_bytep op; lzo_bytep op;
const lzo_bytep ii; const lzo_bytep ii;
lzo_uint lit; lzo_uint lit;
lzo_uint m_len, m_off; lzo_uint m_len, m_off;
LZO_COMPRESS_T cc; LZO_COMPRESS_T cc;
LZO_COMPRESS_T * const c = &cc; LZO_COMPRESS_T* const c = &cc;
lzo_swd_p const swd = (lzo_swd_p) wrkmem; lzo_swd_p const swd = (lzo_swd_p) wrkmem;
int r; int r;
@ -160,15 +168,19 @@ lzo1f_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
lit = 0; lit = 0;
c->r1_lit = c->r1_m_len = 0; c->r1_lit = c->r1_m_len = 0;
r = init_match(c,swd,NULL,0,0); r = init_match(c, swd, NULL, 0, 0);
if (r != 0) if (r != 0)
return r; return r;
if (max_chain > 0) if (max_chain > 0)
swd->max_chain = max_chain; swd->max_chain = max_chain;
r = find_match(c,swd,0,0); r = find_match(c, swd, 0, 0);
if (r != 0) if (r != 0)
return r; return r;
while (c->look > 0) while (c->look > 0)
{ {
int lazy_match_min_gain = -1; int lazy_match_min_gain = -1;
@ -178,13 +190,15 @@ lzo1f_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
m_off = c->m_off; m_off = c->m_off;
assert(c->ip - c->look >= in); assert(c->ip - c->look >= in);
if (lit == 0) if (lit == 0)
ii = c->ip - c->look; ii = c->ip - c->look;
assert(ii + lit == c->ip - c->look); assert(ii + lit == c->ip - c->look);
assert(swd->b_char == *(c->ip - c->look)); assert(swd->b_char == *(c->ip - c->look));
if ((m_len < M2_MIN_LEN) || if ((m_len < M2_MIN_LEN) ||
(m_len < M3_MIN_LEN && m_off > M2_MAX_OFFSET)) (m_len < M3_MIN_LEN && m_off > M2_MAX_OFFSET))
{ {
m_len = 0; m_len = 0;
} }
@ -208,12 +222,13 @@ lzo1f_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
/* try a lazy match */ /* try a lazy match */
if (m_len > 0 && lazy_match_min_gain >= 0 && c->look > m_len) if (m_len > 0 && lazy_match_min_gain >= 0 && c->look > m_len)
{ {
r = find_match(c,swd,1,0); r = find_match(c, swd, 1, 0);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
assert(c->look > 0); assert(c->look > 0);
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET && if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET &&
c->m_off > M2_MAX_OFFSET) c->m_off > M2_MAX_OFFSET)
{ {
lazy_match_min_gain += 1; lazy_match_min_gain += 1;
} }
@ -250,8 +265,10 @@ lzo1f_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
ahead = 1; ahead = 1;
assert(ii + lit + 1 == c->ip - c->look); assert(ii + lit + 1 == c->ip - c->look);
} }
assert(m_len > 0); assert(m_len > 0);
} }
assert(ii + lit + ahead == c->ip - c->look); assert(ii + lit + ahead == c->ip - c->look);
@ -259,15 +276,16 @@ lzo1f_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
{ {
/* a literal */ /* a literal */
lit++; lit++;
r = find_match(c,swd,1,0); r = find_match(c, swd, 1, 0);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
} }
else else
{ {
/* 1 - store run */ /* 1 - store run */
if (lit > 0) if (lit > 0)
{ {
op = STORE_RUN(op,ii,lit,out); op = STORE_RUN(op, ii, lit, out);
c->r1_m_len = m_len; c->r1_m_len = m_len;
c->r1_lit = lit; c->r1_lit = lit;
lit = 0; lit = 0;
@ -276,9 +294,10 @@ lzo1f_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
c->r1_lit = c->r1_m_len = 0; c->r1_lit = c->r1_m_len = 0;
/* 2 - code match */ /* 2 - code match */
op = code_match(c,op,m_len,m_off); op = code_match(c, op, m_len, m_off);
r = find_match(c,swd,m_len,1+ahead); r = find_match(c, swd, m_len, 1 + ahead);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
} }
c->codesize = pd(op, out); c->codesize = pd(op, out);
@ -287,7 +306,7 @@ lzo1f_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
/* store final run */ /* store final run */
if (lit > 0) if (lit > 0)
op = STORE_RUN(op,ii,lit,out); op = STORE_RUN(op, ii, lit, out);
#if defined(LZO_EOF_CODE) #if defined(LZO_EOF_CODE)
*op++ = M3_MARKER | 1; *op++ = M3_MARKER | 1;
@ -305,8 +324,8 @@ lzo1f_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
#if 0 #if 0
printf("%ld %ld -> %ld: %ld %ld %ld %ld\n", printf("%ld %ld -> %ld: %ld %ld %ld %ld\n",
(long) c->textsize, (long)in_len, (long) c->codesize, (long) c->textsize, (long)in_len, (long) c->codesize,
c->r1_r, c->m2_m, c->m3_m, c->lazy); c->r1_r, c->m2_m, c->m3_m, c->lazy);
#endif #endif
return LZO_E_OK; return LZO_E_OK;
} }
@ -318,11 +337,11 @@ lzo1f_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1f_999_compress ( const lzo_bytep in , lzo_uint in_len, lzo1f_999_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
return lzo1f_999_compress_callback(in,in_len,out,out_len,wrkmem, return lzo1f_999_compress_callback(in, in_len, out, out_len, wrkmem,
(lzo_callback_p) 0, 0); (lzo_callback_p) 0, 0);
} }

View File

@ -34,9 +34,9 @@
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, DO_DECOMPRESS(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
lzo_bytep op; lzo_bytep op;
const lzo_bytep ip; const lzo_bytep ip;
@ -58,6 +58,7 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
while (TEST_IP_AND_TEST_OP) while (TEST_IP_AND_TEST_OP)
{ {
t = *ip++; t = *ip++;
if (t > 31) if (t > 31)
goto match; goto match;
@ -65,6 +66,7 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
if (t == 0) if (t == 0)
{ {
NEED_IP(1); NEED_IP(1);
while (*ip == 0) while (*ip == 0)
{ {
t += 255; t += 255;
@ -72,22 +74,36 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
TEST_IV(t); TEST_IV(t);
NEED_IP(1); NEED_IP(1);
} }
t += 31 + *ip++; t += 31 + *ip++;
} }
/* copy literals */ /* copy literals */
assert(t > 0); NEED_OP(t); NEED_IP(t+1); assert(t > 0);
NEED_OP(t);
NEED_IP(t + 1);
#if (LZO_OPT_UNALIGNED32) #if (LZO_OPT_UNALIGNED32)
if (t >= 4) if (t >= 4)
{ {
do { do
{
UA_COPY4(op, ip); UA_COPY4(op, ip);
op += 4; ip += 4; t -= 4; op += 4;
} while (t >= 4); ip += 4;
if (t > 0) do *op++ = *ip++; while (--t > 0); t -= 4;
}
while (t >= 4);
if (t > 0) do* op++ = *ip++;
while (--t > 0);
} }
else else
#endif #endif
do *op++ = *ip++; while (--t > 0); do* op++ = *ip++;
while (--t > 0);
t = *ip++; t = *ip++;
@ -99,27 +115,35 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
m_pos = op - 1 - 0x800; m_pos = op - 1 - 0x800;
m_pos -= (t >> 2) & 7; m_pos -= (t >> 2) & 7;
m_pos -= *ip++ << 3; m_pos -= *ip++ << 3;
TEST_LB(m_pos); NEED_OP(3); TEST_LB(m_pos);
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++; NEED_OP(3);
*op++ = *m_pos++;
*op++ = *m_pos++;
*op++ = *m_pos++;
} }
else else
{ {
match: match:
if (t < M3_MARKER) if (t < M3_MARKER)
{ {
m_pos = op - 1; m_pos = op - 1;
m_pos -= (t >> 2) & 7; m_pos -= (t >> 2) & 7;
m_pos -= *ip++ << 3; m_pos -= *ip++ << 3;
t >>= 5; t >>= 5;
TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); TEST_LB(m_pos);
assert(t > 0);
NEED_OP(t + 3 - 1);
goto copy_match; goto copy_match;
} }
else else
{ {
t &= 31; t &= 31;
if (t == 0) if (t == 0)
{ {
NEED_IP(1); NEED_IP(1);
while (*ip == 0) while (*ip == 0)
{ {
t += 255; t += 255;
@ -127,8 +151,10 @@ match:
TEST_OV(t); TEST_OV(t);
NEED_IP(1); NEED_IP(1);
} }
t += 31 + *ip++; t += 31 + *ip++;
} }
NEED_IP(2); NEED_IP(2);
m_pos = op; m_pos = op;
#if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN) #if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
@ -138,38 +164,64 @@ match:
m_pos -= *ip++ >> 2; m_pos -= *ip++ >> 2;
m_pos -= *ip++ << 6; m_pos -= *ip++ << 6;
#endif #endif
if (m_pos == op) if (m_pos == op)
goto eof_found; goto eof_found;
} }
/* copy match */ /* copy match */
TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); TEST_LB(m_pos);
assert(t > 0);
NEED_OP(t + 3 - 1);
#if (LZO_OPT_UNALIGNED32) #if (LZO_OPT_UNALIGNED32)
if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
{ {
UA_COPY4(op, m_pos); UA_COPY4(op, m_pos);
op += 4; m_pos += 4; t -= 4 - (3 - 1); op += 4;
do { m_pos += 4;
t -= 4 - (3 - 1);
do
{
UA_COPY4(op, m_pos); UA_COPY4(op, m_pos);
op += 4; m_pos += 4; t -= 4; op += 4;
} while (t >= 4); m_pos += 4;
if (t > 0) do *op++ = *m_pos++; while (--t > 0); t -= 4;
}
while (t >= 4);
if (t > 0) do* op++ = *m_pos++;
while (--t > 0);
} }
else else
#endif #endif
{ {
copy_match: copy_match:
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++;
do *op++ = *m_pos++; while (--t > 0); *op++ = *m_pos++;
do* op++ = *m_pos++;
while (--t > 0);
} }
} }
t = ip[-2] & 3; t = ip[-2] & 3;
if (t == 0) if (t == 0)
break; break;
/* copy literals */ /* copy literals */
assert(t > 0); NEED_OP(t); NEED_IP(t+1); assert(t > 0);
do *op++ = *ip++; while (--t > 0); NEED_OP(t);
NEED_IP(t + 1);
do* op++ = *ip++;
while (--t > 0);
t = *ip++; t = *ip++;
} }
} }
@ -184,7 +236,7 @@ eof_found:
assert(t == 1); assert(t == 1);
*out_len = pd(op, out); *out_len = pd(op, out);
return (ip == ip_end ? LZO_E_OK : return (ip == ip_end ? LZO_E_OK :
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
#if defined(HAVE_NEED_IP) #if defined(HAVE_NEED_IP)

View File

@ -35,13 +35,13 @@
#if defined(LZO_ARCH_I386) && defined(LZO_USE_ASM) #if defined(LZO_ARCH_I386) && defined(LZO_USE_ASM)
LZO_EXTERN(int) lzo1f_decompress_asm_fast_safe LZO_EXTERN(int) lzo1f_decompress_asm_fast_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_PUBLIC(int) lzo1f_decompress_asm_fast_safe LZO_PUBLIC(int) lzo1f_decompress_asm_fast_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem) lzo_voidp wrkmem)
{ {
return lzo1f_decompress_safe(src, src_len, dst, dst_len, wrkmem); return lzo1f_decompress_safe(src, src_len, dst, dst_len, wrkmem);
} }

View File

@ -86,17 +86,17 @@
/* this is a public functions, but there is no prototype in a header file */ /* this is a public functions, but there is no prototype in a header file */
LZO_EXTERN(int) LZO_EXTERN(int)
lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len, lzo1x_999_compress_internal(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len, const lzo_bytep dict, lzo_uint dict_len,
lzo_callback_p cb, lzo_callback_p cb,
int try_lazy_parm, int try_lazy_parm,
lzo_uint good_length, lzo_uint good_length,
lzo_uint max_lazy, lzo_uint max_lazy,
lzo_uint nice_length, lzo_uint nice_length,
lzo_uint max_chain, lzo_uint max_chain,
lzo_uint32_t flags ); lzo_uint32_t flags);
/*********************************************************************** /***********************************************************************
@ -104,7 +104,7 @@ lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
************************************************************************/ ************************************************************************/
static lzo_bytep static lzo_bytep
code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off ) code_match(LZO_COMPRESS_T* c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off)
{ {
lzo_uint x_len = m_len; lzo_uint x_len = m_len;
lzo_uint x_off = m_off; lzo_uint x_off = m_off;
@ -112,38 +112,40 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
c->match_bytes += m_len; c->match_bytes += m_len;
#if 0 #if 0
/* /*
static lzo_uint last_m_len = 0, last_m_off = 0; static lzo_uint last_m_len = 0, last_m_off = 0;
static lzo_uint prev_m_off[4]; static lzo_uint prev_m_off[4];
static unsigned prev_m_off_ptr = 0; static unsigned prev_m_off_ptr = 0;
unsigned i; unsigned i;
//if (m_len >= 3 && m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) //if (m_len >= 3 && m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET)
if (m_len >= 3 && m_len <= M2_MAX_LEN) if (m_len >= 3 && m_len <= M2_MAX_LEN)
{ {
//if (m_len == last_m_len && m_off == last_m_off) //if (m_len == last_m_len && m_off == last_m_off)
//printf("last_m_len + last_m_off\n"); //printf("last_m_len + last_m_off\n");
//else //else
if (m_off == last_m_off) if (m_off == last_m_off)
printf("last_m_off\n"); printf("last_m_off\n");
else else
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
if (m_off == prev_m_off[i]) if (m_off == prev_m_off[i])
printf("prev_m_off %u: %5ld\n",i,(long)m_off); printf("prev_m_off %u: %5ld\n",i,(long)m_off);
} }
} }
last_m_len = m_len; last_m_len = m_len;
last_m_off = prev_m_off[prev_m_off_ptr] = m_off; last_m_off = prev_m_off[prev_m_off_ptr] = m_off;
prev_m_off_ptr = (prev_m_off_ptr + 1) & 3; prev_m_off_ptr = (prev_m_off_ptr + 1) & 3;
*/ */
#endif #endif
assert(op > c->out); assert(op > c->out);
if (m_len == 2) if (m_len == 2)
{ {
assert(m_off <= M1_MAX_OFFSET); assert(m_off <= M1_MAX_OFFSET);
assert(c->r1_lit > 0); assert(c->r1_lit < 4); assert(c->r1_lit > 0);
assert(c->r1_lit < 4);
m_off -= 1; m_off -= 1;
#if defined(LZO1Z) #if defined(LZO1Z)
*op++ = LZO_BYTE(M1_MARKER | (m_off >> 6)); *op++ = LZO_BYTE(M1_MARKER | (m_off >> 6));
@ -154,6 +156,7 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
#endif #endif
c->m1a_m++; c->m1a_m++;
} }
#if defined(LZO1Z) #if defined(LZO1Z)
else if (m_len <= M2_MAX_LEN && (m_off <= M2_MAX_OFFSET || m_off == c->last_m_off)) else if (m_len <= M2_MAX_LEN && (m_off <= M2_MAX_OFFSET || m_off == c->last_m_off))
#else #else
@ -172,6 +175,7 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
*op++ = LZO_BYTE(m_off >> 2); *op++ = LZO_BYTE(m_off >> 2);
assert(op[-2] >= M2_MARKER); assert(op[-2] >= M2_MARKER);
#elif defined(LZO1Z) #elif defined(LZO1Z)
if (m_off == c->last_m_off) if (m_off == c->last_m_off)
*op++ = LZO_BYTE(((m_len - 1) << 5) | (0x700 >> 6)); *op++ = LZO_BYTE(((m_len - 1) << 5) | (0x700 >> 6));
else else
@ -180,6 +184,7 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
*op++ = LZO_BYTE(((m_len - 1) << 5) | (m_off >> 6)); *op++ = LZO_BYTE(((m_len - 1) << 5) | (m_off >> 6));
*op++ = LZO_BYTE(m_off << 2); *op++ = LZO_BYTE(m_off << 2);
} }
#endif #endif
c->m2_m++; c->m2_m++;
} }
@ -201,20 +206,24 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
{ {
assert(m_len >= 3); assert(m_len >= 3);
m_off -= 1; m_off -= 1;
if (m_len <= M3_MAX_LEN) if (m_len <= M3_MAX_LEN)
*op++ = LZO_BYTE(M3_MARKER | (m_len - 2)); *op++ = LZO_BYTE(M3_MARKER | (m_len - 2));
else else
{ {
m_len -= M3_MAX_LEN; m_len -= M3_MAX_LEN;
*op++ = M3_MARKER | 0; *op++ = M3_MARKER | 0;
while (m_len > 255) while (m_len > 255)
{ {
m_len -= 255; m_len -= 255;
*op++ = 0; *op++ = 0;
} }
assert(m_len > 0); assert(m_len > 0);
*op++ = LZO_BYTE(m_len); *op++ = LZO_BYTE(m_len);
} }
#if defined(LZO1Z) #if defined(LZO1Z)
*op++ = LZO_BYTE(m_off >> 6); *op++ = LZO_BYTE(m_off >> 6);
*op++ = LZO_BYTE(m_off << 2); *op++ = LZO_BYTE(m_off << 2);
@ -229,23 +238,28 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
lzo_uint k; lzo_uint k;
assert(m_len >= 3); assert(m_len >= 3);
assert(m_off > 0x4000); assert(m_off <= 0xbfff); assert(m_off > 0x4000);
assert(m_off <= 0xbfff);
m_off -= 0x4000; m_off -= 0x4000;
k = (m_off & 0x4000) >> 11; k = (m_off & 0x4000) >> 11;
if (m_len <= M4_MAX_LEN) if (m_len <= M4_MAX_LEN)
*op++ = LZO_BYTE(M4_MARKER | k | (m_len - 2)); *op++ = LZO_BYTE(M4_MARKER | k | (m_len - 2));
else else
{ {
m_len -= M4_MAX_LEN; m_len -= M4_MAX_LEN;
*op++ = LZO_BYTE(M4_MARKER | k | 0); *op++ = LZO_BYTE(M4_MARKER | k | 0);
while (m_len > 255) while (m_len > 255)
{ {
m_len -= 255; m_len -= 255;
*op++ = 0; *op++ = 0;
} }
assert(m_len > 0); assert(m_len > 0);
*op++ = LZO_BYTE(m_len); *op++ = LZO_BYTE(m_len);
} }
#if defined(LZO1Z) #if defined(LZO1Z)
*op++ = LZO_BYTE(m_off >> 6); *op++ = LZO_BYTE(m_off >> 6);
*op++ = LZO_BYTE(m_off << 2); *op++ = LZO_BYTE(m_off << 2);
@ -263,7 +277,7 @@ code_match ( LZO_COMPRESS_T *c, lzo_bytep op, lzo_uint m_len, lzo_uint m_off )
static lzo_bytep static lzo_bytep
STORE_RUN ( LZO_COMPRESS_T *c, lzo_bytep op, const lzo_bytep ii, lzo_uint t ) STORE_RUN(LZO_COMPRESS_T* c, lzo_bytep op, const lzo_bytep ii, lzo_uint t)
{ {
c->lit_bytes += t; c->lit_bytes += t;
@ -290,29 +304,34 @@ STORE_RUN ( LZO_COMPRESS_T *c, lzo_bytep op, const lzo_bytep ii, lzo_uint t )
lzo_uint tt = t - 18; lzo_uint tt = t - 18;
*op++ = 0; *op++ = 0;
while (tt > 255) while (tt > 255)
{ {
tt -= 255; tt -= 255;
*op++ = 0; *op++ = 0;
} }
assert(tt > 0); assert(tt > 0);
*op++ = LZO_BYTE(tt); *op++ = LZO_BYTE(tt);
c->lit3_r++; c->lit3_r++;
} }
do *op++ = *ii++; while (--t > 0);
do* op++ = *ii++;
while (--t > 0);
return op; return op;
} }
static lzo_bytep static lzo_bytep
code_run ( LZO_COMPRESS_T *c, lzo_bytep op, const lzo_bytep ii, code_run(LZO_COMPRESS_T* c, lzo_bytep op, const lzo_bytep ii,
lzo_uint lit, lzo_uint m_len ) lzo_uint lit, lzo_uint m_len)
{ {
if (lit > 0) if (lit > 0)
{ {
assert(m_len >= 2); assert(m_len >= 2);
op = STORE_RUN(c,op,ii,lit); op = STORE_RUN(c, op, ii, lit);
c->r1_m_len = m_len; c->r1_m_len = m_len;
c->r1_lit = lit; c->r1_lit = lit;
} }
@ -332,42 +351,54 @@ code_run ( LZO_COMPRESS_T *c, lzo_bytep op, const lzo_bytep ii,
************************************************************************/ ************************************************************************/
static lzo_uint static lzo_uint
len_of_coded_match ( lzo_uint m_len, lzo_uint m_off, lzo_uint lit ) len_of_coded_match(lzo_uint m_len, lzo_uint m_off, lzo_uint lit)
{ {
lzo_uint n = 4; lzo_uint n = 4;
if (m_len < 2) if (m_len < 2)
return 0; return 0;
if (m_len == 2) if (m_len == 2)
return (m_off <= M1_MAX_OFFSET && lit > 0 && lit < 4) ? 2 : 0; return (m_off <= M1_MAX_OFFSET && lit > 0 && lit < 4) ? 2 : 0;
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET)
return 2; return 2;
if (m_len == M2_MIN_LEN && m_off <= MX_MAX_OFFSET && lit >= 4) if (m_len == M2_MIN_LEN && m_off <= MX_MAX_OFFSET && lit >= 4)
return 2; return 2;
if (m_off <= M3_MAX_OFFSET) if (m_off <= M3_MAX_OFFSET)
{ {
if (m_len <= M3_MAX_LEN) if (m_len <= M3_MAX_LEN)
return 3; return 3;
m_len -= M3_MAX_LEN; m_len -= M3_MAX_LEN;
while (m_len > 255) while (m_len > 255)
{ {
m_len -= 255; m_len -= 255;
n++; n++;
} }
return n; return n;
} }
if (m_off <= M4_MAX_OFFSET) if (m_off <= M4_MAX_OFFSET)
{ {
if (m_len <= M4_MAX_LEN) if (m_len <= M4_MAX_LEN)
return 3; return 3;
m_len -= M4_MAX_LEN; m_len -= M4_MAX_LEN;
while (m_len > 255) while (m_len > 255)
{ {
m_len -= 255; m_len -= 255;
n++; n++;
} }
return n; return n;
} }
return 0; return 0;
} }
@ -377,12 +408,14 @@ min_gain(lzo_uint ahead, lzo_uint lit1, lzo_uint lit2, lzo_uint l1, lzo_uint l2,
{ {
lzo_uint lazy_match_min_gain; lzo_uint lazy_match_min_gain;
assert (ahead >= 1); assert(ahead >= 1);
lazy_match_min_gain = ahead; lazy_match_min_gain = ahead;
#if 0 #if 0
if (l3) if (l3)
lit2 -= ahead; lit2 -= ahead;
#endif #endif
if (lit1 <= 3) if (lit1 <= 3)
@ -391,6 +424,7 @@ min_gain(lzo_uint ahead, lzo_uint lit1, lzo_uint lit2, lzo_uint l1, lzo_uint l2,
lazy_match_min_gain += (lit2 <= 18) ? 0 : 1; lazy_match_min_gain += (lit2 <= 18) ? 0 : 1;
lazy_match_min_gain += (l2 - l1) * 2; lazy_match_min_gain += (l2 - l1) * 2;
if (l3) if (l3)
lazy_match_min_gain -= (ahead - l3) * 2; lazy_match_min_gain -= (ahead - l3) * 2;
@ -398,9 +432,11 @@ min_gain(lzo_uint ahead, lzo_uint lit1, lzo_uint lit2, lzo_uint l1, lzo_uint l2,
lazy_match_min_gain = 0; lazy_match_min_gain = 0;
#if 0 #if 0
if (l1 == 2) if (l1 == 2)
if (lazy_match_min_gain == 0) if (lazy_match_min_gain == 0)
lazy_match_min_gain = 1; lazy_match_min_gain = 1;
#endif #endif
return lazy_match_min_gain; return lazy_match_min_gain;
@ -413,13 +449,14 @@ min_gain(lzo_uint ahead, lzo_uint lit1, lzo_uint lit2, lzo_uint l1, lzo_uint l2,
#if !defined(NDEBUG) #if !defined(NDEBUG)
static static
void assert_match( const lzo_swd_p swd, lzo_uint m_len, lzo_uint m_off ) void assert_match(const lzo_swd_p swd, lzo_uint m_len, lzo_uint m_off)
{ {
const LZO_COMPRESS_T *c = swd->c; const LZO_COMPRESS_T* c = swd->c;
lzo_uint d_off; lzo_uint d_off;
assert(m_len >= 2); assert(m_len >= 2);
if (m_off <= (lzo_uint) (c->bp - c->in))
if (m_off <= (lzo_uint)(c->bp - c->in))
{ {
assert(c->bp - m_off + m_len < c->ip); assert(c->bp - m_off + m_len < c->ip);
assert(lzo_memcmp(c->bp, c->bp - m_off, m_len) == 0); assert(lzo_memcmp(c->bp, c->bp - m_off, m_len) == 0);
@ -427,8 +464,9 @@ void assert_match( const lzo_swd_p swd, lzo_uint m_len, lzo_uint m_off )
else else
{ {
assert(swd->dict != NULL); assert(swd->dict != NULL);
d_off = m_off - (lzo_uint) (c->bp - c->in); d_off = m_off - (lzo_uint)(c->bp - c->in);
assert(d_off <= swd->dict_len); assert(d_off <= swd->dict_len);
if (m_len > d_off) if (m_len > d_off)
{ {
assert(lzo_memcmp(c->bp, swd->dict_end - d_off, d_off) == 0); assert(lzo_memcmp(c->bp, swd->dict_end - d_off, d_off) == 0);
@ -449,25 +487,30 @@ void assert_match( const lzo_swd_p swd, lzo_uint m_len, lzo_uint m_off )
#if defined(SWD_BEST_OFF) #if defined(SWD_BEST_OFF)
static void static void
better_match ( const lzo_swd_p swd, lzo_uint *m_len, lzo_uint *m_off ) better_match(const lzo_swd_p swd, lzo_uint* m_len, lzo_uint* m_off)
{ {
#if defined(LZO1Z) #if defined(LZO1Z)
const LZO_COMPRESS_T *c = swd->c; const LZO_COMPRESS_T* c = swd->c;
#endif #endif
if (*m_len <= M2_MIN_LEN) if (*m_len <= M2_MIN_LEN)
return; return;
#if defined(LZO1Z) #if defined(LZO1Z)
if (*m_off == c->last_m_off && *m_len <= M2_MAX_LEN) if (*m_off == c->last_m_off && *m_len <= M2_MAX_LEN)
return; return;
#if 1 #if 1
if (*m_len >= M2_MIN_LEN + 1 && *m_len <= M2_MAX_LEN + 1 && if (*m_len >= M2_MIN_LEN + 1 && *m_len <= M2_MAX_LEN + 1 &&
c->last_m_off && swd->best_off[*m_len-1] == c->last_m_off) c->last_m_off && swd->best_off[*m_len - 1] == c->last_m_off)
{ {
*m_len = *m_len - 1; *m_len = *m_len - 1;
*m_off = swd->best_off[*m_len]; *m_off = swd->best_off[*m_len];
return; return;
} }
#endif #endif
#endif #endif
@ -475,38 +518,44 @@ better_match ( const lzo_swd_p swd, lzo_uint *m_len, lzo_uint *m_off )
return; return;
#if 1 #if 1
/* M3/M4 -> M2 */ /* M3/M4 -> M2 */
if (*m_off > M2_MAX_OFFSET && if (*m_off > M2_MAX_OFFSET &&
*m_len >= M2_MIN_LEN + 1 && *m_len <= M2_MAX_LEN + 1 && *m_len >= M2_MIN_LEN + 1 && *m_len <= M2_MAX_LEN + 1 &&
swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M2_MAX_OFFSET) swd->best_off[*m_len - 1] && swd->best_off[*m_len - 1] <= M2_MAX_OFFSET)
{ {
*m_len = *m_len - 1; *m_len = *m_len - 1;
*m_off = swd->best_off[*m_len]; *m_off = swd->best_off[*m_len];
return; return;
} }
#endif #endif
#if 1 #if 1
/* M4 -> M2 */ /* M4 -> M2 */
if (*m_off > M3_MAX_OFFSET && if (*m_off > M3_MAX_OFFSET &&
*m_len >= M4_MAX_LEN + 1 && *m_len <= M2_MAX_LEN + 2 && *m_len >= M4_MAX_LEN + 1 && *m_len <= M2_MAX_LEN + 2 &&
swd->best_off[*m_len-2] && swd->best_off[*m_len-2] <= M2_MAX_OFFSET) swd->best_off[*m_len - 2] && swd->best_off[*m_len - 2] <= M2_MAX_OFFSET)
{ {
*m_len = *m_len - 2; *m_len = *m_len - 2;
*m_off = swd->best_off[*m_len]; *m_off = swd->best_off[*m_len];
return; return;
} }
#endif #endif
#if 1 #if 1
/* M4 -> M3 */ /* M4 -> M3 */
if (*m_off > M3_MAX_OFFSET && if (*m_off > M3_MAX_OFFSET &&
*m_len >= M4_MAX_LEN + 1 && *m_len <= M3_MAX_LEN + 1 && *m_len >= M4_MAX_LEN + 1 && *m_len <= M3_MAX_LEN + 1 &&
swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M3_MAX_OFFSET) swd->best_off[*m_len - 1] && swd->best_off[*m_len - 1] <= M3_MAX_OFFSET)
{ {
*m_len = *m_len - 1; *m_len = *m_len - 1;
*m_off = swd->best_off[*m_len]; *m_off = swd->best_off[*m_len];
} }
#endif #endif
} }
@ -518,24 +567,24 @@ better_match ( const lzo_swd_p swd, lzo_uint *m_len, lzo_uint *m_off )
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len, lzo1x_999_compress_internal(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len, const lzo_bytep dict, lzo_uint dict_len,
lzo_callback_p cb, lzo_callback_p cb,
int try_lazy_parm, int try_lazy_parm,
lzo_uint good_length, lzo_uint good_length,
lzo_uint max_lazy, lzo_uint max_lazy,
lzo_uint nice_length, lzo_uint nice_length,
lzo_uint max_chain, lzo_uint max_chain,
lzo_uint32_t flags ) lzo_uint32_t flags)
{ {
lzo_bytep op; lzo_bytep op;
const lzo_bytep ii; const lzo_bytep ii;
lzo_uint lit; lzo_uint lit;
lzo_uint m_len, m_off; lzo_uint m_len, m_off;
LZO_COMPRESS_T cc; LZO_COMPRESS_T cc;
LZO_COMPRESS_T * const c = &cc; LZO_COMPRESS_T* const c = &cc;
lzo_swd_p const swd = (lzo_swd_p) wrkmem; lzo_swd_p const swd = (lzo_swd_p) wrkmem;
lzo_uint try_lazy; lzo_uint try_lazy;
int r; int r;
@ -551,20 +600,25 @@ lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
# error # error
#endif #endif
/* setup parameter defaults */ /* setup parameter defaults */
/* number of lazy match tries */ /* number of lazy match tries */
try_lazy = (lzo_uint) try_lazy_parm; try_lazy = (lzo_uint) try_lazy_parm;
if (try_lazy_parm < 0) if (try_lazy_parm < 0)
try_lazy = 1; try_lazy = 1;
/* reduce lazy match search if we already have a match with this length */ /* reduce lazy match search if we already have a match with this length */
if (good_length == 0) if (good_length == 0)
good_length = 32; good_length = 32;
/* do not try a lazy match if we already have a match with this length */ /* do not try a lazy match if we already have a match with this length */
if (max_lazy == 0) if (max_lazy == 0)
max_lazy = 32; max_lazy = 32;
/* stop searching for longer matches than this one */ /* stop searching for longer matches than this one */
if (nice_length == 0) if (nice_length == 0)
nice_length = 0; nice_length = 0;
/* don't search more positions than this */ /* don't search more positions than this */
if (max_chain == 0) if (max_chain == 0)
max_chain = SWD_MAX_CHAIN; max_chain = SWD_MAX_CHAIN;
@ -582,17 +636,22 @@ lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
lit = 0; lit = 0;
c->r1_lit = c->r1_m_len = 0; c->r1_lit = c->r1_m_len = 0;
r = init_match(c,swd,dict,dict_len,flags); r = init_match(c, swd, dict, dict_len, flags);
if (r != 0) if (r != 0)
return r; return r;
if (max_chain > 0) if (max_chain > 0)
swd->max_chain = max_chain; swd->max_chain = max_chain;
if (nice_length > 0) if (nice_length > 0)
swd->nice_length = nice_length; swd->nice_length = nice_length;
r = find_match(c,swd,0,0); r = find_match(c, swd, 0, 0);
if (r != 0) if (r != 0)
return r; return r;
while (c->look > 0) while (c->look > 0)
{ {
lzo_uint ahead; lzo_uint ahead;
@ -606,21 +665,23 @@ lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
assert(c->bp == c->ip - c->look); assert(c->bp == c->ip - c->look);
assert(c->bp >= in); assert(c->bp >= in);
if (lit == 0) if (lit == 0)
ii = c->bp; ii = c->bp;
assert(ii + lit == c->bp); assert(ii + lit == c->bp);
assert(swd->b_char == *(c->bp)); assert(swd->b_char == *(c->bp));
if ( m_len < 2 || if (m_len < 2 ||
(m_len == 2 && (m_off > M1_MAX_OFFSET || lit == 0 || lit >= 4)) || (m_len == 2 && (m_off > M1_MAX_OFFSET || lit == 0 || lit >= 4)) ||
#if 1 #if 1
/* Do not accept this match for compressed-data compatibility /* Do not accept this match for compressed-data compatibility
* with LZO v1.01 and before * with LZO v1.01 and before
* [ might be a problem for decompress() and optimize() ] * [ might be a problem for decompress() and optimize() ]
*/ */
(m_len == 2 && op == out) || (m_len == 2 && op == out) ||
#endif #endif
(op == out && lit == 0)) (op == out && lit == 0))
{ {
/* a literal */ /* a literal */
m_len = 0; m_len = 0;
@ -634,24 +695,28 @@ lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
if (m_len == 0) if (m_len == 0)
{ {
/* a literal */ /* a literal */
lit++; lit++;
swd->max_chain = max_chain; swd->max_chain = max_chain;
r = find_match(c,swd,1,0); r = find_match(c, swd, 1, 0);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
continue; continue;
} }
/* a match */ /* a match */
#if defined(SWD_BEST_OFF) #if defined(SWD_BEST_OFF)
if (swd->use_best_off) if (swd->use_best_off)
better_match(swd,&m_len,&m_off); better_match(swd, &m_len, &m_off);
#endif #endif
assert_match(swd,m_len,m_off); assert_match(swd, m_len, m_off);
/* shall we try a lazy match ? */ /* shall we try a lazy match ? */
ahead = 0; ahead = 0;
if (try_lazy == 0 || m_len >= max_lazy) if (try_lazy == 0 || m_len >= max_lazy)
{ {
/* no */ /* no */
@ -661,7 +726,7 @@ lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
else else
{ {
/* yes, try a lazy match */ /* yes, try a lazy match */
l1 = len_of_coded_match(m_len,m_off,lit); l1 = len_of_coded_match(m_len, m_off, lit);
assert(l1 > 0); assert(l1 > 0);
#if 1 #if 1
max_ahead = LZO_MIN(try_lazy, l1 - 1); max_ahead = LZO_MIN(try_lazy, l1 - 1);
@ -679,63 +744,79 @@ lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
swd->max_chain = max_chain >> 2; swd->max_chain = max_chain >> 2;
else else
swd->max_chain = max_chain; swd->max_chain = max_chain;
r = find_match(c,swd,1,0);
r = find_match(c, swd, 1, 0);
ahead++; ahead++;
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
assert(c->look > 0); assert(c->look > 0);
assert(ii + lit + ahead == c->bp); assert(ii + lit + ahead == c->bp);
#if defined(LZO1Z) #if defined(LZO1Z)
if (m_off == c->last_m_off && c->m_off != c->last_m_off) if (m_off == c->last_m_off && c->m_off != c->last_m_off)
if (m_len >= M2_MIN_LEN && m_len <= M2_MAX_LEN) if (m_len >= M2_MIN_LEN && m_len <= M2_MAX_LEN)
c->m_len = 0; c->m_len = 0;
#endif #endif
if (c->m_len < m_len) if (c->m_len < m_len)
continue; continue;
#if 1 #if 1
if (c->m_len == m_len && c->m_off >= m_off) if (c->m_len == m_len && c->m_off >= m_off)
continue; continue;
#endif #endif
#if defined(SWD_BEST_OFF) #if defined(SWD_BEST_OFF)
if (swd->use_best_off) if (swd->use_best_off)
better_match(swd,&c->m_len,&c->m_off); better_match(swd, &c->m_len, &c->m_off);
#endif #endif
l2 = len_of_coded_match(c->m_len,c->m_off,lit+ahead); l2 = len_of_coded_match(c->m_len, c->m_off, lit + ahead);
if (l2 == 0) if (l2 == 0)
continue; continue;
#if 0 #if 0
if (c->m_len == m_len && l2 >= l1) if (c->m_len == m_len && l2 >= l1)
continue; continue;
#endif #endif
#if 1 #if 1
/* compressed-data compatibility [see above] */ /* compressed-data compatibility [see above] */
l3 = (op == out) ? 0 : len_of_coded_match(ahead,m_off,lit); l3 = (op == out) ? 0 : len_of_coded_match(ahead, m_off, lit);
#else #else
l3 = len_of_coded_match(ahead,m_off,lit); l3 = len_of_coded_match(ahead, m_off, lit);
#endif #endif
lazy_match_min_gain = min_gain(ahead,lit,lit+ahead,l1,l2,l3); lazy_match_min_gain = min_gain(ahead, lit, lit + ahead, l1, l2, l3);
if (c->m_len >= m_len + lazy_match_min_gain) if (c->m_len >= m_len + lazy_match_min_gain)
{ {
c->lazy++; c->lazy++;
assert_match(swd,c->m_len,c->m_off); assert_match(swd, c->m_len, c->m_off);
if (l3) if (l3)
{ {
/* code previous run */ /* code previous run */
op = code_run(c,op,ii,lit,ahead); op = code_run(c, op, ii, lit, ahead);
lit = 0; lit = 0;
/* code shortened match */ /* code shortened match */
op = code_match(c,op,ahead,m_off); op = code_match(c, op, ahead, m_off);
} }
else else
{ {
lit += ahead; lit += ahead;
assert(ii + lit == c->bp); assert(ii + lit == c->bp);
} }
goto lazy_match_done; goto lazy_match_done;
} }
} }
@ -744,22 +825,24 @@ lzo1x_999_compress_internal ( const lzo_bytep in , lzo_uint in_len,
assert(ii + lit + ahead == c->bp); assert(ii + lit + ahead == c->bp);
/* 1 - code run */ /* 1 - code run */
op = code_run(c,op,ii,lit,m_len); op = code_run(c, op, ii, lit, m_len);
lit = 0; lit = 0;
/* 2 - code match */ /* 2 - code match */
op = code_match(c,op,m_len,m_off); op = code_match(c, op, m_len, m_off);
swd->max_chain = max_chain; swd->max_chain = max_chain;
r = find_match(c,swd,m_len,1+ahead); r = find_match(c, swd, m_len, 1 + ahead);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
lazy_match_done: ; lazy_match_done:
;
} }
/* store final run */ /* store final run */
if (lit > 0) if (lit > 0)
op = STORE_RUN(c,op,ii,lit); op = STORE_RUN(c, op, ii, lit);
#if defined(LZO_EOF_CODE) #if defined(LZO_EOF_CODE)
*op++ = M4_MARKER | 1; *op++ = M4_MARKER | 1;
@ -777,9 +860,9 @@ lazy_match_done: ;
#if 0 #if 0
printf("%ld %ld -> %ld %ld: %ld %ld %ld %ld %ld %ld: %ld %ld %ld %ld\n", printf("%ld %ld -> %ld %ld: %ld %ld %ld %ld %ld %ld: %ld %ld %ld %ld\n",
(long) c->textsize, (long) in_len, (long) c->codesize, (long) c->textsize, (long) in_len, (long) c->codesize,
c->match_bytes, c->m1a_m, c->m1b_m, c->m2_m, c->m3_m, c->m4_m, c->match_bytes, c->m1a_m, c->m1b_m, c->m2_m, c->m3_m, c->m4_m,
c->lit_bytes, c->lit1_r, c->lit2_r, c->lit3_r, c->lazy); c->lit_bytes, c->lit1_r, c->lit2_r, c->lit3_r, c->lazy);
#endif #endif
assert(c->lit_bytes + c->match_bytes == in_len); assert(c->lit_bytes + c->match_bytes == in_len);
@ -792,12 +875,12 @@ lazy_match_done: ;
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1x_999_compress_level ( const lzo_bytep in , lzo_uint in_len, lzo1x_999_compress_level(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len, const lzo_bytep dict, lzo_uint dict_len,
lzo_callback_p cb, lzo_callback_p cb,
int compression_level ) int compression_level)
{ {
static const struct static const struct
{ {
@ -807,7 +890,8 @@ lzo1x_999_compress_level ( const lzo_bytep in , lzo_uint in_len,
lzo_uint nice_length; lzo_uint nice_length;
lzo_uint max_chain; lzo_uint max_chain;
lzo_uint32_t flags; lzo_uint32_t flags;
} c[9] = { } c[9] =
{
/* faster compression */ /* faster compression */
{ 0, 0, 0, 8, 4, 0 }, { 0, 0, 0, 8, 4, 0 },
{ 0, 0, 0, 16, 8, 0 }, { 0, 0, 0, 16, 8, 0 },
@ -845,19 +929,19 @@ lzo1x_999_compress_level ( const lzo_bytep in , lzo_uint in_len,
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1x_999_compress_dict ( const lzo_bytep in , lzo_uint in_len, lzo1x_999_compress_dict(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
const lzo_bytep dict, lzo_uint dict_len ) const lzo_bytep dict, lzo_uint dict_len)
{ {
return lzo1x_999_compress_level(in, in_len, out, out_len, wrkmem, return lzo1x_999_compress_level(in, in_len, out, out_len, wrkmem,
dict, dict_len, 0, 8); dict, dict_len, 0, 8);
} }
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1x_999_compress ( const lzo_bytep in , lzo_uint in_len, lzo1x_999_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
return lzo1x_999_compress_level(in, in_len, out, out_len, wrkmem, return lzo1x_999_compress_level(in, in_len, out, out_len, wrkmem,
NULL, 0, (lzo_callback_p) 0, 8); NULL, 0, (lzo_callback_p) 0, 8);

View File

@ -28,7 +28,7 @@
#if 1 && defined(DO_COMPRESS) && !defined(do_compress) #if 1 && defined(DO_COMPRESS) && !defined(do_compress)
/* choose a unique name to better help PGO optimizations */ /* choose a unique name to better help PGO optimizations */
# define do_compress LZO_PP_ECONCAT2(DO_COMPRESS,_core) # define do_compress LZO_PP_ECONCAT2(DO_COMPRESS,_core)
#endif #endif
@ -38,9 +38,9 @@
************************************************************************/ ************************************************************************/
static __lzo_noinline lzo_uint static __lzo_noinline lzo_uint
do_compress ( const lzo_bytep in , lzo_uint in_len, do_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_uint ti, lzo_voidp wrkmem) lzo_uint ti, lzo_voidp wrkmem)
{ {
const lzo_bytep ip; const lzo_bytep ip;
lzo_bytep op; lzo_bytep op;
@ -54,6 +54,7 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
ii = ip; ii = ip;
ip += ti < 4 ? 4 - ti : 0; ip += ti < 4 ? 4 - ti : 0;
for (;;) for (;;)
{ {
const lzo_bytep m_pos; const lzo_bytep m_pos;
@ -62,26 +63,36 @@ do_compress ( const lzo_bytep in , lzo_uint in_len,
lzo_uint m_len; lzo_uint m_len;
lzo_uint dindex; lzo_uint dindex;
next: next:
if __lzo_unlikely(ip >= ip_end) if __lzo_unlikely(ip >= ip_end)
break; break;
DINDEX1(dindex,ip);
GINDEX(m_pos,m_off,dict,dindex,in); DINDEX1(dindex, ip);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET)) GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, M4_MAX_OFFSET))
goto literal; goto literal;
#if 1 #if 1
if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
goto try_match; goto try_match;
DINDEX2(dindex,ip);
DINDEX2(dindex, ip);
#endif #endif
GINDEX(m_pos,m_off,dict,dindex,in); GINDEX(m_pos, m_off, dict, dindex, in);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
if (LZO_CHECK_MPOS_NON_DET(m_pos, m_off, in, ip, M4_MAX_OFFSET))
goto literal; goto literal;
if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
goto try_match; goto try_match;
goto literal; goto literal;
try_match: try_match:
#if (LZO_OPT_UNALIGNED32) #if (LZO_OPT_UNALIGNED32)
if (UA_GET_NE32(m_pos) != UA_GET_NE32(ip)) if (UA_GET_NE32(m_pos) != UA_GET_NE32(ip))
#else #else
if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3]) if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3])
@ -89,187 +100,264 @@ try_match:
{ {
/* a literal */ /* a literal */
literal: literal:
UPDATE_I(dict,0,dindex,ip,in); UPDATE_I(dict, 0, dindex, ip, in);
ip += 1 + ((ip - ii) >> 5); ip += 1 + ((ip - ii) >> 5);
continue; continue;
} }
/*match:*/
UPDATE_I(dict,0,dindex,ip,in); /*match:*/
UPDATE_I(dict, 0, dindex, ip, in);
#else #else
lzo_uint m_off; lzo_uint m_off;
lzo_uint m_len; lzo_uint m_len;
{ {
lzo_uint32_t dv; lzo_uint32_t dv;
lzo_uint dindex; lzo_uint dindex;
literal: literal:
ip += 1 + ((ip - ii) >> 5); ip += 1 + ((ip - ii) >> 5);
next: next:
if __lzo_unlikely(ip >= ip_end)
break; if __lzo_unlikely(ip >= ip_end)
dv = UA_GET_LE32(ip); break;
dindex = DINDEX(dv,ip);
GINDEX(m_off,m_pos,in+dict,dindex,in); dv = UA_GET_LE32(ip);
UPDATE_I(dict,0,dindex,ip,in); dindex = DINDEX(dv, ip);
if __lzo_unlikely(dv != UA_GET_LE32(m_pos)) GINDEX(m_off, m_pos, in + dict, dindex, in);
goto literal; UPDATE_I(dict, 0, dindex, ip, in);
if __lzo_unlikely(dv != UA_GET_LE32(m_pos))
goto literal;
} }
#endif #endif
/* a match */ /* a match */
ii -= ti; ti = 0; ii -= ti;
ti = 0;
{ {
lzo_uint t = pd(ip,ii); lzo_uint t = pd(ip, ii);
if (t != 0)
{ if (t != 0)
if (t <= 3)
{ {
op[-2] = LZO_BYTE(op[-2] | t); if (t <= 3)
{
op[-2] = LZO_BYTE(op[-2] | t);
#if (LZO_OPT_UNALIGNED32) #if (LZO_OPT_UNALIGNED32)
UA_COPY4(op, ii); UA_COPY4(op, ii);
op += t; op += t;
#else #else
{ do *op++ = *ii++; while (--t > 0); } { do* op++ = *ii++; while (--t > 0); }
#endif #endif
} }
#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) #if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64)
else if (t <= 16) else if (t <= 16)
{ {
*op++ = LZO_BYTE(t - 3);
UA_COPY8(op, ii);
UA_COPY8(op+8, ii+8);
op += t;
}
#endif
else
{
if (t <= 18)
*op++ = LZO_BYTE(t - 3); *op++ = LZO_BYTE(t - 3);
UA_COPY8(op, ii);
UA_COPY8(op + 8, ii + 8);
op += t;
}
#endif
else else
{ {
lzo_uint tt = t - 18; if (t <= 18)
*op++ = 0; *op++ = LZO_BYTE(t - 3);
while __lzo_unlikely(tt > 255) else
{ {
tt -= 255; lzo_uint tt = t - 18;
UA_SET1(op, 0); *op++ = 0;
op++;
while __lzo_unlikely(tt > 255)
{
tt -= 255;
UA_SET1(op, 0);
op++;
}
assert(tt > 0);
*op++ = LZO_BYTE(tt);
} }
assert(tt > 0);
*op++ = LZO_BYTE(tt);
}
#if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64) #if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64)
do {
UA_COPY8(op, ii); do
UA_COPY8(op+8, ii+8); {
op += 16; ii += 16; t -= 16; UA_COPY8(op, ii);
} while (t >= 16); if (t > 0) UA_COPY8(op + 8, ii + 8);
op += 16;
ii += 16;
t -= 16;
}
while (t >= 16);
if (t > 0)
#endif #endif
{ do *op++ = *ii++; while (--t > 0); } { do* op++ = *ii++; while (--t > 0); }
}
} }
} }
}
m_len = 4; m_len = 4;
{ {
#if (LZO_OPT_UNALIGNED64) #if (LZO_OPT_UNALIGNED64)
lzo_uint64_t v; lzo_uint64_t v;
v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len);
if __lzo_unlikely(v == 0) {
do { if __lzo_unlikely(v == 0)
m_len += 8; {
v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len); do
if __lzo_unlikely(ip + m_len >= ip_end) {
goto m_len_done; m_len += 8;
} while (v == 0); v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len);
}
if __lzo_unlikely(ip + m_len >= ip_end)
goto m_len_done;
}
while (v == 0);
}
#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz64) #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz64)
m_len += lzo_bitops_ctlz64(v) / CHAR_BIT; m_len += lzo_bitops_ctlz64(v) / CHAR_BIT;
#elif (LZO_ABI_BIG_ENDIAN) #elif (LZO_ABI_BIG_ENDIAN)
if ((v >> (64 - CHAR_BIT)) == 0) do {
v <<= CHAR_BIT; if ((v >> (64 - CHAR_BIT)) == 0) do
m_len += 1; {
} while ((v >> (64 - CHAR_BIT)) == 0); v <<= CHAR_BIT;
m_len += 1;
}
while ((v >> (64 - CHAR_BIT)) == 0);
#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz64) #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz64)
m_len += lzo_bitops_cttz64(v) / CHAR_BIT; m_len += lzo_bitops_cttz64(v) / CHAR_BIT;
#elif (LZO_ABI_LITTLE_ENDIAN) #elif (LZO_ABI_LITTLE_ENDIAN)
if ((v & UCHAR_MAX) == 0) do {
v >>= CHAR_BIT; if ((v & UCHAR_MAX) == 0) do
m_len += 1; {
} while ((v & UCHAR_MAX) == 0); v >>= CHAR_BIT;
m_len += 1;
}
while ((v & UCHAR_MAX) == 0);
#else #else
if (ip[m_len] == m_pos[m_len]) do {
m_len += 1; if (ip[m_len] == m_pos[m_len]) do
} while (ip[m_len] == m_pos[m_len]); {
m_len += 1;
}
while (ip[m_len] == m_pos[m_len]);
#endif #endif
#elif (LZO_OPT_UNALIGNED32) #elif (LZO_OPT_UNALIGNED32)
lzo_uint32_t v; lzo_uint32_t v;
v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len);
if __lzo_unlikely(v == 0) {
do { if __lzo_unlikely(v == 0)
m_len += 4; {
v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len); do
if (v != 0) {
break; m_len += 4;
m_len += 4; v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len);
v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len);
if __lzo_unlikely(ip + m_len >= ip_end) if (v != 0)
goto m_len_done; break;
} while (v == 0);
} m_len += 4;
v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len);
if __lzo_unlikely(ip + m_len >= ip_end)
goto m_len_done;
}
while (v == 0);
}
#if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz32) #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz32)
m_len += lzo_bitops_ctlz32(v) / CHAR_BIT; m_len += lzo_bitops_ctlz32(v) / CHAR_BIT;
#elif (LZO_ABI_BIG_ENDIAN) #elif (LZO_ABI_BIG_ENDIAN)
if ((v >> (32 - CHAR_BIT)) == 0) do {
v <<= CHAR_BIT; if ((v >> (32 - CHAR_BIT)) == 0) do
m_len += 1; {
} while ((v >> (32 - CHAR_BIT)) == 0); v <<= CHAR_BIT;
m_len += 1;
}
while ((v >> (32 - CHAR_BIT)) == 0);
#elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz32) #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz32)
m_len += lzo_bitops_cttz32(v) / CHAR_BIT; m_len += lzo_bitops_cttz32(v) / CHAR_BIT;
#elif (LZO_ABI_LITTLE_ENDIAN) #elif (LZO_ABI_LITTLE_ENDIAN)
if ((v & UCHAR_MAX) == 0) do {
v >>= CHAR_BIT; if ((v & UCHAR_MAX) == 0) do
m_len += 1; {
} while ((v & UCHAR_MAX) == 0); v >>= CHAR_BIT;
m_len += 1;
}
while ((v & UCHAR_MAX) == 0);
#else #else
if (ip[m_len] == m_pos[m_len]) do {
m_len += 1; if (ip[m_len] == m_pos[m_len]) do
} while (ip[m_len] == m_pos[m_len]); {
m_len += 1;
}
while (ip[m_len] == m_pos[m_len]);
#endif #endif
#else #else
if __lzo_unlikely(ip[m_len] == m_pos[m_len]) {
do { if __lzo_unlikely(ip[m_len] == m_pos[m_len])
m_len += 1; {
if (ip[m_len] != m_pos[m_len]) do
break; {
m_len += 1; m_len += 1;
if (ip[m_len] != m_pos[m_len])
break; if (ip[m_len] != m_pos[m_len])
m_len += 1; break;
if (ip[m_len] != m_pos[m_len])
break; m_len += 1;
m_len += 1;
if (ip[m_len] != m_pos[m_len]) if (ip[m_len] != m_pos[m_len])
break; break;
m_len += 1;
if (ip[m_len] != m_pos[m_len]) m_len += 1;
break;
m_len += 1; if (ip[m_len] != m_pos[m_len])
if (ip[m_len] != m_pos[m_len]) break;
break;
m_len += 1; m_len += 1;
if (ip[m_len] != m_pos[m_len])
break; if (ip[m_len] != m_pos[m_len])
m_len += 1; break;
if __lzo_unlikely(ip + m_len >= ip_end)
goto m_len_done; m_len += 1;
} while (ip[m_len] == m_pos[m_len]);
} if (ip[m_len] != m_pos[m_len])
break;
m_len += 1;
if (ip[m_len] != m_pos[m_len])
break;
m_len += 1;
if (ip[m_len] != m_pos[m_len])
break;
m_len += 1;
if __lzo_unlikely(ip + m_len >= ip_end)
goto m_len_done;
}
while (ip[m_len] == m_pos[m_len]);
}
#endif #endif
} }
m_len_done: m_len_done:
m_off = pd(ip,m_pos); m_off = pd(ip, m_pos);
ip += m_len; ip += m_len;
ii = ip; ii = ip;
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET)
{ {
m_off -= 1; m_off -= 1;
@ -284,48 +372,57 @@ m_len_done:
else if (m_off <= M3_MAX_OFFSET) else if (m_off <= M3_MAX_OFFSET)
{ {
m_off -= 1; m_off -= 1;
if (m_len <= M3_MAX_LEN) if (m_len <= M3_MAX_LEN)
*op++ = LZO_BYTE(M3_MARKER | (m_len - 2)); *op++ = LZO_BYTE(M3_MARKER | (m_len - 2));
else else
{ {
m_len -= M3_MAX_LEN; m_len -= M3_MAX_LEN;
*op++ = M3_MARKER | 0; *op++ = M3_MARKER | 0;
while __lzo_unlikely(m_len > 255) while __lzo_unlikely(m_len > 255)
{ {
m_len -= 255; m_len -= 255;
UA_SET1(op, 0); UA_SET1(op, 0);
op++; op++;
} }
*op++ = LZO_BYTE(m_len); *op++ = LZO_BYTE(m_len);
} }
*op++ = LZO_BYTE(m_off << 2); *op++ = LZO_BYTE(m_off << 2);
*op++ = LZO_BYTE(m_off >> 6); *op++ = LZO_BYTE(m_off >> 6);
} }
else else
{ {
m_off -= 0x4000; m_off -= 0x4000;
if (m_len <= M4_MAX_LEN) if (m_len <= M4_MAX_LEN)
*op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8) | (m_len - 2)); *op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8) | (m_len - 2));
else else
{ {
m_len -= M4_MAX_LEN; m_len -= M4_MAX_LEN;
*op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8)); *op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8));
while __lzo_unlikely(m_len > 255) while __lzo_unlikely(m_len > 255)
{ {
m_len -= 255; m_len -= 255;
UA_SET1(op, 0); UA_SET1(op, 0);
op++; op++;
} }
*op++ = LZO_BYTE(m_len); *op++ = LZO_BYTE(m_len);
} }
*op++ = LZO_BYTE(m_off << 2); *op++ = LZO_BYTE(m_off << 2);
*op++ = LZO_BYTE(m_off >> 6); *op++ = LZO_BYTE(m_off >> 6);
} }
goto next; goto next;
} }
*out_len = pd(op, out); *out_len = pd(op, out);
return pd(in_end,ii-ti); return pd(in_end, ii - ti);
} }
@ -334,9 +431,9 @@ m_len_done:
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, DO_COMPRESS(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
const lzo_bytep ip = in; const lzo_bytep ip = in;
lzo_bytep op = out; lzo_bytep op = out;
@ -351,16 +448,19 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len,
ll = LZO_MIN(ll, 49152); ll = LZO_MIN(ll, 49152);
#endif #endif
ll_end = (lzo_uintptr_t)ip + ll; ll_end = (lzo_uintptr_t)ip + ll;
if ((ll_end + ((t + ll) >> 5)) <= ll_end || (const lzo_bytep)(ll_end + ((t + ll) >> 5)) <= ip + ll) if ((ll_end + ((t + ll) >> 5)) <= ll_end || (const lzo_bytep)(ll_end + ((t + ll) >> 5)) <= ip + ll)
break; break;
#if (LZO_DETERMINISTIC) #if (LZO_DETERMINISTIC)
lzo_memset(wrkmem, 0, ((lzo_uint)1 << D_BITS) * sizeof(lzo_dict_t)); lzo_memset(wrkmem, 0, ((lzo_uint)1 << D_BITS) * sizeof(lzo_dict_t));
#endif #endif
t = do_compress(ip,ll,op,out_len,t,wrkmem); t = do_compress(ip, ll, op, out_len, t, wrkmem);
ip += ll; ip += ll;
op += *out_len; op += *out_len;
l -= ll; l -= ll;
} }
t += l; t += l;
if (t > 0) if (t > 0)
@ -378,15 +478,18 @@ DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len,
lzo_uint tt = t - 18; lzo_uint tt = t - 18;
*op++ = 0; *op++ = 0;
while (tt > 255) while (tt > 255)
{ {
tt -= 255; tt -= 255;
UA_SET1(op, 0); UA_SET1(op, 0);
op++; op++;
} }
assert(tt > 0); assert(tt > 0);
*op++ = LZO_BYTE(tt); *op++ = LZO_BYTE(tt);
} }
UA_COPYN(op, ii, t); UA_COPYN(op, ii, t);
op += t; op += t;
} }

View File

@ -35,9 +35,9 @@
#if defined(DO_DECOMPRESS) #if defined(DO_DECOMPRESS)
LZO_PUBLIC(int) LZO_PUBLIC(int)
DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, DO_DECOMPRESS(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
#endif #endif
{ {
lzo_bytep op; lzo_bytep op;
@ -61,6 +61,7 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
LZO_UNUSED(wrkmem); LZO_UNUSED(wrkmem);
#if defined(COPY_DICT) #if defined(COPY_DICT)
if (dict) if (dict)
{ {
if (dict_len > M4_MAX_OFFSET) if (dict_len > M4_MAX_OFFSET)
@ -68,6 +69,7 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
dict += dict_len - M4_MAX_OFFSET; dict += dict_len - M4_MAX_OFFSET;
dict_len = M4_MAX_OFFSET; dict_len = M4_MAX_OFFSET;
} }
dict_end = dict + dict_len; dict_end = dict + dict_len;
} }
else else
@ -75,6 +77,7 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
dict_len = 0; dict_len = 0;
dict_end = NULL; dict_end = NULL;
} }
#endif /* COPY_DICT */ #endif /* COPY_DICT */
*out_len = 0; *out_len = 0;
@ -83,13 +86,22 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
ip = in; ip = in;
NEED_IP(1); NEED_IP(1);
if (*ip > 17) if (*ip > 17)
{ {
t = *ip++ - 17; t = *ip++ - 17;
if (t < 4) if (t < 4)
goto match_next; goto match_next;
assert(t > 0); NEED_OP(t); NEED_IP(t+3);
do *op++ = *ip++; while (--t > 0); assert(t > 0);
NEED_OP(t);
NEED_IP(t + 3);
do* op++ = *ip++;
while (--t > 0);
goto first_literal_run; goto first_literal_run;
} }
@ -97,8 +109,10 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
{ {
NEED_IP(3); NEED_IP(3);
t = *ip++; t = *ip++;
if (t >= 16) if (t >= 16)
goto match; goto match;
/* a literal run */ /* a literal run */
if (t == 0) if (t == 0)
{ {
@ -109,47 +123,74 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
TEST_IV(t); TEST_IV(t);
NEED_IP(1); NEED_IP(1);
} }
t += 15 + *ip++; t += 15 + *ip++;
} }
/* copy literals */ /* copy literals */
assert(t > 0); NEED_OP(t+3); NEED_IP(t+6); assert(t > 0);
NEED_OP(t + 3);
NEED_IP(t + 6);
#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) #if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32)
t += 3; t += 3;
if (t >= 8) do if (t >= 8) do
{ {
UA_COPY8(op,ip); UA_COPY8(op, ip);
op += 8; ip += 8; t -= 8; op += 8;
} while (t >= 8); ip += 8;
t -= 8;
}
while (t >= 8);
if (t >= 4) if (t >= 4)
{ {
UA_COPY4(op,ip); UA_COPY4(op, ip);
op += 4; ip += 4; t -= 4; op += 4;
ip += 4;
t -= 4;
} }
if (t > 0) if (t > 0)
{ {
*op++ = *ip++; *op++ = *ip++;
if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
} }
#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) #elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4)
#if !(LZO_OPT_UNALIGNED32) #if !(LZO_OPT_UNALIGNED32)
if (PTR_ALIGNED2_4(op,ip))
if (PTR_ALIGNED2_4(op, ip))
{ {
#endif #endif
UA_COPY4(op,ip); UA_COPY4(op, ip);
op += 4; ip += 4; op += 4;
if (--t > 0) ip += 4;
{
if (t >= 4) if (--t > 0)
{ {
do { if (t >= 4)
UA_COPY4(op,ip); {
op += 4; ip += 4; t -= 4; do
} while (t >= 4); {
if (t > 0) do *op++ = *ip++; while (--t > 0); UA_COPY4(op, ip);
op += 4;
ip += 4;
t -= 4;
}
while (t >= 4);
if (t > 0) do* op++ = *ip++;
while (--t > 0);
}
else
do* op++ = *ip++;
while (--t > 0);
} }
else
do *op++ = *ip++; while (--t > 0);
}
#if !(LZO_OPT_UNALIGNED32) #if !(LZO_OPT_UNALIGNED32)
} }
else else
@ -157,9 +198,15 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
#endif #endif
#if !(LZO_OPT_UNALIGNED32) #if !(LZO_OPT_UNALIGNED32)
{ {
*op++ = *ip++; *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
do *op++ = *ip++; while (--t > 0); *op++ = *ip++;
*op++ = *ip++;
do* op++ = *ip++;
while (--t > 0);
} }
#endif #endif
@ -167,8 +214,10 @@ first_literal_run:
t = *ip++; t = *ip++;
if (t >= 16) if (t >= 16)
goto match; goto match;
#if defined(COPY_DICT) #if defined(COPY_DICT)
#if defined(LZO1Z) #if defined(LZO1Z)
m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
@ -177,7 +226,8 @@ first_literal_run:
m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
#endif #endif
NEED_OP(3); NEED_OP(3);
t = 3; COPY_DICT(t,m_off) t = 3;
COPY_DICT(t, m_off)
#else /* !COPY_DICT */ #else /* !COPY_DICT */
#if defined(LZO1Z) #if defined(LZO1Z)
t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
@ -188,15 +238,20 @@ first_literal_run:
m_pos -= t >> 2; m_pos -= t >> 2;
m_pos -= *ip++ << 2; m_pos -= *ip++ << 2;
#endif #endif
TEST_LB(m_pos); NEED_OP(3); TEST_LB(m_pos);
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos; NEED_OP(3);
*op++ = *m_pos++;
*op++ = *m_pos++;
*op++ = *m_pos;
#endif /* COPY_DICT */ #endif /* COPY_DICT */
goto match_done; goto match_done;
/* handle matches */ /* handle matches */
for (;;) { for (;;)
{
match: match:
if (t >= 64) /* a M2 match */ if (t >= 64) /* a M2 match */
{ {
#if defined(COPY_DICT) #if defined(COPY_DICT)
@ -208,6 +263,7 @@ match:
t = (t >> 4) - 3; t = (t >> 4) - 3;
#elif defined(LZO1Z) #elif defined(LZO1Z)
m_off = t & 0x1f; m_off = t & 0x1f;
if (m_off >= 0x1c) if (m_off >= 0x1c)
m_off = last_m_off; m_off = last_m_off;
else else
@ -215,6 +271,7 @@ match:
m_off = 1 + (m_off << 6) + (*ip++ >> 2); m_off = 1 + (m_off << 6) + (*ip++ >> 2);
last_m_off = m_off; last_m_off = m_off;
} }
t = (t >> 5) - 1; t = (t >> 5) - 1;
#endif #endif
#else /* !COPY_DICT */ #else /* !COPY_DICT */
@ -232,6 +289,7 @@ match:
{ {
lzo_uint off = t & 0x1f; lzo_uint off = t & 0x1f;
m_pos = op; m_pos = op;
if (off >= 0x1c) if (off >= 0x1c)
{ {
assert(last_m_off > 0); assert(last_m_off > 0);
@ -246,13 +304,16 @@ match:
} }
t = (t >> 5) - 1; t = (t >> 5) - 1;
#endif #endif
TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); TEST_LB(m_pos);
assert(t > 0);
NEED_OP(t + 3 - 1);
goto copy_match; goto copy_match;
#endif /* COPY_DICT */ #endif /* COPY_DICT */
} }
else if (t >= 32) /* a M3 match */ else if (t >= 32) /* a M3 match */
{ {
t &= 31; t &= 31;
if (t == 0) if (t == 0)
{ {
while (*ip == 0) while (*ip == 0)
@ -262,9 +323,11 @@ match:
TEST_OV(t); TEST_OV(t);
NEED_IP(1); NEED_IP(1);
} }
t += 31 + *ip++; t += 31 + *ip++;
NEED_IP(2); NEED_IP(2);
} }
#if defined(COPY_DICT) #if defined(COPY_DICT)
#if defined(LZO1Z) #if defined(LZO1Z)
m_off = 1 + (ip[0] << 6) + (ip[1] >> 2); m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
@ -298,6 +361,7 @@ match:
m_pos -= (t & 8) << 11; m_pos -= (t & 8) << 11;
#endif /* COPY_DICT */ #endif /* COPY_DICT */
t &= 7; t &= 7;
if (t == 0) if (t == 0)
{ {
while (*ip == 0) while (*ip == 0)
@ -307,9 +371,11 @@ match:
TEST_OV(t); TEST_OV(t);
NEED_IP(1); NEED_IP(1);
} }
t += 7 + *ip++; t += 7 + *ip++;
NEED_IP(2); NEED_IP(2);
} }
#if defined(COPY_DICT) #if defined(COPY_DICT)
#if defined(LZO1Z) #if defined(LZO1Z)
m_off += (ip[0] << 6) + (ip[1] >> 2); m_off += (ip[0] << 6) + (ip[1] >> 2);
@ -317,8 +383,10 @@ match:
m_off += (ip[0] >> 2) + (ip[1] << 6); m_off += (ip[0] >> 2) + (ip[1] << 6);
#endif #endif
ip += 2; ip += 2;
if (m_off == 0) if (m_off == 0)
goto eof_found; goto eof_found;
m_off += 0x4000; m_off += 0x4000;
#if defined(LZO1Z) #if defined(LZO1Z)
last_m_off = m_off; last_m_off = m_off;
@ -332,8 +400,10 @@ match:
m_pos -= (ip[0] >> 2) + (ip[1] << 6); m_pos -= (ip[0] >> 2) + (ip[1] << 6);
#endif #endif
ip += 2; ip += 2;
if (m_pos == op) if (m_pos == op)
goto eof_found; goto eof_found;
m_pos -= 0x4000; m_pos -= 0x4000;
#if defined(LZO1Z) #if defined(LZO1Z)
last_m_off = pd((const lzo_bytep)op, m_pos); last_m_off = pd((const lzo_bytep)op, m_pos);
@ -350,7 +420,8 @@ match:
m_off = 1 + (t >> 2) + (*ip++ << 2); m_off = 1 + (t >> 2) + (*ip++ << 2);
#endif #endif
NEED_OP(2); NEED_OP(2);
t = 2; COPY_DICT(t,m_off) t = 2;
COPY_DICT(t, m_off)
#else /* !COPY_DICT */ #else /* !COPY_DICT */
#if defined(LZO1Z) #if defined(LZO1Z)
t = 1 + (t << 6) + (*ip++ >> 2); t = 1 + (t << 6) + (*ip++ >> 2);
@ -361,8 +432,10 @@ match:
m_pos -= t >> 2; m_pos -= t >> 2;
m_pos -= *ip++ << 2; m_pos -= *ip++ << 2;
#endif #endif
TEST_LB(m_pos); NEED_OP(2); TEST_LB(m_pos);
*op++ = *m_pos++; *op++ = *m_pos; NEED_OP(2);
*op++ = *m_pos++;
*op++ = *m_pos;
#endif /* COPY_DICT */ #endif /* COPY_DICT */
goto match_done; goto match_done;
} }
@ -370,56 +443,84 @@ match:
/* copy match */ /* copy match */
#if defined(COPY_DICT) #if defined(COPY_DICT)
NEED_OP(t+3-1); NEED_OP(t + 3 - 1);
t += 3-1; COPY_DICT(t,m_off) t += 3 - 1;
COPY_DICT(t, m_off)
#else /* !COPY_DICT */ #else /* !COPY_DICT */
TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); TEST_LB(m_pos);
assert(t > 0);
NEED_OP(t + 3 - 1);
#if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32) #if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32)
if (op - m_pos >= 8) if (op - m_pos >= 8)
{ {
t += (3 - 1); t += (3 - 1);
if (t >= 8) do if (t >= 8) do
{ {
UA_COPY8(op,m_pos); UA_COPY8(op, m_pos);
op += 8; m_pos += 8; t -= 8; op += 8;
} while (t >= 8); m_pos += 8;
t -= 8;
}
while (t >= 8);
if (t >= 4) if (t >= 4)
{ {
UA_COPY4(op,m_pos); UA_COPY4(op, m_pos);
op += 4; m_pos += 4; t -= 4; op += 4;
m_pos += 4;
t -= 4;
} }
if (t > 0) if (t > 0)
{ {
*op++ = m_pos[0]; *op++ = m_pos[0];
if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } } if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } }
} }
} }
else else
#elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4) #elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4)
#if !(LZO_OPT_UNALIGNED32) #if !(LZO_OPT_UNALIGNED32)
if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op, m_pos))
{ {
assert((op - m_pos) >= 4); /* both pointers are aligned */ assert((op - m_pos) >= 4); /* both pointers are aligned */
#else #else
if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
{ {
#endif #endif
UA_COPY4(op,m_pos); UA_COPY4(op, m_pos);
op += 4; m_pos += 4; t -= 4 - (3 - 1); op += 4;
do { m_pos += 4;
UA_COPY4(op,m_pos); t -= 4 - (3 - 1);
op += 4; m_pos += 4; t -= 4;
} while (t >= 4); do
if (t > 0) do *op++ = *m_pos++; while (--t > 0); {
UA_COPY4(op, m_pos);
op += 4;
m_pos += 4;
t -= 4;
}
while (t >= 4);
if (t > 0) do* op++ = *m_pos++;
while (--t > 0);
} }
else else
#endif #endif
{ {
copy_match: copy_match:
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++;
do *op++ = *m_pos++; while (--t > 0); *op++ = *m_pos++;
do* op++ = *m_pos++;
while (--t > 0);
} }
#endif /* COPY_DICT */ #endif /* COPY_DICT */
@ -430,17 +531,27 @@ match_done:
#else #else
t = ip[-2] & 3; t = ip[-2] & 3;
#endif #endif
if (t == 0) if (t == 0)
break; break;
/* copy literals */ /* copy literals */
match_next: match_next:
assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3); assert(t > 0);
assert(t < 4);
NEED_OP(t);
NEED_IP(t + 3);
#if 0 #if 0
do *op++ = *ip++; while (--t > 0);
do* op++ = *ip++;
while (--t > 0);
#else #else
*op++ = *ip++; *op++ = *ip++;
if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
#endif #endif
t = *ip++; t = *ip++;
} }
@ -449,7 +560,7 @@ match_next:
eof_found: eof_found:
*out_len = pd(op, out); *out_len = pd(op, out);
return (ip == ip_end ? LZO_E_OK : return (ip == ip_end ? LZO_E_OK :
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
#if defined(HAVE_NEED_IP) #if defined(HAVE_NEED_IP)

View File

@ -35,24 +35,24 @@
#if defined(LZO_ARCH_I386) && defined(LZO_USE_ASM) #if defined(LZO_ARCH_I386) && defined(LZO_USE_ASM)
LZO_EXTERN(int) lzo1x_decompress_asm_safe LZO_EXTERN(int) lzo1x_decompress_asm_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_PUBLIC(int) lzo1x_decompress_asm_safe LZO_PUBLIC(int) lzo1x_decompress_asm_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem) lzo_voidp wrkmem)
{ {
return lzo1x_decompress_safe(src, src_len, dst, dst_len, wrkmem); return lzo1x_decompress_safe(src, src_len, dst, dst_len, wrkmem);
} }
LZO_EXTERN(int) lzo1x_decompress_asm_fast_safe LZO_EXTERN(int) lzo1x_decompress_asm_fast_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_PUBLIC(int) lzo1x_decompress_asm_fast_safe LZO_PUBLIC(int) lzo1x_decompress_asm_fast_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem) lzo_voidp wrkmem)
{ {
return lzo1x_decompress_safe(src, src_len, dst, dst_len, wrkmem); return lzo1x_decompress_safe(src, src_len, dst, dst_len, wrkmem);
} }

View File

@ -81,10 +81,10 @@
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo1x_decompress_dict_safe ( const lzo_bytep in, lzo_uint in_len, lzo1x_decompress_dict_safe(const lzo_bytep in, lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem /* NOT USED */, lzo_voidp wrkmem /* NOT USED */,
const lzo_bytep dict, lzo_uint dict_len) const lzo_bytep dict, lzo_uint dict_len)
#include "lzo1x_d.ch" #include "lzo1x_d.ch"

View File

@ -41,6 +41,7 @@ static void copy2(lzo_bytep ip, const lzo_bytep m_pos, lzo_uint off)
{ {
assert(off > 0); assert(off > 0);
ip[0] = m_pos[0]; ip[0] = m_pos[0];
if (off == 1) if (off == 1)
ip[1] = m_pos[0]; ip[1] = m_pos[0];
else else
@ -52,6 +53,7 @@ static void copy3(lzo_bytep ip, const lzo_bytep m_pos, lzo_uint off)
{ {
assert(off > 0); assert(off > 0);
ip[0] = m_pos[0]; ip[0] = m_pos[0];
if (off == 1) if (off == 1)
{ {
ip[2] = ip[1] = m_pos[0]; ip[2] = ip[1] = m_pos[0];
@ -74,9 +76,9 @@ static void copy3(lzo_bytep ip, const lzo_bytep m_pos, lzo_uint off)
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
DO_OPTIMIZE ( lzo_bytep in , lzo_uint in_len, DO_OPTIMIZE(lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
lzo_bytep op; lzo_bytep op;
lzo_bytep ip; lzo_bytep ip;
@ -98,41 +100,57 @@ DO_OPTIMIZE ( lzo_bytep in , lzo_uint in_len,
ip = in; ip = in;
assert(in_len >= 3); assert(in_len >= 3);
if (*ip > 17) if (*ip > 17)
{ {
t = *ip++ - 17; t = *ip++ - 17;
if (t < 4) if (t < 4)
goto match_next; goto match_next;
goto first_literal_run; goto first_literal_run;
} }
assert(*ip < 16 || (*ip == 17 && in_len == 3)); assert(*ip < 16 || (*ip == 17 && in_len == 3));
while (TEST_IP_AND_TEST_OP) while (TEST_IP_AND_TEST_OP)
{ {
t = *ip++; t = *ip++;
if (t >= 16) if (t >= 16)
goto match; goto match;
/* a literal run */ /* a literal run */
litp = ip - 1; litp = ip - 1;
if (t == 0) if (t == 0)
{ {
t = 15; t = 15;
while (*ip == 0) while (*ip == 0)
t += 255, ip++; t += 255, ip++;
t += *ip++; t += *ip++;
} }
lit = t + 3; lit = t + 3;
/* copy literals */ /* copy literals */
copy_literal_run: copy_literal_run:
*op++ = *ip++; *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
*op++ = *ip++;
*op++ = *ip++;
first_literal_run: first_literal_run:
do *op++ = *ip++; while (--t > 0);
do* op++ = *ip++;
while (--t > 0);
t = *ip++; t = *ip++;
if (t >= 16) if (t >= 16)
goto match; goto match;
#if defined(LZO1X) #if defined(LZO1X)
m_pos = op - 1 - 0x800; m_pos = op - 1 - 0x800;
#elif defined(LZO1Y) #elif defined(LZO1Y)
@ -140,13 +158,16 @@ first_literal_run:
#endif #endif
m_pos -= t >> 2; m_pos -= t >> 2;
m_pos -= *ip++ << 2; m_pos -= *ip++ << 2;
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++;
*op++ = *m_pos++;
*op++ = *m_pos++;
lit = 0; lit = 0;
goto match_done; goto match_done;
/* handle matches */ /* handle matches */
do { do
{
if (t < 16) /* a M1 match */ if (t < 16) /* a M1 match */
{ {
m_pos = op - 1; m_pos = op - 1;
@ -161,6 +182,7 @@ first_literal_run:
assert(litp == ip - 2 - lit - 2); assert(litp == ip - 2 - lit - 2);
assert((lzo_uint)(*litp & 3) == lit); assert((lzo_uint)(*litp & 3) == lit);
nl = ip[-2] & 3; nl = ip[-2] & 3;
/* test if a match follows */ /* test if a match follows */
if (nl == 0 && lit == 1 && ip[0] >= 16) if (nl == 0 && lit == 1 && ip[0] >= 16)
{ {
@ -169,7 +191,7 @@ first_literal_run:
lit += 2; lit += 2;
*litp = LZO_BYTE((*litp & ~3) | lit); *litp = LZO_BYTE((*litp & ~3) | lit);
/* copy over the 2 literals that replace the match */ /* copy over the 2 literals that replace the match */
copy2(ip-2,m_pos,pd(op,m_pos)); copy2(ip - 2, m_pos, pd(op, m_pos));
o_m1_a++; o_m1_a++;
} }
/* test if a literal run follows */ /* test if a literal run follows */
@ -180,25 +202,32 @@ first_literal_run:
/* remove short run */ /* remove short run */
*litp &= ~3; *litp &= ~3;
/* copy over the 2 literals that replace the match */ /* copy over the 2 literals that replace the match */
copy2(ip-3+1,m_pos,pd(op,m_pos)); copy2(ip - 3 + 1, m_pos, pd(op, m_pos));
/* move literals 1 byte ahead */ /* move literals 1 byte ahead */
litp += 2; litp += 2;
if (lit > 0) if (lit > 0)
lzo_memmove(litp+1,litp,lit); lzo_memmove(litp + 1, litp, lit);
/* insert new length of long literal run */ /* insert new length of long literal run */
lit += 2 + t + 3; assert(lit <= 18); lit += 2 + t + 3;
assert(lit <= 18);
*litp = LZO_BYTE(lit - 3); *litp = LZO_BYTE(lit - 3);
o_m1_b++; o_m1_b++;
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++;
*op++ = *m_pos++;
goto copy_literal_run; goto copy_literal_run;
} }
copy_m1: copy_m1:
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++;
*op++ = *m_pos++;
} }
else else
{ {
match: match:
if (t >= 64) /* a M2 match */ if (t >= 64) /* a M2 match */
{ {
m_pos = op - 1; m_pos = op - 1;
@ -211,23 +240,28 @@ match:
m_pos -= *ip++ << 2; m_pos -= *ip++ << 2;
t = (t >> 4) - 3; t = (t >> 4) - 3;
#endif #endif
if (litp == NULL) if (litp == NULL)
goto copy_m; goto copy_m;
nl = ip[-2] & 3; nl = ip[-2] & 3;
/* test if in beetween two long literal runs */ /* test if in beetween two long literal runs */
if (t == 1 && lit > 3 && nl == 0 && if (t == 1 && lit > 3 && nl == 0 &&
ip[0] < 16 && ip[0] != 0 && (lit + 3 + ip[0] < 16)) ip[0] < 16 && ip[0] != 0 && (lit + 3 + ip[0] < 16))
{ {
assert(*litp == lit - 3); assert(*litp == lit - 3);
t = *ip++; t = *ip++;
/* copy over the 3 literals that replace the match */ /* copy over the 3 literals that replace the match */
copy3(ip-1-2,m_pos,pd(op,m_pos)); copy3(ip - 1 - 2, m_pos, pd(op, m_pos));
/* set new length of previous literal run */ /* set new length of previous literal run */
lit += 3 + t + 3; assert(lit <= 18); lit += 3 + t + 3;
assert(lit <= 18);
*litp = LZO_BYTE(lit - 3); *litp = LZO_BYTE(lit - 3);
o_m2++; o_m2++;
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++;
*op++ = *m_pos++;
*op++ = *m_pos++;
goto copy_literal_run; goto copy_literal_run;
} }
} }
@ -236,13 +270,17 @@ match:
if (t >= 32) /* a M3 match */ if (t >= 32) /* a M3 match */
{ {
t &= 31; t &= 31;
if (t == 0) if (t == 0)
{ {
t = 31; t = 31;
while (*ip == 0) while (*ip == 0)
t += 255, ip++; t += 255, ip++;
t += *ip++; t += *ip++;
} }
m_pos = op - 1; m_pos = op - 1;
m_pos -= *ip++ >> 2; m_pos -= *ip++ >> 2;
m_pos -= *ip++ << 6; m_pos -= *ip++ << 6;
@ -252,23 +290,31 @@ match:
m_pos = op; m_pos = op;
m_pos -= (t & 8) << 11; m_pos -= (t & 8) << 11;
t &= 7; t &= 7;
if (t == 0) if (t == 0)
{ {
t = 7; t = 7;
while (*ip == 0) while (*ip == 0)
t += 255, ip++; t += 255, ip++;
t += *ip++; t += *ip++;
} }
m_pos -= *ip++ >> 2; m_pos -= *ip++ >> 2;
m_pos -= *ip++ << 6; m_pos -= *ip++ << 6;
if (m_pos == op) if (m_pos == op)
goto eof_found; goto eof_found;
m_pos -= 0x4000; m_pos -= 0x4000;
} }
if (litp == NULL) if (litp == NULL)
goto copy_m; goto copy_m;
nl = ip[-2] & 3; nl = ip[-2] & 3;
/* test if in beetween two matches */ /* test if in beetween two matches */
if (t == 1 && lit == 0 && nl == 0 && ip[0] >= 16) if (t == 1 && lit == 0 && nl == 0 && ip[0] >= 16)
{ {
@ -279,7 +325,7 @@ match:
lit += 3; lit += 3;
*litp = LZO_BYTE((*litp & ~3) | lit); *litp = LZO_BYTE((*litp & ~3) | lit);
/* copy over the 3 literals that replace the match */ /* copy over the 3 literals that replace the match */
copy3(ip-3,m_pos,pd(op,m_pos)); copy3(ip - 3, m_pos, pd(op, m_pos));
o_m3_a++; o_m3_a++;
} }
/* test if a literal run follows */ /* test if a literal run follows */
@ -292,26 +338,37 @@ match:
/* remove short run */ /* remove short run */
*litp &= ~3; *litp &= ~3;
/* copy over the 3 literals that replace the match */ /* copy over the 3 literals that replace the match */
copy3(ip-4+1,m_pos,pd(op,m_pos)); copy3(ip - 4 + 1, m_pos, pd(op, m_pos));
/* move literals 1 byte ahead */ /* move literals 1 byte ahead */
litp += 2; litp += 2;
if (lit > 0) if (lit > 0)
lzo_memmove(litp+1,litp,lit); lzo_memmove(litp + 1, litp, lit);
/* insert new length of long literal run */ /* insert new length of long literal run */
lit += 3 + t + 3; assert(lit <= 18); lit += 3 + t + 3;
assert(lit <= 18);
*litp = LZO_BYTE(lit - 3); *litp = LZO_BYTE(lit - 3);
o_m3_b++; o_m3_b++;
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++;
*op++ = *m_pos++;
*op++ = *m_pos++;
goto copy_literal_run; goto copy_literal_run;
} }
} }
copy_m: copy_m:
*op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos++;
do *op++ = *m_pos++; while (--t > 0); *op++ = *m_pos++;
do* op++ = *m_pos++;
while (--t > 0);
} }
match_done: match_done:
if (next_lit == NO_LIT) if (next_lit == NO_LIT)
{ {
t = ip[-2] & 3; t = ip[-2] & 3;
@ -320,15 +377,23 @@ match_done:
} }
else else
t = next_lit; t = next_lit;
assert(t <= 3); assert(t <= 3);
next_lit = NO_LIT; next_lit = NO_LIT;
if (t == 0) if (t == 0)
break; break;
/* copy literals */ /* copy literals */
match_next: match_next:
do *op++ = *ip++; while (--t > 0);
do* op++ = *ip++;
while (--t > 0);
t = *ip++; t = *ip++;
} while (TEST_IP_AND_TEST_OP); }
while (TEST_IP_AND_TEST_OP);
} }
/* no EOF code was found */ /* no EOF code was found */
@ -341,11 +406,14 @@ eof_found:
printf("optimize: %5lu %5lu %5lu %5lu %5lu\n", printf("optimize: %5lu %5lu %5lu %5lu %5lu\n",
o_m1_a, o_m1_b, o_m2, o_m3_a, o_m3_b); o_m1_a, o_m1_b, o_m2, o_m3_a, o_m3_b);
#endif #endif
LZO_UNUSED(o_m1_a); LZO_UNUSED(o_m1_b); LZO_UNUSED(o_m2); LZO_UNUSED(o_m1_a);
LZO_UNUSED(o_m3_a); LZO_UNUSED(o_m3_b); LZO_UNUSED(o_m1_b);
LZO_UNUSED(o_m2);
LZO_UNUSED(o_m3_a);
LZO_UNUSED(o_m3_b);
*out_len = pd(op, out); *out_len = pd(op, out);
return (ip == ip_end ? LZO_E_OK : return (ip == ip_end ? LZO_E_OK :
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
} }

View File

@ -35,24 +35,24 @@
#if defined(LZO_ARCH_I386) && defined(LZO_USE_ASM) #if defined(LZO_ARCH_I386) && defined(LZO_USE_ASM)
LZO_EXTERN(int) lzo1y_decompress_asm_safe LZO_EXTERN(int) lzo1y_decompress_asm_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_PUBLIC(int) lzo1y_decompress_asm_safe LZO_PUBLIC(int) lzo1y_decompress_asm_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem) lzo_voidp wrkmem)
{ {
return lzo1y_decompress_safe(src, src_len, dst, dst_len, wrkmem); return lzo1y_decompress_safe(src, src_len, dst, dst_len, wrkmem);
} }
LZO_EXTERN(int) lzo1y_decompress_asm_fast_safe LZO_EXTERN(int) lzo1y_decompress_asm_fast_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem); lzo_voidp wrkmem);
LZO_PUBLIC(int) lzo1y_decompress_asm_fast_safe LZO_PUBLIC(int) lzo1y_decompress_asm_fast_safe
(const lzo_bytep src, lzo_uint src_len, (const lzo_bytep src, lzo_uint src_len,
lzo_bytep dst, lzo_uintp dst_len, lzo_bytep dst, lzo_uintp dst_len,
lzo_voidp wrkmem) lzo_voidp wrkmem)
{ {
return lzo1y_decompress_safe(src, src_len, dst, dst_len, wrkmem); return lzo1y_decompress_safe(src, src_len, dst, dst_len, wrkmem);
} }

View File

@ -46,7 +46,7 @@
#if (LZO_CC_BORLANDC && LZO_MM_FLAT) #if (LZO_CC_BORLANDC && LZO_MM_FLAT)
# if ((__BORLANDC__) >= 0x0450 && (__BORLANDC__) < 0x0460) # if ((__BORLANDC__) >= 0x0450 && (__BORLANDC__) < 0x0460)
/* avoid internal compiler error */ /* avoid internal compiler error */
# pragma option -Od # pragma option -Od
# endif # endif
#endif #endif
@ -72,24 +72,24 @@
************************************************************************/ ************************************************************************/
LZO_EXTERN(int) LZO_EXTERN(int)
lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len, lzo2a_999_compress_callback(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_callback_p cb, lzo_callback_p cb,
lzo_uint max_chain ); lzo_uint max_chain);
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len, lzo2a_999_compress_callback(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem, lzo_voidp wrkmem,
lzo_callback_p cb, lzo_callback_p cb,
lzo_uint max_chain ) lzo_uint max_chain)
{ {
lzo_bytep op; lzo_bytep op;
lzo_bytep bitp = 0; lzo_bytep bitp = 0;
lzo_uint m_len, m_off; lzo_uint m_len, m_off;
LZO_COMPRESS_T cc; LZO_COMPRESS_T cc;
LZO_COMPRESS_T * const c = &cc; LZO_COMPRESS_T* const c = &cc;
lzo_swd_p const swd = (lzo_swd_p) wrkmem; lzo_swd_p const swd = (lzo_swd_p) wrkmem;
int r; int r;
@ -107,15 +107,19 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
op = out; op = out;
r = init_match(c,swd,NULL,0,0); r = init_match(c, swd, NULL, 0, 0);
if (r != 0) if (r != 0)
return r; return r;
if (max_chain > 0) if (max_chain > 0)
swd->max_chain = max_chain; swd->max_chain = max_chain;
r = find_match(c,swd,0,0); r = find_match(c, swd, 0, 0);
if (r != 0) if (r != 0)
return r; return r;
while (c->look > 0) while (c->look > 0)
{ {
lzo_uint lazy_match_min_gain = 0; lzo_uint lazy_match_min_gain = 0;
@ -129,6 +133,7 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
m_off = c->m_off; m_off = c->m_off;
#if (SWD_N >= 8192) #if (SWD_N >= 8192)
if (m_off >= 8192) if (m_off >= 8192)
{ {
if (m_len < M3_MIN_LEN) if (m_len < M3_MIN_LEN)
@ -138,25 +143,25 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
} }
else else
#endif #endif
if (m_len >= M1_MIN_LEN && m_len <= M1_MAX_LEN && m_off <= 256) if (m_len >= M1_MIN_LEN && m_len <= M1_MAX_LEN && m_off <= 256)
{ {
lazy_match_min_gain = 2; lazy_match_min_gain = 2;
#if (SWD_N >= 8192) #if (SWD_N >= 8192)
extra1 = 3; extra1 = 3;
#endif #endif
extra2 = 2; extra2 = 2;
} }
else if (m_len >= 10) else if (m_len >= 10)
lazy_match_min_gain = 1; lazy_match_min_gain = 1;
else if (m_len >= 3) else if (m_len >= 3)
{ {
lazy_match_min_gain = 1; lazy_match_min_gain = 1;
#if (SWD_N >= 8192) #if (SWD_N >= 8192)
extra1 = 1; extra1 = 1;
#endif #endif
} }
else else
m_len = 0; m_len = 0;
/* try a lazy match */ /* try a lazy match */
@ -164,25 +169,28 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
{ {
unsigned char lit = LZO_BYTE(swd->b_char); unsigned char lit = LZO_BYTE(swd->b_char);
r = find_match(c,swd,1,0); r = find_match(c, swd, 1, 0);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
assert(c->look > 0); assert(c->look > 0);
#if (SWD_N >= 8192) #if (SWD_N >= 8192)
if (m_off < 8192 && c->m_off >= 8192) if (m_off < 8192 && c->m_off >= 8192)
lazy_match_min_gain += extra1; lazy_match_min_gain += extra1;
else else
#endif #endif
if (m_len >= M1_MIN_LEN && m_len <= M1_MAX_LEN && m_off <= 256) if (m_len >= M1_MIN_LEN && m_len <= M1_MAX_LEN && m_off <= 256)
{ {
if (!(c->m_len >= M1_MIN_LEN && if (!(c->m_len >= M1_MIN_LEN &&
c->m_len <= M1_MAX_LEN && c->m_off <= 256)) c->m_len <= M1_MAX_LEN && c->m_off <= 256))
lazy_match_min_gain += extra2; lazy_match_min_gain += extra2;
} }
if (c->m_len >= M1_MIN_LEN && if (c->m_len >= M1_MIN_LEN &&
c->m_len <= M1_MAX_LEN && c->m_off <= 256) c->m_len <= M1_MAX_LEN && c->m_off <= 256)
{ {
lazy_match_min_gain -= 1; lazy_match_min_gain -= 1;
} }
if ((lzo_int) lazy_match_min_gain < 1) if ((lzo_int) lazy_match_min_gain < 1)
@ -206,6 +214,7 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
} }
else else
ahead = 1; ahead = 1;
assert(m_len > 0); assert(m_len > 0);
} }
@ -216,8 +225,9 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
putbit(0); putbit(0);
putbyte(swd->b_char); putbyte(swd->b_char);
c->lit_bytes++; c->lit_bytes++;
r = find_match(c,swd,1,0); r = find_match(c, swd, 1, 0);
assert(r == 0); LZO_UNUSED(r); assert(r == 0);
LZO_UNUSED(r);
} }
else else
{ {
@ -230,10 +240,11 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
{ {
putbit(1); putbit(1);
putbit(0); putbit(0);
putbits(2,m_len - M1_MIN_LEN); putbits(2, m_len - M1_MIN_LEN);
putbyte(m_off - 1); putbyte(m_off - 1);
c->m1++; c->m1++;
} }
#if (SWD_N >= 8192) #if (SWD_N >= 8192)
else if (m_off >= 8192) else if (m_off >= 8192)
{ {
@ -245,14 +256,17 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
putbyte(m_off >> 5); putbyte(m_off >> 5);
putbit(1); putbit(1);
len -= M3_MIN_LEN - 1; len -= M3_MIN_LEN - 1;
while (len > 255) while (len > 255)
{ {
len -= 255; len -= 255;
putbyte(0); putbyte(0);
} }
putbyte(len); putbyte(len);
c->m4++; c->m4++;
} }
#endif #endif
else else
{ {
@ -260,6 +274,7 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
putbit(1); putbit(1);
putbit(1); putbit(1);
if (m_len <= 9) if (m_len <= 9)
{ {
putbyte(((m_len - 2) << 5) | (m_off & 31)); putbyte(((m_len - 2) << 5) | (m_off & 31));
@ -275,17 +290,21 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
putbit(0); putbit(0);
#endif #endif
len -= 10 - 1; len -= 10 - 1;
while (len > 255) while (len > 255)
{ {
len -= 255; len -= 255;
putbyte(0); putbyte(0);
} }
putbyte(len); putbyte(len);
c->m3++; c->m3++;
} }
} }
r = find_match(c,swd,m_len,1+ahead);
assert(r == 0); LZO_UNUSED(r); r = find_match(c, swd, m_len, 1 + ahead);
assert(r == 0);
LZO_UNUSED(r);
} }
c->codesize = pd(op, out); c->codesize = pd(op, out);
@ -301,6 +320,7 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
/* flush remaining bits */ /* flush remaining bits */
assert(k < CHAR_BIT); assert(k < CHAR_BIT);
if (k > 0) if (k > 0)
{ {
assert(b == MASKBITS(k)); assert(b == MASKBITS(k));
@ -321,8 +341,8 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
#if 0 #if 0
printf("%ld -> %ld: %ld %ld %ld %ld %ld %ld\n", printf("%ld -> %ld: %ld %ld %ld %ld %ld %ld\n",
(long) c->textsize, (long) c->codesize, (long) c->textsize, (long) c->codesize,
c->lit_bytes, c->m1, c->m2, c->m3, c->m4, c->lazy); c->lit_bytes, c->m1, c->m2, c->m3, c->m4, c->lazy);
#endif #endif
return LZO_E_OK; return LZO_E_OK;
} }
@ -334,11 +354,11 @@ lzo2a_999_compress_callback ( const lzo_bytep in , lzo_uint in_len,
************************************************************************/ ************************************************************************/
LZO_PUBLIC(int) LZO_PUBLIC(int)
lzo2a_999_compress ( const lzo_bytep in , lzo_uint in_len, lzo2a_999_compress(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
return lzo2a_999_compress_callback(in,in_len,out,out_len,wrkmem, return lzo2a_999_compress_callback(in, in_len, out, out_len, wrkmem,
(lzo_callback_p) 0, 0); (lzo_callback_p) 0, 0);
} }

View File

@ -37,9 +37,9 @@
#define _NEXTBYTE (*ip++) #define _NEXTBYTE (*ip++)
LZO_PUBLIC(int) LZO_PUBLIC(int)
DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, DO_DECOMPRESS(const lzo_bytep in , lzo_uint in_len,
lzo_bytep out, lzo_uintp out_len, lzo_bytep out, lzo_uintp out_len,
lzo_voidp wrkmem ) lzo_voidp wrkmem)
{ {
lzo_bytep op; lzo_bytep op;
const lzo_bytep ip; const lzo_bytep ip;
@ -62,17 +62,21 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
while (TEST_IP_AND_TEST_OP) while (TEST_IP_AND_TEST_OP)
{ {
NEEDBITS(1); NEEDBITS(1);
if (MASKBITS(1) == 0) if (MASKBITS(1) == 0)
{ {
DUMPBITS(1); DUMPBITS(1);
/* a literal */ /* a literal */
NEED_IP(1); NEED_OP(1); NEED_IP(1);
NEED_OP(1);
*op++ = *ip++; *op++ = *ip++;
continue; continue;
} }
DUMPBITS(1); DUMPBITS(1);
NEEDBITS(1); NEEDBITS(1);
if (MASKBITS(1) == 0) if (MASKBITS(1) == 0)
{ {
DUMPBITS(1); DUMPBITS(1);
@ -80,26 +84,31 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
NEEDBITS(2); NEEDBITS(2);
t = M1_MIN_LEN + (lzo_uint) MASKBITS(2); t = M1_MIN_LEN + (lzo_uint) MASKBITS(2);
DUMPBITS(2); DUMPBITS(2);
NEED_IP(1); NEED_OP(t); NEED_IP(1);
NEED_OP(t);
m_pos = op - 1 - *ip++; m_pos = op - 1 - *ip++;
assert(m_pos >= out); assert(m_pos < op); assert(m_pos >= out);
assert(m_pos < op);
TEST_LB(m_pos); TEST_LB(m_pos);
MEMCPY_DS(op,m_pos,t); MEMCPY_DS(op, m_pos, t);
continue; continue;
} }
DUMPBITS(1); DUMPBITS(1);
NEED_IP(2); NEED_IP(2);
t = *ip++; t = *ip++;
m_pos = op; m_pos = op;
m_pos -= (t & 31) | (((lzo_uint) *ip++) << 5); m_pos -= (t & 31) | (((lzo_uint) * ip++) << 5);
t >>= 5; t >>= 5;
if (t == 0) if (t == 0)
{ {
#if (SWD_N >= 8192) #if (SWD_N >= 8192)
NEEDBITS(1); NEEDBITS(1);
t = MASKBITS(1); t = MASKBITS(1);
DUMPBITS(1); DUMPBITS(1);
if (t == 0) if (t == 0)
t = 10 - 1; t = 10 - 1;
else else
@ -108,10 +117,12 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
m_pos -= 8192; /* t << 13 */ m_pos -= 8192; /* t << 13 */
t = M3_MIN_LEN - 1; t = M3_MIN_LEN - 1;
} }
#else #else
t = 10 - 1; t = 10 - 1;
#endif #endif
NEED_IP(1); NEED_IP(1);
while (*ip == 0) while (*ip == 0)
{ {
t += 255; t += 255;
@ -119,20 +130,25 @@ DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
TEST_OV(t); TEST_OV(t);
NEED_IP(1); NEED_IP(1);
} }
t += *ip++; t += *ip++;
} }
else else
{ {
#if defined(LZO_EOF_CODE) #if defined(LZO_EOF_CODE)
if (m_pos == op) if (m_pos == op)
goto eof_found; goto eof_found;
#endif #endif
t += 2; t += 2;
} }
assert(m_pos >= out); assert(m_pos < op);
assert(m_pos >= out);
assert(m_pos < op);
TEST_LB(m_pos); TEST_LB(m_pos);
NEED_OP(t); NEED_OP(t);
MEMCPY_DS(op,m_pos,t); MEMCPY_DS(op, m_pos, t);
} }
@ -148,7 +164,7 @@ eof_found:
#endif #endif
*out_len = pd(op, out); *out_len = pd(op, out);
return (ip == ip_end ? LZO_E_OK : return (ip == ip_end ? LZO_E_OK :
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
#if defined(HAVE_NEED_IP) #if defined(HAVE_NEED_IP)

View File

@ -47,7 +47,7 @@
# error "include this file first" # error "include this file first"
#endif #endif
#if defined(LZO_CFG_BUILD_DLL) && (LZO_CFG_BUILD_DLL+0) && !defined(__LZO_EXPORT1) && !defined(__LZO_EXPORT2) && 0 #if defined(LZO_CFG_BUILD_DLL) && (LZO_CFG_BUILD_DLL+0) && !defined(__LZO_EXPORT1) && !defined(__LZO_EXPORT2) && 0
/* idea: we could auto-define __LZO_EXPORT1 for DLL exports */ /* idea: we could auto-define __LZO_EXPORT1 for DLL exports */
#ifndef __LZODEFS_H_INCLUDED #ifndef __LZODEFS_H_INCLUDED
#if defined(LZO_HAVE_CONFIG_H) #if defined(LZO_HAVE_CONFIG_H)
# include <config.h> # include <config.h>
@ -56,8 +56,8 @@
#include <stddef.h> #include <stddef.h>
#include <lzo/lzodefs.h> #include <lzo/lzodefs.h>
#endif #endif
/* #define __LZO_EXPORT1 __attribute__((__visibility__("default"))) */ /* #define __LZO_EXPORT1 __attribute__((__visibility__("default"))) */
/* #define __LZO_EXPORT1 __declspec(dllexport) */ /* #define __LZO_EXPORT1 __declspec(dllexport) */
#endif #endif
#include <lzo/lzoconf.h> #include <lzo/lzoconf.h>
#if defined(LZO_CFG_EXTRA_CONFIG_HEADER2) #if defined(LZO_CFG_EXTRA_CONFIG_HEADER2)
@ -75,24 +75,24 @@
************************************************************************/ ************************************************************************/
#if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100)) #if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100))
/* disable bogus "unreachable code" warnings */ /* disable bogus "unreachable code" warnings */
# pragma warning(disable: 4702) # pragma warning(disable: 4702)
#endif #endif
#if (LZO_CC_MSC && (_MSC_VER >= 1000)) #if (LZO_CC_MSC && (_MSC_VER >= 1000))
# pragma warning(disable: 4127 4701) # pragma warning(disable: 4127 4701)
/* disable warnings about inlining */ /* disable warnings about inlining */
# pragma warning(disable: 4514 4710 4711) # pragma warning(disable: 4514 4710 4711)
#endif #endif
#if (LZO_CC_MSC && (_MSC_VER >= 1300)) #if (LZO_CC_MSC && (_MSC_VER >= 1300))
/* disable '-Wall' warnings in system header files */ /* disable '-Wall' warnings in system header files */
# pragma warning(disable: 4820) # pragma warning(disable: 4820)
#endif #endif
#if (LZO_CC_MSC && (_MSC_VER >= 1800)) #if (LZO_CC_MSC && (_MSC_VER >= 1800))
/* disable '-Wall' warnings in system header files */ /* disable '-Wall' warnings in system header files */
# pragma warning(disable: 4746) # pragma warning(disable: 4746)
#endif #endif
#if (LZO_CC_INTELC && (__INTEL_COMPILER >= 900)) #if (LZO_CC_INTELC && (__INTEL_COMPILER >= 900))
/* disable pedantic warnings in system header files */ /* disable pedantic warnings in system header files */
# pragma warning(disable: 1684) # pragma warning(disable: 1684)
#endif #endif
@ -277,8 +277,8 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8)
#if !defined(DMUL) #if !defined(DMUL)
#if 0 #if 0
/* 32*32 multiplies may be faster than 64*64 on some 64-bit machines, /* 32*32 multiplies may be faster than 64*64 on some 64-bit machines,
* but then we need extra casts from unsigned<->size_t */ * but then we need extra casts from unsigned<->size_t */
# define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b))) # define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b)))
#else #else
# define DMUL(a,b) ((lzo_xint) ((a) * (b))) # define DMUL(a,b) ((lzo_xint) ((a) * (b)))

View File

@ -35,59 +35,60 @@
// see http://www.zlib.org/ // see http://www.zlib.org/
************************************************************************/ ************************************************************************/
static const lzo_uint32_t lzo_crc32_table[256] = { static const lzo_uint32_t lzo_crc32_table[256] =
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, {
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x2d02ef8dL 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
}; };
@ -119,25 +120,29 @@ lzo_crc32(lzo_uint32_t c, const lzo_bytep buf, lzo_uint len)
#if 1 #if 1
# define table lzo_crc32_table # define table lzo_crc32_table
#else #else
const lzo_uint32_t * table = lzo_crc32_table; const lzo_uint32_t* table = lzo_crc32_table;
#endif #endif
if (buf == NULL) if (buf == NULL)
return 0; return 0;
crc = (c & LZO_UINT32_C(0xffffffff)) ^ LZO_UINT32_C(0xffffffff); crc = (c & LZO_UINT32_C(0xffffffff)) ^ LZO_UINT32_C(0xffffffff);
if (len >= 16) do if (len >= 16) do
{ {
LZO_DO16(buf,0); LZO_DO16(buf, 0);
buf += 16; buf += 16;
len -= 16; len -= 16;
} while (len >= 16); }
while (len >= 16);
if (len != 0) do if (len != 0) do
{ {
LZO_DO1(buf,0); LZO_DO1(buf, 0);
buf += 1; buf += 1;
len -= 1; len -= 1;
} while (len > 0); }
while (len > 0);
return crc ^ LZO_UINT32_C(0xffffffff); return crc ^ LZO_UINT32_C(0xffffffff);
#undef table #undef table

View File

@ -152,11 +152,11 @@ extern "C" {
#if (LZO_HASH == LZO_HASH_GZIP) #if (LZO_HASH == LZO_HASH_GZIP)
/* hash function like in gzip/zlib (deflate) */ /* hash function like in gzip/zlib (deflate) */
# define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT)) # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT))
#elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL) #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL)
/* incremental hash like in gzip/zlib (deflate) */ /* incremental hash like in gzip/zlib (deflate) */
# define __LZO_HASH_INCREMENTAL 1 # define __LZO_HASH_INCREMENTAL 1
# define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT) # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT)
# define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2]) # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2])
@ -164,7 +164,7 @@ extern "C" {
# define DVAL_LOOKAHEAD DL_MIN_LEN # define DVAL_LOOKAHEAD DL_MIN_LEN
#elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A) #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A)
/* incremental LZO hash version A */ /* incremental LZO hash version A */
# define __LZO_HASH_INCREMENTAL 1 # define __LZO_HASH_INCREMENTAL 1
# define DVAL_FIRST(dv,p) dv = _DV_A((p),5) # define DVAL_FIRST(dv,p) dv = _DV_A((p),5)
# define DVAL_NEXT(dv,p) \ # define DVAL_NEXT(dv,p) \
@ -173,7 +173,7 @@ extern "C" {
# define DVAL_LOOKAHEAD DL_MIN_LEN # define DVAL_LOOKAHEAD DL_MIN_LEN
#elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B) #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
/* incremental LZO hash version B */ /* incremental LZO hash version B */
# define __LZO_HASH_INCREMENTAL 1 # define __LZO_HASH_INCREMENTAL 1
# define DVAL_FIRST(dv,p) dv = _DV_B((p),5) # define DVAL_FIRST(dv,p) dv = _DV_B((p),5)
# define DVAL_NEXT(dv,p) \ # define DVAL_NEXT(dv,p) \
@ -215,8 +215,8 @@ static void
DVAL_ASSERT(lzo_xint dv, const lzo_bytep p) DVAL_ASSERT(lzo_xint dv, const lzo_bytep p)
{ {
lzo_xint df; lzo_xint df;
DVAL_FIRST(df,(p)); DVAL_FIRST(df, (p));
assert(DINDEX(dv,p) == DINDEX(df,p)); assert(DINDEX(dv, p) == DINDEX(df, p));
} }
#else #else
# define DVAL_ASSERT(dv,p) ((void) 0) # define DVAL_ASSERT(dv,p) ((void) 0)

View File

@ -34,13 +34,16 @@
/* don't pull in <windows.h> - we don't need it */ /* don't pull in <windows.h> - we don't need it */
#if 0 #if 0
BOOL FAR PASCAL LibMain ( HANDLE hInstance, WORD wDataSegment, BOOL FAR PASCAL LibMain(HANDLE hInstance, WORD wDataSegment,
WORD wHeapSize, LPSTR lpszCmdLine ) WORD wHeapSize, LPSTR lpszCmdLine)
#else #else
int __far __pascal LibMain ( int a, short b, short c, long d ) int __far __pascal LibMain(int a, short b, short c, long d)
#endif #endif
{ {
LZO_UNUSED(a); LZO_UNUSED(b); LZO_UNUSED(c); LZO_UNUSED(d); LZO_UNUSED(a);
LZO_UNUSED(b);
LZO_UNUSED(c);
LZO_UNUSED(d);
return 1; return 1;
} }

View File

@ -64,21 +64,28 @@
__lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v) __lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v)
{ {
#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
unsigned long r; (void) _BitScanReverse(&r, v); return (unsigned) r ^ 31; unsigned long r;
(void) _BitScanReverse(&r, v);
return (unsigned) r ^ 31;
#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) #define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v)
#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
lzo_uint32_t r; lzo_uint32_t r;
__asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); __asm__("bsr %1,%0" : "=r"(r) : "rm"(v) __LZO_ASM_CLOBBER_LIST_CC);
return (unsigned) r ^ 31; return (unsigned) r ^ 31;
#define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v) #define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v)
#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT == 4) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT == 4)
unsigned r; r = (unsigned) __builtin_clz(v); return r; unsigned r;
r = (unsigned) __builtin_clz(v);
return r;
#define lzo_bitops_ctlz32(v) ((unsigned) __builtin_clz(v)) #define lzo_bitops_ctlz32(v) ((unsigned) __builtin_clz(v))
#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8)
unsigned r; r = (unsigned) __builtin_clzl(v); return r ^ 32; unsigned r;
r = (unsigned) __builtin_clzl(v);
return r ^ 32;
#define lzo_bitops_ctlz32(v) (((unsigned) __builtin_clzl(v)) ^ 32) #define lzo_bitops_ctlz32(v) (((unsigned) __builtin_clzl(v)) ^ 32)
#else #else
LZO_UNUSED(v); return 0; LZO_UNUSED(v);
return 0;
#endif #endif
} }
@ -86,21 +93,28 @@ __lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v)
__lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v) __lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v)
{ {
#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64)
unsigned long r; (void) _BitScanReverse64(&r, v); return (unsigned) r ^ 63; unsigned long r;
(void) _BitScanReverse64(&r, v);
return (unsigned) r ^ 63;
#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) #define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v)
#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC)
lzo_uint64_t r; lzo_uint64_t r;
__asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); __asm__("bsr %1,%0" : "=r"(r) : "rm"(v) __LZO_ASM_CLOBBER_LIST_CC);
return (unsigned) r ^ 63; return (unsigned) r ^ 63;
#define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v) #define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v)
#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8)
unsigned r; r = (unsigned) __builtin_clzl(v); return r; unsigned r;
r = (unsigned) __builtin_clzl(v);
return r;
#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzl(v)) #define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzl(v))
#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG == 8) && (LZO_WORDSIZE >= 8) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG == 8) && (LZO_WORDSIZE >= 8)
unsigned r; r = (unsigned) __builtin_clzll(v); return r; unsigned r;
r = (unsigned) __builtin_clzll(v);
return r;
#define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzll(v)) #define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzll(v))
#else #else
LZO_UNUSED(v); return 0; LZO_UNUSED(v);
return 0;
#endif #endif
} }
#endif #endif
@ -108,18 +122,23 @@ __lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v)
__lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v) __lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v)
{ {
#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
unsigned long r; (void) _BitScanForward(&r, v); return (unsigned) r; unsigned long r;
(void) _BitScanForward(&r, v);
return (unsigned) r;
#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) #define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v)
#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC) #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
lzo_uint32_t r; lzo_uint32_t r;
__asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); __asm__("bsf %1,%0" : "=r"(r) : "rm"(v) __LZO_ASM_CLOBBER_LIST_CC);
return (unsigned) r; return (unsigned) r;
#define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v) #define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v)
#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT >= 4) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT >= 4)
unsigned r; r = (unsigned) __builtin_ctz(v); return r; unsigned r;
r = (unsigned) __builtin_ctz(v);
return r;
#define lzo_bitops_cttz32(v) ((unsigned) __builtin_ctz(v)) #define lzo_bitops_cttz32(v) ((unsigned) __builtin_ctz(v))
#else #else
LZO_UNUSED(v); return 0; LZO_UNUSED(v);
return 0;
#endif #endif
} }
@ -127,21 +146,28 @@ __lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v)
__lzo_static_forceinline unsigned lzo_bitops_cttz64_func(lzo_uint64_t v) __lzo_static_forceinline unsigned lzo_bitops_cttz64_func(lzo_uint64_t v)
{ {
#if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64) #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64)
unsigned long r; (void) _BitScanForward64(&r, v); return (unsigned) r; unsigned long r;
(void) _BitScanForward64(&r, v);
return (unsigned) r;
#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) #define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v)
#elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC) #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC)
lzo_uint64_t r; lzo_uint64_t r;
__asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC); __asm__("bsf %1,%0" : "=r"(r) : "rm"(v) __LZO_ASM_CLOBBER_LIST_CC);
return (unsigned) r; return (unsigned) r;
#define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v) #define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v)
#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG >= 8) && (LZO_WORDSIZE >= 8) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG >= 8) && (LZO_WORDSIZE >= 8)
unsigned r; r = (unsigned) __builtin_ctzl(v); return r; unsigned r;
r = (unsigned) __builtin_ctzl(v);
return r;
#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzl(v)) #define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzl(v))
#elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG >= 8) && (LZO_WORDSIZE >= 8) #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG >= 8) && (LZO_WORDSIZE >= 8)
unsigned r; r = (unsigned) __builtin_ctzll(v); return r; unsigned r;
r = (unsigned) __builtin_ctzll(v);
return r;
#define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzll(v)) #define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzll(v))
#else #else
LZO_UNUSED(v); return 0; LZO_UNUSED(v);
return 0;
#endif #endif
} }
#endif #endif
@ -179,7 +205,7 @@ lzo_unused_funcs_impl(void, lzo_bitops_unused_funcs)(void)
typedef lzo_uint16_t __lzo_may_alias lzo_memops_TU2; typedef lzo_uint16_t __lzo_may_alias lzo_memops_TU2;
#define lzo_memops_TU2p volatile lzo_memops_TU2 * #define lzo_memops_TU2p volatile lzo_memops_TU2 *
#elif defined(__lzo_byte_struct) #elif defined(__lzo_byte_struct)
__lzo_byte_struct(lzo_memops_TU2_struct,2) __lzo_byte_struct(lzo_memops_TU2_struct, 2)
typedef struct lzo_memops_TU2_struct lzo_memops_TU2; typedef struct lzo_memops_TU2_struct lzo_memops_TU2;
#else #else
struct lzo_memops_TU2_struct { unsigned char a[2]; } __lzo_may_alias; struct lzo_memops_TU2_struct { unsigned char a[2]; } __lzo_may_alias;
@ -194,7 +220,7 @@ typedef struct lzo_memops_TU2_struct lzo_memops_TU2;
typedef lzo_uint32_t __lzo_may_alias lzo_memops_TU4; typedef lzo_uint32_t __lzo_may_alias lzo_memops_TU4;
#define lzo_memops_TU4p volatile lzo_memops_TU4 __LZO_MMODEL * #define lzo_memops_TU4p volatile lzo_memops_TU4 __LZO_MMODEL *
#elif defined(__lzo_byte_struct) #elif defined(__lzo_byte_struct)
__lzo_byte_struct(lzo_memops_TU4_struct,4) __lzo_byte_struct(lzo_memops_TU4_struct, 4)
typedef struct lzo_memops_TU4_struct lzo_memops_TU4; typedef struct lzo_memops_TU4_struct lzo_memops_TU4;
#else #else
struct lzo_memops_TU4_struct { unsigned char a[4]; } __lzo_may_alias; struct lzo_memops_TU4_struct { unsigned char a[4]; } __lzo_may_alias;
@ -209,7 +235,7 @@ typedef struct lzo_memops_TU4_struct lzo_memops_TU4;
typedef lzo_uint64_t __lzo_may_alias lzo_memops_TU8; typedef lzo_uint64_t __lzo_may_alias lzo_memops_TU8;
#define lzo_memops_TU8p volatile lzo_memops_TU8 __LZO_MMODEL * #define lzo_memops_TU8p volatile lzo_memops_TU8 __LZO_MMODEL *
#elif defined(__lzo_byte_struct) #elif defined(__lzo_byte_struct)
__lzo_byte_struct(lzo_memops_TU8_struct,8) __lzo_byte_struct(lzo_memops_TU8_struct, 8)
typedef struct lzo_memops_TU8_struct lzo_memops_TU8; typedef struct lzo_memops_TU8_struct lzo_memops_TU8;
#else #else
struct lzo_memops_TU8_struct { unsigned char a[8]; } __lzo_may_alias; struct lzo_memops_TU8_struct { unsigned char a[8]; } __lzo_may_alias;
@ -276,10 +302,10 @@ typedef struct lzo_memops_TU8_struct lzo_memops_TU8;
d__8[0] = s__8[0]; d__8[1] = s__8[1]; d__8[2] = s__8[2]; d__8[3] = s__8[3]; \ d__8[0] = s__8[0]; d__8[1] = s__8[1]; d__8[2] = s__8[2]; d__8[3] = s__8[3]; \
d__8[4] = s__8[4]; d__8[5] = s__8[5]; d__8[6] = s__8[6]; d__8[7] = s__8[7]; \ d__8[4] = s__8[4]; d__8[5] = s__8[5]; d__8[6] = s__8[6]; d__8[7] = s__8[7]; \
LZO_BLOCK_END LZO_BLOCK_END
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU1p)0)==1) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU1p)0) == 1)
#define LZO_MEMOPS_COPY1(dd,ss) LZO_MEMOPS_MOVE1(dd,ss) #define LZO_MEMOPS_COPY1(dd,ss) LZO_MEMOPS_MOVE1(dd,ss)
#if (LZO_OPT_UNALIGNED16) #if (LZO_OPT_UNALIGNED16)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0) == 2)
#define LZO_MEMOPS_COPY2(dd,ss) \ #define LZO_MEMOPS_COPY2(dd,ss) \
* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss) * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss)
#elif defined(lzo_memops_tcheck__) #elif defined(lzo_memops_tcheck__)
@ -291,7 +317,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2)
#define LZO_MEMOPS_COPY2(dd,ss) LZO_MEMOPS_MOVE2(dd,ss) #define LZO_MEMOPS_COPY2(dd,ss) LZO_MEMOPS_MOVE2(dd,ss)
#endif #endif
#if (LZO_OPT_UNALIGNED32) #if (LZO_OPT_UNALIGNED32)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0) == 4)
#define LZO_MEMOPS_COPY4(dd,ss) \ #define LZO_MEMOPS_COPY4(dd,ss) \
* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss) * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss)
#elif defined(lzo_memops_tcheck__) #elif defined(lzo_memops_tcheck__)
@ -307,7 +333,7 @@ LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4)
LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END
#else #else
#if (LZO_OPT_UNALIGNED64) #if (LZO_OPT_UNALIGNED64)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0) == 8)
#define LZO_MEMOPS_COPY8(dd,ss) \ #define LZO_MEMOPS_COPY8(dd,ss) \
* (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss) * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss)
#elif (LZO_OPT_UNALIGNED32) #elif (LZO_OPT_UNALIGNED32)
@ -340,11 +366,11 @@ __lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss)
#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) #elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
const lzo_memops_TU2p s = (const lzo_memops_TU2p) ss; const lzo_memops_TU2p s = (const lzo_memops_TU2p) ss;
unsigned long vv; unsigned long vv;
__asm__("lhbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); __asm__("lhbrx %0,0,%1" : "=r"(vv) : "r"(s), "m"(*s));
v = (lzo_uint16_t) vv; v = (lzo_uint16_t) vv;
#else #else
const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss;
v = (lzo_uint16_t) (((lzo_uint16_t)s[0]) | ((lzo_uint16_t)s[1] << 8)); v = (lzo_uint16_t)(((lzo_uint16_t)s[0]) | ((lzo_uint16_t)s[1] << 8));
#endif #endif
return v; return v;
} }
@ -362,11 +388,11 @@ __lzo_static_forceinline lzo_uint32_t lzo_memops_get_le32(const lzo_voidp ss)
#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) #elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
const lzo_memops_TU4p s = (const lzo_memops_TU4p) ss; const lzo_memops_TU4p s = (const lzo_memops_TU4p) ss;
unsigned long vv; unsigned long vv;
__asm__("lwbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s)); __asm__("lwbrx %0,0,%1" : "=r"(vv) : "r"(s), "m"(*s));
v = (lzo_uint32_t) vv; v = (lzo_uint32_t) vv;
#else #else
const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss; const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss;
v = (lzo_uint32_t) (((lzo_uint32_t)s[0]) | ((lzo_uint32_t)s[1] << 8) | ((lzo_uint32_t)s[2] << 16) | ((lzo_uint32_t)s[3] << 24)); v = (lzo_uint32_t)(((lzo_uint32_t)s[0]) | ((lzo_uint32_t)s[1] << 8) | ((lzo_uint32_t)s[2] << 16) | ((lzo_uint32_t)s[3] << 24));
#endif #endif
return v; return v;
} }
@ -387,7 +413,7 @@ __lzo_static_forceinline lzo_uint16_t lzo_memops_get_ne16(const lzo_voidp ss)
return v; return v;
} }
#if (LZO_OPT_UNALIGNED16) #if (LZO_OPT_UNALIGNED16)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0) == 2)
#define LZO_MEMOPS_GET_NE16(ss) (* (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss)) #define LZO_MEMOPS_GET_NE16(ss) (* (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss))
#else #else
#define LZO_MEMOPS_GET_NE16(ss) lzo_memops_get_ne16(ss) #define LZO_MEMOPS_GET_NE16(ss) lzo_memops_get_ne16(ss)
@ -400,14 +426,14 @@ __lzo_static_forceinline lzo_uint32_t lzo_memops_get_ne32(const lzo_voidp ss)
return v; return v;
} }
#if (LZO_OPT_UNALIGNED32) #if (LZO_OPT_UNALIGNED32)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0) == 4)
#define LZO_MEMOPS_GET_NE32(ss) (* (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss)) #define LZO_MEMOPS_GET_NE32(ss) (* (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss))
#else #else
#define LZO_MEMOPS_GET_NE32(ss) lzo_memops_get_ne32(ss) #define LZO_MEMOPS_GET_NE32(ss) lzo_memops_get_ne32(ss)
#endif #endif
#if (LZO_OPT_UNALIGNED64) #if (LZO_OPT_UNALIGNED64)
LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0) == 8)
#define LZO_MEMOPS_GET_NE64(ss) (* (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss)) #define LZO_MEMOPS_GET_NE64(ss) (* (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss))
#endif #endif
@ -418,10 +444,10 @@ __lzo_static_forceinline void lzo_memops_put_le16(lzo_voidp dd, lzo_uint16_t vv)
#elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) #elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
lzo_memops_TU2p d = (lzo_memops_TU2p) dd; lzo_memops_TU2p d = (lzo_memops_TU2p) dd;
unsigned long v = vv; unsigned long v = vv;
__asm__("sthbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); __asm__("sthbrx %2,0,%1" : "=m"(*d) : "r"(d), "r"(v));
#else #else
lzo_memops_TU1p d = (lzo_memops_TU1p) dd; lzo_memops_TU1p d = (lzo_memops_TU1p) dd;
d[0] = LZO_BYTE((vv ) & 0xff); d[0] = LZO_BYTE((vv) & 0xff);
d[1] = LZO_BYTE((vv >> 8) & 0xff); d[1] = LZO_BYTE((vv >> 8) & 0xff);
#endif #endif
} }
@ -438,10 +464,10 @@ __lzo_static_forceinline void lzo_memops_put_le32(lzo_voidp dd, lzo_uint32_t vv)
#elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC) #elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
lzo_memops_TU4p d = (lzo_memops_TU4p) dd; lzo_memops_TU4p d = (lzo_memops_TU4p) dd;
unsigned long v = vv; unsigned long v = vv;
__asm__("stwbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v)); __asm__("stwbrx %2,0,%1" : "=m"(*d) : "r"(d), "r"(v));
#else #else
lzo_memops_TU1p d = (lzo_memops_TU1p) dd; lzo_memops_TU1p d = (lzo_memops_TU1p) dd;
d[0] = LZO_BYTE((vv ) & 0xff); d[0] = LZO_BYTE((vv) & 0xff);
d[1] = LZO_BYTE((vv >> 8) & 0xff); d[1] = LZO_BYTE((vv >> 8) & 0xff);
d[2] = LZO_BYTE((vv >> 16) & 0xff); d[2] = LZO_BYTE((vv >> 16) & 0xff);
d[3] = LZO_BYTE((vv >> 24) & 0xff); d[3] = LZO_BYTE((vv >> 24) & 0xff);

View File

@ -48,14 +48,14 @@
#undef LZOCHK_ASSERT #undef LZOCHK_ASSERT
#include "lzo_supp.h" #include "lzo_supp.h"
LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8 * sizeof(LZO_UINT32_C(1)) - 1)) > 0)
LZOCHK_ASSERT_IS_SIGNED_T(lzo_int) LZOCHK_ASSERT_IS_SIGNED_T(lzo_int)
LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint)
#if !(__LZO_UINTPTR_T_IS_POINTER) #if !(__LZO_UINTPTR_T_IS_POINTER)
LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t)
#endif #endif
LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp))
LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint)
#endif #endif
#undef LZOCHK_ASSERT #undef LZOCHK_ASSERT
@ -65,9 +65,10 @@
// //
************************************************************************/ ************************************************************************/
union lzo_config_check_union { union lzo_config_check_union
{
lzo_uint a[2]; lzo_uint a[2];
unsigned char b[2*LZO_MAX(8,sizeof(lzo_uint))]; unsigned char b[2 * LZO_MAX(8, sizeof(lzo_uint))];
#if defined(lzo_uint64_t) #if defined(lzo_uint64_t)
lzo_uint64_t c[2]; lzo_uint64_t c[2];
#endif #endif
@ -79,7 +80,7 @@ union lzo_config_check_union {
#else #else
static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off) static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off)
{ {
return (lzo_voidp) ((lzo_bytep) ptr + off); return (lzo_voidp)((lzo_bytep) ptr + off);
} }
#endif #endif
@ -102,17 +103,20 @@ _lzo_config_check(void)
r &= ((* (lzo_bytep) p) == 0); r &= ((* (lzo_bytep) p) == 0);
#if !(LZO_CFG_NO_CONFIG_CHECK) #if !(LZO_CFG_NO_CONFIG_CHECK)
#if (LZO_ABI_BIG_ENDIAN) #if (LZO_ABI_BIG_ENDIAN)
u.a[0] = u.a[1] = 0; u.b[sizeof(lzo_uint) - 1] = 128; u.a[0] = u.a[1] = 0;
u.b[sizeof(lzo_uint) - 1] = 128;
p = u2p(&u, 0); p = u2p(&u, 0);
r &= ((* (lzo_uintp) p) == 128); r &= ((* (lzo_uintp) p) == 128);
#endif #endif
#if (LZO_ABI_LITTLE_ENDIAN) #if (LZO_ABI_LITTLE_ENDIAN)
u.a[0] = u.a[1] = 0; u.b[0] = 128; u.a[0] = u.a[1] = 0;
u.b[0] = 128;
p = u2p(&u, 0); p = u2p(&u, 0);
r &= ((* (lzo_uintp) p) == 128); r &= ((* (lzo_uintp) p) == 128);
#endif #endif
u.a[0] = u.a[1] = 0; u.a[0] = u.a[1] = 0;
u.b[0] = 1; u.b[3] = 2; u.b[0] = 1;
u.b[3] = 2;
p = u2p(&u, 1); p = u2p(&u, 1);
r &= UA_GET_NE16(p) == 0; r &= UA_GET_NE16(p) == 0;
r &= UA_GET_LE16(p) == 0; r &= UA_GET_LE16(p) == 0;
@ -127,13 +131,16 @@ _lzo_config_check(void)
r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8180); r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8180);
#endif #endif
u.a[0] = u.a[1] = 0; u.a[0] = u.a[1] = 0;
u.b[0] = 3; u.b[5] = 4; u.b[0] = 3;
u.b[5] = 4;
p = u2p(&u, 1); p = u2p(&u, 1);
r &= UA_GET_NE32(p) == 0; r &= UA_GET_NE32(p) == 0;
r &= UA_GET_LE32(p) == 0; r &= UA_GET_LE32(p) == 0;
u.b[1] = 128; u.b[1] = 128;
r &= UA_GET_LE32(p) == 128; r &= UA_GET_LE32(p) == 128;
u.b[2] = 129; u.b[3] = 130; u.b[4] = 131; u.b[2] = 129;
u.b[3] = 130;
u.b[4] = 131;
r &= UA_GET_LE32(p) == LZO_UINT32_C(0x83828180); r &= UA_GET_LE32(p) == LZO_UINT32_C(0x83828180);
#if (LZO_ABI_BIG_ENDIAN) #if (LZO_ABI_BIG_ENDIAN)
r &= UA_GET_NE32(p) == LZO_UINT32_C(0x80818283); r &= UA_GET_NE32(p) == LZO_UINT32_C(0x80818283);
@ -143,7 +150,8 @@ _lzo_config_check(void)
#endif #endif
#if defined(UA_GET_NE64) #if defined(UA_GET_NE64)
u.c[0] = u.c[1] = 0; u.c[0] = u.c[1] = 0;
u.b[0] = 5; u.b[9] = 6; u.b[0] = 5;
u.b[9] = 6;
p = u2p(&u, 1); p = u2p(&u, 1);
u.c[0] = u.c[1] = 0; u.c[0] = u.c[1] = 0;
r &= UA_GET_NE64(p) == 0; r &= UA_GET_NE64(p) == 0;
@ -154,32 +162,52 @@ _lzo_config_check(void)
#endif #endif
#endif #endif
#if defined(lzo_bitops_ctlz32) #if defined(lzo_bitops_ctlz32)
{ unsigned i = 0; lzo_uint32_t v; {
for (v = 1; v != 0 && r == 1; v <<= 1, i++) { unsigned i = 0;
r &= lzo_bitops_ctlz32(v) == 31 - i; lzo_uint32_t v;
r &= lzo_bitops_ctlz32_func(v) == 31 - i;
}} for (v = 1; v != 0 && r == 1; v <<= 1, i++)
{
r &= lzo_bitops_ctlz32(v) == 31 - i;
r &= lzo_bitops_ctlz32_func(v) == 31 - i;
}
}
#endif #endif
#if defined(lzo_bitops_ctlz64) #if defined(lzo_bitops_ctlz64)
{ unsigned i = 0; lzo_uint64_t v; {
for (v = 1; v != 0 && r == 1; v <<= 1, i++) { unsigned i = 0;
r &= lzo_bitops_ctlz64(v) == 63 - i; lzo_uint64_t v;
r &= lzo_bitops_ctlz64_func(v) == 63 - i;
}} for (v = 1; v != 0 && r == 1; v <<= 1, i++)
{
r &= lzo_bitops_ctlz64(v) == 63 - i;
r &= lzo_bitops_ctlz64_func(v) == 63 - i;
}
}
#endif #endif
#if defined(lzo_bitops_cttz32) #if defined(lzo_bitops_cttz32)
{ unsigned i = 0; lzo_uint32_t v; {
for (v = 1; v != 0 && r == 1; v <<= 1, i++) { unsigned i = 0;
r &= lzo_bitops_cttz32(v) == i; lzo_uint32_t v;
r &= lzo_bitops_cttz32_func(v) == i;
}} for (v = 1; v != 0 && r == 1; v <<= 1, i++)
{
r &= lzo_bitops_cttz32(v) == i;
r &= lzo_bitops_cttz32_func(v) == i;
}
}
#endif #endif
#if defined(lzo_bitops_cttz64) #if defined(lzo_bitops_cttz64)
{ unsigned i = 0; lzo_uint64_t v; {
for (v = 1; v != 0 && r == 1; v <<= 1, i++) { unsigned i = 0;
r &= lzo_bitops_cttz64(v) == i; lzo_uint64_t v;
r &= lzo_bitops_cttz64_func(v) == i;
}} for (v = 1; v != 0 && r == 1; v <<= 1, i++)
{
r &= lzo_bitops_cttz64(v) == i;
r &= lzo_bitops_cttz64_func(v) == i;
}
}
#endif #endif
#endif #endif
LZO_UNUSED_FUNC(lzo_bitops_unused_funcs); LZO_UNUSED_FUNC(lzo_bitops_unused_funcs);
@ -194,7 +222,7 @@ _lzo_config_check(void)
LZO_PUBLIC(int) LZO_PUBLIC(int)
__lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5,
int s6, int s7, int s8, int s9) int s6, int s7, int s8, int s9)
{ {
int r; int r;
@ -217,13 +245,15 @@ __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5,
(s4 == -1 || s4 == (int) sizeof(lzo_uint32_t)) && (s4 == -1 || s4 == (int) sizeof(lzo_uint32_t)) &&
(s5 == -1 || s5 == (int) sizeof(lzo_uint)) && (s5 == -1 || s5 == (int) sizeof(lzo_uint)) &&
(s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) &&
(s7 == -1 || s7 == (int) sizeof(char *)) && (s7 == -1 || s7 == (int) sizeof(char*)) &&
(s8 == -1 || s8 == (int) sizeof(lzo_voidp)) && (s8 == -1 || s8 == (int) sizeof(lzo_voidp)) &&
(s9 == -1 || s9 == (int) sizeof(lzo_callback_t)); (s9 == -1 || s9 == (int) sizeof(lzo_callback_t));
if (!r) if (!r)
return LZO_E_ERROR; return LZO_E_ERROR;
r = _lzo_config_check(); r = _lzo_config_check();
if (r != LZO_E_OK) if (r != LZO_E_OK)
return r; return r;

View File

@ -110,9 +110,9 @@ LZO_COMPRESS_T;
************************************************************************/ ************************************************************************/
static int static int
init_match ( LZO_COMPRESS_T *c, lzo_swd_p s, init_match(LZO_COMPRESS_T* c, lzo_swd_p s,
const lzo_bytep dict, lzo_uint dict_len, const lzo_bytep dict, lzo_uint dict_len,
lzo_uint32_t flags ) lzo_uint32_t flags)
{ {
int r; int r;
@ -127,7 +127,8 @@ init_match ( LZO_COMPRESS_T *c, lzo_swd_p s,
c->lit_bytes = c->match_bytes = c->rep_bytes = 0; c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
c->lazy = 0; c->lazy = 0;
r = swd_init(s,dict,dict_len); r = swd_init(s, dict, dict_len);
if (r != LZO_E_OK) if (r != LZO_E_OK)
{ {
swd_exit(s); swd_exit(s);
@ -144,8 +145,8 @@ init_match ( LZO_COMPRESS_T *c, lzo_swd_p s,
************************************************************************/ ************************************************************************/
static int static int
find_match ( LZO_COMPRESS_T *c, lzo_swd_p s, find_match(LZO_COMPRESS_T* c, lzo_swd_p s,
lzo_uint this_len, lzo_uint skip ) lzo_uint this_len, lzo_uint skip)
{ {
assert(c->init); assert(c->init);
@ -164,8 +165,10 @@ find_match ( LZO_COMPRESS_T *c, lzo_swd_p s,
s->m_len = SWD_THRESHOLD; s->m_len = SWD_THRESHOLD;
s->m_off = 0; s->m_off = 0;
#ifdef SWD_BEST_OFF #ifdef SWD_BEST_OFF
if (s->use_best_off) if (s->use_best_off)
lzo_memset(s->best_pos,0,sizeof(s->best_pos)); lzo_memset(s->best_pos, 0, sizeof(s->best_pos));
#endif #endif
swd_findbest(s); swd_findbest(s);
c->m_len = s->m_len; c->m_len = s->m_len;
@ -183,9 +186,11 @@ find_match ( LZO_COMPRESS_T *c, lzo_swd_p s,
{ {
c->look = s->look + 1; c->look = s->look + 1;
} }
c->bp = c->ip - c->look; c->bp = c->ip - c->look;
#if 0 #if 0
/* brute force match search */ /* brute force match search */
if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look) if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look)
{ {
@ -195,18 +200,23 @@ find_match ( LZO_COMPRESS_T *c, lzo_swd_p s,
if (ip - in > s->swd_n) if (ip - in > s->swd_n)
in = ip - s->swd_n; in = ip - s->swd_n;
for (;;) for (;;)
{ {
while (*in != *ip) while (*in != *ip)
in++; in++;
if (in == ip) if (in == ip)
break; break;
if (in != m) if (in != m)
if (lzo_memcmp(in,ip,c->m_len+1) == 0) if (lzo_memcmp(in, ip, c->m_len + 1) == 0)
printf("%p %p %p %5d\n",in,ip,m,c->m_len); printf("%p %p %p %5d\n", in, ip, m, c->m_len);
in++; in++;
} }
} }
#endif #endif
if (c->cb && c->cb->nprogress && c->textsize > c->printcount) if (c->cb && c->cb->nprogress && c->textsize > c->printcount)

View File

@ -61,14 +61,19 @@ __lzo_align_gap(const lzo_voidp ptr, lzo_uint size)
#error "__LZO_UINTPTR_T_IS_POINTER is unsupported" #error "__LZO_UINTPTR_T_IS_POINTER is unsupported"
#else #else
lzo_uintptr_t p, n; lzo_uintptr_t p, n;
if (size < 2) return 0; if (size < 2) return 0;
p = __lzo_ptr_linear(ptr); p = __lzo_ptr_linear(ptr);
#if 0 #if 0
n = (((p + size - 1) / size) * size) - p; n = (((p + size - 1) / size) * size) - p;
#else #else
if ((size & (size - 1)) != 0) if ((size & (size - 1)) != 0)
return 0; return 0;
n = size; n = ((p + n - 1) & ~(n - 1)) - p;
n = size;
n = ((p + n - 1) & ~(n - 1)) - p;
#endif #endif
#endif #endif
assert((long)n >= 0); assert((long)n >= 0);

View File

@ -98,12 +98,12 @@ typedef union
size_t a_size_t; size_t a_size_t;
ptrdiff_t a_ptrdiff_t; ptrdiff_t a_ptrdiff_t;
lzo_uintptr_t a_lzo_uintptr_t; lzo_uintptr_t a_lzo_uintptr_t;
void * a_void_p; void* a_void_p;
char * a_char_p; char* a_char_p;
unsigned char * a_uchar_p; unsigned char* a_uchar_p;
const void * a_c_void_p; const void* a_c_void_p;
const char * a_c_char_p; const char* a_c_char_p;
const unsigned char * a_c_uchar_p; const unsigned char* a_c_uchar_p;
lzo_voidp a_lzo_voidp; lzo_voidp a_lzo_voidp;
lzo_bytep a_lzo_bytep; lzo_bytep a_lzo_bytep;
const lzo_voidp a_c_lzo_voidp; const lzo_voidp a_c_lzo_voidp;

File diff suppressed because it is too large Load Diff

View File

@ -43,10 +43,10 @@
/* unsigned type for dictionary access - don't waste memory here */ /* unsigned type for dictionary access - don't waste memory here */
#if (0UL + SWD_N + SWD_F + SWD_F < 65535UL) #if (0UL + SWD_N + SWD_F + SWD_F < 65535UL)
typedef lzo_uint16_t swd_uint; typedef lzo_uint16_t swd_uint;
# define SWD_UINT_MAX 0xffffu # define SWD_UINT_MAX 0xffffu
#else #else
typedef lzo_uint32_t swd_uint; typedef lzo_uint32_t swd_uint;
# define SWD_UINT_MAX 0xffffffffu # define SWD_UINT_MAX 0xffffffffu
#endif #endif
#define swd_uintp swd_uint * #define swd_uintp swd_uint *
@ -85,18 +85,18 @@
typedef struct typedef struct
{ {
/* public - "built-in" */ /* public - "built-in" */
lzo_uint swd_n; lzo_uint swd_n;
lzo_uint swd_f; lzo_uint swd_f;
lzo_uint swd_threshold; lzo_uint swd_threshold;
/* public - configuration */ /* public - configuration */
lzo_uint max_chain; lzo_uint max_chain;
lzo_uint nice_length; lzo_uint nice_length;
lzo_bool use_best_off; lzo_bool use_best_off;
lzo_uint lazy_insert; lzo_uint lazy_insert;
/* public - output */ /* public - output */
lzo_uint m_len; lzo_uint m_len;
lzo_uint m_off; lzo_uint m_off;
lzo_uint look; lzo_uint look;
@ -105,19 +105,19 @@ typedef struct
lzo_uint best_off[ SWD_BEST_OFF ]; lzo_uint best_off[ SWD_BEST_OFF ];
#endif #endif
/* semi public */ /* semi public */
LZO_COMPRESS_T *c; LZO_COMPRESS_T* c;
lzo_uint m_pos; lzo_uint m_pos;
#if defined(SWD_BEST_OFF) #if defined(SWD_BEST_OFF)
lzo_uint best_pos[ SWD_BEST_OFF ]; lzo_uint best_pos[ SWD_BEST_OFF ];
#endif #endif
/* private */ /* private */
const lzo_bytep dict; const lzo_bytep dict;
const lzo_bytep dict_end; const lzo_bytep dict_end;
lzo_uint dict_len; lzo_uint dict_len;
/* private */ /* private */
lzo_uint ip; /* input pointer (lookahead) */ lzo_uint ip; /* input pointer (lookahead) */
lzo_uint bp; /* buffer pointer */ lzo_uint bp; /* buffer pointer */
lzo_uint rp; /* remove pointer */ lzo_uint rp; /* remove pointer */
@ -130,13 +130,13 @@ typedef struct
#if defined(__LZO_CHECKER) #if defined(__LZO_CHECKER)
/* malloc arrays of the exact size to detect any overrun */ /* malloc arrays of the exact size to detect any overrun */
unsigned char *b; unsigned char* b;
swd_uint *head3; swd_uint* head3;
swd_uint *succ3; swd_uint* succ3;
swd_uint *best3; swd_uint* best3;
swd_uint *llen3; swd_uint* llen3;
# ifdef HEAD2 # ifdef HEAD2
swd_uint *head2; swd_uint* head2;
# endif # endif
#else #else
@ -189,6 +189,7 @@ void swd_initdict(lzo_swd_p s, const lzo_bytep dict, lzo_uint dict_len)
if (!dict || dict_len == 0) if (!dict || dict_len == 0)
return; return;
if (dict_len > s->swd_n) if (dict_len > s->swd_n)
{ {
dict += dict_len - s->swd_n; dict += dict_len - s->swd_n;
@ -198,7 +199,7 @@ void swd_initdict(lzo_swd_p s, const lzo_bytep dict, lzo_uint dict_len)
s->dict = dict; s->dict = dict;
s->dict_len = dict_len; s->dict_len = dict_len;
s->dict_end = dict + dict_len; s->dict_end = dict + dict_len;
lzo_memcpy(s_b(s),dict,dict_len); lzo_memcpy(s_b(s), dict, dict_len);
s->ip = dict_len; s->ip = dict_len;
} }
@ -212,24 +213,25 @@ void swd_insertdict(lzo_swd_p s, lzo_uint node, lzo_uint len)
s->first_rp = node; s->first_rp = node;
if (len) do if (len) do
{ {
key = HEAD3(s_b(s),node); key = HEAD3(s_b(s), node);
s_succ3(s)[node] = s_get_head3(s,key); s_succ3(s)[node] = s_get_head3(s, key);
s_head3(s)[key] = SWD_UINT(node); s_head3(s)[key] = SWD_UINT(node);
s_best3(s)[node] = SWD_UINT(s->swd_f + 1); s_best3(s)[node] = SWD_UINT(s->swd_f + 1);
s_llen3(s)[key]++; s_llen3(s)[key]++;
assert(s_llen3(s)[key] <= s->swd_n); assert(s_llen3(s)[key] <= s->swd_n);
#ifdef HEAD2 #ifdef HEAD2
IF_HEAD2(s) { IF_HEAD2(s)
key = HEAD2(s_b(s),node); {
s_head2(s)[key] = SWD_UINT(node); key = HEAD2(s_b(s), node);
} s_head2(s)[key] = SWD_UINT(node);
}
#endif #endif
node++; node++;
} }
while (--len != 0); while (--len != 0);
} }
@ -255,15 +257,19 @@ int swd_init(lzo_swd_p s, const lzo_bytep dict, lzo_uint dict_len)
r &= s->best3 != NULL; r &= s->best3 != NULL;
r &= s->llen3 != NULL; r &= s->llen3 != NULL;
#ifdef HEAD2 #ifdef HEAD2
IF_HEAD2(s) { IF_HEAD2(s)
{
s->head2 = (swd_uintp) malloc(sizeof(swd_uint) * 65536L); s->head2 = (swd_uintp) malloc(sizeof(swd_uint) * 65536L);
r &= s->head2 != NULL; r &= s->head2 != NULL;
} }
#endif #endif
if (r != 1) {
if (r != 1)
{
swd_exit(s); swd_exit(s);
return LZO_E_OUT_OF_MEMORY; return LZO_E_OUT_OF_MEMORY;
} }
#endif #endif
s->m_len = 0; s->m_len = 0;
@ -271,6 +277,7 @@ int swd_init(lzo_swd_p s, const lzo_bytep dict, lzo_uint dict_len)
#if defined(SWD_BEST_OFF) #if defined(SWD_BEST_OFF)
{ {
unsigned i; unsigned i;
for (i = 0; i < SWD_BEST_OFF; i++) for (i = 0; i < SWD_BEST_OFF; i++)
s->best_off[i] = s->best_pos[i] = 0; s->best_off[i] = s->best_pos[i] = 0;
} }
@ -288,8 +295,10 @@ int swd_init(lzo_swd_p s, const lzo_bytep dict, lzo_uint dict_len)
s->b_size = s->swd_n + s->swd_f; s->b_size = s->swd_n + s->swd_f;
#if 0 #if 0
if (2 * s->swd_f >= s->swd_n || s->b_size + s->swd_f >= SWD_UINT_MAX) if (2 * s->swd_f >= s->swd_n || s->b_size + s->swd_f >= SWD_UINT_MAX)
return LZO_E_ERROR; return LZO_E_ERROR;
#else #else
LZO_COMPILE_TIME_ASSERT(!(0ul + 2 * SWD_F >= SWD_N)) LZO_COMPILE_TIME_ASSERT(!(0ul + 2 * SWD_F >= SWD_N))
LZO_COMPILE_TIME_ASSERT(!(0ul + SWD_N + SWD_F + SWD_F >= SWD_UINT_MAX)) LZO_COMPILE_TIME_ASSERT(!(0ul + SWD_N + SWD_F + SWD_F >= SWD_UINT_MAX))
@ -299,65 +308,80 @@ int swd_init(lzo_swd_p s, const lzo_bytep dict, lzo_uint dict_len)
lzo_memset(s_llen3(s), 0, (lzo_uint)sizeof(s_llen3(s)[0]) * (lzo_uint)SWD_HSIZE); lzo_memset(s_llen3(s), 0, (lzo_uint)sizeof(s_llen3(s)[0]) * (lzo_uint)SWD_HSIZE);
#ifdef HEAD2 #ifdef HEAD2
IF_HEAD2(s) { IF_HEAD2(s)
{
#if 1 #if 1
lzo_memset(s_head2(s), 0xff, (lzo_uint)sizeof(s_head2(s)[0]) * 65536L); lzo_memset(s_head2(s), 0xff, (lzo_uint)sizeof(s_head2(s)[0]) * 65536L);
assert(s_head2(s)[0] == NIL2); assert(s_head2(s)[0] == NIL2);
#else #else
lzo_xint i; lzo_xint i;
for (i = 0; i < 65536L; i++) for (i = 0; i < 65536L; i++)
s_head2(s)[i] = NIL2; s_head2(s)[i] = NIL2;
#endif #endif
} }
#endif #endif
s->ip = 0; s->ip = 0;
swd_initdict(s,dict,dict_len); swd_initdict(s, dict, dict_len);
s->bp = s->ip; s->bp = s->ip;
s->first_rp = s->ip; s->first_rp = s->ip;
assert(s->ip + s->swd_f <= s->b_size); assert(s->ip + s->swd_f <= s->b_size);
#if 1 #if 1
s->look = (lzo_uint) (s->c->in_end - s->c->ip); s->look = (lzo_uint)(s->c->in_end - s->c->ip);
if (s->look > 0) if (s->look > 0)
{ {
if (s->look > s->swd_f) if (s->look > s->swd_f)
s->look = s->swd_f; s->look = s->swd_f;
lzo_memcpy(&s_b(s)[s->ip],s->c->ip,s->look);
lzo_memcpy(&s_b(s)[s->ip], s->c->ip, s->look);
s->c->ip += s->look; s->c->ip += s->look;
s->ip += s->look; s->ip += s->look;
} }
#else #else
s->look = 0; s->look = 0;
while (s->look < s->swd_f) while (s->look < s->swd_f)
{ {
int c; int c;
if ((c = getbyte(*(s->c))) < 0) if ((c = getbyte(*(s->c))) < 0)
break; break;
s_b(s)[s->ip] = LZO_BYTE(c); s_b(s)[s->ip] = LZO_BYTE(c);
s->ip++; s->ip++;
s->look++; s->look++;
} }
#endif #endif
if (s->ip == s->b_size) if (s->ip == s->b_size)
s->ip = 0; s->ip = 0;
if (s->look >= 2 && s->dict_len > 0) if (s->look >= 2 && s->dict_len > 0)
swd_insertdict(s,0,s->dict_len); swd_insertdict(s, 0, s->dict_len);
s->rp = s->first_rp; s->rp = s->first_rp;
if (s->rp >= s->node_count) if (s->rp >= s->node_count)
s->rp -= s->node_count; s->rp -= s->node_count;
else else
s->rp += s->b_size - s->node_count; s->rp += s->b_size - s->node_count;
#if 1 || defined(__LZO_CHECKER) #if 1 || defined(__LZO_CHECKER)
/* initialize memory for the first few HEAD3 (if s->ip is not far /* initialize memory for the first few HEAD3 (if s->ip is not far
* enough ahead to do this job for us). The value doesn't matter. */ * enough ahead to do this job for us). The value doesn't matter. */
if (s->look < 3) { if (s->look < 3)
lzo_bytep p = &s_b(s)[s->bp+s->look]; {
lzo_bytep p = &s_b(s)[s->bp + s->look];
p[0] = p[1] = p[2] = 0; p[0] = p[1] = p[2] = 0;
} }
#endif #endif
return LZO_E_OK; return LZO_E_OK;
@ -370,13 +394,19 @@ void swd_exit(lzo_swd_p s)
#if defined(__LZO_CHECKER) #if defined(__LZO_CHECKER)
/* free in reverse order of allocations */ /* free in reverse order of allocations */
#ifdef HEAD2 #ifdef HEAD2
free(s->head2); s->head2 = NULL; free(s->head2);
s->head2 = NULL;
#endif #endif
free(s->llen3); s->llen3 = NULL; free(s->llen3);
free(s->best3); s->best3 = NULL; s->llen3 = NULL;
free(s->succ3); s->succ3 = NULL; free(s->best3);
free(s->head3); s->head3 = NULL; s->best3 = NULL;
free(s->b); s->b = NULL; free(s->succ3);
s->succ3 = NULL;
free(s->head3);
s->head3 = NULL;
free(s->b);
s->b = NULL;
#else #else
LZO_UNUSED(s); LZO_UNUSED(s);
#endif #endif
@ -400,23 +430,30 @@ void swd_getbyte(lzo_swd_p s)
{ {
if (s->look > 0) if (s->look > 0)
--s->look; --s->look;
#if 1 || defined(__LZO_CHECKER) #if 1 || defined(__LZO_CHECKER)
/* initialize memory - value doesn't matter */ /* initialize memory - value doesn't matter */
s_b(s)[s->ip] = 0; s_b(s)[s->ip] = 0;
if (s->ip < s->swd_f) if (s->ip < s->swd_f)
s->b_wrap[s->ip] = 0; s->b_wrap[s->ip] = 0;
#endif #endif
} }
else else
{ {
s_b(s)[s->ip] = LZO_BYTE(c); s_b(s)[s->ip] = LZO_BYTE(c);
if (s->ip < s->swd_f) if (s->ip < s->swd_f)
s->b_wrap[s->ip] = LZO_BYTE(c); s->b_wrap[s->ip] = LZO_BYTE(c);
} }
if (++s->ip == s->b_size) if (++s->ip == s->b_size)
s->ip = 0; s->ip = 0;
if (++s->bp == s->b_size) if (++s->bp == s->b_size)
s->bp = 0; s->bp = 0;
if (++s->rp == s->b_size) if (++s->rp == s->b_size)
s->rp = 0; s->rp = 0;
} }
@ -434,26 +471,31 @@ void swd_remove_node(lzo_swd_p s, lzo_uint node)
lzo_uint key; lzo_uint key;
#ifdef LZO_DEBUG #ifdef LZO_DEBUG
if (s->first_rp != LZO_UINT_MAX) if (s->first_rp != LZO_UINT_MAX)
{ {
if (node != s->first_rp) if (node != s->first_rp)
printf("Remove %5ld: %5ld %5ld %5ld %5ld %6ld %6ld\n", printf("Remove %5ld: %5ld %5ld %5ld %5ld %6ld %6ld\n",
(long)node, (long)s->rp, (long)s->ip, (long)s->bp, (long)node, (long)s->rp, (long)s->ip, (long)s->bp,
(long)s->first_rp, (long)(s->ip - node), (long)s->first_rp, (long)(s->ip - node),
(long)(s->ip - s->bp)); (long)(s->ip - s->bp));
assert(node == s->first_rp); assert(node == s->first_rp);
s->first_rp = LZO_UINT_MAX; s->first_rp = LZO_UINT_MAX;
} }
#endif #endif
key = HEAD3(s_b(s),node); key = HEAD3(s_b(s), node);
assert(s_llen3(s)[key] > 0); assert(s_llen3(s)[key] > 0);
--s_llen3(s)[key]; --s_llen3(s)[key];
#ifdef HEAD2 #ifdef HEAD2
IF_HEAD2(s) { IF_HEAD2(s)
key = HEAD2(s_b(s),node); {
key = HEAD2(s_b(s), node);
assert(s_head2(s)[key] != NIL2); assert(s_head2(s)[key] != NIL2);
if ((lzo_uint) s_head2(s)[key] == node) if ((lzo_uint) s_head2(s)[key] == node)
s_head2(s)[key] = NIL2; s_head2(s)[key] = NIL2;
} }
@ -474,29 +516,31 @@ void swd_accept(lzo_swd_p s, lzo_uint n)
assert(n <= s->look); assert(n <= s->look);
if (n) do if (n) do
{ {
lzo_uint key; lzo_uint key;
swd_remove_node(s,s->rp); swd_remove_node(s, s->rp);
/* add bp into HEAD3 */ /* add bp into HEAD3 */
key = HEAD3(s_b(s),s->bp); key = HEAD3(s_b(s), s->bp);
s_succ3(s)[s->bp] = s_get_head3(s,key); s_succ3(s)[s->bp] = s_get_head3(s, key);
s_head3(s)[key] = SWD_UINT(s->bp); s_head3(s)[key] = SWD_UINT(s->bp);
s_best3(s)[s->bp] = SWD_UINT(s->swd_f + 1); s_best3(s)[s->bp] = SWD_UINT(s->swd_f + 1);
s_llen3(s)[key]++; s_llen3(s)[key]++;
assert(s_llen3(s)[key] <= s->swd_n); assert(s_llen3(s)[key] <= s->swd_n);
#ifdef HEAD2 #ifdef HEAD2
/* add bp into HEAD2 */ /* add bp into HEAD2 */
IF_HEAD2(s) { IF_HEAD2(s)
key = HEAD2(s_b(s),s->bp); {
s_head2(s)[key] = SWD_UINT(s->bp); key = HEAD2(s_b(s), s->bp);
} s_head2(s)[key] = SWD_UINT(s->bp);
}
#endif #endif
swd_getbyte(s); swd_getbyte(s);
} while (--n != 0); }
while (--n != 0);
} }
@ -519,7 +563,8 @@ void swd_search(lzo_swd_p s, lzo_uint node, lzo_uint cnt)
assert(s->m_len > 0); assert(s->m_len > 0);
scan_end1 = bp[m_len - 1]; scan_end1 = bp[m_len - 1];
for ( ; cnt-- > 0; node = s_succ3(s)[node])
for (; cnt-- > 0; node = s_succ3(s)[node])
{ {
p1 = bp; p1 = bp;
p2 = b + node; p2 = b + node;
@ -536,45 +581,62 @@ void swd_search(lzo_swd_p s, lzo_uint node, lzo_uint cnt)
p2[1] == p1[1]) p2[1] == p1[1])
{ {
lzo_uint i; lzo_uint i;
assert(lzo_memcmp(bp,&b[node],3) == 0); assert(lzo_memcmp(bp, &b[node], 3) == 0);
#if 0 && (LZO_OPT_UNALIGNED32) #if 0 && (LZO_OPT_UNALIGNED32)
p1 += 3; p2 += 3; p1 += 3;
p2 += 3;
while (p1 + 4 <= px && UA_GET_NE32(p1) == UA_GET_NE32(p2)) while (p1 + 4 <= px && UA_GET_NE32(p1) == UA_GET_NE32(p2))
p1 += 4, p2 += 4; p1 += 4, p2 += 4;
while (p1 < px && *p1 == *p2) while (p1 < px && *p1 == *p2)
p1 += 1, p2 += 1; p1 += 1, p2 += 1;
#else #else
p1 += 2; p2 += 2; p1 += 2;
do {} while (++p1 < px && *p1 == *++p2); p2 += 2;
do {}
while (++p1 < px && *p1 == *++p2);
#endif #endif
i = pd(p1, bp); i = pd(p1, bp);
#ifdef LZO_DEBUG #ifdef LZO_DEBUG
if (lzo_memcmp(bp,&b[node],i) != 0)
if (lzo_memcmp(bp, &b[node], i) != 0)
printf("%5ld %5ld %5ld %02x/%02x %02x/%02x\n", printf("%5ld %5ld %5ld %02x/%02x %02x/%02x\n",
(long)s->bp, (long) node, (long) i, (long)s->bp, (long) node, (long) i,
bp[0], bp[1], b[node], b[node+1]); bp[0], bp[1], b[node], b[node + 1]);
#endif #endif
assert(lzo_memcmp(bp,&b[node],i) == 0); assert(lzo_memcmp(bp, &b[node], i) == 0);
#if defined(SWD_BEST_OFF) #if defined(SWD_BEST_OFF)
if (i < SWD_BEST_OFF) if (i < SWD_BEST_OFF)
{ {
if (s->best_pos[i] == 0) if (s->best_pos[i] == 0)
s->best_pos[i] = node + 1; s->best_pos[i] = node + 1;
} }
#endif #endif
if (i > m_len) if (i > m_len)
{ {
s->m_len = m_len = i; s->m_len = m_len = i;
s->m_pos = node; s->m_pos = node;
if (m_len == s->look) if (m_len == s->look)
return; return;
if (m_len >= s->nice_length) if (m_len >= s->nice_length)
return; return;
if (m_len > (lzo_uint) s_best3(s)[node]) if (m_len > (lzo_uint) s_best3(s)[node])
return; return;
scan_end1 = bp[m_len - 1]; scan_end1 = bp[m_len - 1];
} }
} }
@ -596,18 +658,24 @@ lzo_bool swd_search2(lzo_swd_p s)
assert(s->look >= 2); assert(s->look >= 2);
assert(s->m_len > 0); assert(s->m_len > 0);
key = s_head2(s)[ HEAD2(s_b(s),s->bp) ]; key = s_head2(s)[ HEAD2(s_b(s), s->bp) ];
if (key == NIL2) if (key == NIL2)
return 0; return 0;
#ifdef LZO_DEBUG #ifdef LZO_DEBUG
if (lzo_memcmp(&s_b(s)[s->bp],&s_b(s)[key],2) != 0)
if (lzo_memcmp(&s_b(s)[s->bp], &s_b(s)[key], 2) != 0)
printf("%5ld %5ld %02x/%02x %02x/%02x\n", (long)s->bp, (long)key, printf("%5ld %5ld %02x/%02x %02x/%02x\n", (long)s->bp, (long)key,
s_b(s)[s->bp], s_b(s)[s->bp+1], s_b(s)[key], s_b(s)[key+1]); s_b(s)[s->bp], s_b(s)[s->bp + 1], s_b(s)[key], s_b(s)[key + 1]);
#endif #endif
assert(lzo_memcmp(&s_b(s)[s->bp],&s_b(s)[key],2) == 0); assert(lzo_memcmp(&s_b(s)[s->bp], &s_b(s)[key], 2) == 0);
#if defined(SWD_BEST_OFF) #if defined(SWD_BEST_OFF)
if (s->best_pos[2] == 0) if (s->best_pos[2] == 0)
s->best_pos[2] = key + 1; s->best_pos[2] = key + 1;
#endif #endif
if (s->m_len < 2) if (s->m_len < 2)
@ -615,6 +683,7 @@ lzo_bool swd_search2(lzo_swd_p s)
s->m_len = 2; s->m_len = 2;
s->m_pos = key; s->m_pos = key;
} }
return 1; return 1;
} }
@ -635,55 +704,69 @@ void swd_findbest(lzo_swd_p s)
assert(s->m_len > 0); assert(s->m_len > 0);
/* get current head, add bp into HEAD3 */ /* get current head, add bp into HEAD3 */
key = HEAD3(s_b(s),s->bp); key = HEAD3(s_b(s), s->bp);
node = s_succ3(s)[s->bp] = s_get_head3(s,key); node = s_succ3(s)[s->bp] = s_get_head3(s, key);
cnt = s_llen3(s)[key]++; cnt = s_llen3(s)[key]++;
assert(s_llen3(s)[key] <= s->swd_n + s->swd_f); assert(s_llen3(s)[key] <= s->swd_n + s->swd_f);
if (cnt > s->max_chain && s->max_chain > 0) if (cnt > s->max_chain && s->max_chain > 0)
cnt = s->max_chain; cnt = s->max_chain;
s_head3(s)[key] = SWD_UINT(s->bp); s_head3(s)[key] = SWD_UINT(s->bp);
s->b_char = s_b(s)[s->bp]; s->b_char = s_b(s)[s->bp];
len = s->m_len; len = s->m_len;
if (s->m_len >= s->look) if (s->m_len >= s->look)
{ {
if (s->look == 0) if (s->look == 0)
s->b_char = -1; s->b_char = -1;
s->m_off = 0; s->m_off = 0;
s_best3(s)[s->bp] = SWD_UINT(s->swd_f + 1); s_best3(s)[s->bp] = SWD_UINT(s->swd_f + 1);
} }
else else
{ {
#if defined(HEAD2) #if defined(HEAD2)
if (swd_search2(s) && s->look >= 3) if (swd_search2(s) && s->look >= 3)
swd_search(s,node,cnt); swd_search(s, node, cnt);
#else #else
if (s->look >= 3) if (s->look >= 3)
swd_search(s,node,cnt); swd_search(s, node, cnt);
#endif #endif
if (s->m_len > len) if (s->m_len > len)
s->m_off = swd_pos2off(s,s->m_pos); s->m_off = swd_pos2off(s, s->m_pos);
s_best3(s)[s->bp] = SWD_UINT(s->m_len); s_best3(s)[s->bp] = SWD_UINT(s->m_len);
#if defined(SWD_BEST_OFF) #if defined(SWD_BEST_OFF)
if (s->use_best_off) if (s->use_best_off)
{ {
unsigned i; unsigned i;
for (i = 2; i < SWD_BEST_OFF; i++) for (i = 2; i < SWD_BEST_OFF; i++)
if (s->best_pos[i] > 0) if (s->best_pos[i] > 0)
s->best_off[i] = swd_pos2off(s,s->best_pos[i]-1); s->best_off[i] = swd_pos2off(s, s->best_pos[i] - 1);
else else
s->best_off[i] = 0; s->best_off[i] = 0;
} }
#endif #endif
} }
swd_remove_node(s,s->rp); swd_remove_node(s, s->rp);
#ifdef HEAD2 #ifdef HEAD2
/* add bp into HEAD2 */ /* add bp into HEAD2 */
IF_HEAD2(s) { IF_HEAD2(s)
key = HEAD2(s_b(s),s->bp); {
key = HEAD2(s_b(s), s->bp);
s_head2(s)[key] = SWD_UINT(s->bp); s_head2(s)[key] = SWD_UINT(s->bp);
} }
#endif #endif

View File

@ -66,13 +66,13 @@ lzo_version(void)
return LZO_VERSION; return LZO_VERSION;
} }
LZO_PUBLIC(const char *) LZO_PUBLIC(const char*)
lzo_version_string(void) lzo_version_string(void)
{ {
return lzo_version_string_; return lzo_version_string_;
} }
LZO_PUBLIC(const char *) LZO_PUBLIC(const char*)
lzo_version_date(void) lzo_version_date(void)
{ {
return lzo_version_date_; return lzo_version_date_;
@ -121,20 +121,26 @@ lzo_adler32(lzo_uint32_t adler, const lzo_bytep buf, lzo_uint len)
{ {
k = len < LZO_NMAX ? (unsigned) len : LZO_NMAX; k = len < LZO_NMAX ? (unsigned) len : LZO_NMAX;
len -= k; len -= k;
if (k >= 16) do if (k >= 16) do
{ {
LZO_DO16(buf,0); LZO_DO16(buf, 0);
buf += 16; buf += 16;
k -= 16; k -= 16;
} while (k >= 16); }
while (k >= 16);
if (k != 0) do if (k != 0) do
{ {
s1 += *buf++; s1 += *buf++;
s2 += s1; s2 += s1;
} while (--k > 0); }
while (--k > 0);
s1 %= LZO_BASE; s1 %= LZO_BASE;
s2 %= LZO_BASE; s2 %= LZO_BASE;
} }
return (s2 << 16) | s1; return (s2 << 16) | s1;
} }

View File

@ -57,17 +57,18 @@ extern "C" {
// //
************************************************************************/ ************************************************************************/
typedef struct { typedef struct
{
/* configuration */ /* configuration */
unsigned rbits; unsigned rbits;
unsigned clevel; unsigned clevel;
/* internal configuration */ /* internal configuration */
unsigned dbits; unsigned dbits;
unsigned lbits; unsigned lbits;
/* constants */ /* constants */
unsigned min_match_short; unsigned min_match_short;
unsigned max_match_short; unsigned max_match_short;
unsigned min_match_long; unsigned min_match_long;
@ -78,7 +79,7 @@ typedef struct {
unsigned r0fast; unsigned r0fast;
unsigned r0max; unsigned r0max;
/* counts */ /* counts */
long short_matches; long short_matches;
long long_matches; long long_matches;
long r1_matches; long r1_matches;
@ -88,14 +89,14 @@ typedef struct {
long r0fast_runs; long r0fast_runs;
long r0long_runs; long r0long_runs;
/* */ /* */
long lit_run[RSIZE]; long lit_run[RSIZE];
long lit_run_after_long_match[RSIZE]; long lit_run_after_long_match[RSIZE];
long short_match[MAX_MATCH_SHORT + 1]; long short_match[MAX_MATCH_SHORT + 1];
long long_match[MAX_MATCH_LONG + 1]; long long_match[MAX_MATCH_LONG + 1];
long marker[256]; long marker[256];
/* these could prove useful for further optimizations */ /* these could prove useful for further optimizations */
long short_match_offset_osize[MAX_MATCH_SHORT + 1]; long short_match_offset_osize[MAX_MATCH_SHORT + 1];
long short_match_offset_256[MAX_MATCH_SHORT + 1]; long short_match_offset_256[MAX_MATCH_SHORT + 1];
long short_match_offset_1024[MAX_MATCH_SHORT + 1]; long short_match_offset_1024[MAX_MATCH_SHORT + 1];
@ -104,13 +105,13 @@ typedef struct {
long matches_out_of_range_4; long matches_out_of_range_4;
long match_out_of_range[MAX_MATCH_SHORT + 1]; long match_out_of_range[MAX_MATCH_SHORT + 1];
/* */ /* */
long in_len; long in_len;
long out_len; long out_len;
} }
lzo1a_stats_t; lzo1a_stats_t;
extern lzo1a_stats_t *lzo1a_stats; extern lzo1a_stats_t* lzo1a_stats;

View File

@ -57,19 +57,19 @@ extern "C" {
typedef struct typedef struct
{ {
/* algorithm configuration */ /* algorithm configuration */
unsigned r_bits; unsigned r_bits;
unsigned m3o_bits; unsigned m3o_bits;
unsigned dd_bits; unsigned dd_bits;
unsigned clevel; unsigned clevel;
/* internal configuration */ /* internal configuration */
unsigned d_bits; unsigned d_bits;
long min_lookahead; long min_lookahead;
long max_lookbehind; long max_lookbehind;
const char *compress_id; const char* compress_id;
/* counts */ /* counts */
long lit_runs; long lit_runs;
long r0short_runs; long r0short_runs;
long r0fast_runs; long r0fast_runs;
@ -80,16 +80,16 @@ typedef struct
long m4_matches; long m4_matches;
long r1_matches; long r1_matches;
/* */ /* */
long lit_run[R0MIN]; long lit_run[R0MIN];
long m2_match[M2_MAX_LEN + 1]; long m2_match[M2_MAX_LEN + 1];
long m3_match[M3_MAX_LEN + 1]; long m3_match[M3_MAX_LEN + 1];
#if (M3O_BITS < 8) #if (M3O_BITS < 8)
long lit_runs_after_m3_match; long lit_runs_after_m3_match;
long lit_run_after_m3_match[LZO_SIZE(8-M3O_BITS)]; long lit_run_after_m3_match[LZO_SIZE(8 - M3O_BITS)];
#endif #endif
/* */ /* */
long matches; long matches;
long match_bytes; long match_bytes;
long literals; long literals;
@ -97,21 +97,21 @@ typedef struct
long literal_bytes; long literal_bytes;
double literal_overhead_percent; double literal_overhead_percent;
/* */ /* */
long unused_dict_entries; long unused_dict_entries;
double unused_dict_entries_percent; double unused_dict_entries_percent;
/* */ /* */
long in_len; long in_len;
long out_len; long out_len;
} }
lzo1b_stats_t; lzo1b_stats_t;
void _lzo1b_stats_init(lzo1b_stats_t *lzo_stats); void _lzo1b_stats_init(lzo1b_stats_t* lzo_stats);
void _lzo1b_stats_calc(lzo1b_stats_t *lzo_stats); void _lzo1b_stats_calc(lzo1b_stats_t* lzo_stats);
extern lzo1b_stats_t * const lzo1b_stats; extern lzo1b_stats_t* const lzo1b_stats;
#define lzo_stats_t lzo1b_stats_t #define lzo_stats_t lzo1b_stats_t
#define lzo_stats lzo1b_stats #define lzo_stats lzo1b_stats

68
extern/zlib/adler32.c vendored
View File

@ -63,12 +63,12 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
/* ========================================================================= */ /* ========================================================================= */
#ifdef WIN32 #ifdef WIN32
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) uLong ZEXPORT adler32(uLong adler, const Bytef* buf, uInt len)
#else #else
uLong ZEXPORT adler32(adler, buf, len) uLong ZEXPORT adler32(adler, buf, len)
uLong adler; uLong adler;
const Bytef *buf; const Bytef* buf;
uInt len; uInt len;
#endif #endif
{ {
unsigned long sum2; unsigned long sum2;
@ -79,13 +79,18 @@ uLong ZEXPORT adler32(adler, buf, len)
adler &= 0xffff; adler &= 0xffff;
/* in case user likes doing a byte at a time, keep it fast */ /* in case user likes doing a byte at a time, keep it fast */
if (len == 1) { if (len == 1)
{
adler += buf[0]; adler += buf[0];
if (adler >= BASE) if (adler >= BASE)
adler -= BASE; adler -= BASE;
sum2 += adler; sum2 += adler;
if (sum2 >= BASE) if (sum2 >= BASE)
sum2 -= BASE; sum2 -= BASE;
return adler | (sum2 << 16); return adler | (sum2 << 16);
} }
@ -94,40 +99,54 @@ uLong ZEXPORT adler32(adler, buf, len)
return 1L; return 1L;
/* in case short lengths are provided, keep it somewhat fast */ /* in case short lengths are provided, keep it somewhat fast */
if (len < 16) { if (len < 16)
while (len--) { {
while (len--)
{
adler += *buf++; adler += *buf++;
sum2 += adler; sum2 += adler;
} }
if (adler >= BASE) if (adler >= BASE)
adler -= BASE; adler -= BASE;
MOD28(sum2); /* only added so many BASE's */ MOD28(sum2); /* only added so many BASE's */
return adler | (sum2 << 16); return adler | (sum2 << 16);
} }
/* do length NMAX blocks -- requires just one modulo operation */ /* do length NMAX blocks -- requires just one modulo operation */
while (len >= NMAX) { while (len >= NMAX)
{
len -= NMAX; len -= NMAX;
n = NMAX / 16; /* NMAX is divisible by 16 */ n = NMAX / 16; /* NMAX is divisible by 16 */
do {
do
{
DO16(buf); /* 16 sums unrolled */ DO16(buf); /* 16 sums unrolled */
buf += 16; buf += 16;
} while (--n); }
while (--n);
MOD(adler); MOD(adler);
MOD(sum2); MOD(sum2);
} }
/* do remaining bytes (less than NMAX, still just one modulo) */ /* do remaining bytes (less than NMAX, still just one modulo) */
if (len) { /* avoid modulos if none remaining */ if (len) /* avoid modulos if none remaining */
while (len >= 16) { {
while (len >= 16)
{
len -= 16; len -= 16;
DO16(buf); DO16(buf);
buf += 16; buf += 16;
} }
while (len--) {
while (len--)
{
adler += *buf++; adler += *buf++;
sum2 += adler; sum2 += adler;
} }
MOD(adler); MOD(adler);
MOD(sum2); MOD(sum2);
} }
@ -141,9 +160,9 @@ uLong ZEXPORT adler32(adler, buf, len)
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2)
#else #else
local uLong adler32_combine_(adler1, adler2, len2) local uLong adler32_combine_(adler1, adler2, len2)
uLong adler1; uLong adler1;
uLong adler2; uLong adler2;
z_off64_t len2; z_off64_t len2;
#endif #endif
{ {
unsigned long sum1; unsigned long sum1;
@ -162,10 +181,15 @@ local uLong adler32_combine_(adler1, adler2, len2)
MOD(sum2); MOD(sum2);
sum1 += (adler2 & 0xffff) + BASE - 1; sum1 += (adler2 & 0xffff) + BASE - 1;
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 >= BASE) sum1 -= BASE; if (sum1 >= BASE) sum1 -= BASE;
if (sum1 >= BASE) sum1 -= BASE; if (sum1 >= BASE) sum1 -= BASE;
if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
if (sum2 >= BASE) sum2 -= BASE; if (sum2 >= BASE) sum2 -= BASE;
return sum1 | (sum2 << 16); return sum1 | (sum2 << 16);
} }
@ -174,9 +198,9 @@ local uLong adler32_combine_(adler1, adler2, len2)
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2)
#else #else
uLong ZEXPORT adler32_combine(adler1, adler2, len2) uLong ZEXPORT adler32_combine(adler1, adler2, len2)
uLong adler1; uLong adler1;
uLong adler2; uLong adler2;
z_off_t len2; z_off_t len2;
#endif #endif
{ {
return adler32_combine_(adler1, adler2, len2); return adler32_combine_(adler1, adler2, len2);
@ -186,9 +210,9 @@ uLong ZEXPORT adler32_combine(adler1, adler2, len2)
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2)
#else #else
uLong ZEXPORT adler32_combine64(adler1, adler2, len2) uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
uLong adler1; uLong adler1;
uLong adler2; uLong adler2;
z_off64_t len2; z_off64_t len2;
#endif #endif
{ {
return adler32_combine_(adler1, adler2, len2); return adler32_combine_(adler1, adler2, len2);

View File

@ -20,14 +20,14 @@
Z_STREAM_ERROR if the level parameter is invalid. Z_STREAM_ERROR if the level parameter is invalid.
*/ */
#ifdef WIN32 #ifdef WIN32
int ZEXPORT compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level) int ZEXPORT compress2(Bytef* dest, uLongf* destLen, const Bytef* source, uLong sourceLen, int level)
#else #else
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) int ZEXPORT compress2(dest, destLen, source, sourceLen, level)
Bytef *dest; Bytef* dest;
uLongf *destLen; uLongf* destLen;
const Bytef *source; const Bytef* source;
uLong sourceLen; uLong sourceLen;
int level; int level;
#endif #endif
{ {
z_stream stream; z_stream stream;
@ -36,11 +36,14 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
stream.next_in = (Bytef*)source; stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen; stream.avail_in = (uInt)sourceLen;
#ifdef MAXSEG_64K #ifdef MAXSEG_64K
/* Check for source > 64K on 16-bit machine: */ /* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
#endif #endif
stream.next_out = dest; stream.next_out = dest;
stream.avail_out = (uInt)*destLen; stream.avail_out = (uInt) * destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
stream.zalloc = (alloc_func)0; stream.zalloc = (alloc_func)0;
@ -48,13 +51,17 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
stream.opaque = (voidpf)0; stream.opaque = (voidpf)0;
err = deflateInit(&stream, level); err = deflateInit(&stream, level);
if (err != Z_OK) return err; if (err != Z_OK) return err;
err = deflate(&stream, Z_FINISH); err = deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
if (err != Z_STREAM_END)
{
deflateEnd(&stream); deflateEnd(&stream);
return err == Z_OK ? Z_BUF_ERROR : err; return err == Z_OK ? Z_BUF_ERROR : err;
} }
*destLen = stream.total_out; *destLen = stream.total_out;
err = deflateEnd(&stream); err = deflateEnd(&stream);
@ -64,13 +71,13 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
/* =========================================================================== /* ===========================================================================
*/ */
#ifdef WIN32 #ifdef WIN32
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) int ZEXPORT compress(Bytef* dest, uLongf* destLen, const Bytef* source, uLong sourceLen)
#else #else
int ZEXPORT compress (dest, destLen, source, sourceLen) int ZEXPORT compress(dest, destLen, source, sourceLen)
Bytef *dest; Bytef* dest;
uLongf *destLen; uLongf* destLen;
const Bytef *source; const Bytef* source;
uLong sourceLen; uLong sourceLen;
#endif #endif
{ {
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
@ -81,10 +88,10 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
this function needs to be updated. this function needs to be updated.
*/ */
#ifdef WIN32 #ifdef WIN32
uLong ZEXPORT compressBound (uLong sourceLen) uLong ZEXPORT compressBound(uLong sourceLen)
#else #else
uLong ZEXPORT compressBound (sourceLen) uLong ZEXPORT compressBound(sourceLen)
uLong sourceLen; uLong sourceLen;
#endif #endif
{ {
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +

232
extern/zlib/crc32.c vendored
View File

@ -37,19 +37,19 @@
# define BYFOUR # define BYFOUR
#endif #endif
#ifdef BYFOUR #ifdef BYFOUR
local unsigned long crc32_little OF((unsigned long, local unsigned long crc32_little OF((unsigned long,
const unsigned char FAR *, unsigned)); const unsigned char FAR*, unsigned));
local unsigned long crc32_big OF((unsigned long, local unsigned long crc32_big OF((unsigned long,
const unsigned char FAR *, unsigned)); const unsigned char FAR*, unsigned));
# define TBLS 8 # define TBLS 8
#else #else
# define TBLS 1 # define TBLS 1
#endif /* BYFOUR */ #endif /* BYFOUR */
/* Local functions for crc concatenation */ /* Local functions for crc concatenation */
local unsigned long gf2_matrix_times OF((unsigned long *mat, local unsigned long gf2_matrix_times OF((unsigned long* mat,
unsigned long vec)); unsigned long vec));
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); local void gf2_matrix_square OF((unsigned long* square, unsigned long* mat));
local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
@ -59,7 +59,7 @@ local volatile int crc_table_empty = 1;
local z_crc_t FAR crc_table[TBLS][256]; local z_crc_t FAR crc_table[TBLS][256];
local void make_crc_table OF((void)); local void make_crc_table OF((void));
#ifdef MAKECRCH #ifdef MAKECRCH
local void write_table OF((FILE *, const z_crc_t FAR *)); local void write_table OF((FILE*, const z_crc_t FAR*));
#endif /* MAKECRCH */ #endif /* MAKECRCH */
/* /*
Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
@ -94,44 +94,55 @@ local void make_crc_table()
z_crc_t poly; /* polynomial exclusive-or pattern */ z_crc_t poly; /* polynomial exclusive-or pattern */
/* terms of polynomial defining this crc (except x^32): */ /* terms of polynomial defining this crc (except x^32): */
static volatile int first = 1; /* flag to limit concurrent making */ static volatile int first = 1; /* flag to limit concurrent making */
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; static const unsigned char p[] = {0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26};
/* See if another task is already doing this (not thread-safe, but better /* See if another task is already doing this (not thread-safe, but better
than nothing -- significantly reduces duration of vulnerability in than nothing -- significantly reduces duration of vulnerability in
case the advice about DYNAMIC_CRC_TABLE is ignored) */ case the advice about DYNAMIC_CRC_TABLE is ignored) */
if (first) { if (first)
{
first = 0; first = 0;
/* make exclusive-or pattern from polynomial (0xedb88320UL) */ /* make exclusive-or pattern from polynomial (0xedb88320UL) */
poly = 0; poly = 0;
for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
for (n = 0; n < (int)(sizeof(p) / sizeof(unsigned char)); n++)
poly |= (z_crc_t)1 << (31 - p[n]); poly |= (z_crc_t)1 << (31 - p[n]);
/* generate a crc for every 8-bit value */ /* generate a crc for every 8-bit value */
for (n = 0; n < 256; n++) { for (n = 0; n < 256; n++)
{
c = (z_crc_t)n; c = (z_crc_t)n;
for (k = 0; k < 8; k++) for (k = 0; k < 8; k++)
c = c & 1 ? poly ^ (c >> 1) : c >> 1; c = c & 1 ? poly ^ (c >> 1) : c >> 1;
crc_table[0][n] = c; crc_table[0][n] = c;
} }
#ifdef BYFOUR #ifdef BYFOUR
/* generate crc for each value followed by one, two, and three zeros, /* generate crc for each value followed by one, two, and three zeros,
and then the byte reversal of those as well as the first table */ and then the byte reversal of those as well as the first table */
for (n = 0; n < 256; n++) { for (n = 0; n < 256; n++)
{
c = crc_table[0][n]; c = crc_table[0][n];
crc_table[4][n] = ZSWAP32(c); crc_table[4][n] = ZSWAP32(c);
for (k = 1; k < 4; k++) {
for (k = 1; k < 4; k++)
{
c = crc_table[0][c & 0xff] ^ (c >> 8); c = crc_table[0][c & 0xff] ^ (c >> 8);
crc_table[k][n] = c; crc_table[k][n] = c;
crc_table[k + 4][n] = ZSWAP32(c); crc_table[k + 4][n] = ZSWAP32(c);
} }
} }
#endif /* BYFOUR */ #endif /* BYFOUR */
crc_table_empty = 0; crc_table_empty = 0;
} }
else { /* not first */ else /* not first */
{
/* wait for the other guy to finish (not efficient, but rare) */ /* wait for the other guy to finish (not efficient, but rare) */
while (crc_table_empty) while (crc_table_empty)
; ;
@ -140,10 +151,12 @@ local void make_crc_table()
#ifdef MAKECRCH #ifdef MAKECRCH
/* write out CRC tables to crc32.h */ /* write out CRC tables to crc32.h */
{ {
FILE *out; FILE* out;
out = fopen("crc32.h", "w"); out = fopen("crc32.h", "w");
if (out == NULL) return; if (out == NULL) return;
fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
fprintf(out, "local const z_crc_t FAR "); fprintf(out, "local const z_crc_t FAR ");
@ -151,10 +164,13 @@ local void make_crc_table()
write_table(out, crc_table[0]); write_table(out, crc_table[0]);
# ifdef BYFOUR # ifdef BYFOUR
fprintf(out, "#ifdef BYFOUR\n"); fprintf(out, "#ifdef BYFOUR\n");
for (k = 1; k < 8; k++) {
for (k = 1; k < 8; k++)
{
fprintf(out, " },\n {\n"); fprintf(out, " },\n {\n");
write_table(out, crc_table[k]); write_table(out, crc_table[k]);
} }
fprintf(out, "#endif\n"); fprintf(out, "#endif\n");
# endif /* BYFOUR */ # endif /* BYFOUR */
fprintf(out, " }\n};\n"); fprintf(out, " }\n};\n");
@ -165,8 +181,8 @@ local void make_crc_table()
#ifdef MAKECRCH #ifdef MAKECRCH
local void write_table(out, table) local void write_table(out, table)
FILE *out; FILE* out;
const z_crc_t FAR *table; const z_crc_t FAR* table;
{ {
int n; int n;
@ -187,13 +203,15 @@ local void write_table(out, table)
/* ========================================================================= /* =========================================================================
* This function can be used by asm versions of crc32() * This function can be used by asm versions of crc32()
*/ */
const z_crc_t FAR * ZEXPORT get_crc_table() const z_crc_t FAR* ZEXPORT get_crc_table()
{ {
#ifdef DYNAMIC_CRC_TABLE #ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty) if (crc_table_empty)
make_crc_table(); make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */ #endif /* DYNAMIC_CRC_TABLE */
return (const z_crc_t FAR *)crc_table; return (const z_crc_t FAR*)crc_table;
} }
/* ========================================================================= */ /* ========================================================================= */
@ -202,45 +220,59 @@ const z_crc_t FAR * ZEXPORT get_crc_table()
/* ========================================================================= */ /* ========================================================================= */
#ifdef WIN32 #ifdef WIN32
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len) unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR* buf, uInt len)
#else #else
unsigned long ZEXPORT crc32(crc, buf, len) unsigned long ZEXPORT crc32(crc, buf, len)
unsigned long crc; unsigned long crc;
const unsigned char FAR *buf; const unsigned char FAR* buf;
uInt len; uInt len;
#endif #endif
{ {
if (buf == Z_NULL) return 0UL; if (buf == Z_NULL) return 0UL;
#ifdef DYNAMIC_CRC_TABLE #ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty) if (crc_table_empty)
make_crc_table(); make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */ #endif /* DYNAMIC_CRC_TABLE */
#ifdef BYFOUR #ifdef BYFOUR
#ifdef WIN32 #ifdef WIN32
int size_match = (sizeof(void *) == sizeof(ptrdiff_t)); int size_match = (sizeof(void*) == sizeof(ptrdiff_t));
if (size_match) {
#else
if (sizeof(void *) == sizeof(ptrdiff_t)) {
#endif /* WIN32 */
z_crc_t endian;
endian = 1; if (size_match)
if (*((unsigned char *)(&endian))) {
#else
if (sizeof(void*) == sizeof(ptrdiff_t))
{
#endif /* WIN32 */
z_crc_t endian;
endian = 1;
if (*((unsigned char*)(&endian)))
return crc32_little(crc, buf, len); return crc32_little(crc, buf, len);
else else
return crc32_big(crc, buf, len); return crc32_big(crc, buf, len);
} }
#endif /* BYFOUR */ #endif /* BYFOUR */
crc = crc ^ 0xffffffffUL; crc = crc ^ 0xffffffffUL;
while (len >= 8) {
while (len >= 8)
{
DO8; DO8;
len -= 8; len -= 8;
} }
if (len) do {
DO1; if (len) do
} while (--len); {
DO1;
}
while (--len);
return crc ^ 0xffffffffUL; return crc ^ 0xffffffffUL;
} }
@ -254,38 +286,48 @@ unsigned long ZEXPORT crc32(crc, buf, len)
/* ========================================================================= */ /* ========================================================================= */
#ifdef WIN32 #ifdef WIN32
local unsigned long crc32_little(unsigned long crc, const unsigned char FAR *buf, unsigned len) local unsigned long crc32_little(unsigned long crc, const unsigned char FAR* buf, unsigned len)
#else #else
local unsigned long crc32_little(crc, buf, len) local unsigned long crc32_little(crc, buf, len)
unsigned long crc; unsigned long crc;
const unsigned char FAR *buf; const unsigned char FAR* buf;
unsigned len; unsigned len;
#endif #endif
{ {
register z_crc_t c; register z_crc_t c;
register const z_crc_t FAR *buf4; register const z_crc_t FAR* buf4;
c = (z_crc_t)crc; c = (z_crc_t)crc;
c = ~c; c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
while (len && ((ptrdiff_t)buf & 3))
{
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
len--; len--;
} }
buf4 = (const z_crc_t FAR *)(const void FAR *)buf; buf4 = (const z_crc_t FAR*)(const void FAR*)buf;
while (len >= 32) {
while (len >= 32)
{
DOLIT32; DOLIT32;
len -= 32; len -= 32;
} }
while (len >= 4) {
while (len >= 4)
{
DOLIT4; DOLIT4;
len -= 4; len -= 4;
} }
buf = (const unsigned char FAR *)buf4;
if (len) do { buf = (const unsigned char FAR*)buf4;
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
} while (--len); if (len) do
{
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
}
while (--len);
c = ~c; c = ~c;
return (unsigned long)c; return (unsigned long)c;
} }
@ -298,40 +340,50 @@ local unsigned long crc32_little(crc, buf, len)
/* ========================================================================= */ /* ========================================================================= */
#ifdef WIN32 #ifdef WIN32
local unsigned long crc32_big(unsigned long crc, const unsigned char FAR *buf, unsigned len) local unsigned long crc32_big(unsigned long crc, const unsigned char FAR* buf, unsigned len)
#else #else
local unsigned long crc32_big(crc, buf, len) local unsigned long crc32_big(crc, buf, len)
unsigned long crc; unsigned long crc;
const unsigned char FAR *buf; const unsigned char FAR* buf;
unsigned len; unsigned len;
#endif #endif
{ {
register z_crc_t c; register z_crc_t c;
register const z_crc_t FAR *buf4; register const z_crc_t FAR* buf4;
c = ZSWAP32((z_crc_t)crc); c = ZSWAP32((z_crc_t)crc);
c = ~c; c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
while (len && ((ptrdiff_t)buf & 3))
{
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
len--; len--;
} }
buf4 = (const z_crc_t FAR *)(const void FAR *)buf; buf4 = (const z_crc_t FAR*)(const void FAR*)buf;
buf4--; buf4--;
while (len >= 32) {
while (len >= 32)
{
DOBIG32; DOBIG32;
len -= 32; len -= 32;
} }
while (len >= 4) {
while (len >= 4)
{
DOBIG4; DOBIG4;
len -= 4; len -= 4;
} }
buf4++;
buf = (const unsigned char FAR *)buf4;
if (len) do { buf4++;
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); buf = (const unsigned char FAR*)buf4;
} while (--len);
if (len) do
{
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
}
while (--len);
c = ~c; c = ~c;
return (unsigned long)(ZSWAP32(c)); return (unsigned long)(ZSWAP32(c));
} }
@ -342,32 +394,36 @@ local unsigned long crc32_big(crc, buf, len)
/* ========================================================================= */ /* ========================================================================= */
#ifdef WIN32 #ifdef WIN32
local unsigned long gf2_matrix_times(unsigned long *mat, unsigned long vec) local unsigned long gf2_matrix_times(unsigned long* mat, unsigned long vec)
#else #else
local unsigned long gf2_matrix_times(mat, vec) local unsigned long gf2_matrix_times(mat, vec)
unsigned long *mat; unsigned long* mat;
unsigned long vec; unsigned long vec;
#endif #endif
{ {
unsigned long sum; unsigned long sum;
sum = 0; sum = 0;
while (vec) {
while (vec)
{
if (vec & 1) if (vec & 1)
sum ^= *mat; sum ^= *mat;
vec >>= 1; vec >>= 1;
mat++; mat++;
} }
return sum; return sum;
} }
/* ========================================================================= */ /* ========================================================================= */
#ifdef WIN32 #ifdef WIN32
local void gf2_matrix_square(unsigned long *square, unsigned long *mat) local void gf2_matrix_square(unsigned long* square, unsigned long* mat)
#else #else
local void gf2_matrix_square(square, mat) local void gf2_matrix_square(square, mat)
unsigned long *square; unsigned long* square;
unsigned long *mat; unsigned long* mat;
#endif #endif
{ {
int n; int n;
@ -381,9 +437,9 @@ local void gf2_matrix_square(square, mat)
local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2) local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2)
#else #else
local uLong crc32_combine_(crc1, crc2, len2) local uLong crc32_combine_(crc1, crc2, len2)
uLong crc1; uLong crc1;
uLong crc2; uLong crc2;
z_off64_t len2; z_off64_t len2;
#endif #endif
{ {
int n; int n;
@ -398,7 +454,9 @@ local uLong crc32_combine_(crc1, crc2, len2)
/* put operator for one zero bit in odd */ /* put operator for one zero bit in odd */
odd[0] = 0xedb88320UL; /* CRC-32 polynomial */ odd[0] = 0xedb88320UL; /* CRC-32 polynomial */
row = 1; row = 1;
for (n = 1; n < GF2_DIM; n++) {
for (n = 1; n < GF2_DIM; n++)
{
odd[n] = row; odd[n] = row;
row <<= 1; row <<= 1;
} }
@ -411,11 +469,14 @@ local uLong crc32_combine_(crc1, crc2, len2)
/* apply len2 zeros to crc1 (first square will put the operator for one /* apply len2 zeros to crc1 (first square will put the operator for one
zero byte, eight zero bits, in even) */ zero byte, eight zero bits, in even) */
do { do
{
/* apply zeros operator for this bit of len2 */ /* apply zeros operator for this bit of len2 */
gf2_matrix_square(even, odd); gf2_matrix_square(even, odd);
if (len2 & 1) if (len2 & 1)
crc1 = gf2_matrix_times(even, crc1); crc1 = gf2_matrix_times(even, crc1);
len2 >>= 1; len2 >>= 1;
/* if no more bits set, then done */ /* if no more bits set, then done */
@ -424,12 +485,15 @@ local uLong crc32_combine_(crc1, crc2, len2)
/* another iteration of the loop with odd and even swapped */ /* another iteration of the loop with odd and even swapped */
gf2_matrix_square(odd, even); gf2_matrix_square(odd, even);
if (len2 & 1) if (len2 & 1)
crc1 = gf2_matrix_times(odd, crc1); crc1 = gf2_matrix_times(odd, crc1);
len2 >>= 1; len2 >>= 1;
/* if no more bits set, then done */ /* if no more bits set, then done */
} while (len2 != 0); }
while (len2 != 0);
/* return combined crc */ /* return combined crc */
crc1 ^= crc2; crc1 ^= crc2;
@ -441,9 +505,9 @@ local uLong crc32_combine_(crc1, crc2, len2)
uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2)
#else #else
uLong ZEXPORT crc32_combine(crc1, crc2, len2) uLong ZEXPORT crc32_combine(crc1, crc2, len2)
uLong crc1; uLong crc1;
uLong crc2; uLong crc2;
z_off_t len2; z_off_t len2;
#endif #endif
{ {
return crc32_combine_(crc1, crc2, len2); return crc32_combine_(crc1, crc2, len2);
@ -453,9 +517,9 @@ uLong ZEXPORT crc32_combine(crc1, crc2, len2)
uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2)
#else #else
uLong ZEXPORT crc32_combine64(crc1, crc2, len2) uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
uLong crc1; uLong crc1;
uLong crc2; uLong crc2;
z_off64_t len2; z_off64_t len2;
#endif #endif
{ {
return crc32_combine_(crc1, crc2, len2); return crc32_combine_(crc1, crc2, len2);

864
extern/zlib/crc32.h vendored
View File

@ -4,438 +4,438 @@
local const z_crc_t FAR crc_table[TBLS][256] = local const z_crc_t FAR crc_table[TBLS][256] =
{ {
{ {
0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
0x2d02ef8dUL 0x2d02ef8dUL
#ifdef BYFOUR #ifdef BYFOUR
}, },
{ {
0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
0x9324fd72UL 0x9324fd72UL
}, },
{ {
0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
0xbe9834edUL 0xbe9834edUL
}, },
{ {
0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
0xde0506f1UL 0xde0506f1UL
}, },
{ {
0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
0x8def022dUL 0x8def022dUL
}, },
{ {
0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
0x72fd2493UL 0x72fd2493UL
}, },
{ {
0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
0xed3498beUL 0xed3498beUL
}, },
{ {
0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
0xf10605deUL 0xf10605deUL
#endif #endif
} }
}; };

1296
extern/zlib/deflate.c vendored

File diff suppressed because it is too large Load Diff

73
extern/zlib/deflate.h vendored
View File

@ -62,12 +62,15 @@
/* Data structure describing a single value and its code string. */ /* Data structure describing a single value and its code string. */
typedef struct ct_data_s { typedef struct ct_data_s
union { {
union
{
ush freq; /* frequency count */ ush freq; /* frequency count */
ush code; /* bit string */ ush code; /* bit string */
} fc; } fc;
union { union
{
ush dad; /* father node in Huffman tree */ ush dad; /* father node in Huffman tree */
ush len; /* length of bit string */ ush len; /* length of bit string */
} dl; } dl;
@ -80,10 +83,11 @@ typedef struct ct_data_s {
typedef struct static_tree_desc_s static_tree_desc; typedef struct static_tree_desc_s static_tree_desc;
typedef struct tree_desc_s { typedef struct tree_desc_s
ct_data *dyn_tree; /* the dynamic tree */ {
ct_data* dyn_tree; /* the dynamic tree */
int max_code; /* largest code with non zero frequency */ int max_code; /* largest code with non zero frequency */
static_tree_desc *stat_desc; /* the corresponding static tree */ static_tree_desc* stat_desc; /* the corresponding static tree */
} FAR tree_desc; } FAR tree_desc;
typedef ush Pos; typedef ush Pos;
@ -94,12 +98,13 @@ typedef unsigned IPos;
* save space in the various tables. IPos is used only for parameter passing. * save space in the various tables. IPos is used only for parameter passing.
*/ */
typedef struct internal_state { typedef struct internal_state
{
z_streamp strm; /* pointer back to this zlib stream */ z_streamp strm; /* pointer back to this zlib stream */
int status; /* as the name implies */ int status; /* as the name implies */
Bytef *pending_buf; /* output still pending */ Bytef* pending_buf; /* output still pending */
ulg pending_buf_size; /* size of pending_buf */ ulg pending_buf_size; /* size of pending_buf */
Bytef *pending_out; /* next pending byte to output to the stream */ Bytef* pending_out; /* next pending byte to output to the stream */
uInt pending; /* nb of bytes in the pending buffer */ uInt pending; /* nb of bytes in the pending buffer */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
gz_headerp gzhead; /* gzip header information to write */ gz_headerp gzhead; /* gzip header information to write */
@ -107,13 +112,13 @@ typedef struct internal_state {
Byte method; /* STORED (for zip only) or DEFLATED */ Byte method; /* STORED (for zip only) or DEFLATED */
int last_flush; /* value of flush param for previous deflate call */ int last_flush; /* value of flush param for previous deflate call */
/* used by deflate.c: */ /* used by deflate.c: */
uInt w_size; /* LZ77 window size (32K by default) */ uInt w_size; /* LZ77 window size (32K by default) */
uInt w_bits; /* log2(w_size) (8..16) */ uInt w_bits; /* log2(w_size) (8..16) */
uInt w_mask; /* w_size - 1 */ uInt w_mask; /* w_size - 1 */
Bytef *window; Bytef* window;
/* Sliding window. Input bytes are read into the second half of the window, /* Sliding window. Input bytes are read into the second half of the window,
* and move to the first half later to keep a dictionary of at least wSize * and move to the first half later to keep a dictionary of at least wSize
* bytes. With this organization, matches are limited to a distance of * bytes. With this organization, matches are limited to a distance of
@ -128,13 +133,13 @@ typedef struct internal_state {
* is directly used as sliding window. * is directly used as sliding window.
*/ */
Posf *prev; Posf* prev;
/* Link to older string with same hash index. To limit the size of this /* Link to older string with same hash index. To limit the size of this
* array to 64K, this link is maintained only for the last 32K strings. * array to 64K, this link is maintained only for the last 32K strings.
* An index in this array is thus a window index modulo 32K. * An index in this array is thus a window index modulo 32K.
*/ */
Posf *head; /* Heads of the hash chains or NIL. */ Posf* head; /* Heads of the hash chains or NIL. */
uInt ins_h; /* hash index of string to be inserted */ uInt ins_h; /* hash index of string to be inserted */
uInt hash_size; /* number of elements in hash table */ uInt hash_size; /* number of elements in hash table */
@ -190,31 +195,31 @@ typedef struct internal_state {
int nice_match; /* Stop searching when current match exceeds this */ int nice_match; /* Stop searching when current match exceeds this */
/* used by trees.c: */ /* used by trees.c: */
/* Didn't use ct_data typedef below to suppress compiler warning */ /* Didn't use ct_data typedef below to suppress compiler warning */
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ struct ct_data_s dyn_dtree[2 * D_CODES + 1]; /* distance tree */
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ struct ct_data_s bl_tree[2 * BL_CODES + 1]; /* Huffman tree for bit lengths */
struct tree_desc_s l_desc; /* desc. for literal tree */ struct tree_desc_s l_desc; /* desc. for literal tree */
struct tree_desc_s d_desc; /* desc. for distance tree */ struct tree_desc_s d_desc; /* desc. for distance tree */
struct tree_desc_s bl_desc; /* desc. for bit length tree */ struct tree_desc_s bl_desc; /* desc. for bit length tree */
ush bl_count[MAX_BITS+1]; ush bl_count[MAX_BITS + 1];
/* number of codes at each bit length for an optimal tree */ /* number of codes at each bit length for an optimal tree */
int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ int heap[2 * L_CODES + 1]; /* heap used to build the Huffman trees */
int heap_len; /* number of elements in the heap */ int heap_len; /* number of elements in the heap */
int heap_max; /* element of largest frequency */ int heap_max; /* element of largest frequency */
/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
* The same heap array is used to build all trees. * The same heap array is used to build all trees.
*/ */
uch depth[2*L_CODES+1]; uch depth[2 * L_CODES + 1];
/* Depth of each subtree used as tie breaker for trees of equal frequency /* Depth of each subtree used as tie breaker for trees of equal frequency
*/ */
uchf *l_buf; /* buffer for literals or lengths */ uchf* l_buf; /* buffer for literals or lengths */
uInt lit_bufsize; uInt lit_bufsize;
/* Size of match buffer for literals/lengths. There are 4 reasons for /* Size of match buffer for literals/lengths. There are 4 reasons for
@ -238,7 +243,7 @@ typedef struct internal_state {
uInt last_lit; /* running index in l_buf */ uInt last_lit; /* running index in l_buf */
ushf *d_buf; ushf* d_buf;
/* Buffer for distances. To simplify the code, d_buf and l_buf have /* Buffer for distances. To simplify the code, d_buf and l_buf have
* the same number of elements. To use different lengths, an extra flag * the same number of elements. To use different lengths, an extra flag
* array would be necessary. * array would be necessary.
@ -292,15 +297,15 @@ typedef struct internal_state {
/* Number of bytes after end of data in window to initialize in order to avoid /* Number of bytes after end of data in window to initialize in order to avoid
memory checker errors from longest match routines */ memory checker errors from longest match routines */
/* in trees.c */ /* in trees.c */
void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); void ZLIB_INTERNAL _tr_init OF((deflate_state* s));
int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); int ZLIB_INTERNAL _tr_tally OF((deflate_state* s, unsigned dist, unsigned lc));
void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, void ZLIB_INTERNAL _tr_flush_block OF((deflate_state* s, charf* buf,
ulg stored_len, int last)); ulg stored_len, int last));
void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state* s));
void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); void ZLIB_INTERNAL _tr_align OF((deflate_state* s));
void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, void ZLIB_INTERNAL _tr_stored_block OF((deflate_state* s, charf* buf,
ulg stored_len, int last)); ulg stored_len, int last));
#define d_code(dist) \ #define d_code(dist) \
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
@ -313,11 +318,11 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
/* Inline versions of _tr_tally for speed: */ /* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC) #if defined(GEN_TREES_H) || !defined(STDC)
extern uch ZLIB_INTERNAL _length_code[]; extern uch ZLIB_INTERNAL _length_code[];
extern uch ZLIB_INTERNAL _dist_code[]; extern uch ZLIB_INTERNAL _dist_code[];
#else #else
extern const uch ZLIB_INTERNAL _length_code[]; extern const uch ZLIB_INTERNAL _length_code[];
extern const uch ZLIB_INTERNAL _dist_code[]; extern const uch ZLIB_INTERNAL _dist_code[];
#endif #endif
# define _tr_tally_lit(s, c, flush) \ # define _tr_tally_lit(s, c, flush) \

View File

@ -12,7 +12,7 @@
int ZEXPORT gzclose(gzFile file) int ZEXPORT gzclose(gzFile file)
#else #else
int ZEXPORT gzclose(file) int ZEXPORT gzclose(file)
gzFile file; gzFile file;
#endif #endif
{ {
#ifndef NO_GZCOMPRESS #ifndef NO_GZCOMPRESS
@ -20,6 +20,7 @@ int ZEXPORT gzclose(file)
if (file == NULL) if (file == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
state = (gz_statep)file; state = (gz_statep)file;
return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);

49
extern/zlib/gzguts.h vendored
View File

@ -100,8 +100,8 @@
/* gz* functions always use library allocation functions */ /* gz* functions always use library allocation functions */
#ifndef STDC #ifndef STDC
extern voidp malloc OF((uInt size)); extern voidp malloc OF((uInt size));
extern void free OF((voidpf ptr)); extern void free OF((voidpf ptr));
#endif #endif
/* get errno and strerror definition */ /* get errno and strerror definition */
@ -119,10 +119,10 @@
/* provide prototypes for these when building zlib without LFS */ /* provide prototypes for these when building zlib without LFS */
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN gzFile ZEXPORT gzopen64 OF((const char*, const char*));
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
#endif #endif
/* default memLevel */ /* default memLevel */
@ -147,44 +147,45 @@
#define GZIP 2 /* decompress a gzip stream */ #define GZIP 2 /* decompress a gzip stream */
/* internal gzip file state data structure */ /* internal gzip file state data structure */
typedef struct { typedef struct
/* exposed contents for gzgetc() macro */ {
/* exposed contents for gzgetc() macro */
struct gzFile_s x; /* "x" for exposed */ struct gzFile_s x; /* "x" for exposed */
/* x.have: number of bytes available at x.next */ /* x.have: number of bytes available at x.next */
/* x.next: next output data to deliver or write */ /* x.next: next output data to deliver or write */
/* x.pos: current position in uncompressed data */ /* x.pos: current position in uncompressed data */
/* used for both reading and writing */ /* used for both reading and writing */
int mode; /* see gzip modes above */ int mode; /* see gzip modes above */
int fd; /* file descriptor */ int fd; /* file descriptor */
char *path; /* path or fd for error messages */ char* path; /* path or fd for error messages */
unsigned size; /* buffer size, zero if not allocated yet */ unsigned size; /* buffer size, zero if not allocated yet */
unsigned want; /* requested buffer size, default is GZBUFSIZE */ unsigned want; /* requested buffer size, default is GZBUFSIZE */
unsigned char *in; /* input buffer */ unsigned char* in; /* input buffer */
unsigned char *out; /* output buffer (double-sized when reading) */ unsigned char* out; /* output buffer (double-sized when reading) */
int direct; /* 0 if processing gzip, 1 if transparent */ int direct; /* 0 if processing gzip, 1 if transparent */
/* just for reading */ /* just for reading */
int how; /* 0: get header, 1: copy, 2: decompress */ int how; /* 0: get header, 1: copy, 2: decompress */
z_off64_t start; /* where the gzip data started, for rewinding */ z_off64_t start; /* where the gzip data started, for rewinding */
int eof; /* true if end of input file reached */ int eof; /* true if end of input file reached */
int past; /* true if read requested past end */ int past; /* true if read requested past end */
/* just for writing */ /* just for writing */
int level; /* compression level */ int level; /* compression level */
int strategy; /* compression strategy */ int strategy; /* compression strategy */
/* seek request */ /* seek request */
z_off64_t skip; /* amount to skip (already rewound if backwards) */ z_off64_t skip; /* amount to skip (already rewound if backwards) */
int seek; /* true if seek request pending */ int seek; /* true if seek request pending */
/* error information */ /* error information */
int err; /* error code */ int err; /* error code */
char *msg; /* error message */ char* msg; /* error message */
/* zlib inflate or deflate stream */ /* zlib inflate or deflate stream */
z_stream strm; /* stream structure in-place (not a pointer) */ z_stream strm; /* stream structure in-place (not a pointer) */
} gz_state; } gz_state;
typedef gz_state FAR *gz_statep; typedef gz_state FAR* gz_statep;
/* shared functions */ /* shared functions */
void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char*));
#if defined UNDER_CE #if defined UNDER_CE
char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); char ZLIB_INTERNAL* gz_strwinerror OF((DWORD error));
#endif #endif
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t

322
extern/zlib/gzlib.c vendored
View File

@ -17,7 +17,7 @@
/* Local functions */ /* Local functions */
local void gz_reset OF((gz_statep)); local void gz_reset OF((gz_statep));
local gzFile gz_open OF((const void *, int, const char *)); local gzFile gz_open OF((const void*, int, const char*));
#if defined UNDER_CE #if defined UNDER_CE
@ -30,38 +30,43 @@ local gzFile gz_open OF((const void *, int, const char *));
The gz_strwinerror function does not change the current setting of The gz_strwinerror function does not change the current setting of
GetLastError. */ GetLastError. */
char ZLIB_INTERNAL *gz_strwinerror (error) char ZLIB_INTERNAL* gz_strwinerror(error)
DWORD error; DWORD error;
{ {
static char buf[1024]; static char buf[1024];
wchar_t *msgbuf; wchar_t* msgbuf;
DWORD lasterr = GetLastError(); DWORD lasterr = GetLastError();
DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER, | FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, NULL,
error, error,
0, /* Default language */ 0, /* Default language */
(LPVOID)&msgbuf, (LPVOID)&msgbuf,
0, 0,
NULL); NULL);
if (chars != 0) {
if (chars != 0)
{
/* If there is an \r\n appended, zap it. */ /* If there is an \r\n appended, zap it. */
if (chars >= 2 if (chars >= 2
&& msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n')
{
chars -= 2; chars -= 2;
msgbuf[chars] = 0; msgbuf[chars] = 0;
} }
if (chars > sizeof (buf) - 1) { if (chars > sizeof(buf) - 1)
chars = sizeof (buf) - 1; {
chars = sizeof(buf) - 1;
msgbuf[chars] = 0; msgbuf[chars] = 0;
} }
wcstombs(buf, msgbuf, chars + 1); wcstombs(buf, msgbuf, chars + 1);
LocalFree(msgbuf); LocalFree(msgbuf);
} }
else { else
{
sprintf(buf, "unknown win32 error (%ld)", error); sprintf(buf, "unknown win32 error (%ld)", error);
} }
@ -76,15 +81,18 @@ char ZLIB_INTERNAL *gz_strwinerror (error)
local void gz_reset(gz_statep state) local void gz_reset(gz_statep state)
#else #else
local void gz_reset(state) local void gz_reset(state)
gz_statep state; gz_statep state;
#endif #endif
{ {
state->x.have = 0; /* no output data available */ state->x.have = 0; /* no output data available */
if (state->mode == GZ_READ) { /* for reading ... */
if (state->mode == GZ_READ) /* for reading ... */
{
state->eof = 0; /* not at end of file */ state->eof = 0; /* not at end of file */
state->past = 0; /* have not read past end yet */ state->past = 0; /* have not read past end yet */
state->how = LOOK; /* look for gzip header */ state->how = LOOK; /* look for gzip header */
} }
state->seek = 0; /* no seek request pending */ state->seek = 0; /* no seek request pending */
gz_error(state, Z_OK, NULL); /* clear error */ gz_error(state, Z_OK, NULL); /* clear error */
state->x.pos = 0; /* no uncompressed data yet */ state->x.pos = 0; /* no uncompressed data yet */
@ -93,12 +101,12 @@ local void gz_reset(state)
/* Open a gzip file either by name or file descriptor. */ /* Open a gzip file either by name or file descriptor. */
#ifdef WIN32 #ifdef WIN32
local gzFile gz_open(const void *path, int fd, const char *mode) local gzFile gz_open(const void* path, int fd, const char* mode)
#else #else
local gzFile gz_open(path, fd, mode) local gzFile gz_open(path, fd, mode)
const void *path; const void* path;
int fd; int fd;
const char *mode; const char* mode;
#endif #endif
{ {
gz_statep state; gz_statep state;
@ -117,8 +125,10 @@ local gzFile gz_open(path, fd, mode)
/* allocate gzFile structure to return */ /* allocate gzFile structure to return */
state = malloc(sizeof(gz_state)); state = malloc(sizeof(gz_state));
if (state == NULL) if (state == NULL)
return NULL; return NULL;
state->size = 0; /* no buffers allocated yet */ state->size = 0; /* no buffers allocated yet */
state->want = GZBUFSIZE; /* requested buffer size */ state->want = GZBUFSIZE; /* requested buffer size */
state->msg = NULL; /* no error message yet */ state->msg = NULL; /* no error message yet */
@ -128,87 +138,115 @@ local gzFile gz_open(path, fd, mode)
state->level = Z_DEFAULT_COMPRESSION; state->level = Z_DEFAULT_COMPRESSION;
state->strategy = Z_DEFAULT_STRATEGY; state->strategy = Z_DEFAULT_STRATEGY;
state->direct = 0; state->direct = 0;
while (*mode) {
while (*mode)
{
if (*mode >= '0' && *mode <= '9') if (*mode >= '0' && *mode <= '9')
state->level = *mode - '0'; state->level = *mode - '0';
else else
switch (*mode) { switch (*mode)
case 'r': {
state->mode = GZ_READ; case 'r':
break; state->mode = GZ_READ;
break;
#ifndef NO_GZCOMPRESS #ifndef NO_GZCOMPRESS
case 'w':
state->mode = GZ_WRITE; case 'w':
break; state->mode = GZ_WRITE;
case 'a': break;
state->mode = GZ_APPEND;
break; case 'a':
state->mode = GZ_APPEND;
break;
#endif #endif
case '+': /* can't read and write at the same time */
free(state); case '+': /* can't read and write at the same time */
return NULL; free(state);
case 'b': /* ignore -- will request binary anyway */ return NULL;
break;
case 'b': /* ignore -- will request binary anyway */
break;
#ifdef O_CLOEXEC #ifdef O_CLOEXEC
case 'e':
cloexec = 1; case 'e':
break; cloexec = 1;
break;
#endif #endif
#ifdef O_EXCL #ifdef O_EXCL
case 'x':
exclusive = 1; case 'x':
break; exclusive = 1;
break;
#endif #endif
case 'f':
state->strategy = Z_FILTERED; case 'f':
break; state->strategy = Z_FILTERED;
case 'h': break;
state->strategy = Z_HUFFMAN_ONLY;
break; case 'h':
case 'R': state->strategy = Z_HUFFMAN_ONLY;
state->strategy = Z_RLE; break;
break;
case 'F': case 'R':
state->strategy = Z_FIXED; state->strategy = Z_RLE;
case 'T': break;
state->direct = 1;
default: /* could consider as an error, but just ignore */ case 'F':
; state->strategy = Z_FIXED;
case 'T':
state->direct = 1;
default: /* could consider as an error, but just ignore */
;
} }
mode++; mode++;
} }
/* must provide an "r", "w", or "a" */ /* must provide an "r", "w", or "a" */
if (state->mode == GZ_NONE) { if (state->mode == GZ_NONE)
{
free(state); free(state);
return NULL; return NULL;
} }
/* can't force transparent read */ /* can't force transparent read */
if (state->mode == GZ_READ) { if (state->mode == GZ_READ)
if (state->direct) { {
if (state->direct)
{
free(state); free(state);
return NULL; return NULL;
} }
state->direct = 1; /* for empty file */ state->direct = 1; /* for empty file */
} }
/* save the path name for error messages */ /* save the path name for error messages */
#ifdef _WIN32 #ifdef _WIN32
if (fd == -2) {
if (fd == -2)
{
len = wcstombs(NULL, path, 0); len = wcstombs(NULL, path, 0);
if (len == (size_t)-1)
if (len == (size_t) - 1)
len = 0; len = 0;
} }
else else
#endif #endif
len = strlen(path); len = strlen(path);
state->path = malloc(len + 1); state->path = malloc(len + 1);
if (state->path == NULL) {
if (state->path == NULL)
{
free(state); free(state);
return NULL; return NULL;
} }
#ifdef _WIN32 #ifdef _WIN32
if (fd == -2) if (fd == -2)
if (len) if (len)
wcstombs(state->path, path, len + 1); wcstombs(state->path, path, len + 1);
@ -242,20 +280,25 @@ local gzFile gz_open(path, fd, mode)
/* open the file with the appropriate flags (or just use fd) */ /* open the file with the appropriate flags (or just use fd) */
state->fd = fd > -1 ? fd : ( state->fd = fd > -1 ? fd : (
#ifdef _WIN32 #ifdef _WIN32
fd == -2 ? _wopen(path, oflag, 0666) : fd == -2 ? _wopen(path, oflag, 0666) :
#endif #endif
open(path, oflag, 0666)); open(path, oflag, 0666));
if (state->fd == -1) {
if (state->fd == -1)
{
free(state->path); free(state->path);
free(state); free(state);
return NULL; return NULL;
} }
if (state->mode == GZ_APPEND) if (state->mode == GZ_APPEND)
state->mode = GZ_WRITE; /* simplify later checks */ state->mode = GZ_WRITE; /* simplify later checks */
/* save the current position for rewinding (only if reading) */ /* save the current position for rewinding (only if reading) */
if (state->mode == GZ_READ) { if (state->mode == GZ_READ)
{
state->start = LSEEK(state->fd, 0, SEEK_CUR); state->start = LSEEK(state->fd, 0, SEEK_CUR);
if (state->start == -1) state->start = 0; if (state->start == -1) state->start = 0;
} }
@ -268,11 +311,11 @@ local gzFile gz_open(path, fd, mode)
/* -- see zlib.h -- */ /* -- see zlib.h -- */
#ifdef WIN32 #ifdef WIN32
gzFile ZEXPORT gzopen(const char *path, const char *mode) gzFile ZEXPORT gzopen(const char* path, const char* mode)
#else #else
gzFile ZEXPORT gzopen(path, mode) gzFile ZEXPORT gzopen(path, mode)
const char *path; const char* path;
const char *mode; const char* mode;
#endif #endif
{ {
return gz_open(path, -1, mode); return gz_open(path, -1, mode);
@ -280,11 +323,11 @@ gzFile ZEXPORT gzopen(path, mode)
/* -- see zlib.h -- */ /* -- see zlib.h -- */
#ifdef WIN32 #ifdef WIN32
gzFile ZEXPORT gzopen64(const char *path, const char *mode) gzFile ZEXPORT gzopen64(const char* path, const char* mode)
#else #else
gzFile ZEXPORT gzopen64(path, mode) gzFile ZEXPORT gzopen64(path, mode)
const char *path; const char* path;
const char *mode; const char* mode;
#endif #endif
{ {
return gz_open(path, -1, mode); return gz_open(path, -1, mode);
@ -292,18 +335,19 @@ gzFile ZEXPORT gzopen64(path, mode)
/* -- see zlib.h -- */ /* -- see zlib.h -- */
#ifdef WIN32 #ifdef WIN32
gzFile ZEXPORT gzdopen(int fd, const char *mode) gzFile ZEXPORT gzdopen(int fd, const char* mode)
#else #else
gzFile ZEXPORT gzdopen(fd, mode) gzFile ZEXPORT gzdopen(fd, mode)
int fd; int fd;
const char *mode; const char* mode;
#endif #endif
{ {
char *path; /* identifier for error messages */ char* path; /* identifier for error messages */
gzFile gz; gzFile gz;
if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL) if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL)
return NULL; return NULL;
sprintf(path, "<fd:%d>", fd); /* for debugging */ sprintf(path, "<fd:%d>", fd); /* for debugging */
gz = gz_open(path, fd, mode); gz = gz_open(path, fd, mode);
free(path); free(path);
@ -312,11 +356,11 @@ gzFile ZEXPORT gzdopen(fd, mode)
/* -- see zlib.h -- */ /* -- see zlib.h -- */
#ifdef _WIN32 #ifdef _WIN32
gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) gzFile ZEXPORT gzopen_w(const wchar_t* path, const char* mode)
#else #else
gzFile ZEXPORT gzopen_w(path, mode) gzFile ZEXPORT gzopen_w(path, mode)
const wchar_t *path; const wchar_t* path;
const char *mode; const char* mode;
#endif #endif
{ {
return gz_open(path, -2, mode); return gz_open(path, -2, mode);
@ -327,8 +371,8 @@ gzFile ZEXPORT gzopen_w(path, mode)
int ZEXPORT gzbuffer(gzFile file, unsigned size) int ZEXPORT gzbuffer(gzFile file, unsigned size)
#else #else
int ZEXPORT gzbuffer(file, size) int ZEXPORT gzbuffer(file, size)
gzFile file; gzFile file;
unsigned size; unsigned size;
#endif #endif
{ {
gz_statep state; gz_statep state;
@ -336,7 +380,9 @@ int ZEXPORT gzbuffer(file, size)
/* get internal structure and check integrity */ /* get internal structure and check integrity */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
if (state->mode != GZ_READ && state->mode != GZ_WRITE) if (state->mode != GZ_READ && state->mode != GZ_WRITE)
return -1; return -1;
@ -347,6 +393,7 @@ int ZEXPORT gzbuffer(file, size)
/* check and set requested size */ /* check and set requested size */
if (size < 2) if (size < 2)
size = 2; /* need two bytes to check magic header */ size = 2; /* need two bytes to check magic header */
state->want = size; state->want = size;
return 0; return 0;
} }
@ -356,7 +403,7 @@ int ZEXPORT gzbuffer(file, size)
int ZEXPORT gzrewind(gzFile file) int ZEXPORT gzrewind(gzFile file)
#else #else
int ZEXPORT gzrewind(file) int ZEXPORT gzrewind(file)
gzFile file; gzFile file;
#endif #endif
{ {
gz_statep state; gz_statep state;
@ -364,6 +411,7 @@ int ZEXPORT gzrewind(file)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
/* check that we're reading and that there's no error */ /* check that we're reading and that there's no error */
@ -374,6 +422,7 @@ int ZEXPORT gzrewind(file)
/* back up and start over */ /* back up and start over */
if (LSEEK(state->fd, state->start, SEEK_SET) == -1) if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
return -1; return -1;
gz_reset(state); gz_reset(state);
return 0; return 0;
} }
@ -383,9 +432,9 @@ int ZEXPORT gzrewind(file)
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence)
#else #else
z_off64_t ZEXPORT gzseek64(file, offset, whence) z_off64_t ZEXPORT gzseek64(file, offset, whence)
gzFile file; gzFile file;
z_off64_t offset; z_off64_t offset;
int whence; int whence;
#endif #endif
{ {
unsigned n; unsigned n;
@ -395,7 +444,9 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
/* get internal structure and check integrity */ /* get internal structure and check integrity */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
if (state->mode != GZ_READ && state->mode != GZ_WRITE) if (state->mode != GZ_READ && state->mode != GZ_WRITE)
return -1; return -1;
@ -412,14 +463,18 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
offset -= state->x.pos; offset -= state->x.pos;
else if (state->seek) else if (state->seek)
offset += state->skip; offset += state->skip;
state->seek = 0; state->seek = 0;
/* if within raw area while reading, just go there */ /* if within raw area while reading, just go there */
if (state->mode == GZ_READ && state->how == COPY && if (state->mode == GZ_READ && state->how == COPY &&
state->x.pos + offset >= 0) { state->x.pos + offset >= 0)
{
ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR); ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR);
if (ret == -1) if (ret == -1)
return -1; return -1;
state->x.have = 0; state->x.have = 0;
state->eof = 0; state->eof = 0;
state->past = 0; state->past = 0;
@ -431,18 +486,23 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
} }
/* calculate skip amount, rewinding if needed for back seek when reading */ /* calculate skip amount, rewinding if needed for back seek when reading */
if (offset < 0) { if (offset < 0)
{
if (state->mode != GZ_READ) /* writing -- can't go backwards */ if (state->mode != GZ_READ) /* writing -- can't go backwards */
return -1; return -1;
offset += state->x.pos; offset += state->x.pos;
if (offset < 0) /* before start of file! */ if (offset < 0) /* before start of file! */
return -1; return -1;
if (gzrewind(file) == -1) /* rewind, then skip to offset */ if (gzrewind(file) == -1) /* rewind, then skip to offset */
return -1; return -1;
} }
/* if reading, skip what's in output buffer (one less gzgetc() check) */ /* if reading, skip what's in output buffer (one less gzgetc() check) */
if (state->mode == GZ_READ) { if (state->mode == GZ_READ)
{
n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ? n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ?
(unsigned)offset : state->x.have; (unsigned)offset : state->x.have;
state->x.have -= n; state->x.have -= n;
@ -452,10 +512,12 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
} }
/* request skip (if not zero) */ /* request skip (if not zero) */
if (offset) { if (offset)
{
state->seek = 1; state->seek = 1;
state->skip = offset; state->skip = offset;
} }
return state->x.pos + offset; return state->x.pos + offset;
} }
@ -464,9 +526,9 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence)
#else #else
z_off_t ZEXPORT gzseek(file, offset, whence) z_off_t ZEXPORT gzseek(file, offset, whence)
gzFile file; gzFile file;
z_off_t offset; z_off_t offset;
int whence; int whence;
#endif #endif
{ {
z_off64_t ret; z_off64_t ret;
@ -480,7 +542,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence)
z_off64_t ZEXPORT gztell64(gzFile file) z_off64_t ZEXPORT gztell64(gzFile file)
#else #else
z_off64_t ZEXPORT gztell64(file) z_off64_t ZEXPORT gztell64(file)
gzFile file; gzFile file;
#endif #endif
{ {
gz_statep state; gz_statep state;
@ -488,7 +550,9 @@ z_off64_t ZEXPORT gztell64(file)
/* get internal structure and check integrity */ /* get internal structure and check integrity */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
if (state->mode != GZ_READ && state->mode != GZ_WRITE) if (state->mode != GZ_READ && state->mode != GZ_WRITE)
return -1; return -1;
@ -501,7 +565,7 @@ z_off64_t ZEXPORT gztell64(file)
z_off_t ZEXPORT gztell(gzFile file) z_off_t ZEXPORT gztell(gzFile file)
#else #else
z_off_t ZEXPORT gztell(file) z_off_t ZEXPORT gztell(file)
gzFile file; gzFile file;
#endif #endif
{ {
z_off64_t ret; z_off64_t ret;
@ -515,7 +579,7 @@ z_off_t ZEXPORT gztell(file)
z_off64_t ZEXPORT gzoffset64(gzFile file) z_off64_t ZEXPORT gzoffset64(gzFile file)
#else #else
z_off64_t ZEXPORT gzoffset64(file) z_off64_t ZEXPORT gzoffset64(file)
gzFile file; gzFile file;
#endif #endif
{ {
z_off64_t offset; z_off64_t offset;
@ -524,16 +588,21 @@ z_off64_t ZEXPORT gzoffset64(file)
/* get internal structure and check integrity */ /* get internal structure and check integrity */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
if (state->mode != GZ_READ && state->mode != GZ_WRITE) if (state->mode != GZ_READ && state->mode != GZ_WRITE)
return -1; return -1;
/* compute and return effective offset in file */ /* compute and return effective offset in file */
offset = LSEEK(state->fd, 0, SEEK_CUR); offset = LSEEK(state->fd, 0, SEEK_CUR);
if (offset == -1) if (offset == -1)
return -1; return -1;
if (state->mode == GZ_READ) /* reading */ if (state->mode == GZ_READ) /* reading */
offset -= state->strm.avail_in; /* don't count buffered input */ offset -= state->strm.avail_in; /* don't count buffered input */
return offset; return offset;
} }
@ -542,7 +611,7 @@ z_off64_t ZEXPORT gzoffset64(file)
z_off_t ZEXPORT gzoffset(gzFile file) z_off_t ZEXPORT gzoffset(gzFile file)
#else #else
z_off_t ZEXPORT gzoffset(file) z_off_t ZEXPORT gzoffset(file)
gzFile file; gzFile file;
#endif #endif
{ {
z_off64_t ret; z_off64_t ret;
@ -556,7 +625,7 @@ z_off_t ZEXPORT gzoffset(file)
int ZEXPORT gzeof(gzFile file) int ZEXPORT gzeof(gzFile file)
#else #else
int ZEXPORT gzeof(file) int ZEXPORT gzeof(file)
gzFile file; gzFile file;
#endif #endif
{ {
gz_statep state; gz_statep state;
@ -564,7 +633,9 @@ int ZEXPORT gzeof(file)
/* get internal structure and check integrity */ /* get internal structure and check integrity */
if (file == NULL) if (file == NULL)
return 0; return 0;
state = (gz_statep)file; state = (gz_statep)file;
if (state->mode != GZ_READ && state->mode != GZ_WRITE) if (state->mode != GZ_READ && state->mode != GZ_WRITE)
return 0; return 0;
@ -574,11 +645,11 @@ int ZEXPORT gzeof(file)
/* -- see zlib.h -- */ /* -- see zlib.h -- */
#ifdef WIN32 #ifdef WIN32
const char * ZEXPORT gzerror(gzFile file, int *errnum) const char* ZEXPORT gzerror(gzFile file, int* errnum)
#else #else
const char * ZEXPORT gzerror(file, errnum) const char* ZEXPORT gzerror(file, errnum)
gzFile file; gzFile file;
int *errnum; int* errnum;
#endif #endif
{ {
gz_statep state; gz_statep state;
@ -586,13 +657,16 @@ const char * ZEXPORT gzerror(file, errnum)
/* get internal structure and check integrity */ /* get internal structure and check integrity */
if (file == NULL) if (file == NULL)
return NULL; return NULL;
state = (gz_statep)file; state = (gz_statep)file;
if (state->mode != GZ_READ && state->mode != GZ_WRITE) if (state->mode != GZ_READ && state->mode != GZ_WRITE)
return NULL; return NULL;
/* return error information */ /* return error information */
if (errnum != NULL) if (errnum != NULL)
*errnum = state->err; *errnum = state->err;
return state->msg == NULL ? "" : state->msg; return state->msg == NULL ? "" : state->msg;
} }
@ -601,7 +675,7 @@ const char * ZEXPORT gzerror(file, errnum)
void ZEXPORT gzclearerr(gzFile file) void ZEXPORT gzclearerr(gzFile file)
#else #else
void ZEXPORT gzclearerr(file) void ZEXPORT gzclearerr(file)
gzFile file; gzFile file;
#endif #endif
{ {
gz_statep state; gz_statep state;
@ -609,15 +683,19 @@ void ZEXPORT gzclearerr(file)
/* get internal structure and check integrity */ /* get internal structure and check integrity */
if (file == NULL) if (file == NULL)
return; return;
state = (gz_statep)file; state = (gz_statep)file;
if (state->mode != GZ_READ && state->mode != GZ_WRITE) if (state->mode != GZ_READ && state->mode != GZ_WRITE)
return; return;
/* clear error and end-of-file */ /* clear error and end-of-file */
if (state->mode == GZ_READ) { if (state->mode == GZ_READ)
{
state->eof = 0; state->eof = 0;
state->past = 0; state->past = 0;
} }
gz_error(state, Z_OK, NULL); gz_error(state, Z_OK, NULL);
} }
@ -628,18 +706,20 @@ void ZEXPORT gzclearerr(file)
allocation failure constructing the error message, then convert the error to allocation failure constructing the error message, then convert the error to
out of memory. */ out of memory. */
#ifdef WIN32 #ifdef WIN32
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char* msg)
#else #else
void ZLIB_INTERNAL gz_error(state, err, msg) void ZLIB_INTERNAL gz_error(state, err, msg)
gz_statep state; gz_statep state;
int err; int err;
const char *msg; const char* msg;
#endif #endif
{ {
/* free previously allocated message and clear */ /* free previously allocated message and clear */
if (state->msg != NULL) { if (state->msg != NULL)
{
if (state->err != Z_MEM_ERROR) if (state->err != Z_MEM_ERROR)
free(state->msg); free(state->msg);
state->msg = NULL; state->msg = NULL;
} }
@ -649,21 +729,25 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
/* set error code, and if no message, then done */ /* set error code, and if no message, then done */
state->err = err; state->err = err;
if (msg == NULL) if (msg == NULL)
return; return;
/* for an out of memory error, save as static string */ /* for an out of memory error, save as static string */
if (err == Z_MEM_ERROR) { if (err == Z_MEM_ERROR)
state->msg = (char *)msg; {
state->msg = (char*)msg;
return; return;
} }
/* construct error message with path */ /* construct error message with path */
if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) { if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL)
{
state->err = Z_MEM_ERROR; state->err = Z_MEM_ERROR;
state->msg = (char *)"out of memory"; state->msg = (char*)"out of memory";
return; return;
} }
strcpy(state->msg, state->path); strcpy(state->msg, state->path);
strcat(state->msg, ": "); strcat(state->msg, ": ");
strcat(state->msg, msg); strcat(state->msg, msg);
@ -680,11 +764,15 @@ unsigned ZLIB_INTERNAL gz_intmax()
unsigned p, q; unsigned p, q;
p = 1; p = 1;
do {
do
{
q = p; q = p;
p <<= 1; p <<= 1;
p++; p++;
} while (p > q); }
while (p > q);
return q >> 1; return q >> 1;
} }
#endif #endif

328
extern/zlib/gzread.c vendored
View File

@ -6,7 +6,7 @@
#include "gzguts.h" #include "gzguts.h"
/* Local functions */ /* Local functions */
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); local int gz_load OF((gz_statep, unsigned char*, unsigned, unsigned*));
local int gz_avail OF((gz_statep)); local int gz_avail OF((gz_statep));
local int gz_look OF((gz_statep)); local int gz_look OF((gz_statep));
local int gz_decomp OF((gz_statep)); local int gz_decomp OF((gz_statep));
@ -18,30 +18,39 @@ local int gz_skip OF((gz_statep, z_off64_t));
This function needs to loop on read(), since read() is not guaranteed to This function needs to loop on read(), since read() is not guaranteed to
read the number of bytes requested, depending on the type of descriptor. */ read the number of bytes requested, depending on the type of descriptor. */
#ifdef WIN32 #ifdef WIN32
local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have) local int gz_load(gz_statep state, unsigned char* buf, unsigned len, unsigned* have)
#else #else
local int gz_load(state, buf, len, have) local int gz_load(state, buf, len, have)
gz_statep state; gz_statep state;
unsigned char *buf; unsigned char* buf;
unsigned len; unsigned len;
unsigned *have; unsigned* have;
#endif #endif
{ {
int ret; int ret;
*have = 0; *have = 0;
do {
do
{
ret = read(state->fd, buf + *have, len - *have); ret = read(state->fd, buf + *have, len - *have);
if (ret <= 0) if (ret <= 0)
break; break;
*have += ret; *have += ret;
} while (*have < len); }
if (ret < 0) { while (*have < len);
if (ret < 0)
{
gz_error(state, Z_ERRNO, zstrerror()); gz_error(state, Z_ERRNO, zstrerror());
return -1; return -1;
} }
if (ret == 0) if (ret == 0)
state->eof = 1; state->eof = 1;
return 0; return 0;
} }
@ -56,7 +65,7 @@ local int gz_load(state, buf, len, have)
local int gz_avail(gz_statep state) local int gz_avail(gz_statep state)
#else #else
local int gz_avail(state) local int gz_avail(state)
gz_statep state; gz_statep state;
#endif #endif
{ {
unsigned got; unsigned got;
@ -64,20 +73,29 @@ local int gz_avail(state)
if (state->err != Z_OK && state->err != Z_BUF_ERROR) if (state->err != Z_OK && state->err != Z_BUF_ERROR)
return -1; return -1;
if (state->eof == 0) {
if (strm->avail_in) { /* copy what's there to the start */ if (state->eof == 0)
unsigned char *p = state->in, *q = strm->next_in; {
if (strm->avail_in) /* copy what's there to the start */
{
unsigned char* p = state->in, *q = strm->next_in;
unsigned n = strm->avail_in; unsigned n = strm->avail_in;
do {
do
{
*p++ = *q++; *p++ = *q++;
} while (--n); }
while (--n);
} }
if (gz_load(state, state->in + strm->avail_in, if (gz_load(state, state->in + strm->avail_in,
state->size - strm->avail_in, &got) == -1) state->size - strm->avail_in, &got) == -1)
return -1; return -1;
strm->avail_in += got; strm->avail_in += got;
strm->next_in = state->in; strm->next_in = state->in;
} }
return 0; return 0;
} }
@ -94,24 +112,30 @@ local int gz_avail(state)
local int gz_look(gz_statep state) local int gz_look(gz_statep state)
#else #else
local int gz_look(state) local int gz_look(state)
gz_statep state; gz_statep state;
#endif #endif
{ {
z_streamp strm = &(state->strm); z_streamp strm = &(state->strm);
/* allocate read buffers and inflate memory */ /* allocate read buffers and inflate memory */
if (state->size == 0) { if (state->size == 0)
{
/* allocate buffers */ /* allocate buffers */
state->in = malloc(state->want); state->in = malloc(state->want);
state->out = malloc(state->want << 1); state->out = malloc(state->want << 1);
if (state->in == NULL || state->out == NULL) {
if (state->in == NULL || state->out == NULL)
{
if (state->out != NULL) if (state->out != NULL)
free(state->out); free(state->out);
if (state->in != NULL) if (state->in != NULL)
free(state->in); free(state->in);
gz_error(state, Z_MEM_ERROR, "out of memory"); gz_error(state, Z_MEM_ERROR, "out of memory");
return -1; return -1;
} }
state->size = state->want; state->size = state->want;
/* allocate inflate memory */ /* allocate inflate memory */
@ -120,7 +144,9 @@ local int gz_look(state)
state->strm.opaque = Z_NULL; state->strm.opaque = Z_NULL;
state->strm.avail_in = 0; state->strm.avail_in = 0;
state->strm.next_in = Z_NULL; state->strm.next_in = Z_NULL;
if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) { /* gunzip */
if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) /* gunzip */
{
free(state->out); free(state->out);
free(state->in); free(state->in);
state->size = 0; state->size = 0;
@ -130,9 +156,11 @@ local int gz_look(state)
} }
/* get at least the magic bytes in the input buffer */ /* get at least the magic bytes in the input buffer */
if (strm->avail_in < 2) { if (strm->avail_in < 2)
{
if (gz_avail(state) == -1) if (gz_avail(state) == -1)
return -1; return -1;
if (strm->avail_in == 0) if (strm->avail_in == 0)
return 0; return 0;
} }
@ -145,7 +173,8 @@ local int gz_look(state)
the header will be written in a single operation, so that reading a the header will be written in a single operation, so that reading a
single byte is sufficient indication that it is not a gzip file) */ single byte is sufficient indication that it is not a gzip file) */
if (strm->avail_in > 1 && if (strm->avail_in > 1 &&
strm->next_in[0] == 31 && strm->next_in[1] == 139) { strm->next_in[0] == 31 && strm->next_in[1] == 139)
{
inflateReset(strm); inflateReset(strm);
state->how = GZIP; state->how = GZIP;
state->direct = 0; state->direct = 0;
@ -154,7 +183,8 @@ local int gz_look(state)
/* no gzip header -- if we were decoding gzip before, then this is trailing /* no gzip header -- if we were decoding gzip before, then this is trailing
garbage. Ignore the trailing garbage and finish. */ garbage. Ignore the trailing garbage and finish. */
if (state->direct == 0) { if (state->direct == 0)
{
strm->avail_in = 0; strm->avail_in = 0;
state->eof = 1; state->eof = 1;
state->x.have = 0; state->x.have = 0;
@ -165,11 +195,14 @@ local int gz_look(state)
the output buffer is larger than the input buffer, which also assures the output buffer is larger than the input buffer, which also assures
space for gzungetc() */ space for gzungetc() */
state->x.next = state->out; state->x.next = state->out;
if (strm->avail_in) {
if (strm->avail_in)
{
memcpy(state->x.next, strm->next_in, strm->avail_in); memcpy(state->x.next, strm->next_in, strm->avail_in);
state->x.have = strm->avail_in; state->x.have = strm->avail_in;
strm->avail_in = 0; strm->avail_in = 0;
} }
state->how = COPY; state->how = COPY;
state->direct = 1; state->direct = 1;
return 0; return 0;
@ -184,7 +217,7 @@ local int gz_look(state)
local int gz_decomp(gz_statep state) local int gz_decomp(gz_statep state)
#else #else
local int gz_decomp(state) local int gz_decomp(state)
gz_statep state; gz_statep state;
#endif #endif
{ {
int ret = Z_OK; int ret = Z_OK;
@ -193,32 +226,43 @@ local int gz_decomp(state)
/* fill output buffer up to end of deflate stream */ /* fill output buffer up to end of deflate stream */
had = strm->avail_out; had = strm->avail_out;
do {
do
{
/* get more input for inflate() */ /* get more input for inflate() */
if (strm->avail_in == 0 && gz_avail(state) == -1) if (strm->avail_in == 0 && gz_avail(state) == -1)
return -1; return -1;
if (strm->avail_in == 0) {
if (strm->avail_in == 0)
{
gz_error(state, Z_BUF_ERROR, "unexpected end of file"); gz_error(state, Z_BUF_ERROR, "unexpected end of file");
break; break;
} }
/* decompress and handle errors */ /* decompress and handle errors */
ret = inflate(strm, Z_NO_FLUSH); ret = inflate(strm, Z_NO_FLUSH);
if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT)
{
gz_error(state, Z_STREAM_ERROR, gz_error(state, Z_STREAM_ERROR,
"internal error: inflate stream corrupt"); "internal error: inflate stream corrupt");
return -1; return -1;
} }
if (ret == Z_MEM_ERROR) {
if (ret == Z_MEM_ERROR)
{
gz_error(state, Z_MEM_ERROR, "out of memory"); gz_error(state, Z_MEM_ERROR, "out of memory");
return -1; return -1;
} }
if (ret == Z_DATA_ERROR) { /* deflate stream invalid */
if (ret == Z_DATA_ERROR) /* deflate stream invalid */
{
gz_error(state, Z_DATA_ERROR, gz_error(state, Z_DATA_ERROR,
strm->msg == NULL ? "compressed data error" : strm->msg); strm->msg == NULL ? "compressed data error" : strm->msg);
return -1; return -1;
} }
} while (strm->avail_out && ret != Z_STREAM_END); }
while (strm->avail_out && ret != Z_STREAM_END);
/* update available output */ /* update available output */
state->x.have = had - strm->avail_out; state->x.have = had - strm->avail_out;
@ -242,32 +286,42 @@ local int gz_decomp(state)
local int gz_fetch(gz_statep state) local int gz_fetch(gz_statep state)
#else #else
local int gz_fetch(state) local int gz_fetch(state)
gz_statep state; gz_statep state;
#endif #endif
{ {
z_streamp strm = &(state->strm); z_streamp strm = &(state->strm);
do { do
switch(state->how) { {
case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ switch (state->how)
if (gz_look(state) == -1) {
return -1; case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */
if (state->how == LOOK) if (gz_look(state) == -1)
return -1;
if (state->how == LOOK)
return 0;
break;
case COPY: /* -> COPY */
if (gz_load(state, state->out, state->size << 1, &(state->x.have))
== -1)
return -1;
state->x.next = state->out;
return 0; return 0;
break;
case COPY: /* -> COPY */ case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */
if (gz_load(state, state->out, state->size << 1, &(state->x.have)) strm->avail_out = state->size << 1;
== -1) strm->next_out = state->out;
return -1;
state->x.next = state->out; if (gz_decomp(state) == -1)
return 0; return -1;
case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */
strm->avail_out = state->size << 1;
strm->next_out = state->out;
if (gz_decomp(state) == -1)
return -1;
} }
} while (state->x.have == 0 && (!state->eof || strm->avail_in)); }
while (state->x.have == 0 && (!state->eof || strm->avail_in));
return 0; return 0;
} }
@ -276,16 +330,18 @@ local int gz_fetch(state)
local int gz_skip(gz_statep state, z_off64_t len) local int gz_skip(gz_statep state, z_off64_t len)
#else #else
local int gz_skip(state, len) local int gz_skip(state, len)
gz_statep state; gz_statep state;
z_off64_t len; z_off64_t len;
#endif #endif
{ {
unsigned n; unsigned n;
/* skip over len bytes or reach end-of-file, whichever comes first */ /* skip over len bytes or reach end-of-file, whichever comes first */
while (len) while (len)
/* skip over whatever is in output buffer */ /* skip over whatever is in output buffer */
if (state->x.have) { if (state->x.have)
{
n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ? n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ?
(unsigned)len : state->x.have; (unsigned)len : state->x.have;
state->x.have -= n; state->x.have -= n;
@ -294,16 +350,18 @@ local int gz_skip(state, len)
len -= n; len -= n;
} }
/* output buffer empty -- return if we're at the end of the input */ /* output buffer empty -- return if we're at the end of the input */
else if (state->eof && state->strm.avail_in == 0) else if (state->eof && state->strm.avail_in == 0)
break; break;
/* need more data to skip -- load up output buffer */ /* need more data to skip -- load up output buffer */
else { else
{
/* get more output, looking for header if required */ /* get more output, looking for header if required */
if (gz_fetch(state) == -1) if (gz_fetch(state) == -1)
return -1; return -1;
} }
return 0; return 0;
} }
@ -312,9 +370,9 @@ local int gz_skip(state, len)
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
#else #else
int ZEXPORT gzread(file, buf, len) int ZEXPORT gzread(file, buf, len)
gzFile file; gzFile file;
voidp buf; voidp buf;
unsigned len; unsigned len;
#endif #endif
{ {
unsigned got, n; unsigned got, n;
@ -324,6 +382,7 @@ int ZEXPORT gzread(file, buf, len)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
strm = &(state->strm); strm = &(state->strm);
@ -334,7 +393,8 @@ int ZEXPORT gzread(file, buf, len)
/* since an int is returned, make sure len fits in one, otherwise return /* since an int is returned, make sure len fits in one, otherwise return
with an error (this avoids the flaw in the interface) */ with an error (this avoids the flaw in the interface) */
if ((int)len < 0) { if ((int)len < 0)
{
gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
return -1; return -1;
} }
@ -344,17 +404,22 @@ int ZEXPORT gzread(file, buf, len)
return 0; return 0;
/* process a skip request */ /* process a skip request */
if (state->seek) { if (state->seek)
{
state->seek = 0; state->seek = 0;
if (gz_skip(state, state->skip) == -1) if (gz_skip(state, state->skip) == -1)
return -1; return -1;
} }
/* get len bytes to buf, or less than len if at the end */ /* get len bytes to buf, or less than len if at the end */
got = 0; got = 0;
do {
do
{
/* first just try copying data from the output buffer */ /* first just try copying data from the output buffer */
if (state->x.have) { if (state->x.have)
{
n = state->x.have > len ? len : state->x.have; n = state->x.have > len ? len : state->x.have;
memcpy(buf, state->x.next, n); memcpy(buf, state->x.next, n);
state->x.next += n; state->x.next += n;
@ -362,44 +427,52 @@ int ZEXPORT gzread(file, buf, len)
} }
/* output buffer empty -- return if we're at the end of the input */ /* output buffer empty -- return if we're at the end of the input */
else if (state->eof && strm->avail_in == 0) { else if (state->eof && strm->avail_in == 0)
{
state->past = 1; /* tried to read past end */ state->past = 1; /* tried to read past end */
break; break;
} }
/* need output data -- for small len or new stream load up our output /* need output data -- for small len or new stream load up our output
buffer */ buffer */
else if (state->how == LOOK || len < (state->size << 1)) { else if (state->how == LOOK || len < (state->size << 1))
{
/* get more output, looking for header if required */ /* get more output, looking for header if required */
if (gz_fetch(state) == -1) if (gz_fetch(state) == -1)
return -1; return -1;
continue; /* no progress yet -- go back to copy above */ continue; /* no progress yet -- go back to copy above */
/* the copy above assures that we will leave with space in the /* the copy above assures that we will leave with space in the
output buffer, allowing at least one gzungetc() to succeed */ output buffer, allowing at least one gzungetc() to succeed */
} }
/* large len -- read directly into user buffer */ /* large len -- read directly into user buffer */
else if (state->how == COPY) { /* read directly */ else if (state->how == COPY) /* read directly */
{
if (gz_load(state, buf, len, &n) == -1) if (gz_load(state, buf, len, &n) == -1)
return -1; return -1;
} }
/* large len -- decompress directly into user buffer */ /* large len -- decompress directly into user buffer */
else { /* state->how == GZIP */ else /* state->how == GZIP */
{
strm->avail_out = len; strm->avail_out = len;
strm->next_out = buf; strm->next_out = buf;
if (gz_decomp(state) == -1) if (gz_decomp(state) == -1)
return -1; return -1;
n = state->x.have; n = state->x.have;
state->x.have = 0; state->x.have = 0;
} }
/* update progress */ /* update progress */
len -= n; len -= n;
buf = (char *)buf + n; buf = (char*)buf + n;
got += n; got += n;
state->x.pos += n; state->x.pos += n;
} while (len); }
while (len);
/* return number of bytes read into user buffer (will fit in int) */ /* return number of bytes read into user buffer (will fit in int) */
return (int)got; return (int)got;
@ -411,7 +484,7 @@ int ZEXPORT gzread(file, buf, len)
int ZEXPORT gzgetc(gzFile file) int ZEXPORT gzgetc(gzFile file)
#else #else
int ZEXPORT gzgetc(file) int ZEXPORT gzgetc(file)
gzFile file; gzFile file;
#endif #endif
{ {
int ret; int ret;
@ -421,15 +494,17 @@ int ZEXPORT gzgetc(file)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
/* check that we're reading and that there's no (serious) error */ /* check that we're reading and that there's no (serious) error */
if (state->mode != GZ_READ || if (state->mode != GZ_READ ||
(state->err != Z_OK && state->err != Z_BUF_ERROR)) (state->err != Z_OK && state->err != Z_BUF_ERROR))
return -1; return -1;
/* try output buffer (no need to check for skip request) */ /* try output buffer (no need to check for skip request) */
if (state->x.have) { if (state->x.have)
{
state->x.have--; state->x.have--;
state->x.pos++; state->x.pos++;
return *(state->x.next)++; return *(state->x.next)++;
@ -455,8 +530,8 @@ gzFile file;
int ZEXPORT gzungetc(signed char c, gzFile file) int ZEXPORT gzungetc(signed char c, gzFile file)
#else #else
int ZEXPORT gzungetc(c, file) int ZEXPORT gzungetc(c, file)
int c; int c;
gzFile file; gzFile file;
#endif #endif
{ {
gz_statep state; gz_statep state;
@ -464,16 +539,19 @@ int ZEXPORT gzungetc(c, file)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
/* check that we're reading and that there's no (serious) error */ /* check that we're reading and that there's no (serious) error */
if (state->mode != GZ_READ || if (state->mode != GZ_READ ||
(state->err != Z_OK && state->err != Z_BUF_ERROR)) (state->err != Z_OK && state->err != Z_BUF_ERROR))
return -1; return -1;
/* process a skip request */ /* process a skip request */
if (state->seek) { if (state->seek)
{
state->seek = 0; state->seek = 0;
if (gz_skip(state, state->skip) == -1) if (gz_skip(state, state->skip) == -1)
return -1; return -1;
} }
@ -483,7 +561,8 @@ int ZEXPORT gzungetc(c, file)
return -1; return -1;
/* if output buffer empty, put byte at end (allows more pushing) */ /* if output buffer empty, put byte at end (allows more pushing) */
if (state->x.have == 0) { if (state->x.have == 0)
{
state->x.have = 1; state->x.have = 1;
state->x.next = state->out + (state->size << 1) - 1; state->x.next = state->out + (state->size << 1) - 1;
state->x.next[0] = c; state->x.next[0] = c;
@ -493,19 +572,24 @@ int ZEXPORT gzungetc(c, file)
} }
/* if no room, give up (must have already done a gzungetc()) */ /* if no room, give up (must have already done a gzungetc()) */
if (state->x.have == (state->size << 1)) { if (state->x.have == (state->size << 1))
{
gz_error(state, Z_DATA_ERROR, "out of room to push characters"); gz_error(state, Z_DATA_ERROR, "out of room to push characters");
return -1; return -1;
} }
/* slide output data if needed and insert byte before existing data */ /* slide output data if needed and insert byte before existing data */
if (state->x.next == state->out) { if (state->x.next == state->out)
unsigned char *src = state->out + state->x.have; {
unsigned char *dest = state->out + (state->size << 1); unsigned char* src = state->out + state->x.have;
unsigned char* dest = state->out + (state->size << 1);
while (src > state->out) while (src > state->out)
*--dest = *--src; *--dest = *--src;
state->x.next = dest; state->x.next = dest;
} }
state->x.have++; state->x.have++;
state->x.next--; state->x.next--;
state->x.next[0] = c; state->x.next[0] = c;
@ -516,32 +600,35 @@ int ZEXPORT gzungetc(c, file)
/* -- see zlib.h -- */ /* -- see zlib.h -- */
#ifdef WIN32 #ifdef WIN32
char * ZEXPORT gzgets(gzFile file, char *buf, int len) char* ZEXPORT gzgets(gzFile file, char* buf, int len)
#else #else
char * ZEXPORT gzgets(file, buf, len) char* ZEXPORT gzgets(file, buf, len)
gzFile file; gzFile file;
char *buf; char* buf;
int len; int len;
#endif #endif
{ {
unsigned left, n; unsigned left, n;
char *str; char* str;
unsigned char *eol; unsigned char* eol;
gz_statep state; gz_statep state;
/* check parameters and get internal structure */ /* check parameters and get internal structure */
if (file == NULL || buf == NULL || len < 1) if (file == NULL || buf == NULL || len < 1)
return NULL; return NULL;
state = (gz_statep)file; state = (gz_statep)file;
/* check that we're reading and that there's no (serious) error */ /* check that we're reading and that there's no (serious) error */
if (state->mode != GZ_READ || if (state->mode != GZ_READ ||
(state->err != Z_OK && state->err != Z_BUF_ERROR)) (state->err != Z_OK && state->err != Z_BUF_ERROR))
return NULL; return NULL;
/* process a skip request */ /* process a skip request */
if (state->seek) { if (state->seek)
{
state->seek = 0; state->seek = 0;
if (gz_skip(state, state->skip) == -1) if (gz_skip(state, state->skip) == -1)
return NULL; return NULL;
} }
@ -551,33 +638,40 @@ char * ZEXPORT gzgets(file, buf, len)
the contents, let the user worry about that) */ the contents, let the user worry about that) */
str = buf; str = buf;
left = (unsigned)len - 1; left = (unsigned)len - 1;
if (left) do {
/* assure that something is in the output buffer */ if (left) do
if (state->x.have == 0 && gz_fetch(state) == -1) {
return NULL; /* error */ /* assure that something is in the output buffer */
if (state->x.have == 0) { /* end of file */ if (state->x.have == 0 && gz_fetch(state) == -1)
state->past = 1; /* read past end */ return NULL; /* error */
break; /* return what we have */
if (state->x.have == 0) /* end of file */
{
state->past = 1; /* read past end */
break; /* return what we have */
}
/* look for end-of-line in current output buffer */
n = state->x.have > left ? left : state->x.have;
eol = memchr(state->x.next, '\n', n);
if (eol != NULL)
n = (unsigned)(eol - state->x.next) + 1;
/* copy through end-of-line, or remainder if not found */
memcpy(buf, state->x.next, n);
state->x.have -= n;
state->x.next += n;
state->x.pos += n;
left -= n;
buf += n;
} }
while (left && eol == NULL);
/* look for end-of-line in current output buffer */
n = state->x.have > left ? left : state->x.have;
eol = memchr(state->x.next, '\n', n);
if (eol != NULL)
n = (unsigned)(eol - state->x.next) + 1;
/* copy through end-of-line, or remainder if not found */
memcpy(buf, state->x.next, n);
state->x.have -= n;
state->x.next += n;
state->x.pos += n;
left -= n;
buf += n;
} while (left && eol == NULL);
/* return terminated string, or if nothing, end of file */ /* return terminated string, or if nothing, end of file */
if (buf == str) if (buf == str)
return NULL; return NULL;
buf[0] = 0; buf[0] = 0;
return str; return str;
} }
@ -587,7 +681,7 @@ char * ZEXPORT gzgets(file, buf, len)
int ZEXPORT gzdirect(gzFile file) int ZEXPORT gzdirect(gzFile file)
#else #else
int ZEXPORT gzdirect(file) int ZEXPORT gzdirect(file)
gzFile file; gzFile file;
#endif #endif
{ {
gz_statep state; gz_statep state;
@ -595,6 +689,7 @@ int ZEXPORT gzdirect(file)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return 0; return 0;
state = (gz_statep)file; state = (gz_statep)file;
/* if the state is not known, but we can find out, then do so (this is /* if the state is not known, but we can find out, then do so (this is
@ -611,7 +706,7 @@ int ZEXPORT gzdirect(file)
int ZEXPORT gzclose_r(gzFile file) int ZEXPORT gzclose_r(gzFile file)
#else #else
int ZEXPORT gzclose_r(file) int ZEXPORT gzclose_r(file)
gzFile file; gzFile file;
#endif #endif
{ {
int ret, err; int ret, err;
@ -620,6 +715,7 @@ int ZEXPORT gzclose_r(file)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
state = (gz_statep)file; state = (gz_statep)file;
/* check that we're reading */ /* check that we're reading */
@ -627,11 +723,13 @@ int ZEXPORT gzclose_r(file)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
/* free memory and close file */ /* free memory and close file */
if (state->size) { if (state->size)
{
inflateEnd(&(state->strm)); inflateEnd(&(state->strm));
free(state->out); free(state->out);
free(state->in); free(state->in);
} }
err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK;
gz_error(state, Z_OK, NULL); gz_error(state, Z_OK, NULL);
free(state->path); free(state->path);

220
extern/zlib/gzwrite.c vendored
View File

@ -16,7 +16,7 @@ local int gz_zero OF((gz_statep, z_off64_t));
local int gz_init(gz_statep state) local int gz_init(gz_statep state)
#else #else
local int gz_init(state) local int gz_init(state)
gz_statep state; gz_statep state;
#endif #endif
{ {
int ret; int ret;
@ -24,16 +24,21 @@ local int gz_init(state)
/* allocate input buffer */ /* allocate input buffer */
state->in = malloc(state->want); state->in = malloc(state->want);
if (state->in == NULL) {
if (state->in == NULL)
{
gz_error(state, Z_MEM_ERROR, "out of memory"); gz_error(state, Z_MEM_ERROR, "out of memory");
return -1; return -1;
} }
/* only need output buffer and deflate state if compressing */ /* only need output buffer and deflate state if compressing */
if (!state->direct) { if (!state->direct)
{
/* allocate output buffer */ /* allocate output buffer */
state->out = malloc(state->want); state->out = malloc(state->want);
if (state->out == NULL) {
if (state->out == NULL)
{
free(state->in); free(state->in);
gz_error(state, Z_MEM_ERROR, "out of memory"); gz_error(state, Z_MEM_ERROR, "out of memory");
return -1; return -1;
@ -45,7 +50,9 @@ local int gz_init(state)
strm->opaque = Z_NULL; strm->opaque = Z_NULL;
ret = deflateInit2(strm, state->level, Z_DEFLATED, ret = deflateInit2(strm, state->level, Z_DEFLATED,
MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy);
if (ret != Z_OK) {
if (ret != Z_OK)
{
free(state->out); free(state->out);
free(state->in); free(state->in);
gz_error(state, Z_MEM_ERROR, "out of memory"); gz_error(state, Z_MEM_ERROR, "out of memory");
@ -57,11 +64,13 @@ local int gz_init(state)
state->size = state->want; state->size = state->want;
/* initialize write buffer if compressing */ /* initialize write buffer if compressing */
if (!state->direct) { if (!state->direct)
{
strm->avail_out = state->size; strm->avail_out = state->size;
strm->next_out = state->out; strm->next_out = state->out;
state->x.next = strm->next_out; state->x.next = strm->next_out;
} }
return 0; return 0;
} }
@ -75,8 +84,8 @@ local int gz_init(state)
local int gz_comp(gz_statep state, int flush) local int gz_comp(gz_statep state, int flush)
#else #else
local int gz_comp(state, flush) local int gz_comp(state, flush)
gz_statep state; gz_statep state;
int flush; int flush;
#endif #endif
{ {
int ret, got; int ret, got;
@ -88,46 +97,62 @@ local int gz_comp(state, flush)
return -1; return -1;
/* write directly if requested */ /* write directly if requested */
if (state->direct) { if (state->direct)
{
got = write(state->fd, strm->next_in, strm->avail_in); got = write(state->fd, strm->next_in, strm->avail_in);
if (got < 0 || (unsigned)got != strm->avail_in) {
if (got < 0 || (unsigned)got != strm->avail_in)
{
gz_error(state, Z_ERRNO, zstrerror()); gz_error(state, Z_ERRNO, zstrerror());
return -1; return -1;
} }
strm->avail_in = 0; strm->avail_in = 0;
return 0; return 0;
} }
/* run deflate() on provided input until it produces no more output */ /* run deflate() on provided input until it produces no more output */
ret = Z_OK; ret = Z_OK;
do {
do
{
/* write out current buffer contents if full, or if flushing, but if /* write out current buffer contents if full, or if flushing, but if
doing Z_FINISH then don't write until we get to Z_STREAM_END */ doing Z_FINISH then don't write until we get to Z_STREAM_END */
if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
(flush != Z_FINISH || ret == Z_STREAM_END))) { (flush != Z_FINISH || ret == Z_STREAM_END)))
{
have = (unsigned)(strm->next_out - state->x.next); have = (unsigned)(strm->next_out - state->x.next);
if (have && ((got = write(state->fd, state->x.next, have)) < 0 || if (have && ((got = write(state->fd, state->x.next, have)) < 0 ||
(unsigned)got != have)) { (unsigned)got != have))
{
gz_error(state, Z_ERRNO, zstrerror()); gz_error(state, Z_ERRNO, zstrerror());
return -1; return -1;
} }
if (strm->avail_out == 0) {
if (strm->avail_out == 0)
{
strm->avail_out = state->size; strm->avail_out = state->size;
strm->next_out = state->out; strm->next_out = state->out;
} }
state->x.next = strm->next_out; state->x.next = strm->next_out;
} }
/* compress */ /* compress */
have = strm->avail_out; have = strm->avail_out;
ret = deflate(strm, flush); ret = deflate(strm, flush);
if (ret == Z_STREAM_ERROR) {
if (ret == Z_STREAM_ERROR)
{
gz_error(state, Z_STREAM_ERROR, gz_error(state, Z_STREAM_ERROR,
"internal error: deflate stream corrupt"); "internal error: deflate stream corrupt");
return -1; return -1;
} }
have -= strm->avail_out; have -= strm->avail_out;
} while (have); }
while (have);
/* if that completed a deflate stream, allow another to start */ /* if that completed a deflate stream, allow another to start */
if (flush == Z_FINISH) if (flush == Z_FINISH)
@ -142,8 +167,8 @@ local int gz_comp(state, flush)
local int gz_zero(gz_statep state, z_off64_t len) local int gz_zero(gz_statep state, z_off64_t len)
#else #else
local int gz_zero(state, len) local int gz_zero(state, len)
gz_statep state; gz_statep state;
z_off64_t len; z_off64_t len;
#endif #endif
{ {
int first; int first;
@ -156,20 +181,28 @@ local int gz_zero(state, len)
/* compress len zeros (len guaranteed > 0) */ /* compress len zeros (len guaranteed > 0) */
first = 1; first = 1;
while (len) {
while (len)
{
n = GT_OFF(state->size) || (z_off64_t)state->size > len ? n = GT_OFF(state->size) || (z_off64_t)state->size > len ?
(unsigned)len : state->size; (unsigned)len : state->size;
if (first) {
if (first)
{
memset(state->in, 0, n); memset(state->in, 0, n);
first = 0; first = 0;
} }
strm->avail_in = n; strm->avail_in = n;
strm->next_in = state->in; strm->next_in = state->in;
state->x.pos += n; state->x.pos += n;
if (gz_comp(state, Z_NO_FLUSH) == -1) if (gz_comp(state, Z_NO_FLUSH) == -1)
return -1; return -1;
len -= n; len -= n;
} }
return 0; return 0;
} }
@ -178,9 +211,9 @@ local int gz_zero(state, len)
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
#else #else
int ZEXPORT gzwrite(file, buf, len) int ZEXPORT gzwrite(file, buf, len)
gzFile file; gzFile file;
voidpc buf; voidpc buf;
unsigned len; unsigned len;
#endif #endif
{ {
unsigned put = len; unsigned put = len;
@ -191,6 +224,7 @@ int ZEXPORT gzwrite(file, buf, len)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return 0; return 0;
state = (gz_statep)file; state = (gz_statep)file;
strm = &(state->strm); strm = &(state->strm);
@ -200,7 +234,8 @@ int ZEXPORT gzwrite(file, buf, len)
/* since an int is returned, make sure len fits in one, otherwise return /* since an int is returned, make sure len fits in one, otherwise return
with an error (this avoids the flaw in the interface) */ with an error (this avoids the flaw in the interface) */
if ((int)len < 0) { if ((int)len < 0)
{
gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
return 0; return 0;
} }
@ -214,31 +249,41 @@ int ZEXPORT gzwrite(file, buf, len)
return 0; return 0;
/* check for seek request */ /* check for seek request */
if (state->seek) { if (state->seek)
{
state->seek = 0; state->seek = 0;
if (gz_zero(state, state->skip) == -1) if (gz_zero(state, state->skip) == -1)
return 0; return 0;
} }
/* for small len, copy to input buffer, otherwise compress directly */ /* for small len, copy to input buffer, otherwise compress directly */
if (len < state->size) { if (len < state->size)
{
/* copy to input buffer, compress when full */ /* copy to input buffer, compress when full */
do { do
{
if (strm->avail_in == 0) if (strm->avail_in == 0)
strm->next_in = state->in; strm->next_in = state->in;
n = state->size - strm->avail_in; n = state->size - strm->avail_in;
if (n > len) if (n > len)
n = len; n = len;
memcpy(strm->next_in + strm->avail_in, buf, n); memcpy(strm->next_in + strm->avail_in, buf, n);
strm->avail_in += n; strm->avail_in += n;
state->x.pos += n; state->x.pos += n;
buf = (char *)buf + n; buf = (char*)buf + n;
len -= n; len -= n;
if (len && gz_comp(state, Z_NO_FLUSH) == -1) if (len && gz_comp(state, Z_NO_FLUSH) == -1)
return 0; return 0;
} while (len); }
while (len);
} }
else { else
{
/* consume whatever's left in the input buffer */ /* consume whatever's left in the input buffer */
if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
return 0; return 0;
@ -247,6 +292,7 @@ int ZEXPORT gzwrite(file, buf, len)
strm->avail_in = len; strm->avail_in = len;
strm->next_in = (voidp)buf; strm->next_in = (voidp)buf;
state->x.pos += len; state->x.pos += len;
if (gz_comp(state, Z_NO_FLUSH) == -1) if (gz_comp(state, Z_NO_FLUSH) == -1)
return 0; return 0;
} }
@ -260,8 +306,8 @@ int ZEXPORT gzwrite(file, buf, len)
int ZEXPORT gzputc(gzFile file, unsigned char c) int ZEXPORT gzputc(gzFile file, unsigned char c)
#else #else
int ZEXPORT gzputc(file, c) int ZEXPORT gzputc(file, c)
gzFile file; gzFile file;
int c; int c;
#endif #endif
{ {
unsigned char buf[1]; unsigned char buf[1];
@ -271,6 +317,7 @@ int ZEXPORT gzputc(file, c)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
strm = &(state->strm); strm = &(state->strm);
@ -279,17 +326,21 @@ int ZEXPORT gzputc(file, c)
return -1; return -1;
/* check for seek request */ /* check for seek request */
if (state->seek) { if (state->seek)
{
state->seek = 0; state->seek = 0;
if (gz_zero(state, state->skip) == -1) if (gz_zero(state, state->skip) == -1)
return -1; return -1;
} }
/* try writing to input buffer for speed (state->size == 0 if buffer not /* try writing to input buffer for speed (state->size == 0 if buffer not
initialized) */ initialized) */
if (strm->avail_in < state->size) { if (strm->avail_in < state->size)
{
if (strm->avail_in == 0) if (strm->avail_in == 0)
strm->next_in = state->in; strm->next_in = state->in;
strm->next_in[strm->avail_in++] = c; strm->next_in[strm->avail_in++] = c;
state->x.pos++; state->x.pos++;
return c & 0xff; return c & 0xff;
@ -297,18 +348,20 @@ int ZEXPORT gzputc(file, c)
/* no room in buffer or not initialized, use gz_write() */ /* no room in buffer or not initialized, use gz_write() */
buf[0] = c; buf[0] = c;
if (gzwrite(file, buf, 1) != 1) if (gzwrite(file, buf, 1) != 1)
return -1; return -1;
return c & 0xff; return c & 0xff;
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
#ifdef WIN32 #ifdef WIN32
int ZEXPORT gzputs(gzFile file, const char *str) int ZEXPORT gzputs(gzFile file, const char* str)
#else #else
int ZEXPORT gzputs(file, str) int ZEXPORT gzputs(file, str)
gzFile file; gzFile file;
const char *str; const char* str;
#endif #endif
{ {
int ret; int ret;
@ -324,7 +377,7 @@ int ZEXPORT gzputs(file, str)
#include <stdarg.h> #include <stdarg.h>
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) int ZEXPORTVA gzprintf(gzFile file, const char* format, ...)
{ {
int size, len; int size, len;
gz_statep state; gz_statep state;
@ -334,6 +387,7 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
strm = &(state->strm); strm = &(state->strm);
@ -346,8 +400,10 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
return 0; return 0;
/* check for seek request */ /* check for seek request */
if (state->seek) { if (state->seek)
{
state->seek = 0; state->seek = 0;
if (gz_zero(state, state->skip) == -1) if (gz_zero(state, state->skip) == -1)
return 0; return 0;
} }
@ -362,21 +418,23 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
va_start(va, format); va_start(va, format);
#ifdef NO_vsnprintf #ifdef NO_vsnprintf
# ifdef HAS_vsprintf_void # ifdef HAS_vsprintf_void
(void)vsprintf((char *)(state->in), format, va); (void)vsprintf((char*)(state->in), format, va);
va_end(va); va_end(va);
for (len = 0; len < size; len++) for (len = 0; len < size; len++)
if (state->in[len] == 0) break; if (state->in[len] == 0) break;
# else # else
len = vsprintf((char *)(state->in), format, va); len = vsprintf((char*)(state->in), format, va);
va_end(va); va_end(va);
# endif # endif
#else #else
# ifdef HAS_vsnprintf_void # ifdef HAS_vsnprintf_void
(void)vsnprintf((char *)(state->in), size, format, va); (void)vsnprintf((char*)(state->in), size, format, va);
va_end(va); va_end(va);
len = strlen((char *)(state->in)); len = strlen((char*)(state->in));
# else # else
len = vsnprintf((char *)(state->in), size, format, va); len = vsnprintf((char*)(state->in), size, format, va);
va_end(va); va_end(va);
# endif # endif
#endif #endif
@ -395,12 +453,12 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
#else /* !STDC && !Z_HAVE_STDARG_H */ #else /* !STDC && !Z_HAVE_STDARG_H */
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
gzFile file; gzFile file;
const char *format; const char* format;
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
{ {
int size, len; int size, len;
gz_statep state; gz_statep state;
@ -409,11 +467,12 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
strm = &(state->strm); strm = &(state->strm);
/* check that can really pass pointer in ints */ /* check that can really pass pointer in ints */
if (sizeof(int) != sizeof(void *)) if (sizeof(int) != sizeof(void*))
return 0; return 0;
/* check that we're writing and that there's no error */ /* check that we're writing and that there's no error */
@ -425,8 +484,10 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
return 0; return 0;
/* check for seek request */ /* check for seek request */
if (state->seek) { if (state->seek)
{
state->seek = 0; state->seek = 0;
if (gz_zero(state, state->skip) == -1) if (gz_zero(state, state->skip) == -1)
return 0; return 0;
} }
@ -440,21 +501,23 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
state->in[size - 1] = 0; state->in[size - 1] = 0;
#ifdef NO_snprintf #ifdef NO_snprintf
# ifdef HAS_sprintf_void # ifdef HAS_sprintf_void
sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8, sprintf((char*)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
for (len = 0; len < size; len++) for (len = 0; len < size; len++)
if (state->in[len] == 0) break; if (state->in[len] == 0) break;
# else # else
len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8, len = sprintf((char*)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8,
a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
# endif # endif
#else #else
# ifdef HAS_snprintf_void # ifdef HAS_snprintf_void
snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8, snprintf((char*)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8,
a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
len = strlen((char *)(state->in)); len = strlen((char*)(state->in));
# else # else
len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, len = snprintf((char*)(state->in), size, format, a1, a2, a3, a4, a5, a6,
a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18,
a19, a20); a19, a20);
# endif # endif
@ -478,8 +541,8 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
int ZEXPORT gzflush(gzFile file, int flush) int ZEXPORT gzflush(gzFile file, int flush)
#else #else
int ZEXPORT gzflush(file, flush) int ZEXPORT gzflush(file, flush)
gzFile file; gzFile file;
int flush; int flush;
#endif #endif
{ {
gz_statep state; gz_statep state;
@ -487,6 +550,7 @@ int ZEXPORT gzflush(file, flush)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
/* check that we're writing and that there's no error */ /* check that we're writing and that there's no error */
@ -498,8 +562,10 @@ int ZEXPORT gzflush(file, flush)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
/* check for seek request */ /* check for seek request */
if (state->seek) { if (state->seek)
{
state->seek = 0; state->seek = 0;
if (gz_zero(state, state->skip) == -1) if (gz_zero(state, state->skip) == -1)
return -1; return -1;
} }
@ -514,9 +580,9 @@ int ZEXPORT gzflush(file, flush)
int ZEXPORT gzsetparams(gzFile file, int level, int strategy) int ZEXPORT gzsetparams(gzFile file, int level, int strategy)
#else #else
int ZEXPORT gzsetparams(file, level, strategy) int ZEXPORT gzsetparams(file, level, strategy)
gzFile file; gzFile file;
int level; int level;
int strategy; int strategy;
#endif #endif
{ {
gz_statep state; gz_statep state;
@ -525,6 +591,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
state = (gz_statep)file; state = (gz_statep)file;
strm = &(state->strm); strm = &(state->strm);
@ -537,19 +604,24 @@ int ZEXPORT gzsetparams(file, level, strategy)
return Z_OK; return Z_OK;
/* check for seek request */ /* check for seek request */
if (state->seek) { if (state->seek)
{
state->seek = 0; state->seek = 0;
if (gz_zero(state, state->skip) == -1) if (gz_zero(state, state->skip) == -1)
return -1; return -1;
} }
/* change compression parameters for subsequent input */ /* change compression parameters for subsequent input */
if (state->size) { if (state->size)
{
/* flush previous input with previous parameters before changing */ /* flush previous input with previous parameters before changing */
if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1) if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1)
return state->err; return state->err;
deflateParams(strm, level, strategy); deflateParams(strm, level, strategy);
} }
state->level = level; state->level = level;
state->strategy = strategy; state->strategy = strategy;
return Z_OK; return Z_OK;
@ -560,7 +632,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
int ZEXPORT gzclose_w(gzFile file) int ZEXPORT gzclose_w(gzFile file)
#else #else
int ZEXPORT gzclose_w(file) int ZEXPORT gzclose_w(file)
gzFile file; gzFile file;
#endif #endif
{ {
int ret = Z_OK; int ret = Z_OK;
@ -569,6 +641,7 @@ int ZEXPORT gzclose_w(file)
/* get internal structure */ /* get internal structure */
if (file == NULL) if (file == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
state = (gz_statep)file; state = (gz_statep)file;
/* check that we're writing */ /* check that we're writing */
@ -576,26 +649,35 @@ int ZEXPORT gzclose_w(file)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
/* check for seek request */ /* check for seek request */
if (state->seek) { if (state->seek)
{
state->seek = 0; state->seek = 0;
if (gz_zero(state, state->skip) == -1) if (gz_zero(state, state->skip) == -1)
ret = state->err; ret = state->err;
} }
/* flush, free memory, and close file */ /* flush, free memory, and close file */
if (state->size) { if (state->size)
{
if (gz_comp(state, Z_FINISH) == -1) if (gz_comp(state, Z_FINISH) == -1)
ret = state->err; ret = state->err;
if (!state->direct) {
if (!state->direct)
{
(void)deflateEnd(&(state->strm)); (void)deflateEnd(&(state->strm));
free(state->out); free(state->out);
} }
free(state->in); free(state->in);
} }
gz_error(state, Z_OK, NULL); gz_error(state, Z_OK, NULL);
free(state->path); free(state->path);
if (close(state->fd) == -1) if (close(state->fd) == -1)
ret = Z_ERRNO; ret = Z_ERRNO;
free(state); free(state);
return ret; return ret;
} }

781
extern/zlib/infback.c vendored
View File

@ -33,7 +33,7 @@ while (0) \
#endif #endif
/* function prototypes */ /* function prototypes */
local void fixedtables OF((struct inflate_state FAR *state)); local void fixedtables OF((struct inflate_state FAR* state));
/* /*
strm provides memory allocation functions in zalloc and zfree, or strm provides memory allocation functions in zalloc and zfree, or
@ -43,26 +43,30 @@ local void fixedtables OF((struct inflate_state FAR *state));
window and output buffer that is 2**windowBits bytes. window and output buffer that is 2**windowBits bytes.
*/ */
#ifdef WIN32 #ifdef WIN32
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size) int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, unsigned char FAR* window, const char* version, int stream_size)
#else #else
int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
z_streamp strm; z_streamp strm;
int windowBits; int windowBits;
unsigned char FAR *window; unsigned char FAR* window;
const char *version; const char* version;
int stream_size; int stream_size;
#endif #endif
{ {
struct inflate_state FAR *state; struct inflate_state FAR* state;
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
stream_size != (int)(sizeof(z_stream))) stream_size != (int)(sizeof(z_stream)))
return Z_VERSION_ERROR; return Z_VERSION_ERROR;
if (strm == Z_NULL || window == Z_NULL || if (strm == Z_NULL || window == Z_NULL ||
windowBits < 8 || windowBits > 15) windowBits < 8 || windowBits > 15)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
strm->msg = Z_NULL; /* in case we return an error */ strm->msg = Z_NULL; /* in case we return an error */
if (strm->zalloc == (alloc_func)0) {
if (strm->zalloc == (alloc_func)0)
{
#ifdef Z_SOLO #ifdef Z_SOLO
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
#else #else
@ -70,17 +74,21 @@ int stream_size;
strm->opaque = (voidpf)0; strm->opaque = (voidpf)0;
#endif #endif
} }
if (strm->zfree == (free_func)0) if (strm->zfree == (free_func)0)
#ifdef Z_SOLO #ifdef Z_SOLO
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
#else #else
strm->zfree = zcfree; strm->zfree = zcfree;
#endif #endif
state = (struct inflate_state FAR *)ZALLOC(strm, 1, state = (struct inflate_state FAR*)ZALLOC(strm, 1,
sizeof(struct inflate_state)); sizeof(struct inflate_state));
if (state == Z_NULL) return Z_MEM_ERROR; if (state == Z_NULL) return Z_MEM_ERROR;
Tracev((stderr, "inflate: allocated\n")); Tracev((stderr, "inflate: allocated\n"));
strm->state = (struct internal_state FAR *)state; strm->state = (struct internal_state FAR*)state;
state->dmax = 32768U; state->dmax = 32768U;
state->wbits = windowBits; state->wbits = windowBits;
state->wsize = 1U << windowBits; state->wsize = 1U << windowBits;
@ -101,28 +109,34 @@ int stream_size;
may not be thread-safe. may not be thread-safe.
*/ */
#ifdef WIN32 #ifdef WIN32
local void fixedtables(struct inflate_state FAR *state) local void fixedtables(struct inflate_state FAR* state)
#else #else
local void fixedtables(state) local void fixedtables(state)
struct inflate_state FAR *state; struct inflate_state FAR* state;
#endif #endif
{ {
#ifdef BUILDFIXED #ifdef BUILDFIXED
static int virgin = 1; static int virgin = 1;
static code *lenfix, *distfix; static code* lenfix, *distfix;
static code fixed[544]; static code fixed[544];
/* build fixed huffman tables if first call (may not be thread safe) */ /* build fixed huffman tables if first call (may not be thread safe) */
if (virgin) { if (virgin)
{
unsigned sym, bits; unsigned sym, bits;
static code *next; static code* next;
/* literal/length table */ /* literal/length table */
sym = 0; sym = 0;
while (sym < 144) state->lens[sym++] = 8; while (sym < 144) state->lens[sym++] = 8;
while (sym < 256) state->lens[sym++] = 9; while (sym < 256) state->lens[sym++] = 9;
while (sym < 280) state->lens[sym++] = 7; while (sym < 280) state->lens[sym++] = 7;
while (sym < 288) state->lens[sym++] = 8; while (sym < 288) state->lens[sym++] = 8;
next = fixed; next = fixed;
lenfix = next; lenfix = next;
bits = 9; bits = 9;
@ -130,7 +144,9 @@ struct inflate_state FAR *state;
/* distance table */ /* distance table */
sym = 0; sym = 0;
while (sym < 32) state->lens[sym++] = 5; while (sym < 32) state->lens[sym++] = 5;
distfix = next; distfix = next;
bits = 5; bits = 5;
inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
@ -138,6 +154,7 @@ struct inflate_state FAR *state;
/* do this just once */ /* do this just once */
virgin = 0; virgin = 0;
} }
#else /* !BUILDFIXED */ #else /* !BUILDFIXED */
# include "inffixed.h" # include "inffixed.h"
#endif /* BUILDFIXED */ #endif /* BUILDFIXED */
@ -273,35 +290,36 @@ struct inflate_state FAR *state;
are not correct, i.e. strm is Z_NULL or the state was not initialized. are not correct, i.e. strm is Z_NULL or the state was not initialized.
*/ */
#ifdef WIN32 #ifdef WIN32
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc) int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR* in_desc, out_func out, void FAR* out_desc)
#else #else
int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
z_streamp strm; z_streamp strm;
in_func in; in_func in;
void FAR *in_desc; void FAR* in_desc;
out_func out; out_func out;
void FAR *out_desc; void FAR* out_desc;
#endif #endif
{ {
struct inflate_state FAR *state; struct inflate_state FAR* state;
unsigned char FAR *next; /* next input */ unsigned char FAR* next; /* next input */
unsigned char FAR *put; /* next output */ unsigned char FAR* put; /* next output */
unsigned have, left; /* available input and output */ unsigned have, left; /* available input and output */
unsigned long hold; /* bit buffer */ unsigned long hold; /* bit buffer */
unsigned bits; /* bits in bit buffer */ unsigned bits; /* bits in bit buffer */
unsigned copy; /* number of stored or match bytes to copy */ unsigned copy; /* number of stored or match bytes to copy */
unsigned char FAR *from; /* where to copy match bytes from */ unsigned char FAR* from; /* where to copy match bytes from */
code here; /* current decoding table entry */ code here; /* current decoding table entry */
code last; /* parent table entry */ code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */ unsigned len; /* length to copy for repeats, bits to drop */
int ret; /* return code */ int ret; /* return code */
static const unsigned short order[19] = /* permutation of code lengths */ static const unsigned short order[19] = /* permutation of code lengths */
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
/* Check that the strm exists and that the state was initialized */ /* Check that the strm exists and that the state was initialized */
if (strm == Z_NULL || strm->state == Z_NULL) if (strm == Z_NULL || strm->state == Z_NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
state = (struct inflate_state FAR*)strm->state;
/* Reset the state */ /* Reset the state */
strm->msg = Z_NULL; strm->msg = Z_NULL;
@ -317,341 +335,447 @@ void FAR *out_desc;
/* Inflate until end of block marked as last */ /* Inflate until end of block marked as last */
for (;;) for (;;)
switch (state->mode) { switch (state->mode)
case TYPE: {
/* determine and dispatch block type */ case TYPE:
if (state->last) {
BYTEBITS();
state->mode = DONE;
break;
}
NEEDBITS(3);
state->last = BITS(1);
DROPBITS(1);
switch (BITS(2)) {
case 0: /* stored block */
Tracev((stderr, "inflate: stored block%s\n",
state->last ? " (last)" : ""));
state->mode = STORED;
break;
case 1: /* fixed block */
fixedtables(state);
Tracev((stderr, "inflate: fixed codes block%s\n",
state->last ? " (last)" : ""));
state->mode = LEN; /* decode codes */
break;
case 2: /* dynamic block */
Tracev((stderr, "inflate: dynamic codes block%s\n",
state->last ? " (last)" : ""));
state->mode = TABLE;
break;
case 3:
strm->msg = (char *)"invalid block type";
state->mode = BAD;
}
DROPBITS(2);
break;
case STORED: /* determine and dispatch block type */
/* get and verify stored block length */ if (state->last)
BYTEBITS(); /* go to byte boundary */ {
NEEDBITS(32); BYTEBITS();
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { state->mode = DONE;
strm->msg = (char *)"invalid stored block lengths"; break;
state->mode = BAD; }
break;
}
state->length = (unsigned)hold & 0xffff;
Tracev((stderr, "inflate: stored length %u\n",
state->length));
INITBITS();
/* copy stored block from input to output */
while (state->length != 0) {
copy = state->length;
PULL();
ROOM();
if (copy > have) copy = have;
if (copy > left) copy = left;
zmemcpy(put, next, copy);
have -= copy;
next += copy;
left -= copy;
put += copy;
state->length -= copy;
}
Tracev((stderr, "inflate: stored end\n"));
state->mode = TYPE;
break;
case TABLE:
/* get dynamic table entries descriptor */
NEEDBITS(14);
state->nlen = BITS(5) + 257;
DROPBITS(5);
state->ndist = BITS(5) + 1;
DROPBITS(5);
state->ncode = BITS(4) + 4;
DROPBITS(4);
#ifndef PKZIP_BUG_WORKAROUND
if (state->nlen > 286 || state->ndist > 30) {
strm->msg = (char *)"too many length or distance symbols";
state->mode = BAD;
break;
}
#endif
Tracev((stderr, "inflate: table sizes ok\n"));
/* get code length code lengths (not a typo) */
state->have = 0;
while (state->have < state->ncode) {
NEEDBITS(3); NEEDBITS(3);
state->lens[order[state->have++]] = (unsigned short)BITS(3); state->last = BITS(1);
DROPBITS(3); DROPBITS(1);
}
while (state->have < 19)
state->lens[order[state->have++]] = 0;
state->next = state->codes;
state->lencode = (code const FAR *)(state->next);
state->lenbits = 7;
ret = inflate_table(CODES, state->lens, 19, &(state->next),
&(state->lenbits), state->work);
if (ret) {
strm->msg = (char *)"invalid code lengths set";
state->mode = BAD;
break;
}
Tracev((stderr, "inflate: code lengths ok\n"));
/* get length and distance code code lengths */ switch (BITS(2))
state->have = 0; {
while (state->have < state->nlen + state->ndist) { case 0: /* stored block */
for (;;) { Tracev((stderr, "inflate: stored block%s\n",
here = state->lencode[BITS(state->lenbits)]; state->last ? " (last)" : ""));
if ((unsigned)(here.bits) <= bits) break; state->mode = STORED;
PULLBYTE(); break;
case 1: /* fixed block */
fixedtables(state);
Tracev((stderr, "inflate: fixed codes block%s\n",
state->last ? " (last)" : ""));
state->mode = LEN; /* decode codes */
break;
case 2: /* dynamic block */
Tracev((stderr, "inflate: dynamic codes block%s\n",
state->last ? " (last)" : ""));
state->mode = TABLE;
break;
case 3:
strm->msg = (char*)"invalid block type";
state->mode = BAD;
} }
if (here.val < 16) {
DROPBITS(here.bits); DROPBITS(2);
state->lens[state->have++] = here.val; break;
case STORED:
/* get and verify stored block length */
BYTEBITS(); /* go to byte boundary */
NEEDBITS(32);
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff))
{
strm->msg = (char*)"invalid stored block lengths";
state->mode = BAD;
break;
} }
else {
if (here.val == 16) { state->length = (unsigned)hold & 0xffff;
NEEDBITS(here.bits + 2); Tracev((stderr, "inflate: stored length %u\n",
state->length));
INITBITS();
/* copy stored block from input to output */
while (state->length != 0)
{
copy = state->length;
PULL();
ROOM();
if (copy > have) copy = have;
if (copy > left) copy = left;
zmemcpy(put, next, copy);
have -= copy;
next += copy;
left -= copy;
put += copy;
state->length -= copy;
}
Tracev((stderr, "inflate: stored end\n"));
state->mode = TYPE;
break;
case TABLE:
/* get dynamic table entries descriptor */
NEEDBITS(14);
state->nlen = BITS(5) + 257;
DROPBITS(5);
state->ndist = BITS(5) + 1;
DROPBITS(5);
state->ncode = BITS(4) + 4;
DROPBITS(4);
#ifndef PKZIP_BUG_WORKAROUND
if (state->nlen > 286 || state->ndist > 30)
{
strm->msg = (char*)"too many length or distance symbols";
state->mode = BAD;
break;
}
#endif
Tracev((stderr, "inflate: table sizes ok\n"));
/* get code length code lengths (not a typo) */
state->have = 0;
while (state->have < state->ncode)
{
NEEDBITS(3);
state->lens[order[state->have++]] = (unsigned short)BITS(3);
DROPBITS(3);
}
while (state->have < 19)
state->lens[order[state->have++]] = 0;
state->next = state->codes;
state->lencode = (code const FAR*)(state->next);
state->lenbits = 7;
ret = inflate_table(CODES, state->lens, 19, &(state->next),
&(state->lenbits), state->work);
if (ret)
{
strm->msg = (char*)"invalid code lengths set";
state->mode = BAD;
break;
}
Tracev((stderr, "inflate: code lengths ok\n"));
/* get length and distance code code lengths */
state->have = 0;
while (state->have < state->nlen + state->ndist)
{
for (;;)
{
here = state->lencode[BITS(state->lenbits)];
if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
if (here.val < 16)
{
DROPBITS(here.bits); DROPBITS(here.bits);
if (state->have == 0) { state->lens[state->have++] = here.val;
strm->msg = (char *)"invalid bit length repeat"; }
else
{
if (here.val == 16)
{
NEEDBITS(here.bits + 2);
DROPBITS(here.bits);
if (state->have == 0)
{
strm->msg = (char*)"invalid bit length repeat";
state->mode = BAD;
break;
}
len = (unsigned)(state->lens[state->have - 1]);
copy = 3 + BITS(2);
DROPBITS(2);
}
else if (here.val == 17)
{
NEEDBITS(here.bits + 3);
DROPBITS(here.bits);
len = 0;
copy = 3 + BITS(3);
DROPBITS(3);
}
else
{
NEEDBITS(here.bits + 7);
DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist)
{
strm->msg = (char*)"invalid bit length repeat";
state->mode = BAD; state->mode = BAD;
break; break;
} }
len = (unsigned)(state->lens[state->have - 1]);
copy = 3 + BITS(2); while (copy--)
DROPBITS(2); state->lens[state->have++] = (unsigned short)len;
} }
else if (here.val == 17) {
NEEDBITS(here.bits + 3);
DROPBITS(here.bits);
len = 0;
copy = 3 + BITS(3);
DROPBITS(3);
}
else {
NEEDBITS(here.bits + 7);
DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist) {
strm->msg = (char *)"invalid bit length repeat";
state->mode = BAD;
break;
}
while (copy--)
state->lens[state->have++] = (unsigned short)len;
} }
}
/* handle error breaks in while */ /* handle error breaks in while */
if (state->mode == BAD) break; if (state->mode == BAD) break;
/* check for end-of-block code (better have one) */ /* check for end-of-block code (better have one) */
if (state->lens[256] == 0) { if (state->lens[256] == 0)
strm->msg = (char *)"invalid code -- missing end-of-block"; {
state->mode = BAD; strm->msg = (char*)"invalid code -- missing end-of-block";
break; state->mode = BAD;
} break;
/* build code tables -- note: do not change the lenbits or distbits
values here (9 and 6) without reading the comments in inftrees.h
concerning the ENOUGH constants, which depend on those values */
state->next = state->codes;
state->lencode = (code const FAR *)(state->next);
state->lenbits = 9;
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
&(state->lenbits), state->work);
if (ret) {
strm->msg = (char *)"invalid literal/lengths set";
state->mode = BAD;
break;
}
state->distcode = (code const FAR *)(state->next);
state->distbits = 6;
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
&(state->next), &(state->distbits), state->work);
if (ret) {
strm->msg = (char *)"invalid distances set";
state->mode = BAD;
break;
}
Tracev((stderr, "inflate: codes ok\n"));
state->mode = LEN;
case LEN:
/* use inflate_fast() if we have enough input and output */
if (have >= 6 && left >= 258) {
RESTORE();
if (state->whave < state->wsize)
state->whave = state->wsize - left;
inflate_fast(strm, state->wsize);
LOAD();
break;
}
/* get a literal, length, or end-of-block code */
for (;;) {
here = state->lencode[BITS(state->lenbits)];
if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
if (here.op && (here.op & 0xf0) == 0) {
last = here;
for (;;) {
here = state->lencode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
} }
DROPBITS(last.bits);
}
DROPBITS(here.bits);
state->length = (unsigned)here.val;
/* process literal */ /* build code tables -- note: do not change the lenbits or distbits
if (here.op == 0) { values here (9 and 6) without reading the comments in inftrees.h
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? concerning the ENOUGH constants, which depend on those values */
"inflate: literal '%c'\n" : state->next = state->codes;
"inflate: literal 0x%02x\n", here.val)); state->lencode = (code const FAR*)(state->next);
ROOM(); state->lenbits = 9;
*put++ = (unsigned char)(state->length); ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
left--; &(state->lenbits), state->work);
if (ret)
{
strm->msg = (char*)"invalid literal/lengths set";
state->mode = BAD;
break;
}
state->distcode = (code const FAR*)(state->next);
state->distbits = 6;
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
&(state->next), &(state->distbits), state->work);
if (ret)
{
strm->msg = (char*)"invalid distances set";
state->mode = BAD;
break;
}
Tracev((stderr, "inflate: codes ok\n"));
state->mode = LEN; state->mode = LEN;
break;
}
/* process end of block */ case LEN:
if (here.op & 32) {
Tracevv((stderr, "inflate: end of block\n"));
state->mode = TYPE;
break;
}
/* invalid code */ /* use inflate_fast() if we have enough input and output */
if (here.op & 64) { if (have >= 6 && left >= 258)
strm->msg = (char *)"invalid literal/length code"; {
state->mode = BAD; RESTORE();
break;
}
/* length code -- get extra bits, if any */ if (state->whave < state->wsize)
state->extra = (unsigned)(here.op) & 15; state->whave = state->wsize - left;
if (state->extra != 0) {
NEEDBITS(state->extra); inflate_fast(strm, state->wsize);
state->length += BITS(state->extra); LOAD();
DROPBITS(state->extra); break;
} }
Tracevv((stderr, "inflate: length %u\n", state->length));
/* get a literal, length, or end-of-block code */
for (;;)
{
here = state->lencode[BITS(state->lenbits)];
if ((unsigned)(here.bits) <= bits) break;
/* get distance code */
for (;;) {
here = state->distcode[BITS(state->distbits)];
if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
if ((here.op & 0xf0) == 0) {
last = here;
for (;;) {
here = state->distcode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE(); PULLBYTE();
} }
DROPBITS(last.bits);
}
DROPBITS(here.bits);
if (here.op & 64) {
strm->msg = (char *)"invalid distance code";
state->mode = BAD;
break;
}
state->offset = (unsigned)here.val;
/* get distance extra bits, if any */ if (here.op && (here.op & 0xf0) == 0)
state->extra = (unsigned)(here.op) & 15; {
if (state->extra != 0) { last = here;
NEEDBITS(state->extra);
state->offset += BITS(state->extra);
DROPBITS(state->extra);
}
if (state->offset > state->wsize - (state->whave < state->wsize ?
left : 0)) {
strm->msg = (char *)"invalid distance too far back";
state->mode = BAD;
break;
}
Tracevv((stderr, "inflate: distance %u\n", state->offset));
/* copy match from window to output */ for (;;)
do { {
ROOM(); here = state->lencode[last.val +
copy = state->wsize - state->offset; (BITS(last.bits + last.op) >> last.bits)];
if (copy < left) {
from = put + copy; if ((unsigned)(last.bits + here.bits) <= bits) break;
copy = left - copy;
PULLBYTE();
}
DROPBITS(last.bits);
} }
else {
from = put - state->offset; DROPBITS(here.bits);
copy = left; state->length = (unsigned)here.val;
/* process literal */
if (here.op == 0)
{
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
"inflate: literal 0x%02x\n", here.val));
ROOM();
*put++ = (unsigned char)(state->length);
left--;
state->mode = LEN;
break;
} }
if (copy > state->length) copy = state->length;
state->length -= copy;
left -= copy;
do {
*put++ = *from++;
} while (--copy);
} while (state->length != 0);
break;
case DONE: /* process end of block */
/* inflate stream terminated properly -- write leftover output */ if (here.op & 32)
ret = Z_STREAM_END; {
if (left < state->wsize) { Tracevv((stderr, "inflate: end of block\n"));
if (out(out_desc, state->window, state->wsize - left)) state->mode = TYPE;
ret = Z_BUF_ERROR; break;
} }
goto inf_leave;
case BAD: /* invalid code */
ret = Z_DATA_ERROR; if (here.op & 64)
goto inf_leave; {
strm->msg = (char*)"invalid literal/length code";
state->mode = BAD;
break;
}
default: /* can't happen, but makes compilers happy */ /* length code -- get extra bits, if any */
ret = Z_STREAM_ERROR; state->extra = (unsigned)(here.op) & 15;
goto inf_leave;
if (state->extra != 0)
{
NEEDBITS(state->extra);
state->length += BITS(state->extra);
DROPBITS(state->extra);
}
Tracevv((stderr, "inflate: length %u\n", state->length));
/* get distance code */
for (;;)
{
here = state->distcode[BITS(state->distbits)];
if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
if ((here.op & 0xf0) == 0)
{
last = here;
for (;;)
{
here = state->distcode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
DROPBITS(here.bits);
if (here.op & 64)
{
strm->msg = (char*)"invalid distance code";
state->mode = BAD;
break;
}
state->offset = (unsigned)here.val;
/* get distance extra bits, if any */
state->extra = (unsigned)(here.op) & 15;
if (state->extra != 0)
{
NEEDBITS(state->extra);
state->offset += BITS(state->extra);
DROPBITS(state->extra);
}
if (state->offset > state->wsize - (state->whave < state->wsize ?
left : 0))
{
strm->msg = (char*)"invalid distance too far back";
state->mode = BAD;
break;
}
Tracevv((stderr, "inflate: distance %u\n", state->offset));
/* copy match from window to output */
do
{
ROOM();
copy = state->wsize - state->offset;
if (copy < left)
{
from = put + copy;
copy = left - copy;
}
else
{
from = put - state->offset;
copy = left;
}
if (copy > state->length) copy = state->length;
state->length -= copy;
left -= copy;
do
{
*put++ = *from++;
}
while (--copy);
}
while (state->length != 0);
break;
case DONE:
/* inflate stream terminated properly -- write leftover output */
ret = Z_STREAM_END;
if (left < state->wsize)
{
if (out(out_desc, state->window, state->wsize - left))
ret = Z_BUF_ERROR;
}
goto inf_leave;
case BAD:
ret = Z_DATA_ERROR;
goto inf_leave;
default: /* can't happen, but makes compilers happy */
ret = Z_STREAM_ERROR;
goto inf_leave;
} }
/* Return unused input */ /* Return unused input */
inf_leave: inf_leave:
strm->next_in = next; strm->next_in = next;
strm->avail_in = have; strm->avail_in = have;
return ret; return ret;
@ -666,6 +790,7 @@ z_streamp strm;
{ {
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
ZFREE(strm, strm->state); ZFREE(strm, strm->state);
strm->state = Z_NULL; strm->state = Z_NULL;
Tracev((stderr, "inflate: end\n")); Tracev((stderr, "inflate: end\n"));

231
extern/zlib/inffast.c vendored
View File

@ -72,34 +72,34 @@ z_streamp strm;
unsigned start; /* inflate()'s starting value for strm->avail_out */ unsigned start; /* inflate()'s starting value for strm->avail_out */
#endif #endif
{ {
struct inflate_state FAR *state; struct inflate_state FAR* state;
unsigned char FAR *in; /* local strm->next_in */ unsigned char FAR* in; /* local strm->next_in */
unsigned char FAR *last; /* while in < last, enough input available */ unsigned char FAR* last; /* while in < last, enough input available */
unsigned char FAR *out; /* local strm->next_out */ unsigned char FAR* out; /* local strm->next_out */
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ unsigned char FAR* beg; /* inflate()'s initial strm->next_out */
unsigned char FAR *end; /* while out < end, enough space available */ unsigned char FAR* end; /* while out < end, enough space available */
#ifdef INFLATE_STRICT #ifdef INFLATE_STRICT
unsigned dmax; /* maximum distance from zlib header */ unsigned dmax; /* maximum distance from zlib header */
#endif #endif
unsigned wsize; /* window size or zero if not using window */ unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */ unsigned whave; /* valid bytes in the window */
unsigned wnext; /* window write index */ unsigned wnext; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ unsigned char FAR* window; /* allocated sliding window, if wsize != 0 */
unsigned long hold; /* local strm->hold */ unsigned long hold; /* local strm->hold */
unsigned bits; /* local strm->bits */ unsigned bits; /* local strm->bits */
code const FAR *lcode; /* local strm->lencode */ code const FAR* lcode; /* local strm->lencode */
code const FAR *dcode; /* local strm->distcode */ code const FAR* dcode; /* local strm->distcode */
unsigned lmask; /* mask for first level of length codes */ unsigned lmask; /* mask for first level of length codes */
unsigned dmask; /* mask for first level of distance codes */ unsigned dmask; /* mask for first level of distance codes */
code here; /* retrieved table entry */ code here; /* retrieved table entry */
unsigned op; /* code bits, operation, extra bits, or */ unsigned op; /* code bits, operation, extra bits, or */
/* window position, window bytes to copy */ /* window position, window bytes to copy */
unsigned len; /* match length, unused bytes */ unsigned len; /* match length, unused bytes */
unsigned dist; /* match distance */ unsigned dist; /* match distance */
unsigned char FAR *from; /* where to copy match from */ unsigned char FAR* from; /* where to copy match from */
/* copy state to local variables */ /* copy state to local variables */
state = (struct inflate_state FAR *)strm->state; state = (struct inflate_state FAR*)strm->state;
in = strm->next_in - OFF; in = strm->next_in - OFF;
last = in + (strm->avail_in - 5); last = in + (strm->avail_in - 5);
out = strm->next_out - OFF; out = strm->next_out - OFF;
@ -121,194 +121,287 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
/* decode literals and length/distances until end-of-block or not enough /* decode literals and length/distances until end-of-block or not enough
input data or output space */ input data or output space */
do { do
if (bits < 15) { {
if (bits < 15)
{
hold += (unsigned long)(PUP(in)) << bits; hold += (unsigned long)(PUP(in)) << bits;
bits += 8; bits += 8;
hold += (unsigned long)(PUP(in)) << bits; hold += (unsigned long)(PUP(in)) << bits;
bits += 8; bits += 8;
} }
here = lcode[hold & lmask]; here = lcode[hold & lmask];
dolen: dolen:
op = (unsigned)(here.bits); op = (unsigned)(here.bits);
hold >>= op; hold >>= op;
bits -= op; bits -= op;
op = (unsigned)(here.op); op = (unsigned)(here.op);
if (op == 0) { /* literal */
if (op == 0) /* literal */
{
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" : "inflate: literal '%c'\n" :
"inflate: literal 0x%02x\n", here.val)); "inflate: literal 0x%02x\n", here.val));
PUP(out) = (unsigned char)(here.val); PUP(out) = (unsigned char)(here.val);
} }
else if (op & 16) { /* length base */ else if (op & 16) /* length base */
{
len = (unsigned)(here.val); len = (unsigned)(here.val);
op &= 15; /* number of extra bits */ op &= 15; /* number of extra bits */
if (op) {
if (bits < op) { if (op)
{
if (bits < op)
{
hold += (unsigned long)(PUP(in)) << bits; hold += (unsigned long)(PUP(in)) << bits;
bits += 8; bits += 8;
} }
len += (unsigned)hold & ((1U << op) - 1); len += (unsigned)hold & ((1U << op) - 1);
hold >>= op; hold >>= op;
bits -= op; bits -= op;
} }
Tracevv((stderr, "inflate: length %u\n", len)); Tracevv((stderr, "inflate: length %u\n", len));
if (bits < 15) {
if (bits < 15)
{
hold += (unsigned long)(PUP(in)) << bits; hold += (unsigned long)(PUP(in)) << bits;
bits += 8; bits += 8;
hold += (unsigned long)(PUP(in)) << bits; hold += (unsigned long)(PUP(in)) << bits;
bits += 8; bits += 8;
} }
here = dcode[hold & dmask]; here = dcode[hold & dmask];
dodist: dodist:
op = (unsigned)(here.bits); op = (unsigned)(here.bits);
hold >>= op; hold >>= op;
bits -= op; bits -= op;
op = (unsigned)(here.op); op = (unsigned)(here.op);
if (op & 16) { /* distance base */
if (op & 16) /* distance base */
{
dist = (unsigned)(here.val); dist = (unsigned)(here.val);
op &= 15; /* number of extra bits */ op &= 15; /* number of extra bits */
if (bits < op) {
if (bits < op)
{
hold += (unsigned long)(PUP(in)) << bits; hold += (unsigned long)(PUP(in)) << bits;
bits += 8; bits += 8;
if (bits < op) {
if (bits < op)
{
hold += (unsigned long)(PUP(in)) << bits; hold += (unsigned long)(PUP(in)) << bits;
bits += 8; bits += 8;
} }
} }
dist += (unsigned)hold & ((1U << op) - 1); dist += (unsigned)hold & ((1U << op) - 1);
#ifdef INFLATE_STRICT #ifdef INFLATE_STRICT
if (dist > dmax) {
strm->msg = (char *)"invalid distance too far back"; if (dist > dmax)
{
strm->msg = (char*)"invalid distance too far back";
state->mode = BAD; state->mode = BAD;
break; break;
} }
#endif #endif
hold >>= op; hold >>= op;
bits -= op; bits -= op;
Tracevv((stderr, "inflate: distance %u\n", dist)); Tracevv((stderr, "inflate: distance %u\n", dist));
op = (unsigned)(out - beg); /* max distance in output */ op = (unsigned)(out - beg); /* max distance in output */
if (dist > op) { /* see if copy from window */
if (dist > op) /* see if copy from window */
{
op = dist - op; /* distance back in window */ op = dist - op; /* distance back in window */
if (op > whave) {
if (state->sane) { if (op > whave)
{
if (state->sane)
{
strm->msg = strm->msg =
(char *)"invalid distance too far back"; (char*)"invalid distance too far back";
state->mode = BAD; state->mode = BAD;
break; break;
} }
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
if (len <= op - whave) {
do { if (len <= op - whave)
{
do
{
PUP(out) = 0; PUP(out) = 0;
} while (--len); }
while (--len);
continue; continue;
} }
len -= op - whave; len -= op - whave;
do {
do
{
PUP(out) = 0; PUP(out) = 0;
} while (--op > whave); }
if (op == 0) { while (--op > whave);
if (op == 0)
{
from = out - dist; from = out - dist;
do {
do
{
PUP(out) = PUP(from); PUP(out) = PUP(from);
} while (--len); }
while (--len);
continue; continue;
} }
#endif #endif
} }
from = window - OFF; from = window - OFF;
if (wnext == 0) { /* very common case */
if (wnext == 0) /* very common case */
{
from += wsize - op; from += wsize - op;
if (op < len) { /* some from window */
if (op < len) /* some from window */
{
len -= op; len -= op;
do {
do
{
PUP(out) = PUP(from); PUP(out) = PUP(from);
} while (--op); }
while (--op);
from = out - dist; /* rest from output */ from = out - dist; /* rest from output */
} }
} }
else if (wnext < op) { /* wrap around window */ else if (wnext < op) /* wrap around window */
{
from += wsize + wnext - op; from += wsize + wnext - op;
op -= wnext; op -= wnext;
if (op < len) { /* some from end of window */
if (op < len) /* some from end of window */
{
len -= op; len -= op;
do {
do
{
PUP(out) = PUP(from); PUP(out) = PUP(from);
} while (--op); }
while (--op);
from = window - OFF; from = window - OFF;
if (wnext < len) { /* some from start of window */
if (wnext < len) /* some from start of window */
{
op = wnext; op = wnext;
len -= op; len -= op;
do {
do
{
PUP(out) = PUP(from); PUP(out) = PUP(from);
} while (--op); }
while (--op);
from = out - dist; /* rest from output */ from = out - dist; /* rest from output */
} }
} }
} }
else { /* contiguous in window */ else /* contiguous in window */
{
from += wnext - op; from += wnext - op;
if (op < len) { /* some from window */
if (op < len) /* some from window */
{
len -= op; len -= op;
do {
do
{
PUP(out) = PUP(from); PUP(out) = PUP(from);
} while (--op); }
while (--op);
from = out - dist; /* rest from output */ from = out - dist; /* rest from output */
} }
} }
while (len > 2) {
while (len > 2)
{
PUP(out) = PUP(from); PUP(out) = PUP(from);
PUP(out) = PUP(from); PUP(out) = PUP(from);
PUP(out) = PUP(from); PUP(out) = PUP(from);
len -= 3; len -= 3;
} }
if (len) {
if (len)
{
PUP(out) = PUP(from); PUP(out) = PUP(from);
if (len > 1) if (len > 1)
PUP(out) = PUP(from); PUP(out) = PUP(from);
} }
} }
else { else
{
from = out - dist; /* copy direct from output */ from = out - dist; /* copy direct from output */
do { /* minimum length is three */
do /* minimum length is three */
{
PUP(out) = PUP(from); PUP(out) = PUP(from);
PUP(out) = PUP(from); PUP(out) = PUP(from);
PUP(out) = PUP(from); PUP(out) = PUP(from);
len -= 3; len -= 3;
} while (len > 2); }
if (len) { while (len > 2);
if (len)
{
PUP(out) = PUP(from); PUP(out) = PUP(from);
if (len > 1) if (len > 1)
PUP(out) = PUP(from); PUP(out) = PUP(from);
} }
} }
} }
else if ((op & 64) == 0) { /* 2nd level distance code */ else if ((op & 64) == 0) /* 2nd level distance code */
{
here = dcode[here.val + (hold & ((1U << op) - 1))]; here = dcode[here.val + (hold & ((1U << op) - 1))];
goto dodist; goto dodist;
} }
else { else
strm->msg = (char *)"invalid distance code"; {
strm->msg = (char*)"invalid distance code";
state->mode = BAD; state->mode = BAD;
break; break;
} }
} }
else if ((op & 64) == 0) { /* 2nd level length code */ else if ((op & 64) == 0) /* 2nd level length code */
{
here = lcode[here.val + (hold & ((1U << op) - 1))]; here = lcode[here.val + (hold & ((1U << op) - 1))];
goto dolen; goto dolen;
} }
else if (op & 32) { /* end-of-block */ else if (op & 32) /* end-of-block */
{
Tracevv((stderr, "inflate: end of block\n")); Tracevv((stderr, "inflate: end of block\n"));
state->mode = TYPE; state->mode = TYPE;
break; break;
} }
else { else
strm->msg = (char *)"invalid literal/length code"; {
strm->msg = (char*)"invalid literal/length code";
state->mode = BAD; state->mode = BAD;
break; break;
} }
} while (in < last && out < end); }
while (in < last && out < end);
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */ /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
len = bits >> 3; len = bits >> 3;

184
extern/zlib/inffixed.h vendored
View File

@ -1,94 +1,96 @@
/* inffixed.h -- table for decoding fixed codes /* inffixed.h -- table for decoding fixed codes
* Generated automatically by makefixed(). * Generated automatically by makefixed().
*/ */
/* WARNING: this file should *not* be used by applications. /* WARNING: this file should *not* be used by applications.
It is part of the implementation of this library and is It is part of the implementation of this library and is
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
static const code lenfix[512] = { static const code lenfix[512] =
{96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, {
{0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, {96, 7, 0}, {0, 8, 80}, {0, 8, 16}, {20, 8, 115}, {18, 7, 31}, {0, 8, 112}, {0, 8, 48},
{0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, {0, 9, 192}, {16, 7, 10}, {0, 8, 96}, {0, 8, 32}, {0, 9, 160}, {0, 8, 0}, {0, 8, 128},
{0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, {0, 8, 64}, {0, 9, 224}, {16, 7, 6}, {0, 8, 88}, {0, 8, 24}, {0, 9, 144}, {19, 7, 59},
{0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, {0, 8, 120}, {0, 8, 56}, {0, 9, 208}, {17, 7, 17}, {0, 8, 104}, {0, 8, 40}, {0, 9, 176},
{21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, {0, 8, 8}, {0, 8, 136}, {0, 8, 72}, {0, 9, 240}, {16, 7, 4}, {0, 8, 84}, {0, 8, 20},
{0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, {21, 8, 227}, {19, 7, 43}, {0, 8, 116}, {0, 8, 52}, {0, 9, 200}, {17, 7, 13}, {0, 8, 100},
{0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, {0, 8, 36}, {0, 9, 168}, {0, 8, 4}, {0, 8, 132}, {0, 8, 68}, {0, 9, 232}, {16, 7, 8},
{18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, {0, 8, 92}, {0, 8, 28}, {0, 9, 152}, {20, 7, 83}, {0, 8, 124}, {0, 8, 60}, {0, 9, 216},
{0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, {18, 7, 23}, {0, 8, 108}, {0, 8, 44}, {0, 9, 184}, {0, 8, 12}, {0, 8, 140}, {0, 8, 76},
{0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, {0, 9, 248}, {16, 7, 3}, {0, 8, 82}, {0, 8, 18}, {21, 8, 163}, {19, 7, 35}, {0, 8, 114},
{0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, {0, 8, 50}, {0, 9, 196}, {17, 7, 11}, {0, 8, 98}, {0, 8, 34}, {0, 9, 164}, {0, 8, 2},
{20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, {0, 8, 130}, {0, 8, 66}, {0, 9, 228}, {16, 7, 7}, {0, 8, 90}, {0, 8, 26}, {0, 9, 148},
{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, {20, 7, 67}, {0, 8, 122}, {0, 8, 58}, {0, 9, 212}, {18, 7, 19}, {0, 8, 106}, {0, 8, 42},
{0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, {0, 9, 180}, {0, 8, 10}, {0, 8, 138}, {0, 8, 74}, {0, 9, 244}, {16, 7, 5}, {0, 8, 86},
{0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, {0, 8, 22}, {64, 8, 0}, {19, 7, 51}, {0, 8, 118}, {0, 8, 54}, {0, 9, 204}, {17, 7, 15},
{16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, {0, 8, 102}, {0, 8, 38}, {0, 9, 172}, {0, 8, 6}, {0, 8, 134}, {0, 8, 70}, {0, 9, 236},
{0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, {16, 7, 9}, {0, 8, 94}, {0, 8, 30}, {0, 9, 156}, {20, 7, 99}, {0, 8, 126}, {0, 8, 62},
{0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, {0, 9, 220}, {18, 7, 27}, {0, 8, 110}, {0, 8, 46}, {0, 9, 188}, {0, 8, 14}, {0, 8, 142},
{0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, {0, 8, 78}, {0, 9, 252}, {96, 7, 0}, {0, 8, 81}, {0, 8, 17}, {21, 8, 131}, {18, 7, 31},
{0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, {0, 8, 113}, {0, 8, 49}, {0, 9, 194}, {16, 7, 10}, {0, 8, 97}, {0, 8, 33}, {0, 9, 162},
{0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, {0, 8, 1}, {0, 8, 129}, {0, 8, 65}, {0, 9, 226}, {16, 7, 6}, {0, 8, 89}, {0, 8, 25},
{0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, {0, 9, 146}, {19, 7, 59}, {0, 8, 121}, {0, 8, 57}, {0, 9, 210}, {17, 7, 17}, {0, 8, 105},
{0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, {0, 8, 41}, {0, 9, 178}, {0, 8, 9}, {0, 8, 137}, {0, 8, 73}, {0, 9, 242}, {16, 7, 4},
{17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, {0, 8, 85}, {0, 8, 21}, {16, 8, 258}, {19, 7, 43}, {0, 8, 117}, {0, 8, 53}, {0, 9, 202},
{0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, {17, 7, 13}, {0, 8, 101}, {0, 8, 37}, {0, 9, 170}, {0, 8, 5}, {0, 8, 133}, {0, 8, 69},
{0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, {0, 9, 234}, {16, 7, 8}, {0, 8, 93}, {0, 8, 29}, {0, 9, 154}, {20, 7, 83}, {0, 8, 125},
{0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, {0, 8, 61}, {0, 9, 218}, {18, 7, 23}, {0, 8, 109}, {0, 8, 45}, {0, 9, 186}, {0, 8, 13},
{19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, {0, 8, 141}, {0, 8, 77}, {0, 9, 250}, {16, 7, 3}, {0, 8, 83}, {0, 8, 19}, {21, 8, 195},
{0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, {19, 7, 35}, {0, 8, 115}, {0, 8, 51}, {0, 9, 198}, {17, 7, 11}, {0, 8, 99}, {0, 8, 35},
{0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, {0, 9, 166}, {0, 8, 3}, {0, 8, 131}, {0, 8, 67}, {0, 9, 230}, {16, 7, 7}, {0, 8, 91},
{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, {0, 8, 27}, {0, 9, 150}, {20, 7, 67}, {0, 8, 123}, {0, 8, 59}, {0, 9, 214}, {18, 7, 19},
{16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, {0, 8, 107}, {0, 8, 43}, {0, 9, 182}, {0, 8, 11}, {0, 8, 139}, {0, 8, 75}, {0, 9, 246},
{0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, {16, 7, 5}, {0, 8, 87}, {0, 8, 23}, {64, 8, 0}, {19, 7, 51}, {0, 8, 119}, {0, 8, 55},
{0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, {0, 9, 206}, {17, 7, 15}, {0, 8, 103}, {0, 8, 39}, {0, 9, 174}, {0, 8, 7}, {0, 8, 135},
{0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, {0, 8, 71}, {0, 9, 238}, {16, 7, 9}, {0, 8, 95}, {0, 8, 31}, {0, 9, 158}, {20, 7, 99},
{0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, {0, 8, 127}, {0, 8, 63}, {0, 9, 222}, {18, 7, 27}, {0, 8, 111}, {0, 8, 47}, {0, 9, 190},
{20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, {0, 8, 15}, {0, 8, 143}, {0, 8, 79}, {0, 9, 254}, {96, 7, 0}, {0, 8, 80}, {0, 8, 16},
{0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, {20, 8, 115}, {18, 7, 31}, {0, 8, 112}, {0, 8, 48}, {0, 9, 193}, {16, 7, 10}, {0, 8, 96},
{0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, {0, 8, 32}, {0, 9, 161}, {0, 8, 0}, {0, 8, 128}, {0, 8, 64}, {0, 9, 225}, {16, 7, 6},
{17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, {0, 8, 88}, {0, 8, 24}, {0, 9, 145}, {19, 7, 59}, {0, 8, 120}, {0, 8, 56}, {0, 9, 209},
{0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, {17, 7, 17}, {0, 8, 104}, {0, 8, 40}, {0, 9, 177}, {0, 8, 8}, {0, 8, 136}, {0, 8, 72},
{0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, {0, 9, 241}, {16, 7, 4}, {0, 8, 84}, {0, 8, 20}, {21, 8, 227}, {19, 7, 43}, {0, 8, 116},
{0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, {0, 8, 52}, {0, 9, 201}, {17, 7, 13}, {0, 8, 100}, {0, 8, 36}, {0, 9, 169}, {0, 8, 4},
{20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, {0, 8, 132}, {0, 8, 68}, {0, 9, 233}, {16, 7, 8}, {0, 8, 92}, {0, 8, 28}, {0, 9, 153},
{0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, {20, 7, 83}, {0, 8, 124}, {0, 8, 60}, {0, 9, 217}, {18, 7, 23}, {0, 8, 108}, {0, 8, 44},
{0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, {0, 9, 185}, {0, 8, 12}, {0, 8, 140}, {0, 8, 76}, {0, 9, 249}, {16, 7, 3}, {0, 8, 82},
{0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, {0, 8, 18}, {21, 8, 163}, {19, 7, 35}, {0, 8, 114}, {0, 8, 50}, {0, 9, 197}, {17, 7, 11},
{16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, {0, 8, 98}, {0, 8, 34}, {0, 9, 165}, {0, 8, 2}, {0, 8, 130}, {0, 8, 66}, {0, 9, 229},
{0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, {16, 7, 7}, {0, 8, 90}, {0, 8, 26}, {0, 9, 149}, {20, 7, 67}, {0, 8, 122}, {0, 8, 58},
{0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, {0, 9, 213}, {18, 7, 19}, {0, 8, 106}, {0, 8, 42}, {0, 9, 181}, {0, 8, 10}, {0, 8, 138},
{0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, {0, 8, 74}, {0, 9, 245}, {16, 7, 5}, {0, 8, 86}, {0, 8, 22}, {64, 8, 0}, {19, 7, 51},
{0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, {0, 8, 118}, {0, 8, 54}, {0, 9, 205}, {17, 7, 15}, {0, 8, 102}, {0, 8, 38}, {0, 9, 173},
{0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, {0, 8, 6}, {0, 8, 134}, {0, 8, 70}, {0, 9, 237}, {16, 7, 9}, {0, 8, 94}, {0, 8, 30},
{0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, {0, 9, 157}, {20, 7, 99}, {0, 8, 126}, {0, 8, 62}, {0, 9, 221}, {18, 7, 27}, {0, 8, 110},
{0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, {0, 8, 46}, {0, 9, 189}, {0, 8, 14}, {0, 8, 142}, {0, 8, 78}, {0, 9, 253}, {96, 7, 0},
{16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, {0, 8, 81}, {0, 8, 17}, {21, 8, 131}, {18, 7, 31}, {0, 8, 113}, {0, 8, 49}, {0, 9, 195},
{0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, {16, 7, 10}, {0, 8, 97}, {0, 8, 33}, {0, 9, 163}, {0, 8, 1}, {0, 8, 129}, {0, 8, 65},
{0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, {0, 9, 227}, {16, 7, 6}, {0, 8, 89}, {0, 8, 25}, {0, 9, 147}, {19, 7, 59}, {0, 8, 121},
{0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, {0, 8, 57}, {0, 9, 211}, {17, 7, 17}, {0, 8, 105}, {0, 8, 41}, {0, 9, 179}, {0, 8, 9},
{19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, {0, 8, 137}, {0, 8, 73}, {0, 9, 243}, {16, 7, 4}, {0, 8, 85}, {0, 8, 21}, {16, 8, 258},
{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, {19, 7, 43}, {0, 8, 117}, {0, 8, 53}, {0, 9, 203}, {17, 7, 13}, {0, 8, 101}, {0, 8, 37},
{0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, {0, 9, 171}, {0, 8, 5}, {0, 8, 133}, {0, 8, 69}, {0, 9, 235}, {16, 7, 8}, {0, 8, 93},
{0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, {0, 8, 29}, {0, 9, 155}, {20, 7, 83}, {0, 8, 125}, {0, 8, 61}, {0, 9, 219}, {18, 7, 23},
{16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, {0, 8, 109}, {0, 8, 45}, {0, 9, 187}, {0, 8, 13}, {0, 8, 141}, {0, 8, 77}, {0, 9, 251},
{0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, {16, 7, 3}, {0, 8, 83}, {0, 8, 19}, {21, 8, 195}, {19, 7, 35}, {0, 8, 115}, {0, 8, 51},
{0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, {0, 9, 199}, {17, 7, 11}, {0, 8, 99}, {0, 8, 35}, {0, 9, 167}, {0, 8, 3}, {0, 8, 131},
{0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, {0, 8, 67}, {0, 9, 231}, {16, 7, 7}, {0, 8, 91}, {0, 8, 27}, {0, 9, 151}, {20, 7, 67},
{0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, {0, 8, 123}, {0, 8, 59}, {0, 9, 215}, {18, 7, 19}, {0, 8, 107}, {0, 8, 43}, {0, 9, 183},
{64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, {0, 8, 11}, {0, 8, 139}, {0, 8, 75}, {0, 9, 247}, {16, 7, 5}, {0, 8, 87}, {0, 8, 23},
{0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, {64, 8, 0}, {19, 7, 51}, {0, 8, 119}, {0, 8, 55}, {0, 9, 207}, {17, 7, 15}, {0, 8, 103},
{0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, {0, 8, 39}, {0, 9, 175}, {0, 8, 7}, {0, 8, 135}, {0, 8, 71}, {0, 9, 239}, {16, 7, 9},
{18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, {0, 8, 95}, {0, 8, 31}, {0, 9, 159}, {20, 7, 99}, {0, 8, 127}, {0, 8, 63}, {0, 9, 223},
{0,9,255} {18, 7, 27}, {0, 8, 111}, {0, 8, 47}, {0, 9, 191}, {0, 8, 15}, {0, 8, 143}, {0, 8, 79},
}; {0, 9, 255}
};
static const code distfix[32] = { static const code distfix[32] =
{16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, {
{21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, {16, 5, 1}, {23, 5, 257}, {19, 5, 17}, {27, 5, 4097}, {17, 5, 5}, {25, 5, 1025},
{18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, {21, 5, 65}, {29, 5, 16385}, {16, 5, 3}, {24, 5, 513}, {20, 5, 33}, {28, 5, 8193},
{19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, {18, 5, 9}, {26, 5, 2049}, {22, 5, 129}, {64, 5, 0}, {16, 5, 2}, {23, 5, 385},
{16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, {19, 5, 25}, {27, 5, 6145}, {17, 5, 7}, {25, 5, 1537}, {21, 5, 97}, {29, 5, 24577},
{22,5,193},{64,5,0} {16, 5, 4}, {24, 5, 769}, {20, 5, 49}, {28, 5, 12289}, {18, 5, 13}, {26, 5, 3073},
}; {22, 5, 193}, {64, 5, 0}
};

1560
extern/zlib/inflate.c vendored

File diff suppressed because it is too large Load Diff

56
extern/zlib/inflate.h vendored
View File

@ -17,7 +17,8 @@
#endif #endif
/* Possible inflate modes between inflate() calls */ /* Possible inflate modes between inflate() calls */
typedef enum { typedef enum
{
HEAD, /* i: waiting for magic header */ HEAD, /* i: waiting for magic header */
FLAGS, /* i: waiting for method and flags (gzip) */ FLAGS, /* i: waiting for method and flags (gzip) */
TIME, /* i: waiting for modification time (gzip) */ TIME, /* i: waiting for modification time (gzip) */
@ -29,21 +30,21 @@ typedef enum {
HCRC, /* i: waiting for header crc (gzip) */ HCRC, /* i: waiting for header crc (gzip) */
DICTID, /* i: waiting for dictionary check value */ DICTID, /* i: waiting for dictionary check value */
DICT, /* waiting for inflateSetDictionary() call */ DICT, /* waiting for inflateSetDictionary() call */
TYPE, /* i: waiting for type bits, including last-flag bit */ TYPE, /* i: waiting for type bits, including last-flag bit */
TYPEDO, /* i: same, but skip check to exit inflate on new block */ TYPEDO, /* i: same, but skip check to exit inflate on new block */
STORED, /* i: waiting for stored size (length and complement) */ STORED, /* i: waiting for stored size (length and complement) */
COPY_, /* i/o: same as COPY below, but only first time in */ COPY_, /* i/o: same as COPY below, but only first time in */
COPY, /* i/o: waiting for input or output to copy stored block */ COPY, /* i/o: waiting for input or output to copy stored block */
TABLE, /* i: waiting for dynamic block table lengths */ TABLE, /* i: waiting for dynamic block table lengths */
LENLENS, /* i: waiting for code length code lengths */ LENLENS, /* i: waiting for code length code lengths */
CODELENS, /* i: waiting for length/lit and distance code lengths */ CODELENS, /* i: waiting for length/lit and distance code lengths */
LEN_, /* i: same as LEN below, but only first time in */ LEN_, /* i: same as LEN below, but only first time in */
LEN, /* i: waiting for length/lit/eob code */ LEN, /* i: waiting for length/lit/eob code */
LENEXT, /* i: waiting for length extra bits */ LENEXT, /* i: waiting for length extra bits */
DIST, /* i: waiting for distance code */ DIST, /* i: waiting for distance code */
DISTEXT, /* i: waiting for distance extra bits */ DISTEXT, /* i: waiting for distance extra bits */
MATCH, /* o: waiting for output space to copy string */ MATCH, /* o: waiting for output space to copy string */
LIT, /* o: waiting for output space to write literal */ LIT, /* o: waiting for output space to write literal */
CHECK, /* i: waiting for 32-bit check value */ CHECK, /* i: waiting for 32-bit check value */
LENGTH, /* i: waiting for 32-bit length (gzip) */ LENGTH, /* i: waiting for 32-bit length (gzip) */
DONE, /* finished check, done -- remain here until reset */ DONE, /* finished check, done -- remain here until reset */
@ -78,7 +79,8 @@ typedef enum {
*/ */
/* state maintained between inflate() calls. Approximately 10K bytes. */ /* state maintained between inflate() calls. Approximately 10K bytes. */
struct inflate_state { struct inflate_state
{
inflate_mode mode; /* current inflate mode */ inflate_mode mode; /* current inflate mode */
int last; /* true if processing last block */ int last; /* true if processing last block */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
@ -88,31 +90,31 @@ struct inflate_state {
unsigned long check; /* protected copy of check value */ unsigned long check; /* protected copy of check value */
unsigned long total; /* protected copy of output count */ unsigned long total; /* protected copy of output count */
gz_headerp head; /* where to save gzip header information */ gz_headerp head; /* where to save gzip header information */
/* sliding window */ /* sliding window */
unsigned wbits; /* log base 2 of requested window size */ unsigned wbits; /* log base 2 of requested window size */
unsigned wsize; /* window size or zero if not using window */ unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */ unsigned whave; /* valid bytes in the window */
unsigned wnext; /* window write index */ unsigned wnext; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if needed */ unsigned char FAR* window; /* allocated sliding window, if needed */
/* bit accumulator */ /* bit accumulator */
unsigned long hold; /* input bit accumulator */ unsigned long hold; /* input bit accumulator */
unsigned bits; /* number of bits in "in" */ unsigned bits; /* number of bits in "in" */
/* for string and stored block copying */ /* for string and stored block copying */
unsigned length; /* literal or length of data to copy */ unsigned length; /* literal or length of data to copy */
unsigned offset; /* distance back to copy string from */ unsigned offset; /* distance back to copy string from */
/* for table and code decoding */ /* for table and code decoding */
unsigned extra; /* extra bits needed */ unsigned extra; /* extra bits needed */
/* fixed and dynamic code tables */ /* fixed and dynamic code tables */
code const FAR *lencode; /* starting table for length/literal codes */ code const FAR* lencode; /* starting table for length/literal codes */
code const FAR *distcode; /* starting table for distance codes */ code const FAR* distcode; /* starting table for distance codes */
unsigned lenbits; /* index bits for lencode */ unsigned lenbits; /* index bits for lencode */
unsigned distbits; /* index bits for distcode */ unsigned distbits; /* index bits for distcode */
/* dynamic table building */ /* dynamic table building */
unsigned ncode; /* number of code length code lengths */ unsigned ncode; /* number of code length code lengths */
unsigned nlen; /* number of length code lengths */ unsigned nlen; /* number of length code lengths */
unsigned ndist; /* number of distance code lengths */ unsigned ndist; /* number of distance code lengths */
unsigned have; /* number of code lengths in lens[] */ unsigned have; /* number of code lengths in lens[] */
code FAR *next; /* next available space in codes[] */ code FAR* next; /* next available space in codes[] */
unsigned short lens[320]; /* temporary storage for code lengths */ unsigned short lens[320]; /* temporary storage for code lengths */
unsigned short work[288]; /* work area for code table building */ unsigned short work[288]; /* work area for code table building */
code codes[ENOUGH]; /* space for code tables */ code codes[ENOUGH]; /* space for code tables */

146
extern/zlib/inftrees.c vendored
View File

@ -9,8 +9,8 @@
#define MAXBITS 15 #define MAXBITS 15
const char inflate_copyright[] = const char inflate_copyright[] =
// " inflate 1.2.7 Copyright 1995-2012 Mark Adler "; // " inflate 1.2.7 Copyright 1995-2012 Mark Adler ";
" inflate 1.2.7.f-hanba-win64 Copyright (C) 2012-14 Jonathan Hanba"; " inflate 1.2.7.f-hanba-win64 Copyright (C) 2012-14 Jonathan Hanba";
/* /*
If you use the zlib library in a product, an acknowledgment is welcome If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot in the documentation of your product. If for some reason you cannot
@ -43,15 +43,15 @@ const char inflate_copyright[] =
longest code or if it is less than the shortest code. longest code or if it is less than the shortest code.
*/ */
#ifdef WIN32 #ifdef WIN32
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned int codes, code FAR * FAR *table, unsigned FAR *bits, unsigned short FAR *work) int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR* lens, unsigned int codes, code FAR* FAR* table, unsigned FAR* bits, unsigned short FAR* work)
#else #else
int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)
codetype type; codetype type;
unsigned short FAR *lens; unsigned short FAR* lens;
unsigned codes; unsigned codes;
code FAR * FAR *table; code FAR* FAR* table;
unsigned FAR *bits; unsigned FAR* bits;
unsigned short FAR *work; unsigned short FAR* work;
#endif #endif
{ {
unsigned len; /* a code's length in bits */ unsigned len; /* a code's length in bits */
@ -68,26 +68,34 @@ unsigned short FAR *work;
unsigned low; /* low bits for current root entry */ unsigned low; /* low bits for current root entry */
unsigned mask; /* mask for low root bits */ unsigned mask; /* mask for low root bits */
code here; /* table entry for duplication */ code here; /* table entry for duplication */
code FAR *next; /* next available space in table */ code FAR* next; /* next available space in table */
const unsigned short FAR *base; /* base value table to use */ const unsigned short FAR* base; /* base value table to use */
const unsigned short FAR *extra; /* extra bits table to use */ const unsigned short FAR* extra; /* extra bits table to use */
int end; /* use base and extra for symbol > end */ int end; /* use base and extra for symbol > end */
unsigned short count[MAXBITS+1]; /* number of codes of each length */ unsigned short count[MAXBITS + 1]; /* number of codes of each length */
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ unsigned short offs[MAXBITS + 1]; /* offsets in table for each length */
static const unsigned short lbase[31] = { /* Length codes 257..285 base */ static const unsigned short lbase[31] = /* Length codes 257..285 base */
{
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
static const unsigned short lext[31] = { /* Length codes 257..285 extra */ };
static const unsigned short lext[31] = /* Length codes 257..285 extra */
{
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 78, 68}; 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 78, 68
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ };
static const unsigned short dbase[32] = /* Distance codes 0..29 base */
{
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577, 0, 0}; 8193, 12289, 16385, 24577, 0, 0
static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ };
static const unsigned short dext[32] = /* Distance codes 0..29 extra */
{
16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
28, 28, 29, 29, 64, 64}; 28, 28, 29, 29, 64, 64
};
/* /*
Process a set of code lengths to create a canonical Huffman code. The Process a set of code lengths to create a canonical Huffman code. The
@ -123,15 +131,20 @@ unsigned short FAR *work;
/* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
for (len = 0; len <= MAXBITS; len++) for (len = 0; len <= MAXBITS; len++)
count[len] = 0; count[len] = 0;
for (sym = 0; sym < codes; sym++) for (sym = 0; sym < codes; sym++)
count[lens[sym]]++; count[lens[sym]]++;
/* bound code lengths, force root to be within code lengths */ /* bound code lengths, force root to be within code lengths */
root = *bits; root = *bits;
for (max = MAXBITS; max >= 1; max--) for (max = MAXBITS; max >= 1; max--)
if (count[max] != 0) break; if (count[max] != 0) break;
if (root > max) root = max; if (root > max) root = max;
if (max == 0) { /* no symbols to code at all */
if (max == 0) /* no symbols to code at all */
{
here.op = (unsigned char)64; /* invalid code marker */ here.op = (unsigned char)64; /* invalid code marker */
here.bits = (unsigned char)1; here.bits = (unsigned char)1;
here.val = (unsigned short)0; here.val = (unsigned short)0;
@ -140,22 +153,29 @@ unsigned short FAR *work;
*bits = 1; *bits = 1;
return 0; /* no symbols, but wait for decoding to report error */ return 0; /* no symbols, but wait for decoding to report error */
} }
for (min = 1; min < max; min++) for (min = 1; min < max; min++)
if (count[min] != 0) break; if (count[min] != 0) break;
if (root < min) root = min; if (root < min) root = min;
/* check for an over-subscribed or incomplete set of lengths */ /* check for an over-subscribed or incomplete set of lengths */
left = 1; left = 1;
for (len = 1; len <= MAXBITS; len++) {
for (len = 1; len <= MAXBITS; len++)
{
left <<= 1; left <<= 1;
left -= count[len]; left -= count[len];
if (left < 0) return -1; /* over-subscribed */ if (left < 0) return -1; /* over-subscribed */
} }
if (left > 0 && (type == CODES || max != 1)) if (left > 0 && (type == CODES || max != 1))
return -1; /* incomplete set */ return -1; /* incomplete set */
/* generate offsets into symbol table for each length for sorting */ /* generate offsets into symbol table for each length for sorting */
offs[1] = 0; offs[1] = 0;
for (len = 1; len < MAXBITS; len++) for (len = 1; len < MAXBITS; len++)
offs[len + 1] = offs[len] + count[len]; offs[len + 1] = offs[len] + count[len];
@ -195,22 +215,25 @@ unsigned short FAR *work;
*/ */
/* set up for code type */ /* set up for code type */
switch (type) { switch (type)
case CODES: {
base = extra = work; /* dummy value--not used */ case CODES:
end = 19; base = extra = work; /* dummy value--not used */
break; end = 19;
case LENS: break;
base = lbase;
base -= 257; case LENS:
extra = lext; base = lbase;
extra -= 257; base -= 257;
end = 256; extra = lext;
break; extra -= 257;
default: /* DISTS */ end = 256;
base = dbase; break;
extra = dext;
end = -1; default: /* DISTS */
base = dbase;
extra = dext;
end = -1;
} }
/* initialize state for loop */ /* initialize state for loop */
@ -226,22 +249,27 @@ unsigned short FAR *work;
/* check available table space */ /* check available table space */
if ((type == LENS && used >= ENOUGH_LENS) || if ((type == LENS && used >= ENOUGH_LENS) ||
(type == DISTS && used >= ENOUGH_DISTS)) (type == DISTS && used >= ENOUGH_DISTS))
return 1; return 1;
/* process all codes and make table entries */ /* process all codes and make table entries */
for (;;) { for (;;)
{
/* create table entry */ /* create table entry */
here.bits = (unsigned char)(len - drop); here.bits = (unsigned char)(len - drop);
if ((int)(work[sym]) < end) {
if ((int)(work[sym]) < end)
{
here.op = (unsigned char)0; here.op = (unsigned char)0;
here.val = work[sym]; here.val = work[sym];
} }
else if ((int)(work[sym]) > end) { else if ((int)(work[sym]) > end)
{
here.op = (unsigned char)(extra[work[sym]]); here.op = (unsigned char)(extra[work[sym]]);
here.val = base[work[sym]]; here.val = base[work[sym]];
} }
else { else
{
here.op = (unsigned char)(32 + 64); /* end of block */ here.op = (unsigned char)(32 + 64); /* end of block */
here.val = 0; here.val = 0;
} }
@ -250,16 +278,22 @@ unsigned short FAR *work;
incr = 1U << (len - drop); incr = 1U << (len - drop);
fill = 1U << curr; fill = 1U << curr;
min = fill; /* save offset to next table */ min = fill; /* save offset to next table */
do {
do
{
fill -= incr; fill -= incr;
next[(huff >> drop) + fill] = here; next[(huff >> drop) + fill] = here;
} while (fill != 0); }
while (fill != 0);
/* backwards increment the len-bit code huff */ /* backwards increment the len-bit code huff */
incr = 1U << (len - 1); incr = 1U << (len - 1);
while (huff & incr) while (huff & incr)
incr >>= 1; incr >>= 1;
if (incr != 0) {
if (incr != 0)
{
huff &= incr - 1; huff &= incr - 1;
huff += incr; huff += incr;
} }
@ -268,13 +302,17 @@ unsigned short FAR *work;
/* go to next symbol, update count, len */ /* go to next symbol, update count, len */
sym++; sym++;
if (--(count[len]) == 0) {
if (--(count[len]) == 0)
{
if (len == max) break; if (len == max) break;
len = lens[work[sym]]; len = lens[work[sym]];
} }
/* create new sub-table if needed */ /* create new sub-table if needed */
if (len > root && (huff & mask) != low) { if (len > root && (huff & mask) != low)
{
/* if first time, transition to sub-tables */ /* if first time, transition to sub-tables */
if (drop == 0) if (drop == 0)
drop = root; drop = root;
@ -285,17 +323,22 @@ unsigned short FAR *work;
/* determine length of next table */ /* determine length of next table */
curr = len - drop; curr = len - drop;
left = (int)(1 << curr); left = (int)(1 << curr);
while (curr + drop < max) {
while (curr + drop < max)
{
left -= count[curr + drop]; left -= count[curr + drop];
if (left <= 0) break; if (left <= 0) break;
curr++; curr++;
left <<= 1; left <<= 1;
} }
/* check for enough space */ /* check for enough space */
used += 1U << curr; used += 1U << curr;
if ((type == LENS && used >= ENOUGH_LENS) || if ((type == LENS && used >= ENOUGH_LENS) ||
(type == DISTS && used >= ENOUGH_DISTS)) (type == DISTS && used >= ENOUGH_DISTS))
return 1; return 1;
/* point entry in root table to sub-table */ /* point entry in root table to sub-table */
@ -309,7 +352,8 @@ unsigned short FAR *work;
/* fill in remaining table entry if code is incomplete (guaranteed to have /* fill in remaining table entry if code is incomplete (guaranteed to have
at most one remaining entry, since if the code is incomplete, the at most one remaining entry, since if the code is incomplete, the
maximum code length that was allowed to get this far is one bit) */ maximum code length that was allowed to get this far is one bit) */
if (huff != 0) { if (huff != 0)
{
here.op = (unsigned char)64; /* invalid code marker */ here.op = (unsigned char)64; /* invalid code marker */
here.bits = (unsigned char)(len - drop); here.bits = (unsigned char)(len - drop);
here.val = (unsigned short)0; here.val = (unsigned short)0;

View File

@ -21,7 +21,8 @@
of the bit buffer. val is the actual byte to output in the case of the bit buffer. val is the actual byte to output in the case
of a literal, the base length or distance, or the offset from of a literal, the base length or distance, or the offset from
the current table to the next table. Each entry is four bytes. */ the current table to the next table. Each entry is four bytes. */
typedef struct { typedef struct
{
unsigned char op; /* operation, extra bits, table bits */ unsigned char op; /* operation, extra bits, table bits */
unsigned char bits; /* bits in this part of the code */ unsigned char bits; /* bits in this part of the code */
unsigned short val; /* offset in table or code value */ unsigned short val; /* offset in table or code value */
@ -51,12 +52,13 @@ typedef struct {
#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
/* Type of code to build for inflate_table() */ /* Type of code to build for inflate_table() */
typedef enum { typedef enum
{
CODES, CODES,
LENS, LENS,
DISTS DISTS
} codetype; } codetype;
int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR* lens,
unsigned codes, code FAR * FAR *table, unsigned codes, code FAR* FAR* table,
unsigned FAR *bits, unsigned short FAR *work)); unsigned FAR* bits, unsigned short FAR* work));

View File

@ -34,36 +34,36 @@ const char hello[] = "hello, hello!";
const char dictionary[] = "hello"; const char dictionary[] = "hello";
uLong dictId; /* Adler32 value of the dictionary */ uLong dictId; /* Adler32 value of the dictionary */
void test_deflate OF((Byte *compr, uLong comprLen)); void test_deflate OF((Byte* compr, uLong comprLen));
void test_inflate OF((Byte *compr, uLong comprLen, void test_inflate OF((Byte* compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen)); Byte* uncompr, uLong uncomprLen));
void test_large_deflate OF((Byte *compr, uLong comprLen, void test_large_deflate OF((Byte* compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen)); Byte* uncompr, uLong uncomprLen));
void test_large_inflate OF((Byte *compr, uLong comprLen, void test_large_inflate OF((Byte* compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen)); Byte* uncompr, uLong uncomprLen));
void test_flush OF((Byte *compr, uLong *comprLen)); void test_flush OF((Byte* compr, uLong* comprLen));
void test_sync OF((Byte *compr, uLong comprLen, void test_sync OF((Byte* compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen)); Byte* uncompr, uLong uncomprLen));
void test_dict_deflate OF((Byte *compr, uLong comprLen)); void test_dict_deflate OF((Byte* compr, uLong comprLen));
void test_dict_inflate OF((Byte *compr, uLong comprLen, void test_dict_inflate OF((Byte* compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen)); Byte* uncompr, uLong uncomprLen));
int main OF((int argc, char *argv[])); int main OF((int argc, char* argv[]));
#ifdef Z_SOLO #ifdef Z_SOLO
void *myalloc OF((void *, unsigned, unsigned)); void* myalloc OF((void*, unsigned, unsigned));
void myfree OF((void *, void *)); void myfree OF((void*, void*));
void *myalloc(q, n, m) void* myalloc(q, n, m)
void *q; void* q;
unsigned n, m; unsigned n, m;
{ {
q = Z_NULL; q = Z_NULL;
return calloc(n, m); return calloc(n, m);
} }
void myfree(void *q, void *p) void myfree(void* q, void* p)
{ {
q = Z_NULL; q = Z_NULL;
free(p); free(p);
@ -77,20 +77,20 @@ static free_func zfree = myfree;
static alloc_func zalloc = (alloc_func)0; static alloc_func zalloc = (alloc_func)0;
static free_func zfree = (free_func)0; static free_func zfree = (free_func)0;
void test_compress OF((Byte *compr, uLong comprLen, void test_compress OF((Byte* compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen)); Byte* uncompr, uLong uncomprLen));
void test_gzio OF((const char *fname, void test_gzio OF((const char* fname,
Byte *uncompr, uLong uncomprLen)); Byte* uncompr, uLong uncomprLen));
/* =========================================================================== /* ===========================================================================
* Test compress() and uncompress() * Test compress() and uncompress()
*/ */
void test_compress(compr, comprLen, uncompr, uncomprLen) void test_compress(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr; Byte* compr, *uncompr;
uLong comprLen, uncomprLen; uLong comprLen, uncomprLen;
{ {
int err; int err;
uLong len = (uLong)strlen(hello)+1; uLong len = (uLong)strlen(hello) + 1;
err = compress(compr, &comprLen, (const Bytef*)hello, len); err = compress(compr, &comprLen, (const Bytef*)hello, len);
CHECK_ERR(err, "compress"); CHECK_ERR(err, "compress");
@ -100,11 +100,14 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
err = uncompress(uncompr, &uncomprLen, compr, comprLen); err = uncompress(uncompr, &uncomprLen, compr, comprLen);
CHECK_ERR(err, "uncompress"); CHECK_ERR(err, "uncompress");
if (strcmp((char*)uncompr, hello)) { if (strcmp((char*)uncompr, hello))
{
fprintf(stderr, "bad uncompress\n"); fprintf(stderr, "bad uncompress\n");
exit(1); exit(1);
} else { }
printf("uncompress(): %s\n", (char *)uncompr); else
{
printf("uncompress(): %s\n", (char*)uncompr);
} }
} }
@ -112,79 +115,105 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
* Test read/write of .gz files * Test read/write of .gz files
*/ */
void test_gzio(fname, uncompr, uncomprLen) void test_gzio(fname, uncompr, uncomprLen)
const char *fname; /* compressed file name */ const char* fname; /* compressed file name */
Byte *uncompr; Byte* uncompr;
uLong uncomprLen; uLong uncomprLen;
{ {
#ifdef NO_GZCOMPRESS #ifdef NO_GZCOMPRESS
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
#else #else
int err; int err;
int len = (int)strlen(hello)+1; int len = (int)strlen(hello) + 1;
gzFile file; gzFile file;
z_off_t pos; z_off_t pos;
file = gzopen(fname, "wb"); file = gzopen(fname, "wb");
if (file == NULL) {
if (file == NULL)
{
fprintf(stderr, "gzopen error\n"); fprintf(stderr, "gzopen error\n");
exit(1); exit(1);
} }
gzputc(file, 'h'); gzputc(file, 'h');
if (gzputs(file, "ello") != 4) {
if (gzputs(file, "ello") != 4)
{
fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err)); fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
exit(1); exit(1);
} }
if (gzprintf(file, ", %s!", "hello") != 8) {
if (gzprintf(file, ", %s!", "hello") != 8)
{
fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
exit(1); exit(1);
} }
gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
gzclose(file); gzclose(file);
file = gzopen(fname, "rb"); file = gzopen(fname, "rb");
if (file == NULL) {
if (file == NULL)
{
fprintf(stderr, "gzopen error\n"); fprintf(stderr, "gzopen error\n");
exit(1); exit(1);
} }
strcpy((char*)uncompr, "garbage"); strcpy((char*)uncompr, "garbage");
if (gzread(file, uncompr, (unsigned)uncomprLen) != len) { if (gzread(file, uncompr, (unsigned)uncomprLen) != len)
{
fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
exit(1); exit(1);
} }
if (strcmp((char*)uncompr, hello)) {
if (strcmp((char*)uncompr, hello))
{
fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
exit(1); exit(1);
} else { }
else
{
printf("gzread(): %s\n", (char*)uncompr); printf("gzread(): %s\n", (char*)uncompr);
} }
pos = gzseek(file, -8L, SEEK_CUR); pos = gzseek(file, -8L, SEEK_CUR);
if (pos != 6 || gztell(file) != pos) {
if (pos != 6 || gztell(file) != pos)
{
fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
(long)pos, (long)gztell(file)); (long)pos, (long)gztell(file));
exit(1); exit(1);
} }
if (gzgetc(file) != ' ') { if (gzgetc(file) != ' ')
{
fprintf(stderr, "gzgetc error\n"); fprintf(stderr, "gzgetc error\n");
exit(1); exit(1);
} }
if (gzungetc(' ', file) != ' ') { if (gzungetc(' ', file) != ' ')
{
fprintf(stderr, "gzungetc error\n"); fprintf(stderr, "gzungetc error\n");
exit(1); exit(1);
} }
gzgets(file, (char*)uncompr, (int)uncomprLen); gzgets(file, (char*)uncompr, (int)uncomprLen);
if (strlen((char*)uncompr) != 7) { /* " hello!" */
if (strlen((char*)uncompr) != 7) /* " hello!" */
{
fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
exit(1); exit(1);
} }
if (strcmp((char*)uncompr, hello + 6)) {
if (strcmp((char*)uncompr, hello + 6))
{
fprintf(stderr, "bad gzgets after gzseek\n"); fprintf(stderr, "bad gzgets after gzseek\n");
exit(1); exit(1);
} else { }
else
{
printf("gzgets() after gzseek: %s\n", (char*)uncompr); printf("gzgets() after gzseek: %s\n", (char*)uncompr);
} }
@ -198,12 +227,12 @@ void test_gzio(fname, uncompr, uncomprLen)
* Test deflate() with small buffers * Test deflate() with small buffers
*/ */
void test_deflate(compr, comprLen) void test_deflate(compr, comprLen)
Byte *compr; Byte* compr;
uLong comprLen; uLong comprLen;
{ {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
uLong len = (uLong)strlen(hello)+1; uLong len = (uLong)strlen(hello) + 1;
c_stream.zalloc = zalloc; c_stream.zalloc = zalloc;
c_stream.zfree = zfree; c_stream.zfree = zfree;
@ -215,16 +244,21 @@ void test_deflate(compr, comprLen)
c_stream.next_in = (Bytef*)hello; c_stream.next_in = (Bytef*)hello;
c_stream.next_out = compr; c_stream.next_out = compr;
while (c_stream.total_in != len && c_stream.total_out < comprLen) { while (c_stream.total_in != len && c_stream.total_out < comprLen)
{
c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */
err = deflate(&c_stream, Z_NO_FLUSH); err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate"); CHECK_ERR(err, "deflate");
} }
/* Finish the stream, still forcing small buffers: */ /* Finish the stream, still forcing small buffers: */
for (;;) { for (;;)
{
c_stream.avail_out = 1; c_stream.avail_out = 1;
err = deflate(&c_stream, Z_FINISH); err = deflate(&c_stream, Z_FINISH);
if (err == Z_STREAM_END) break; if (err == Z_STREAM_END) break;
CHECK_ERR(err, "deflate"); CHECK_ERR(err, "deflate");
} }
@ -236,8 +270,8 @@ void test_deflate(compr, comprLen)
* Test inflate() with small buffers * Test inflate() with small buffers
*/ */
void test_inflate(compr, comprLen, uncompr, uncomprLen) void test_inflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr; Byte* compr, *uncompr;
uLong comprLen, uncomprLen; uLong comprLen, uncomprLen;
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -255,21 +289,27 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
err = inflateInit(&d_stream); err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit"); CHECK_ERR(err, "inflateInit");
while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen)
{
d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */
err = inflate(&d_stream, Z_NO_FLUSH); err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break; if (err == Z_STREAM_END) break;
CHECK_ERR(err, "inflate"); CHECK_ERR(err, "inflate");
} }
err = inflateEnd(&d_stream); err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd"); CHECK_ERR(err, "inflateEnd");
if (strcmp((char*)uncompr, hello)) { if (strcmp((char*)uncompr, hello))
{
fprintf(stderr, "bad inflate\n"); fprintf(stderr, "bad inflate\n");
exit(1); exit(1);
} else { }
printf("inflate(): %s\n", (char *)uncompr); else
{
printf("inflate(): %s\n", (char*)uncompr);
} }
} }
@ -277,8 +317,8 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
* Test deflate() with large buffers and dynamic change of compression level * Test deflate() with large buffers and dynamic change of compression level
*/ */
void test_large_deflate(compr, comprLen, uncompr, uncomprLen) void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr; Byte* compr, *uncompr;
uLong comprLen, uncomprLen; uLong comprLen, uncomprLen;
{ {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
@ -300,7 +340,9 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
c_stream.avail_in = (uInt)uncomprLen; c_stream.avail_in = (uInt)uncomprLen;
err = deflate(&c_stream, Z_NO_FLUSH); err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate"); CHECK_ERR(err, "deflate");
if (c_stream.avail_in != 0) {
if (c_stream.avail_in != 0)
{
fprintf(stderr, "deflate not greedy\n"); fprintf(stderr, "deflate not greedy\n");
exit(1); exit(1);
} }
@ -308,7 +350,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
/* Feed in already compressed data and switch to no compression: */ /* Feed in already compressed data and switch to no compression: */
deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
c_stream.next_in = compr; c_stream.next_in = compr;
c_stream.avail_in = (uInt)comprLen/2; c_stream.avail_in = (uInt)comprLen / 2;
err = deflate(&c_stream, Z_NO_FLUSH); err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate"); CHECK_ERR(err, "deflate");
@ -320,10 +362,13 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
CHECK_ERR(err, "deflate"); CHECK_ERR(err, "deflate");
err = deflate(&c_stream, Z_FINISH); err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
if (err != Z_STREAM_END)
{
fprintf(stderr, "deflate should report Z_STREAM_END\n"); fprintf(stderr, "deflate should report Z_STREAM_END\n");
exit(1); exit(1);
} }
err = deflateEnd(&c_stream); err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd"); CHECK_ERR(err, "deflateEnd");
} }
@ -332,8 +377,8 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
* Test inflate() with large buffers * Test inflate() with large buffers
*/ */
void test_large_inflate(compr, comprLen, uncompr, uncomprLen) void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr; Byte* compr, *uncompr;
uLong comprLen, uncomprLen; uLong comprLen, uncomprLen;
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -350,21 +395,27 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
err = inflateInit(&d_stream); err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit"); CHECK_ERR(err, "inflateInit");
for (;;) { for (;;)
{
d_stream.next_out = uncompr; /* discard the output */ d_stream.next_out = uncompr; /* discard the output */
d_stream.avail_out = (uInt)uncomprLen; d_stream.avail_out = (uInt)uncomprLen;
err = inflate(&d_stream, Z_NO_FLUSH); err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break; if (err == Z_STREAM_END) break;
CHECK_ERR(err, "large inflate"); CHECK_ERR(err, "large inflate");
} }
err = inflateEnd(&d_stream); err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd"); CHECK_ERR(err, "inflateEnd");
if (d_stream.total_out != 2*uncomprLen + comprLen/2) { if (d_stream.total_out != 2 * uncomprLen + comprLen / 2)
{
fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
exit(1); exit(1);
} else { }
else
{
printf("large_inflate(): OK\n"); printf("large_inflate(): OK\n");
} }
} }
@ -373,12 +424,12 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
* Test deflate() with full flush * Test deflate() with full flush
*/ */
void test_flush(compr, comprLen) void test_flush(compr, comprLen)
Byte *compr; Byte* compr;
uLong *comprLen; uLong* comprLen;
{ {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
uInt len = (uInt)strlen(hello)+1; uInt len = (uInt)strlen(hello) + 1;
c_stream.zalloc = zalloc; c_stream.zalloc = zalloc;
c_stream.zfree = zfree; c_stream.zfree = zfree;
@ -390,7 +441,7 @@ void test_flush(compr, comprLen)
c_stream.next_in = (Bytef*)hello; c_stream.next_in = (Bytef*)hello;
c_stream.next_out = compr; c_stream.next_out = compr;
c_stream.avail_in = 3; c_stream.avail_in = 3;
c_stream.avail_out = (uInt)*comprLen; c_stream.avail_out = (uInt) * comprLen;
err = deflate(&c_stream, Z_FULL_FLUSH); err = deflate(&c_stream, Z_FULL_FLUSH);
CHECK_ERR(err, "deflate"); CHECK_ERR(err, "deflate");
@ -398,9 +449,12 @@ void test_flush(compr, comprLen)
c_stream.avail_in = len - 3; c_stream.avail_in = len - 3;
err = deflate(&c_stream, Z_FINISH); err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
if (err != Z_STREAM_END)
{
CHECK_ERR(err, "deflate"); CHECK_ERR(err, "deflate");
} }
err = deflateEnd(&c_stream); err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd"); CHECK_ERR(err, "deflateEnd");
@ -411,8 +465,8 @@ void test_flush(compr, comprLen)
* Test inflateSync() * Test inflateSync()
*/ */
void test_sync(compr, comprLen, uncompr, uncomprLen) void test_sync(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr; Byte* compr, *uncompr;
uLong comprLen, uncomprLen; uLong comprLen, uncomprLen;
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -435,28 +489,31 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
inflate(&d_stream, Z_NO_FLUSH); inflate(&d_stream, Z_NO_FLUSH);
CHECK_ERR(err, "inflate"); CHECK_ERR(err, "inflate");
d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */ d_stream.avail_in = (uInt)comprLen - 2; /* read all compressed data */
err = inflateSync(&d_stream); /* but skip the damaged part */ err = inflateSync(&d_stream); /* but skip the damaged part */
CHECK_ERR(err, "inflateSync"); CHECK_ERR(err, "inflateSync");
err = inflate(&d_stream, Z_FINISH); err = inflate(&d_stream, Z_FINISH);
if (err != Z_DATA_ERROR) {
if (err != Z_DATA_ERROR)
{
fprintf(stderr, "inflate should report DATA_ERROR\n"); fprintf(stderr, "inflate should report DATA_ERROR\n");
/* Because of incorrect adler32 */ /* Because of incorrect adler32 */
exit(1); exit(1);
} }
err = inflateEnd(&d_stream); err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd"); CHECK_ERR(err, "inflateEnd");
printf("after inflateSync(): hel%s\n", (char *)uncompr); printf("after inflateSync(): hel%s\n", (char*)uncompr);
} }
/* =========================================================================== /* ===========================================================================
* Test deflate() with preset dictionary * Test deflate() with preset dictionary
*/ */
void test_dict_deflate(compr, comprLen) void test_dict_deflate(compr, comprLen)
Byte *compr; Byte* compr;
uLong comprLen; uLong comprLen;
{ {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
@ -469,7 +526,7 @@ void test_dict_deflate(compr, comprLen)
CHECK_ERR(err, "deflateInit"); CHECK_ERR(err, "deflateInit");
err = deflateSetDictionary(&c_stream, err = deflateSetDictionary(&c_stream,
(const Bytef*)dictionary, (int)sizeof(dictionary)); (const Bytef*)dictionary, (int)sizeof(dictionary));
CHECK_ERR(err, "deflateSetDictionary"); CHECK_ERR(err, "deflateSetDictionary");
dictId = c_stream.adler; dictId = c_stream.adler;
@ -477,13 +534,16 @@ void test_dict_deflate(compr, comprLen)
c_stream.avail_out = (uInt)comprLen; c_stream.avail_out = (uInt)comprLen;
c_stream.next_in = (Bytef*)hello; c_stream.next_in = (Bytef*)hello;
c_stream.avail_in = (uInt)strlen(hello)+1; c_stream.avail_in = (uInt)strlen(hello) + 1;
err = deflate(&c_stream, Z_FINISH); err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
if (err != Z_STREAM_END)
{
fprintf(stderr, "deflate should report Z_STREAM_END\n"); fprintf(stderr, "deflate should report Z_STREAM_END\n");
exit(1); exit(1);
} }
err = deflateEnd(&c_stream); err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd"); CHECK_ERR(err, "deflateEnd");
} }
@ -492,8 +552,8 @@ void test_dict_deflate(compr, comprLen)
* Test inflate() with a preset dictionary * Test inflate() with a preset dictionary
*/ */
void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr; Byte* compr, *uncompr;
uLong comprLen, uncomprLen; uLong comprLen, uncomprLen;
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -513,28 +573,38 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
d_stream.next_out = uncompr; d_stream.next_out = uncompr;
d_stream.avail_out = (uInt)uncomprLen; d_stream.avail_out = (uInt)uncomprLen;
for (;;) { for (;;)
{
err = inflate(&d_stream, Z_NO_FLUSH); err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break; if (err == Z_STREAM_END) break;
if (err == Z_NEED_DICT) {
if (d_stream.adler != dictId) { if (err == Z_NEED_DICT)
{
if (d_stream.adler != dictId)
{
fprintf(stderr, "unexpected dictionary"); fprintf(stderr, "unexpected dictionary");
exit(1); exit(1);
} }
err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary, err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
(int)sizeof(dictionary)); (int)sizeof(dictionary));
} }
CHECK_ERR(err, "inflate with dict"); CHECK_ERR(err, "inflate with dict");
} }
err = inflateEnd(&d_stream); err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd"); CHECK_ERR(err, "inflateEnd");
if (strcmp((char*)uncompr, hello)) { if (strcmp((char*)uncompr, hello))
{
fprintf(stderr, "bad inflate with dict\n"); fprintf(stderr, "bad inflate with dict\n");
exit(1); exit(1);
} else { }
printf("inflate with dictionary: %s\n", (char *)uncompr); else
{
printf("inflate with dictionary: %s\n", (char*)uncompr);
} }
} }
@ -543,31 +613,36 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
*/ */
int main(argc, argv) int main(argc, argv)
int argc; int argc;
char *argv[]; char* argv[];
{ {
Byte *compr, *uncompr; Byte* compr, *uncompr;
uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ uLong comprLen = 10000 * sizeof(int); /* don't overflow on MSDOS */
uLong uncomprLen = comprLen; uLong uncomprLen = comprLen;
static const char* myVersion = ZLIB_VERSION; static const char* myVersion = ZLIB_VERSION;
if (zlibVersion()[0] != myVersion[0]) { if (zlibVersion()[0] != myVersion[0])
{
fprintf(stderr, "incompatible zlib version\n"); fprintf(stderr, "incompatible zlib version\n");
exit(1); exit(1);
} else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { }
else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0)
{
fprintf(stderr, "warning: different zlib version\n"); fprintf(stderr, "warning: different zlib version\n");
} }
printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags());
compr = (Byte*)calloc((uInt)comprLen, 1); compr = (Byte*)calloc((uInt)comprLen, 1);
uncompr = (Byte*)calloc((uInt)uncomprLen, 1); uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
/* compr and uncompr are cleared to avoid reading uninitialized /* compr and uncompr are cleared to avoid reading uninitialized
* data and to ensure that uncompr compresses well. * data and to ensure that uncompr compresses well.
*/ */
if (compr == Z_NULL || uncompr == Z_NULL) { if (compr == Z_NULL || uncompr == Z_NULL)
{
printf("out of memory\n"); printf("out of memory\n");
exit(1); exit(1);
} }

View File

@ -53,26 +53,28 @@
*/ */
/* these items are strung together in a linked list, one for each allocation */ /* these items are strung together in a linked list, one for each allocation */
struct mem_item { struct mem_item
void *ptr; /* pointer to allocated memory */ {
void* ptr; /* pointer to allocated memory */
size_t size; /* requested size of allocation */ size_t size; /* requested size of allocation */
struct mem_item *next; /* pointer to next item in list, or NULL */ struct mem_item* next; /* pointer to next item in list, or NULL */
}; };
/* this structure is at the root of the linked list, and tracks statistics */ /* this structure is at the root of the linked list, and tracks statistics */
struct mem_zone { struct mem_zone
struct mem_item *first; /* pointer to first item in list, or NULL */ {
struct mem_item* first; /* pointer to first item in list, or NULL */
size_t total, highwater; /* total allocations, and largest total */ size_t total, highwater; /* total allocations, and largest total */
size_t limit; /* memory allocation limit, or 0 if no limit */ size_t limit; /* memory allocation limit, or 0 if no limit */
int notlifo, rogue; /* counts of non-LIFO frees and rogue frees */ int notlifo, rogue; /* counts of non-LIFO frees and rogue frees */
}; };
/* memory allocation routine to pass to zlib */ /* memory allocation routine to pass to zlib */
local void *mem_alloc(void *mem, unsigned count, unsigned size) local void* mem_alloc(void* mem, unsigned count, unsigned size)
{ {
void *ptr; void* ptr;
struct mem_item *item; struct mem_item* item;
struct mem_zone *zone = mem; struct mem_zone* zone = mem;
size_t len = count * (size_t)size; size_t len = count * (size_t)size;
/* induced allocation failure */ /* induced allocation failure */
@ -82,16 +84,21 @@ local void *mem_alloc(void *mem, unsigned count, unsigned size)
/* perform allocation using the standard library, fill memory with a /* perform allocation using the standard library, fill memory with a
non-zero value to make sure that the code isn't depending on zeros */ non-zero value to make sure that the code isn't depending on zeros */
ptr = malloc(len); ptr = malloc(len);
if (ptr == NULL) if (ptr == NULL)
return NULL; return NULL;
memset(ptr, 0xa5, len); memset(ptr, 0xa5, len);
/* create a new item for the list */ /* create a new item for the list */
item = malloc(sizeof(struct mem_item)); item = malloc(sizeof(struct mem_item));
if (item == NULL) {
if (item == NULL)
{
free(ptr); free(ptr);
return NULL; return NULL;
} }
item->ptr = ptr; item->ptr = ptr;
item->size = len; item->size = len;
@ -101,6 +108,7 @@ local void *mem_alloc(void *mem, unsigned count, unsigned size)
/* update the statistics */ /* update the statistics */
zone->total += item->size; zone->total += item->size;
if (zone->total > zone->highwater) if (zone->total > zone->highwater)
zone->highwater = zone->total; zone->highwater = zone->total;
@ -109,13 +117,14 @@ local void *mem_alloc(void *mem, unsigned count, unsigned size)
} }
/* memory free routine to pass to zlib */ /* memory free routine to pass to zlib */
local void mem_free(void *mem, void *ptr) local void mem_free(void* mem, void* ptr)
{ {
struct mem_item *item, *next; struct mem_item* item, *next;
struct mem_zone *zone = mem; struct mem_zone* zone = mem;
/* if no zone, just do a free */ /* if no zone, just do a free */
if (zone == NULL) { if (zone == NULL)
{
free(ptr); free(ptr);
return; return;
} }
@ -123,15 +132,22 @@ local void mem_free(void *mem, void *ptr)
/* point next to the item that matches ptr, or NULL if not found -- remove /* point next to the item that matches ptr, or NULL if not found -- remove
the item from the linked list if found */ the item from the linked list if found */
next = zone->first; next = zone->first;
if (next) {
if (next)
{
if (next->ptr == ptr) if (next->ptr == ptr)
zone->first = next->next; /* first one is it, remove from list */ zone->first = next->next; /* first one is it, remove from list */
else { else
do { /* search the linked list */ {
do /* search the linked list */
{
item = next; item = next;
next = item->next; next = item->next;
} while (next != NULL && next->ptr != ptr); }
if (next) { /* if found, remove from linked list */ while (next != NULL && next->ptr != ptr);
if (next) /* if found, remove from linked list */
{
item->next = next->next; item->next = next->next;
zone->notlifo++; /* not a LIFO free */ zone->notlifo++; /* not a LIFO free */
} }
@ -140,7 +156,8 @@ local void mem_free(void *mem, void *ptr)
} }
/* if found, update the statistics and free the item */ /* if found, update the statistics and free the item */
if (next) { if (next)
{
zone->total -= next->size; zone->total -= next->size;
free(next); free(next);
} }
@ -155,9 +172,9 @@ local void mem_free(void *mem, void *ptr)
/* set up a controlled memory allocation space for monitoring, set the stream /* set up a controlled memory allocation space for monitoring, set the stream
parameters to the controlled routines, with opaque pointing to the space */ parameters to the controlled routines, with opaque pointing to the space */
local void mem_setup(z_stream *strm) local void mem_setup(z_stream* strm)
{ {
struct mem_zone *zone; struct mem_zone* zone;
zone = malloc(sizeof(struct mem_zone)); zone = malloc(sizeof(struct mem_zone));
assert(zone != NULL); assert(zone != NULL);
@ -173,42 +190,44 @@ local void mem_setup(z_stream *strm)
} }
/* set a limit on the total memory allocation, or 0 to remove the limit */ /* set a limit on the total memory allocation, or 0 to remove the limit */
local void mem_limit(z_stream *strm, size_t limit) local void mem_limit(z_stream* strm, size_t limit)
{ {
struct mem_zone *zone = strm->opaque; struct mem_zone* zone = strm->opaque;
zone->limit = limit; zone->limit = limit;
} }
/* show the current total requested allocations in bytes */ /* show the current total requested allocations in bytes */
local void mem_used(z_stream *strm, char *prefix) local void mem_used(z_stream* strm, char* prefix)
{ {
struct mem_zone *zone = strm->opaque; struct mem_zone* zone = strm->opaque;
fprintf(stderr, "%s: %lu allocated\n", prefix, zone->total); fprintf(stderr, "%s: %lu allocated\n", prefix, zone->total);
} }
/* show the high water allocation in bytes */ /* show the high water allocation in bytes */
local void mem_high(z_stream *strm, char *prefix) local void mem_high(z_stream* strm, char* prefix)
{ {
struct mem_zone *zone = strm->opaque; struct mem_zone* zone = strm->opaque;
fprintf(stderr, "%s: %lu high water mark\n", prefix, zone->highwater); fprintf(stderr, "%s: %lu high water mark\n", prefix, zone->highwater);
} }
/* release the memory allocation zone -- if there are any surprises, notify */ /* release the memory allocation zone -- if there are any surprises, notify */
local void mem_done(z_stream *strm, char *prefix) local void mem_done(z_stream* strm, char* prefix)
{ {
int count = 0; int count = 0;
struct mem_item *item, *next; struct mem_item* item, *next;
struct mem_zone *zone = strm->opaque; struct mem_zone* zone = strm->opaque;
/* show high water mark */ /* show high water mark */
mem_high(strm, prefix); mem_high(strm, prefix);
/* free leftover allocations and item structures, if any */ /* free leftover allocations and item structures, if any */
item = zone->first; item = zone->first;
while (item != NULL) {
while (item != NULL)
{
free(item->ptr); free(item->ptr);
next = item->next; next = item->next;
free(item); free(item);
@ -220,8 +239,10 @@ local void mem_done(z_stream *strm, char *prefix)
if (count || zone->total) if (count || zone->total)
fprintf(stderr, "** %s: %lu bytes in %d blocks not freed\n", fprintf(stderr, "** %s: %lu bytes in %d blocks not freed\n",
prefix, zone->total, count); prefix, zone->total, count);
if (zone->notlifo) if (zone->notlifo)
fprintf(stderr, "** %s: %d frees not LIFO\n", prefix, zone->notlifo); fprintf(stderr, "** %s: %d frees not LIFO\n", prefix, zone->notlifo);
if (zone->rogue) if (zone->rogue)
fprintf(stderr, "** %s: %d frees not recognized\n", fprintf(stderr, "** %s: %d frees not recognized\n",
prefix, zone->rogue); prefix, zone->rogue);
@ -242,17 +263,21 @@ local void mem_done(z_stream *strm, char *prefix)
delimiter in which case that single digit writes a byte. The returned delimiter in which case that single digit writes a byte. The returned
data is allocated and must eventually be freed. NULL is returned if out of data is allocated and must eventually be freed. NULL is returned if out of
memory. If the length is not needed, then len can be NULL. */ memory. If the length is not needed, then len can be NULL. */
local unsigned char *h2b(const char *hex, unsigned *len) local unsigned char* h2b(const char* hex, unsigned* len)
{ {
unsigned char *in; unsigned char* in;
unsigned next, val; unsigned next, val;
in = malloc((strlen(hex) + 1) >> 1); in = malloc((strlen(hex) + 1) >> 1);
if (in == NULL) if (in == NULL)
return NULL; return NULL;
next = 0; next = 0;
val = 1; val = 1;
do {
do
{
if (*hex >= '0' && *hex <= '9') if (*hex >= '0' && *hex <= '9')
val = (val << 4) + *hex - '0'; val = (val << 4) + *hex - '0';
else if (*hex >= 'A' && *hex <= 'F') else if (*hex >= 'A' && *hex <= 'F')
@ -261,13 +286,18 @@ local unsigned char *h2b(const char *hex, unsigned *len)
val = (val << 4) + *hex - 'a' + 10; val = (val << 4) + *hex - 'a' + 10;
else if (val != 1 && val < 32) /* one digit followed by delimiter */ else if (val != 1 && val < 32) /* one digit followed by delimiter */
val += 240; /* make it look like two digits */ val += 240; /* make it look like two digits */
if (val > 255) { /* have two digits */
if (val > 255) /* have two digits */
{
in[next++] = val & 0xff; /* save the decoded byte */ in[next++] = val & 0xff; /* save the decoded byte */
val = 1; /* start over */ val = 1; /* start over */
} }
} while (*hex++); /* go through the loop with the terminating null */ }
while (*hex++); /* go through the loop with the terminating null */
if (len != NULL) if (len != NULL)
*len = next; *len = next;
in = reallocf(in, next); in = reallocf(in, next);
return in; return in;
} }
@ -281,12 +311,12 @@ local unsigned char *h2b(const char *hex, unsigned *len)
header information is collected with inflateGetHeader(). If a zlib stream header information is collected with inflateGetHeader(). If a zlib stream
is looking for a dictionary, then an empty dictionary is provided. is looking for a dictionary, then an empty dictionary is provided.
inflate() is run until all of the input data is consumed. */ inflate() is run until all of the input data is consumed. */
local void inf(char *hex, char *what, unsigned step, int win, unsigned len, local void inf(char* hex, char* what, unsigned step, int win, unsigned len,
int err) int err)
{ {
int ret; int ret;
unsigned have; unsigned have;
unsigned char *in, *out; unsigned char* in, *out;
z_stream strm, copy; z_stream strm, copy;
gz_header head; gz_header head;
@ -294,55 +324,80 @@ local void inf(char *hex, char *what, unsigned step, int win, unsigned len,
strm.avail_in = 0; strm.avail_in = 0;
strm.next_in = Z_NULL; strm.next_in = Z_NULL;
ret = inflateInit2(&strm, win); ret = inflateInit2(&strm, win);
if (ret != Z_OK) {
if (ret != Z_OK)
{
mem_done(&strm, what); mem_done(&strm, what);
return; return;
} }
out = malloc(len); assert(out != NULL);
if (win == 47) { out = malloc(len);
assert(out != NULL);
if (win == 47)
{
head.extra = out; head.extra = out;
head.extra_max = len; head.extra_max = len;
head.name = out; head.name = out;
head.name_max = len; head.name_max = len;
head.comment = out; head.comment = out;
head.comm_max = len; head.comm_max = len;
ret = inflateGetHeader(&strm, &head); assert(ret == Z_OK); ret = inflateGetHeader(&strm, &head);
assert(ret == Z_OK);
} }
in = h2b(hex, &have); assert(in != NULL);
in = h2b(hex, &have);
assert(in != NULL);
if (step == 0 || step > have) if (step == 0 || step > have)
step = have; step = have;
strm.avail_in = step; strm.avail_in = step;
have -= step; have -= step;
strm.next_in = in; strm.next_in = in;
do {
do
{
strm.avail_out = len; strm.avail_out = len;
strm.next_out = out; strm.next_out = out;
ret = inflate(&strm, Z_NO_FLUSH); assert(err == 9 || ret == err); ret = inflate(&strm, Z_NO_FLUSH);
assert(err == 9 || ret == err);
if (ret != Z_OK && ret != Z_BUF_ERROR && ret != Z_NEED_DICT) if (ret != Z_OK && ret != Z_BUF_ERROR && ret != Z_NEED_DICT)
break; break;
if (ret == Z_NEED_DICT) {
if (ret == Z_NEED_DICT)
{
ret = inflateSetDictionary(&strm, in, 1); ret = inflateSetDictionary(&strm, in, 1);
assert(ret == Z_DATA_ERROR); assert(ret == Z_DATA_ERROR);
mem_limit(&strm, 1); mem_limit(&strm, 1);
ret = inflateSetDictionary(&strm, out, 0); ret = inflateSetDictionary(&strm, out, 0);
assert(ret == Z_MEM_ERROR); assert(ret == Z_MEM_ERROR);
mem_limit(&strm, 0); mem_limit(&strm, 0);
((struct inflate_state *)strm.state)->mode = DICT; ((struct inflate_state*)strm.state)->mode = DICT;
ret = inflateSetDictionary(&strm, out, 0); ret = inflateSetDictionary(&strm, out, 0);
assert(ret == Z_OK); assert(ret == Z_OK);
ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_BUF_ERROR); ret = inflate(&strm, Z_NO_FLUSH);
assert(ret == Z_BUF_ERROR);
} }
ret = inflateCopy(&copy, &strm); assert(ret == Z_OK);
ret = inflateEnd(&copy); assert(ret == Z_OK); ret = inflateCopy(&copy, &strm);
assert(ret == Z_OK);
ret = inflateEnd(&copy);
assert(ret == Z_OK);
err = 9; /* don't care next time around */ err = 9; /* don't care next time around */
have += strm.avail_in; have += strm.avail_in;
strm.avail_in = step > have ? have : step; strm.avail_in = step > have ? have : step;
have -= strm.avail_in; have -= strm.avail_in;
} while (strm.avail_in); }
while (strm.avail_in);
free(in); free(in);
free(out); free(out);
ret = inflateReset2(&strm, -8); assert(ret == Z_OK); ret = inflateReset2(&strm, -8);
ret = inflateEnd(&strm); assert(ret == Z_OK); assert(ret == Z_OK);
ret = inflateEnd(&strm);
assert(ret == Z_OK);
mem_done(&strm, what); mem_done(&strm, what);
} }
@ -355,13 +410,17 @@ local void cover_support(void)
mem_setup(&strm); mem_setup(&strm);
strm.avail_in = 0; strm.avail_in = 0;
strm.next_in = Z_NULL; strm.next_in = Z_NULL;
ret = inflateInit(&strm); assert(ret == Z_OK); ret = inflateInit(&strm);
assert(ret == Z_OK);
mem_used(&strm, "inflate init"); mem_used(&strm, "inflate init");
ret = inflatePrime(&strm, 5, 31); assert(ret == Z_OK); ret = inflatePrime(&strm, 5, 31);
ret = inflatePrime(&strm, -1, 0); assert(ret == Z_OK); assert(ret == Z_OK);
ret = inflatePrime(&strm, -1, 0);
assert(ret == Z_OK);
ret = inflateSetDictionary(&strm, Z_NULL, 0); ret = inflateSetDictionary(&strm, Z_NULL, 0);
assert(ret == Z_STREAM_ERROR); assert(ret == Z_STREAM_ERROR);
ret = inflateEnd(&strm); assert(ret == Z_OK); ret = inflateEnd(&strm);
assert(ret == Z_OK);
mem_done(&strm, "prime"); mem_done(&strm, "prime");
inf("63 0", "force window allocation", 0, -15, 1, Z_OK); inf("63 0", "force window allocation", 0, -15, 1, Z_OK);
@ -374,13 +433,15 @@ local void cover_support(void)
strm.avail_in = 0; strm.avail_in = 0;
strm.next_in = Z_NULL; strm.next_in = Z_NULL;
ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream)); ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream));
assert(ret == Z_VERSION_ERROR); assert(ret == Z_VERSION_ERROR);
mem_done(&strm, "wrong version"); mem_done(&strm, "wrong version");
strm.avail_in = 0; strm.avail_in = 0;
strm.next_in = Z_NULL; strm.next_in = Z_NULL;
ret = inflateInit(&strm); assert(ret == Z_OK); ret = inflateInit(&strm);
ret = inflateEnd(&strm); assert(ret == Z_OK); assert(ret == Z_OK);
ret = inflateEnd(&strm);
assert(ret == Z_OK);
fputs("inflate built-in memory routines\n", stderr); fputs("inflate built-in memory routines\n", stderr);
} }
@ -391,9 +452,12 @@ local void cover_wrap(void)
z_stream strm, copy; z_stream strm, copy;
unsigned char dict[257]; unsigned char dict[257];
ret = inflate(Z_NULL, 0); assert(ret == Z_STREAM_ERROR); ret = inflate(Z_NULL, 0);
ret = inflateEnd(Z_NULL); assert(ret == Z_STREAM_ERROR); assert(ret == Z_STREAM_ERROR);
ret = inflateCopy(Z_NULL, Z_NULL); assert(ret == Z_STREAM_ERROR); ret = inflateEnd(Z_NULL);
assert(ret == Z_STREAM_ERROR);
ret = inflateCopy(Z_NULL, Z_NULL);
assert(ret == Z_STREAM_ERROR);
fputs("inflate bad parameters\n", stderr); fputs("inflate bad parameters\n", stderr);
inf("1f 8b 0 0", "bad gzip method", 0, 31, 0, Z_DATA_ERROR); inf("1f 8b 0 0", "bad gzip method", 0, 31, 0, Z_DATA_ERROR);
@ -415,52 +479,65 @@ local void cover_wrap(void)
strm.next_in = Z_NULL; strm.next_in = Z_NULL;
ret = inflateInit2(&strm, -8); ret = inflateInit2(&strm, -8);
strm.avail_in = 2; strm.avail_in = 2;
strm.next_in = (void *)"\x63"; strm.next_in = (void*)"\x63";
strm.avail_out = 1; strm.avail_out = 1;
strm.next_out = (void *)&ret; strm.next_out = (void*)&ret;
mem_limit(&strm, 1); mem_limit(&strm, 1);
ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); ret = inflate(&strm, Z_NO_FLUSH);
ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); assert(ret == Z_MEM_ERROR);
ret = inflate(&strm, Z_NO_FLUSH);
assert(ret == Z_MEM_ERROR);
mem_limit(&strm, 0); mem_limit(&strm, 0);
memset(dict, 0, 257); memset(dict, 0, 257);
ret = inflateSetDictionary(&strm, dict, 257); ret = inflateSetDictionary(&strm, dict, 257);
assert(ret == Z_OK); assert(ret == Z_OK);
mem_limit(&strm, (sizeof(struct inflate_state) << 1) + 256); mem_limit(&strm, (sizeof(struct inflate_state) << 1) + 256);
ret = inflatePrime(&strm, 16, 0); assert(ret == Z_OK); ret = inflatePrime(&strm, 16, 0);
assert(ret == Z_OK);
strm.avail_in = 2; strm.avail_in = 2;
strm.next_in = (void *)"\x80"; strm.next_in = (void*)"\x80";
ret = inflateSync(&strm); assert(ret == Z_DATA_ERROR); ret = inflateSync(&strm);
ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_STREAM_ERROR); assert(ret == Z_DATA_ERROR);
ret = inflate(&strm, Z_NO_FLUSH);
assert(ret == Z_STREAM_ERROR);
strm.avail_in = 4; strm.avail_in = 4;
strm.next_in = (void *)"\0\0\xff\xff"; strm.next_in = (void*)"\0\0\xff\xff";
ret = inflateSync(&strm); assert(ret == Z_OK); ret = inflateSync(&strm);
assert(ret == Z_OK);
(void)inflateSyncPoint(&strm); (void)inflateSyncPoint(&strm);
ret = inflateCopy(&copy, &strm); assert(ret == Z_MEM_ERROR); ret = inflateCopy(&copy, &strm);
assert(ret == Z_MEM_ERROR);
mem_limit(&strm, 0); mem_limit(&strm, 0);
ret = inflateUndermine(&strm, 1); assert(ret == Z_DATA_ERROR); ret = inflateUndermine(&strm, 1);
assert(ret == Z_DATA_ERROR);
(void)inflateMark(&strm); (void)inflateMark(&strm);
ret = inflateEnd(&strm); assert(ret == Z_OK); ret = inflateEnd(&strm);
assert(ret == Z_OK);
mem_done(&strm, "miscellaneous, force memory errors"); mem_done(&strm, "miscellaneous, force memory errors");
} }
/* input and output functions for inflateBack() */ /* input and output functions for inflateBack() */
local unsigned pull(void *desc, unsigned char **buf) local unsigned pull(void* desc, unsigned char** buf)
{ {
static unsigned int next = 0; static unsigned int next = 0;
static unsigned char dat[] = {0x63, 0, 2, 0}; static unsigned char dat[] = {0x63, 0, 2, 0};
struct inflate_state *state; struct inflate_state* state;
if (desc == Z_NULL) { if (desc == Z_NULL)
{
next = 0; next = 0;
return 0; /* no input (already provided at next_in) */ return 0; /* no input (already provided at next_in) */
} }
state = (void *)((z_stream *)desc)->state;
state = (void*)((z_stream*)desc)->state;
if (state != Z_NULL) if (state != Z_NULL)
state->mode = SYNC; /* force an otherwise impossible situation */ state->mode = SYNC; /* force an otherwise impossible situation */
return next < sizeof(dat) ? (*buf = dat + next++, 1) : 0; return next < sizeof(dat) ? (*buf = dat + next++, 1) : 0;
} }
local int push(void *desc, unsigned char *buf, unsigned len) local int push(void* desc, unsigned char* buf, unsigned len)
{ {
buf += len; buf += len;
return desc != Z_NULL; /* force error if desc not null */ return desc != Z_NULL; /* force error if desc not null */
@ -474,42 +551,49 @@ local void cover_back(void)
unsigned char win[32768]; unsigned char win[32768];
ret = inflateBackInit_(Z_NULL, 0, win, 0, 0); ret = inflateBackInit_(Z_NULL, 0, win, 0, 0);
assert(ret == Z_VERSION_ERROR); assert(ret == Z_VERSION_ERROR);
ret = inflateBackInit(Z_NULL, 0, win); assert(ret == Z_STREAM_ERROR); ret = inflateBackInit(Z_NULL, 0, win);
assert(ret == Z_STREAM_ERROR);
ret = inflateBack(Z_NULL, Z_NULL, Z_NULL, Z_NULL, Z_NULL); ret = inflateBack(Z_NULL, Z_NULL, Z_NULL, Z_NULL, Z_NULL);
assert(ret == Z_STREAM_ERROR); assert(ret == Z_STREAM_ERROR);
ret = inflateBackEnd(Z_NULL); assert(ret == Z_STREAM_ERROR); ret = inflateBackEnd(Z_NULL);
assert(ret == Z_STREAM_ERROR);
fputs("inflateBack bad parameters\n", stderr); fputs("inflateBack bad parameters\n", stderr);
mem_setup(&strm); mem_setup(&strm);
ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK); ret = inflateBackInit(&strm, 15, win);
assert(ret == Z_OK);
strm.avail_in = 2; strm.avail_in = 2;
strm.next_in = (void *)"\x03"; strm.next_in = (void*)"\x03";
ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL); ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL);
assert(ret == Z_STREAM_END); assert(ret == Z_STREAM_END);
/* force output error */ /* force output error */
strm.avail_in = 3; strm.avail_in = 3;
strm.next_in = (void *)"\x63\x00"; strm.next_in = (void*)"\x63\x00";
ret = inflateBack(&strm, pull, Z_NULL, push, &strm); ret = inflateBack(&strm, pull, Z_NULL, push, &strm);
assert(ret == Z_BUF_ERROR); assert(ret == Z_BUF_ERROR);
/* force mode error by mucking with state */ /* force mode error by mucking with state */
ret = inflateBack(&strm, pull, &strm, push, Z_NULL); ret = inflateBack(&strm, pull, &strm, push, Z_NULL);
assert(ret == Z_STREAM_ERROR); assert(ret == Z_STREAM_ERROR);
ret = inflateBackEnd(&strm); assert(ret == Z_OK); ret = inflateBackEnd(&strm);
assert(ret == Z_OK);
mem_done(&strm, "inflateBack bad state"); mem_done(&strm, "inflateBack bad state");
ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK); ret = inflateBackInit(&strm, 15, win);
ret = inflateBackEnd(&strm); assert(ret == Z_OK); assert(ret == Z_OK);
ret = inflateBackEnd(&strm);
assert(ret == Z_OK);
fputs("inflateBack built-in memory routines\n", stderr); fputs("inflateBack built-in memory routines\n", stderr);
} }
/* do a raw inflate of data in hexadecimal with both inflate and inflateBack */ /* do a raw inflate of data in hexadecimal with both inflate and inflateBack */
local int try(char *hex, char *id, int err)
local int try(char* hex, char* id, int err)
{ {
int ret; int ret;
unsigned len, size; unsigned len, size;
unsigned char *in, *out, *win; unsigned char* in, *out, *win;
char *prefix; char* prefix;
z_stream strm; z_stream strm;
/* convert to hex */ /* convert to hex */
@ -535,23 +619,31 @@ local int try(char *hex, char *id, int err)
assert(ret == Z_OK); assert(ret == Z_OK);
strm.avail_in = len; strm.avail_in = len;
strm.next_in = in; strm.next_in = in;
do {
do
{
strm.avail_out = size; strm.avail_out = size;
strm.next_out = out; strm.next_out = out;
ret = inflate(&strm, Z_TREES); ret = inflate(&strm, Z_TREES);
assert(ret != Z_STREAM_ERROR && ret != Z_MEM_ERROR); assert(ret != Z_STREAM_ERROR && ret != Z_MEM_ERROR);
if (ret == Z_DATA_ERROR || ret == Z_NEED_DICT) if (ret == Z_DATA_ERROR || ret == Z_NEED_DICT)
break; break;
} while (strm.avail_in || strm.avail_out == 0); }
if (err) { while (strm.avail_in || strm.avail_out == 0);
if (err)
{
assert(ret == Z_DATA_ERROR); assert(ret == Z_DATA_ERROR);
assert(strcmp(id, strm.msg) == 0); assert(strcmp(id, strm.msg) == 0);
} }
inflateEnd(&strm); inflateEnd(&strm);
mem_done(&strm, prefix); mem_done(&strm, prefix);
/* then with inflateBack */ /* then with inflateBack */
if (err >= 0) { if (err >= 0)
{
strcpy(prefix, id); strcpy(prefix, id);
strcat(prefix, "-back"); strcat(prefix, "-back");
mem_setup(&strm); mem_setup(&strm);
@ -561,10 +653,13 @@ local int try(char *hex, char *id, int err)
strm.next_in = in; strm.next_in = in;
ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL); ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL);
assert(ret != Z_STREAM_ERROR); assert(ret != Z_STREAM_ERROR);
if (err) {
if (err)
{
assert(ret == Z_DATA_ERROR); assert(ret == Z_DATA_ERROR);
assert(strcmp(id, strm.msg) == 0); assert(strcmp(id, strm.msg) == 0);
} }
inflateBackEnd(&strm); inflateBackEnd(&strm);
mem_done(&strm, prefix); mem_done(&strm, prefix);
} }
@ -581,33 +676,53 @@ local int try(char *hex, char *id, int err)
local void cover_inflate(void) local void cover_inflate(void)
{ {
try("0 0 0 0 0", "invalid stored block lengths", 1); try("0 0 0 0 0", "invalid stored block lengths", 1);
try("3 0", "fixed", 0); try("3 0", "fixed", 0);
try("6", "invalid block type", 1); try("6", "invalid block type", 1);
try("1 1 0 fe ff 0", "stored", 0); try("1 1 0 fe ff 0", "stored", 0);
try("fc 0 0", "too many length or distance symbols", 1); try("fc 0 0", "too many length or distance symbols", 1);
try("4 0 fe ff", "invalid code lengths set", 1); try("4 0 fe ff", "invalid code lengths set", 1);
try("4 0 24 49 0", "invalid bit length repeat", 1); try("4 0 24 49 0", "invalid bit length repeat", 1);
try("4 0 24 e9 ff ff", "invalid bit length repeat", 1); try("4 0 24 e9 ff ff", "invalid bit length repeat", 1);
try("4 0 24 e9 ff 6d", "invalid code -- missing end-of-block", 1); try("4 0 24 e9 ff 6d", "invalid code -- missing end-of-block", 1);
try("4 80 49 92 24 49 92 24 71 ff ff 93 11 0", try("4 80 49 92 24 49 92 24 71 ff ff 93 11 0",
"invalid literal/lengths set", 1); "invalid literal/lengths set", 1);
try("4 80 49 92 24 49 92 24 f b4 ff ff c3 84", "invalid distances set", 1); try("4 80 49 92 24 49 92 24 f b4 ff ff c3 84", "invalid distances set", 1);
try("4 c0 81 8 0 0 0 0 20 7f eb b 0 0", "invalid literal/length code", 1); try("4 c0 81 8 0 0 0 0 20 7f eb b 0 0", "invalid literal/length code", 1);
try("2 7e ff ff", "invalid distance code", 1); try("2 7e ff ff", "invalid distance code", 1);
try("c c0 81 0 0 0 0 0 90 ff 6b 4 0", "invalid distance too far back", 1); try("c c0 81 0 0 0 0 0 90 ff 6b 4 0", "invalid distance too far back", 1);
/* also trailer mismatch just in inflate() */ /* also trailer mismatch just in inflate() */
try("1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 1", "incorrect data check", -1); try("1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 1", "incorrect data check", -1);
try("1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 1", try("1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 1",
"incorrect length check", -1); "incorrect length check", -1);
try("5 c0 21 d 0 0 0 80 b0 fe 6d 2f 91 6c", "pull 17", 0); try("5 c0 21 d 0 0 0 80 b0 fe 6d 2f 91 6c", "pull 17", 0);
try("5 e0 81 91 24 cb b2 2c 49 e2 f 2e 8b 9a 47 56 9f fb fe ec d2 ff 1f", try("5 e0 81 91 24 cb b2 2c 49 e2 f 2e 8b 9a 47 56 9f fb fe ec d2 ff 1f",
"long code", 0); "long code", 0);
try("ed c0 1 1 0 0 0 40 20 ff 57 1b 42 2c 4f", "length extra", 0); try("ed c0 1 1 0 0 0 40 20 ff 57 1b 42 2c 4f", "length extra", 0);
try("ed cf c1 b1 2c 47 10 c4 30 fa 6f 35 1d 1 82 59 3d fb be 2e 2a fc f c", try("ed cf c1 b1 2c 47 10 c4 30 fa 6f 35 1d 1 82 59 3d fb be 2e 2a fc f c",
"long distance and extra", 0); "long distance and extra", 0);
try("ed c0 81 0 0 0 0 80 a0 fd a9 17 a9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 " try("ed c0 81 0 0 0 0 80 a0 fd a9 17 a9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "
"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6", "window end", 0); "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6", "window end", 0);
inf("2 8 20 80 0 3 0", "inflate_fast TYPE return", 0, -15, 258, inf("2 8 20 80 0 3 0", "inflate_fast TYPE return", 0, -15, 258,
Z_STREAM_END); Z_STREAM_END);
inf("63 18 5 40 c 0", "window wrap", 3, -8, 300, Z_OK); inf("63 18 5 40 c 0", "window wrap", 3, -8, 300, Z_OK);
@ -619,21 +734,22 @@ local void cover_trees(void)
int ret; int ret;
unsigned bits; unsigned bits;
unsigned short lens[16], work[16]; unsigned short lens[16], work[16];
code *next, table[ENOUGH_DISTS]; code* next, table[ENOUGH_DISTS];
/* we need to call inflate_table() directly in order to manifest not- /* we need to call inflate_table() directly in order to manifest not-
enough errors, since zlib insures that enough is always enough */ enough errors, since zlib insures that enough is always enough */
for (bits = 0; bits < 15; bits++) for (bits = 0; bits < 15; bits++)
lens[bits] = (unsigned short)(bits + 1); lens[bits] = (unsigned short)(bits + 1);
lens[15] = 15; lens[15] = 15;
next = table; next = table;
bits = 15; bits = 15;
ret = inflate_table(DISTS, lens, 16, &next, &bits, work); ret = inflate_table(DISTS, lens, 16, &next, &bits, work);
assert(ret == 1); assert(ret == 1);
next = table; next = table;
bits = 1; bits = 1;
ret = inflate_table(DISTS, lens, 16, &next, &bits, work); ret = inflate_table(DISTS, lens, 16, &next, &bits, work);
assert(ret == 1); assert(ret == 1);
fputs("inflate_table not enough errors\n", stderr); fputs("inflate_table not enough errors\n", stderr);
} }

View File

@ -55,7 +55,7 @@
#if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE)
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */ #ifndef WIN32 /* unlink already in stdio.h for WIN32 */
extern int unlink OF((const char *)); extern int unlink OF((const char*));
#endif #endif
#endif #endif
@ -73,38 +73,43 @@
The strwinerror function does not change the current setting The strwinerror function does not change the current setting
of GetLastError. */ of GetLastError. */
static char *strwinerror (error) static char* strwinerror(error)
DWORD error; DWORD error;
{ {
static char buf[1024]; static char buf[1024];
wchar_t *msgbuf; wchar_t* msgbuf;
DWORD lasterr = GetLastError(); DWORD lasterr = GetLastError();
DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_ALLOCATE_BUFFER, | FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, NULL,
error, error,
0, /* Default language */ 0, /* Default language */
(LPVOID)&msgbuf, (LPVOID)&msgbuf,
0, 0,
NULL); NULL);
if (chars != 0) {
if (chars != 0)
{
/* If there is an \r\n appended, zap it. */ /* If there is an \r\n appended, zap it. */
if (chars >= 2 if (chars >= 2
&& msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n')
{
chars -= 2; chars -= 2;
msgbuf[chars] = 0; msgbuf[chars] = 0;
} }
if (chars > sizeof (buf) - 1) { if (chars > sizeof(buf) - 1)
chars = sizeof (buf) - 1; {
chars = sizeof(buf) - 1;
msgbuf[chars] = 0; msgbuf[chars] = 0;
} }
wcstombs(buf, msgbuf, chars + 1); wcstombs(buf, msgbuf, chars + 1);
LocalFree(msgbuf); LocalFree(msgbuf);
} }
else { else
{
sprintf(buf, "unknown win32 error (%ld)", error); sprintf(buf, "unknown win32 error (%ld)", error);
} }
@ -112,13 +117,13 @@ static char *strwinerror (error)
return buf; return buf;
} }
static void pwinerror (s) static void pwinerror(s)
const char *s; const char* s;
{ {
if (s && *s) if (s && *s)
fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ())); fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError()));
else else
fprintf(stderr, "%s\n", strwinerror(GetLastError ())); fprintf(stderr, "%s\n", strwinerror(GetLastError()));
} }
#endif /* UNDER_CE */ #endif /* UNDER_CE */
@ -133,7 +138,7 @@ static void pwinerror (s)
#ifdef MAXSEG_64K #ifdef MAXSEG_64K
# define local static # define local static
/* Needed for systems with limitation on stack size. */ /* Needed for systems with limitation on stack size. */
#else #else
# define local # define local
#endif #endif
@ -145,183 +150,218 @@ static void pwinerror (s)
# include <unistd.h> /* for unlink() */ # include <unistd.h> /* for unlink() */
#endif #endif
void *myalloc OF((void *, unsigned, unsigned)); void* myalloc OF((void*, unsigned, unsigned));
void myfree OF((void *, void *)); void myfree OF((void*, void*));
void *myalloc(q, n, m) void* myalloc(q, n, m)
void *q; void* q;
unsigned n, m; unsigned n, m;
{ {
q = Z_NULL; q = Z_NULL;
return calloc(n, m); return calloc(n, m);
} }
void myfree(q, p) void myfree(q, p)
void *q, *p; void* q, *p;
{ {
q = Z_NULL; q = Z_NULL;
free(p); free(p);
} }
typedef struct gzFile_s { typedef struct gzFile_s
FILE *file; {
FILE* file;
int write; int write;
int err; int err;
char *msg; char* msg;
z_stream strm; z_stream strm;
} *gzFile; }* gzFile;
gzFile gzopen OF((const char *, const char *)); gzFile gzopen OF((const char*, const char*));
gzFile gzdopen OF((int, const char *)); gzFile gzdopen OF((int, const char*));
gzFile gz_open OF((const char *, int, const char *)); gzFile gz_open OF((const char*, int, const char*));
gzFile gzopen(path, mode) gzFile gzopen(path, mode)
const char *path; const char* path;
const char *mode; const char* mode;
{ {
return gz_open(path, -1, mode); return gz_open(path, -1, mode);
} }
gzFile gzdopen(fd, mode) gzFile gzdopen(fd, mode)
int fd; int fd;
const char *mode; const char* mode;
{ {
return gz_open(NULL, fd, mode); return gz_open(NULL, fd, mode);
} }
gzFile gz_open(path, fd, mode) gzFile gz_open(path, fd, mode)
const char *path; const char* path;
int fd; int fd;
const char *mode; const char* mode;
{ {
gzFile gz; gzFile gz;
int ret; int ret;
gz = malloc(sizeof(struct gzFile_s)); gz = malloc(sizeof(struct gzFile_s));
if (gz == NULL) if (gz == NULL)
return NULL; return NULL;
gz->write = strchr(mode, 'w') != NULL; gz->write = strchr(mode, 'w') != NULL;
gz->strm.zalloc = myalloc; gz->strm.zalloc = myalloc;
gz->strm.zfree = myfree; gz->strm.zfree = myfree;
gz->strm.opaque = Z_NULL; gz->strm.opaque = Z_NULL;
if (gz->write) if (gz->write)
ret = deflateInit2(&(gz->strm), -1, 8, 15 + 16, 8, 0); ret = deflateInit2(&(gz->strm), -1, 8, 15 + 16, 8, 0);
else { else
{
gz->strm.next_in = 0; gz->strm.next_in = 0;
gz->strm.avail_in = Z_NULL; gz->strm.avail_in = Z_NULL;
ret = inflateInit2(&(gz->strm), 15 + 16); ret = inflateInit2(&(gz->strm), 15 + 16);
} }
if (ret != Z_OK) {
if (ret != Z_OK)
{
free(gz); free(gz);
return NULL; return NULL;
} }
gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") : gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") :
fopen(path, gz->write ? "wb" : "rb"); fopen(path, gz->write ? "wb" : "rb");
if (gz->file == NULL) {
if (gz->file == NULL)
{
gz->write ? deflateEnd(&(gz->strm)) : inflateEnd(&(gz->strm)); gz->write ? deflateEnd(&(gz->strm)) : inflateEnd(&(gz->strm));
free(gz); free(gz);
return NULL; return NULL;
} }
gz->err = 0; gz->err = 0;
gz->msg = ""; gz->msg = "";
return gz; return gz;
} }
int gzwrite OF((gzFile, const void *, unsigned)); int gzwrite OF((gzFile, const void*, unsigned));
int gzwrite(gz, buf, len) int gzwrite(gz, buf, len)
gzFile gz; gzFile gz;
const void *buf; const void* buf;
unsigned len; unsigned len;
{ {
z_stream *strm; z_stream* strm;
unsigned char out[BUFLEN]; unsigned char out[BUFLEN];
if (gz == NULL || !gz->write) if (gz == NULL || !gz->write)
return 0; return 0;
strm = &(gz->strm); strm = &(gz->strm);
strm->next_in = (void *)buf; strm->next_in = (void*)buf;
strm->avail_in = len; strm->avail_in = len;
do {
do
{
strm->next_out = out; strm->next_out = out;
strm->avail_out = BUFLEN; strm->avail_out = BUFLEN;
(void)deflate(strm, Z_NO_FLUSH); (void)deflate(strm, Z_NO_FLUSH);
fwrite(out, 1, BUFLEN - strm->avail_out, gz->file); fwrite(out, 1, BUFLEN - strm->avail_out, gz->file);
} while (strm->avail_out == 0); }
while (strm->avail_out == 0);
return len; return len;
} }
int gzread OF((gzFile, void *, unsigned)); int gzread OF((gzFile, void*, unsigned));
int gzread(gz, buf, len) int gzread(gz, buf, len)
gzFile gz; gzFile gz;
void *buf; void* buf;
unsigned len; unsigned len;
{ {
int ret; int ret;
unsigned got; unsigned got;
unsigned char in[1]; unsigned char in[1];
z_stream *strm; z_stream* strm;
if (gz == NULL || gz->write) if (gz == NULL || gz->write)
return 0; return 0;
if (gz->err) if (gz->err)
return 0; return 0;
strm = &(gz->strm); strm = &(gz->strm);
strm->next_out = (void *)buf; strm->next_out = (void*)buf;
strm->avail_out = len; strm->avail_out = len;
do {
do
{
got = fread(in, 1, 1, gz->file); got = fread(in, 1, 1, gz->file);
if (got == 0) if (got == 0)
break; break;
strm->next_in = in; strm->next_in = in;
strm->avail_in = 1; strm->avail_in = 1;
ret = inflate(strm, Z_NO_FLUSH); ret = inflate(strm, Z_NO_FLUSH);
if (ret == Z_DATA_ERROR) {
if (ret == Z_DATA_ERROR)
{
gz->err = Z_DATA_ERROR; gz->err = Z_DATA_ERROR;
gz->msg = strm->msg; gz->msg = strm->msg;
return 0; return 0;
} }
if (ret == Z_STREAM_END) if (ret == Z_STREAM_END)
inflateReset(strm); inflateReset(strm);
} while (strm->avail_out); }
while (strm->avail_out);
return len - strm->avail_out; return len - strm->avail_out;
} }
int gzclose OF((gzFile)); int gzclose OF((gzFile));
int gzclose(gz) int gzclose(gz)
gzFile gz; gzFile gz;
{ {
z_stream *strm; z_stream* strm;
unsigned char out[BUFLEN]; unsigned char out[BUFLEN];
if (gz == NULL) if (gz == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
strm = &(gz->strm); strm = &(gz->strm);
if (gz->write) {
if (gz->write)
{
strm->next_in = Z_NULL; strm->next_in = Z_NULL;
strm->avail_in = 0; strm->avail_in = 0;
do {
do
{
strm->next_out = out; strm->next_out = out;
strm->avail_out = BUFLEN; strm->avail_out = BUFLEN;
(void)deflate(strm, Z_FINISH); (void)deflate(strm, Z_FINISH);
fwrite(out, 1, BUFLEN - strm->avail_out, gz->file); fwrite(out, 1, BUFLEN - strm->avail_out, gz->file);
} while (strm->avail_out == 0); }
while (strm->avail_out == 0);
deflateEnd(strm); deflateEnd(strm);
} }
else else
inflateEnd(strm); inflateEnd(strm);
fclose(gz->file); fclose(gz->file);
free(gz); free(gz);
return Z_OK; return Z_OK;
} }
const char *gzerror OF((gzFile, int *)); const char* gzerror OF((gzFile, int*));
const char *gzerror(gz, err) const char* gzerror(gz, err)
gzFile gz; gzFile gz;
int *err; int* err;
{ {
*err = gz->err; *err = gz->err;
return gz->msg; return gz->msg;
@ -329,23 +369,23 @@ const char *gzerror(gz, err)
#endif #endif
char *prog; char* prog;
void error OF((const char *msg)); void error OF((const char* msg));
void gz_compress OF((FILE *in, gzFile out)); void gz_compress OF((FILE* in, gzFile out));
#ifdef USE_MMAP #ifdef USE_MMAP
int gz_compress_mmap OF((FILE *in, gzFile out)); int gz_compress_mmap OF((FILE* in, gzFile out));
#endif #endif
void gz_uncompress OF((gzFile in, FILE *out)); void gz_uncompress OF((gzFile in, FILE* out));
void file_compress OF((char *file, char *mode)); void file_compress OF((char* file, char* mode));
void file_uncompress OF((char *file)); void file_uncompress OF((char* file));
int main OF((int argc, char *argv[])); int main OF((int argc, char* argv[]));
/* =========================================================================== /* ===========================================================================
* Display error message and exit * Display error message and exit
*/ */
void error(msg) void error(msg)
const char *msg; const char* msg;
{ {
fprintf(stderr, "%s: %s\n", prog, msg); fprintf(stderr, "%s: %s\n", prog, msg);
exit(1); exit(1);
@ -356,30 +396,39 @@ void error(msg)
*/ */
void gz_compress(in, out) void gz_compress(in, out)
FILE *in; FILE* in;
gzFile out; gzFile out;
{ {
local char buf[BUFLEN]; local char buf[BUFLEN];
int len; int len;
int err; int err;
#ifdef USE_MMAP #ifdef USE_MMAP
/* Try first compressing with mmap. If mmap fails (minigzip used in a /* Try first compressing with mmap. If mmap fails (minigzip used in a
* pipe), use the normal fread loop. * pipe), use the normal fread loop.
*/ */
if (gz_compress_mmap(in, out) == Z_OK) return; if (gz_compress_mmap(in, out) == Z_OK) return;
#endif #endif
for (;;) {
for (;;)
{
len = (int)fread(buf, 1, sizeof(buf), in); len = (int)fread(buf, 1, sizeof(buf), in);
if (ferror(in)) {
if (ferror(in))
{
perror("fread"); perror("fread");
exit(1); exit(1);
} }
if (len == 0) break; if (len == 0) break;
if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err));
} }
fclose(in); fclose(in);
if (gzclose(out) != Z_OK) error("failed gzclose"); if (gzclose(out) != Z_OK) error("failed gzclose");
} }
@ -389,8 +438,8 @@ void gz_compress(in, out)
* if success, Z_ERRNO otherwise. * if success, Z_ERRNO otherwise.
*/ */
int gz_compress_mmap(in, out) int gz_compress_mmap(in, out)
FILE *in; FILE* in;
gzFile out; gzFile out;
{ {
int len; int len;
int err; int err;
@ -401,21 +450,26 @@ int gz_compress_mmap(in, out)
/* Determine the size of the file, needed for mmap: */ /* Determine the size of the file, needed for mmap: */
if (fstat(ifd, &sb) < 0) return Z_ERRNO; if (fstat(ifd, &sb) < 0) return Z_ERRNO;
buf_len = sb.st_size; buf_len = sb.st_size;
if (buf_len <= 0) return Z_ERRNO; if (buf_len <= 0) return Z_ERRNO;
/* Now do the actual mmap: */ /* Now do the actual mmap: */
buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
if (buf == (caddr_t)(-1)) return Z_ERRNO; if (buf == (caddr_t)(-1)) return Z_ERRNO;
/* Compress the whole file at once: */ /* Compress the whole file at once: */
len = gzwrite(out, (char *)buf, (unsigned)buf_len); len = gzwrite(out, (char*)buf, (unsigned)buf_len);
if (len != (int)buf_len) error(gzerror(out, &err)); if (len != (int)buf_len) error(gzerror(out, &err));
munmap(buf, buf_len); munmap(buf, buf_len);
fclose(in); fclose(in);
if (gzclose(out) != Z_OK) error("failed gzclose"); if (gzclose(out) != Z_OK) error("failed gzclose");
return Z_OK; return Z_OK;
} }
#endif /* USE_MMAP */ #endif /* USE_MMAP */
@ -424,22 +478,27 @@ int gz_compress_mmap(in, out)
* Uncompress input to output then close both files. * Uncompress input to output then close both files.
*/ */
void gz_uncompress(in, out) void gz_uncompress(in, out)
gzFile in; gzFile in;
FILE *out; FILE* out;
{ {
local char buf[BUFLEN]; local char buf[BUFLEN];
int len; int len;
int err; int err;
for (;;) { for (;;)
{
len = gzread(in, buf, sizeof(buf)); len = gzread(in, buf, sizeof(buf));
if (len < 0) error (gzerror(in, &err));
if (len < 0) error(gzerror(in, &err));
if (len == 0) break; if (len == 0) break;
if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { if ((int)fwrite(buf, 1, (unsigned)len, out) != len)
{
error("failed fwrite"); error("failed fwrite");
} }
} }
if (fclose(out)) error("failed fclose"); if (fclose(out)) error("failed fclose");
if (gzclose(in) != Z_OK) error("failed gzclose"); if (gzclose(in) != Z_OK) error("failed gzclose");
@ -451,14 +510,15 @@ void gz_uncompress(in, out)
* original. * original.
*/ */
void file_compress(file, mode) void file_compress(file, mode)
char *file; char* file;
char *mode; char* mode;
{ {
local char outfile[MAX_NAME_LEN]; local char outfile[MAX_NAME_LEN];
FILE *in; FILE* in;
gzFile out; gzFile out;
if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) { if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile))
{
fprintf(stderr, "%s: filename too long\n", prog); fprintf(stderr, "%s: filename too long\n", prog);
exit(1); exit(1);
} }
@ -467,15 +527,21 @@ void file_compress(file, mode)
strcat(outfile, GZ_SUFFIX); strcat(outfile, GZ_SUFFIX);
in = fopen(file, "rb"); in = fopen(file, "rb");
if (in == NULL) {
if (in == NULL)
{
perror(file); perror(file);
exit(1); exit(1);
} }
out = gzopen(outfile, mode); out = gzopen(outfile, mode);
if (out == NULL) {
if (out == NULL)
{
fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);
exit(1); exit(1);
} }
gz_compress(in, out); gz_compress(in, out);
unlink(file); unlink(file);
@ -486,37 +552,47 @@ void file_compress(file, mode)
* Uncompress the given file and remove the original. * Uncompress the given file and remove the original.
*/ */
void file_uncompress(file) void file_uncompress(file)
char *file; char* file;
{ {
local char buf[MAX_NAME_LEN]; local char buf[MAX_NAME_LEN];
char *infile, *outfile; char* infile, *outfile;
FILE *out; FILE* out;
gzFile in; gzFile in;
size_t len = strlen(file); size_t len = strlen(file);
if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) { if (len + strlen(GZ_SUFFIX) >= sizeof(buf))
{
fprintf(stderr, "%s: filename too long\n", prog); fprintf(stderr, "%s: filename too long\n", prog);
exit(1); exit(1);
} }
strcpy(buf, file); strcpy(buf, file);
if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) { if (len > SUFFIX_LEN && strcmp(file + len - SUFFIX_LEN, GZ_SUFFIX) == 0)
{
infile = file; infile = file;
outfile = buf; outfile = buf;
outfile[len-3] = '\0'; outfile[len - 3] = '\0';
} else { }
else
{
outfile = file; outfile = file;
infile = buf; infile = buf;
strcat(infile, GZ_SUFFIX); strcat(infile, GZ_SUFFIX);
} }
in = gzopen(infile, "rb"); in = gzopen(infile, "rb");
if (in == NULL) {
if (in == NULL)
{
fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); fprintf(stderr, "%s: can't gzopen %s\n", prog, infile);
exit(1); exit(1);
} }
out = fopen(outfile, "wb"); out = fopen(outfile, "wb");
if (out == NULL) {
if (out == NULL)
{
perror(file); perror(file);
exit(1); exit(1);
} }
@ -538,94 +614,130 @@ void file_uncompress(file)
*/ */
int main(argc, argv) int main(argc, argv)
int argc; int argc;
char *argv[]; char* argv[];
{ {
int copyout = 0; int copyout = 0;
int uncompr = 0; int uncompr = 0;
gzFile file; gzFile file;
char *bname, outmode[20]; char* bname, outmode[20];
strcpy(outmode, "wb6 "); strcpy(outmode, "wb6 ");
prog = argv[0]; prog = argv[0];
bname = strrchr(argv[0], '/'); bname = strrchr(argv[0], '/');
if (bname) if (bname)
bname++; bname++;
else else
bname = argv[0]; bname = argv[0];
argc--, argv++; argc--, argv++;
if (!strcmp(bname, "gunzip")) if (!strcmp(bname, "gunzip"))
uncompr = 1;
else if (!strcmp(bname, "zcat"))
copyout = uncompr = 1;
while (argc > 0) {
if (strcmp(*argv, "-c") == 0)
copyout = 1;
else if (strcmp(*argv, "-d") == 0)
uncompr = 1; uncompr = 1;
else if (strcmp(*argv, "-f") == 0) else if (!strcmp(bname, "zcat"))
outmode[3] = 'f'; copyout = uncompr = 1;
else if (strcmp(*argv, "-h") == 0)
outmode[3] = 'h'; while (argc > 0)
else if (strcmp(*argv, "-r") == 0) {
outmode[3] = 'R'; if (strcmp(*argv, "-c") == 0)
else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' && copyout = 1;
(*argv)[2] == 0) else if (strcmp(*argv, "-d") == 0)
outmode[2] = (*argv)[1]; uncompr = 1;
else else if (strcmp(*argv, "-f") == 0)
break; outmode[3] = 'f';
argc--, argv++; else if (strcmp(*argv, "-h") == 0)
outmode[3] = 'h';
else if (strcmp(*argv, "-r") == 0)
outmode[3] = 'R';
else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&
(*argv)[2] == 0)
outmode[2] = (*argv)[1];
else
break;
argc--, argv++;
} }
if (outmode[3] == ' ') if (outmode[3] == ' ')
outmode[3] = 0; outmode[3] = 0;
if (argc == 0) {
if (argc == 0)
{
SET_BINARY_MODE(stdin); SET_BINARY_MODE(stdin);
SET_BINARY_MODE(stdout); SET_BINARY_MODE(stdout);
if (uncompr) {
if (uncompr)
{
file = gzdopen(fileno(stdin), "rb"); file = gzdopen(fileno(stdin), "rb");
if (file == NULL) error("can't gzdopen stdin"); if (file == NULL) error("can't gzdopen stdin");
gz_uncompress(file, stdout); gz_uncompress(file, stdout);
} else { }
else
{
file = gzdopen(fileno(stdout), outmode); file = gzdopen(fileno(stdout), outmode);
if (file == NULL) error("can't gzdopen stdout"); if (file == NULL) error("can't gzdopen stdout");
gz_compress(stdin, file); gz_compress(stdin, file);
} }
} else { }
if (copyout) { else
{
if (copyout)
{
SET_BINARY_MODE(stdout); SET_BINARY_MODE(stdout);
} }
do {
if (uncompr) { do
if (copyout) { {
if (uncompr)
{
if (copyout)
{
file = gzopen(*argv, "rb"); file = gzopen(*argv, "rb");
if (file == NULL) if (file == NULL)
fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv); fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv);
else else
gz_uncompress(file, stdout); gz_uncompress(file, stdout);
} else { }
else
{
file_uncompress(*argv); file_uncompress(*argv);
} }
} else { }
if (copyout) { else
FILE * in = fopen(*argv, "rb"); {
if (copyout)
{
FILE* in = fopen(*argv, "rb");
if (in == NULL) { if (in == NULL)
{
perror(*argv); perror(*argv);
} else { }
else
{
file = gzdopen(fileno(stdout), outmode); file = gzdopen(fileno(stdout), outmode);
if (file == NULL) error("can't gzdopen stdout"); if (file == NULL) error("can't gzdopen stdout");
gz_compress(in, file); gz_compress(in, file);
} }
} else { }
else
{
file_compress(*argv, outmode); file_compress(*argv, outmode);
} }
} }
} while (argv++, --argc); }
while (argv++, --argc);
} }
return 0; return 0;
} }

787
extern/zlib/trees.c vendored

File diff suppressed because it is too large Load Diff

232
extern/zlib/trees.h vendored
View File

@ -1,128 +1,134 @@
/* header created automatically with -DGEN_TREES_H */ /* header created automatically with -DGEN_TREES_H */
local const ct_data static_ltree[L_CODES+2] = { local const ct_data static_ltree[L_CODES + 2] =
{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, {
{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, {{ 12}, { 8}}, {{140}, { 8}}, {{ 76}, { 8}}, {{204}, { 8}}, {{ 44}, { 8}},
{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, {{172}, { 8}}, {{108}, { 8}}, {{236}, { 8}}, {{ 28}, { 8}}, {{156}, { 8}},
{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, {{ 92}, { 8}}, {{220}, { 8}}, {{ 60}, { 8}}, {{188}, { 8}}, {{124}, { 8}},
{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, {{252}, { 8}}, {{ 2}, { 8}}, {{130}, { 8}}, {{ 66}, { 8}}, {{194}, { 8}},
{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, {{ 34}, { 8}}, {{162}, { 8}}, {{ 98}, { 8}}, {{226}, { 8}}, {{ 18}, { 8}},
{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, {{146}, { 8}}, {{ 82}, { 8}}, {{210}, { 8}}, {{ 50}, { 8}}, {{178}, { 8}},
{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, {{114}, { 8}}, {{242}, { 8}}, {{ 10}, { 8}}, {{138}, { 8}}, {{ 74}, { 8}},
{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, {{202}, { 8}}, {{ 42}, { 8}}, {{170}, { 8}}, {{106}, { 8}}, {{234}, { 8}},
{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, {{ 26}, { 8}}, {{154}, { 8}}, {{ 90}, { 8}}, {{218}, { 8}}, {{ 58}, { 8}},
{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, {{186}, { 8}}, {{122}, { 8}}, {{250}, { 8}}, {{ 6}, { 8}}, {{134}, { 8}},
{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, {{ 70}, { 8}}, {{198}, { 8}}, {{ 38}, { 8}}, {{166}, { 8}}, {{102}, { 8}},
{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, {{230}, { 8}}, {{ 22}, { 8}}, {{150}, { 8}}, {{ 86}, { 8}}, {{214}, { 8}},
{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, {{ 54}, { 8}}, {{182}, { 8}}, {{118}, { 8}}, {{246}, { 8}}, {{ 14}, { 8}},
{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, {{142}, { 8}}, {{ 78}, { 8}}, {{206}, { 8}}, {{ 46}, { 8}}, {{174}, { 8}},
{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, {{110}, { 8}}, {{238}, { 8}}, {{ 30}, { 8}}, {{158}, { 8}}, {{ 94}, { 8}},
{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, {{222}, { 8}}, {{ 62}, { 8}}, {{190}, { 8}}, {{126}, { 8}}, {{254}, { 8}},
{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, {{ 1}, { 8}}, {{129}, { 8}}, {{ 65}, { 8}}, {{193}, { 8}}, {{ 33}, { 8}},
{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, {{161}, { 8}}, {{ 97}, { 8}}, {{225}, { 8}}, {{ 17}, { 8}}, {{145}, { 8}},
{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, {{ 81}, { 8}}, {{209}, { 8}}, {{ 49}, { 8}}, {{177}, { 8}}, {{113}, { 8}},
{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, {{241}, { 8}}, {{ 9}, { 8}}, {{137}, { 8}}, {{ 73}, { 8}}, {{201}, { 8}},
{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, {{ 41}, { 8}}, {{169}, { 8}}, {{105}, { 8}}, {{233}, { 8}}, {{ 25}, { 8}},
{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, {{153}, { 8}}, {{ 89}, { 8}}, {{217}, { 8}}, {{ 57}, { 8}}, {{185}, { 8}},
{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, {{121}, { 8}}, {{249}, { 8}}, {{ 5}, { 8}}, {{133}, { 8}}, {{ 69}, { 8}},
{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, {{197}, { 8}}, {{ 37}, { 8}}, {{165}, { 8}}, {{101}, { 8}}, {{229}, { 8}},
{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, {{ 21}, { 8}}, {{149}, { 8}}, {{ 85}, { 8}}, {{213}, { 8}}, {{ 53}, { 8}},
{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, {{181}, { 8}}, {{117}, { 8}}, {{245}, { 8}}, {{ 13}, { 8}}, {{141}, { 8}},
{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, {{ 77}, { 8}}, {{205}, { 8}}, {{ 45}, { 8}}, {{173}, { 8}}, {{109}, { 8}},
{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, {{237}, { 8}}, {{ 29}, { 8}}, {{157}, { 8}}, {{ 93}, { 8}}, {{221}, { 8}},
{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, {{ 61}, { 8}}, {{189}, { 8}}, {{125}, { 8}}, {{253}, { 8}}, {{ 19}, { 9}},
{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, {{275}, { 9}}, {{147}, { 9}}, {{403}, { 9}}, {{ 83}, { 9}}, {{339}, { 9}},
{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, {{211}, { 9}}, {{467}, { 9}}, {{ 51}, { 9}}, {{307}, { 9}}, {{179}, { 9}},
{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, {{435}, { 9}}, {{115}, { 9}}, {{371}, { 9}}, {{243}, { 9}}, {{499}, { 9}},
{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, {{ 11}, { 9}}, {{267}, { 9}}, {{139}, { 9}}, {{395}, { 9}}, {{ 75}, { 9}},
{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, {{331}, { 9}}, {{203}, { 9}}, {{459}, { 9}}, {{ 43}, { 9}}, {{299}, { 9}},
{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, {{171}, { 9}}, {{427}, { 9}}, {{107}, { 9}}, {{363}, { 9}}, {{235}, { 9}},
{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, {{491}, { 9}}, {{ 27}, { 9}}, {{283}, { 9}}, {{155}, { 9}}, {{411}, { 9}},
{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, {{ 91}, { 9}}, {{347}, { 9}}, {{219}, { 9}}, {{475}, { 9}}, {{ 59}, { 9}},
{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, {{315}, { 9}}, {{187}, { 9}}, {{443}, { 9}}, {{123}, { 9}}, {{379}, { 9}},
{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, {{251}, { 9}}, {{507}, { 9}}, {{ 7}, { 9}}, {{263}, { 9}}, {{135}, { 9}},
{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, {{391}, { 9}}, {{ 71}, { 9}}, {{327}, { 9}}, {{199}, { 9}}, {{455}, { 9}},
{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, {{ 39}, { 9}}, {{295}, { 9}}, {{167}, { 9}}, {{423}, { 9}}, {{103}, { 9}},
{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, {{359}, { 9}}, {{231}, { 9}}, {{487}, { 9}}, {{ 23}, { 9}}, {{279}, { 9}},
{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, {{151}, { 9}}, {{407}, { 9}}, {{ 87}, { 9}}, {{343}, { 9}}, {{215}, { 9}},
{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, {{471}, { 9}}, {{ 55}, { 9}}, {{311}, { 9}}, {{183}, { 9}}, {{439}, { 9}},
{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, {{119}, { 9}}, {{375}, { 9}}, {{247}, { 9}}, {{503}, { 9}}, {{ 15}, { 9}},
{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, {{271}, { 9}}, {{143}, { 9}}, {{399}, { 9}}, {{ 79}, { 9}}, {{335}, { 9}},
{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, {{207}, { 9}}, {{463}, { 9}}, {{ 47}, { 9}}, {{303}, { 9}}, {{175}, { 9}},
{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, {{431}, { 9}}, {{111}, { 9}}, {{367}, { 9}}, {{239}, { 9}}, {{495}, { 9}},
{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, {{ 31}, { 9}}, {{287}, { 9}}, {{159}, { 9}}, {{415}, { 9}}, {{ 95}, { 9}},
{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, {{351}, { 9}}, {{223}, { 9}}, {{479}, { 9}}, {{ 63}, { 9}}, {{319}, { 9}},
{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, {{191}, { 9}}, {{447}, { 9}}, {{127}, { 9}}, {{383}, { 9}}, {{255}, { 9}},
{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, {{511}, { 9}}, {{ 0}, { 7}}, {{ 64}, { 7}}, {{ 32}, { 7}}, {{ 96}, { 7}},
{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, {{ 16}, { 7}}, {{ 80}, { 7}}, {{ 48}, { 7}}, {{112}, { 7}}, {{ 8}, { 7}},
{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, {{ 72}, { 7}}, {{ 40}, { 7}}, {{104}, { 7}}, {{ 24}, { 7}}, {{ 88}, { 7}},
{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, {{ 56}, { 7}}, {{120}, { 7}}, {{ 4}, { 7}}, {{ 68}, { 7}}, {{ 36}, { 7}},
{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, {{100}, { 7}}, {{ 20}, { 7}}, {{ 84}, { 7}}, {{ 52}, { 7}}, {{116}, { 7}},
{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} {{ 3}, { 8}}, {{131}, { 8}}, {{ 67}, { 8}}, {{195}, { 8}}, {{ 35}, { 8}},
{{163}, { 8}}, {{ 99}, { 8}}, {{227}, { 8}}
}; };
local const ct_data static_dtree[D_CODES] = { local const ct_data static_dtree[D_CODES] =
{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, {
{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, {{ 0}, { 5}}, {{16}, { 5}}, {{ 8}, { 5}}, {{24}, { 5}}, {{ 4}, { 5}},
{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, {{20}, { 5}}, {{12}, { 5}}, {{28}, { 5}}, {{ 2}, { 5}}, {{18}, { 5}},
{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, {{10}, { 5}}, {{26}, { 5}}, {{ 6}, { 5}}, {{22}, { 5}}, {{14}, { 5}},
{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, {{30}, { 5}}, {{ 1}, { 5}}, {{17}, { 5}}, {{ 9}, { 5}}, {{25}, { 5}},
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} {{ 5}, { 5}}, {{21}, { 5}}, {{13}, { 5}}, {{29}, { 5}}, {{ 3}, { 5}},
{{19}, { 5}}, {{11}, { 5}}, {{27}, { 5}}, {{ 7}, { 5}}, {{23}, { 5}}
}; };
const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] =
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, {
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
}; };
const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { const uch ZLIB_INTERNAL _length_code[MAX_MATCH - MIN_MATCH + 1] =
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, {
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
}; };
local const int base_length[LENGTH_CODES] = { local const int base_length[LENGTH_CODES] =
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, {
64, 80, 96, 112, 128, 160, 192, 224, 0 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
64, 80, 96, 112, 128, 160, 192, 224, 0
}; };
local const int base_dist[D_CODES] = { local const int base_dist[D_CODES] =
{
0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
}; };

24
extern/zlib/uncompr.c vendored
View File

@ -22,13 +22,13 @@
buffer, or Z_DATA_ERROR if the input data was corrupted. buffer, or Z_DATA_ERROR if the input data was corrupted.
*/ */
#ifdef WIN32 #ifdef WIN32
int ZEXPORT uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) int ZEXPORT uncompress(Bytef* dest, uLongf* destLen, const Bytef* source, uLong sourceLen)
#else #else
int ZEXPORT uncompress (dest, destLen, source, sourceLen) int ZEXPORT uncompress(dest, destLen, source, sourceLen)
Bytef *dest; Bytef* dest;
uLongf *destLen; uLongf* destLen;
const Bytef *source; const Bytef* source;
uLong sourceLen; uLong sourceLen;
#endif #endif
{ {
z_stream stream; z_stream stream;
@ -36,26 +36,34 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen)
stream.next_in = (Bytef*)source; stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen; stream.avail_in = (uInt)sourceLen;
/* Check for source > 64K on 16-bit machine: */ /* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
stream.next_out = dest; stream.next_out = dest;
stream.avail_out = (uInt)*destLen; stream.avail_out = (uInt) * destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
stream.zalloc = (alloc_func)0; stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0; stream.zfree = (free_func)0;
err = inflateInit(&stream); err = inflateInit(&stream);
if (err != Z_OK) return err; if (err != Z_OK) return err;
err = inflate(&stream, Z_FINISH); err = inflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) {
if (err != Z_STREAM_END)
{
inflateEnd(&stream); inflateEnd(&stream);
if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
return Z_DATA_ERROR; return Z_DATA_ERROR;
return err; return err;
} }
*destLen = stream.total_out; *destLen = stream.total_out;
err = inflateEnd(&stream); err = inflateEnd(&stream);

70
extern/zlib/zconf.h vendored
View File

@ -257,7 +257,7 @@
for small objects. for small objects.
*/ */
/* Type declarations */ /* Type declarations */
#ifndef OF /* function prototypes */ #ifndef OF /* function prototypes */
# ifdef STDC # ifdef STDC
@ -283,7 +283,7 @@
*/ */
#ifdef SYS16BIT #ifdef SYS16BIT
# if defined(M_I86SM) || defined(M_I86MM) # if defined(M_I86SM) || defined(M_I86MM)
/* MSC small or medium model */ /* MSC small or medium model */
# define SMALL_MEDIUM # define SMALL_MEDIUM
# ifdef _MSC_VER # ifdef _MSC_VER
# define FAR _far # define FAR _far
@ -292,7 +292,7 @@
# endif # endif
# endif # endif
# if (defined(__SMALL__) || defined(__MEDIUM__)) # if (defined(__SMALL__) || defined(__MEDIUM__))
/* Turbo C small or medium model */ /* Turbo C small or medium model */
# define SMALL_MEDIUM # define SMALL_MEDIUM
# ifdef __BORLANDC__ # ifdef __BORLANDC__
# define FAR _far # define FAR _far
@ -303,9 +303,9 @@
#endif #endif
#if defined(WINDOWS) || defined(WIN32) #if defined(WINDOWS) || defined(WIN32)
/* If building or using zlib as a DLL, define ZLIB_DLL. /* If building or using zlib as a DLL, define ZLIB_DLL.
* This is not mandatory, but it offers a little performance increase. * This is not mandatory, but it offers a little performance increase.
*/ */
# ifdef ZLIB_DLL # ifdef ZLIB_DLL
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
# ifdef ZLIB_INTERNAL # ifdef ZLIB_INTERNAL
@ -315,17 +315,17 @@
# endif # endif
# endif # endif
# endif /* ZLIB_DLL */ # endif /* ZLIB_DLL */
/* If building or using zlib with the WINAPI/WINAPIV calling convention, /* If building or using zlib with the WINAPI/WINAPIV calling convention,
* define ZLIB_WINAPI. * define ZLIB_WINAPI.
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/ */
# ifdef ZLIB_WINAPI # ifdef ZLIB_WINAPI
# ifdef FAR # ifdef FAR
# undef FAR # undef FAR
# endif # endif
# include <windows.h> # include <windows.h>
/* No need for _export, use ZLIB.DEF instead. */ /* No need for _export, use ZLIB.DEF instead. */
/* For complete Windows compatibility, use WINAPI, not __stdcall. */ /* For complete Windows compatibility, use WINAPI, not __stdcall. */
# define ZEXPORT WINAPI # define ZEXPORT WINAPI
# ifdef WIN32 # ifdef WIN32
# define ZEXPORTVA WINAPIV # define ZEXPORTVA WINAPIV
@ -368,10 +368,10 @@ typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */ typedef unsigned long uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM #ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR # define Bytef Byte FAR
#else #else
typedef Byte FAR Bytef; typedef Byte FAR Bytef;
#endif #endif
typedef char FAR charf; typedef char FAR charf;
typedef int FAR intf; typedef int FAR intf;
@ -379,13 +379,13 @@ typedef uInt FAR uIntf;
typedef uLong FAR uLongf; typedef uLong FAR uLongf;
#ifdef STDC #ifdef STDC
typedef void const *voidpc; typedef void const* voidpc;
typedef void FAR *voidpf; typedef void FAR* voidpf;
typedef void *voidp; typedef void* voidp;
#else #else
typedef Byte const *voidpc; typedef Byte const* voidpc;
typedef Byte FAR *voidpf; typedef Byte FAR* voidpf;
typedef Byte *voidp; typedef Byte* voidp;
#endif #endif
/* ./configure may #define Z_U4 here */ /* ./configure may #define Z_U4 here */
@ -406,9 +406,9 @@ typedef uLong FAR uLongf;
#endif #endif
#ifdef Z_U4 #ifdef Z_U4
typedef Z_U4 z_crc_t; typedef Z_U4 z_crc_t;
#else #else
typedef unsigned long z_crc_t; typedef unsigned long z_crc_t;
#endif #endif
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ #ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
@ -488,19 +488,19 @@ typedef uLong FAR uLongf;
/* MVS linker does not support external names larger than 8 bytes */ /* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__) #if defined(__MVS__)
#pragma map(deflateInit_,"DEIN") #pragma map(deflateInit_,"DEIN")
#pragma map(deflateInit2_,"DEIN2") #pragma map(deflateInit2_,"DEIN2")
#pragma map(deflateEnd,"DEEND") #pragma map(deflateEnd,"DEEND")
#pragma map(deflateBound,"DEBND") #pragma map(deflateBound,"DEBND")
#pragma map(inflateInit_,"ININ") #pragma map(inflateInit_,"ININ")
#pragma map(inflateInit2_,"ININ2") #pragma map(inflateInit2_,"ININ2")
#pragma map(inflateEnd,"INEND") #pragma map(inflateEnd,"INEND")
#pragma map(inflateSync,"INSY") #pragma map(inflateSync,"INSY")
#pragma map(inflateSetDictionary,"INSEDI") #pragma map(inflateSetDictionary,"INSEDI")
#pragma map(compressBound,"CMBND") #pragma map(compressBound,"CMBND")
#pragma map(inflate_table,"INTABL") #pragma map(inflate_table,"INTABL")
#pragma map(inflate_fast,"INFA") #pragma map(inflate_fast,"INFA")
#pragma map(inflate_copyright,"INCOPY") #pragma map(inflate_copyright,"INCOPY")
#endif #endif
#endif /* ZCONF_H */ #endif /* ZCONF_H */

167
extern/zlib/zlib.h vendored
View File

@ -31,7 +31,7 @@
/* /*
version 1.2.7.f-hanba-win64-v3, May 31, 2014 version 1.2.7.f-hanba-win64-v3, May 31, 2014
Copyright (C) 2012-2014 Jonathan Hanba (hanbaj@gmail.com) Copyright (C) 2012-2014 Jonathan Hanba (hanbaj@gmail.com)
@ -102,22 +102,23 @@ extern "C" {
even in case of corrupted input. even in case of corrupted input.
*/ */
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); typedef voidpf(*alloc_func) OF((voidpf opaque, uInt items, uInt size));
typedef void (*free_func) OF((voidpf opaque, voidpf address)); typedef void (*free_func) OF((voidpf opaque, voidpf address));
struct internal_state; struct internal_state;
typedef struct z_stream_s { typedef struct z_stream_s
z_const Bytef *next_in; /* next input byte */ {
z_const Bytef* next_in; /* next input byte */
uInt avail_in; /* number of bytes available at next_in */ uInt avail_in; /* number of bytes available at next_in */
uLong total_in; /* total number of input bytes read so far */ uLong total_in; /* total number of input bytes read so far */
Bytef *next_out; /* next output byte should be put there */ Bytef* next_out; /* next output byte should be put there */
uInt avail_out; /* remaining free space at next_out */ uInt avail_out; /* remaining free space at next_out */
uLong total_out; /* total number of bytes output so far */ uLong total_out; /* total number of bytes output so far */
z_const char *msg; /* last error message, NULL if no error */ z_const char* msg; /* last error message, NULL if no error */
struct internal_state FAR *state; /* not visible by applications */ struct internal_state FAR* state; /* not visible by applications */
alloc_func zalloc; /* used to allocate the internal state */ alloc_func zalloc; /* used to allocate the internal state */
free_func zfree; /* used to free the internal state */ free_func zfree; /* used to free the internal state */
@ -128,30 +129,31 @@ typedef struct z_stream_s {
uLong reserved; /* reserved for future use */ uLong reserved; /* reserved for future use */
} z_stream; } z_stream;
typedef z_stream FAR *z_streamp; typedef z_stream FAR* z_streamp;
/* /*
gzip header information passed to and from zlib routines. See RFC 1952 gzip header information passed to and from zlib routines. See RFC 1952
for more details on the meanings of these fields. for more details on the meanings of these fields.
*/ */
typedef struct gz_header_s { typedef struct gz_header_s
{
int text; /* true if compressed data believed to be text */ int text; /* true if compressed data believed to be text */
uLong time; /* modification time */ uLong time; /* modification time */
int xflags; /* extra flags (not used when writing a gzip file) */ int xflags; /* extra flags (not used when writing a gzip file) */
int os; /* operating system */ int os; /* operating system */
Bytef *extra; /* pointer to extra field or Z_NULL if none */ Bytef* extra; /* pointer to extra field or Z_NULL if none */
uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
uInt extra_max; /* space at extra (only when reading header) */ uInt extra_max; /* space at extra (only when reading header) */
Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ Bytef* name; /* pointer to zero-terminated file name or Z_NULL */
uInt name_max; /* space at name (only when reading header) */ uInt name_max; /* space at name (only when reading header) */
Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ Bytef* comment; /* pointer to zero-terminated comment or Z_NULL */
uInt comm_max; /* space at comment (only when reading header) */ uInt comm_max; /* space at comment (only when reading header) */
int hcrc; /* true if there was or will be a header crc */ int hcrc; /* true if there was or will be a header crc */
int done; /* true when done reading gzip header (not used int done; /* true when done reading gzip header (not used
when writing a gzip file) */ when writing a gzip file) */
} gz_header; } gz_header;
typedef gz_header FAR *gz_headerp; typedef gz_header FAR* gz_headerp;
/* /*
The application must update next_in and avail_in when avail_in has dropped The application must update next_in and avail_in when avail_in has dropped
@ -184,7 +186,7 @@ typedef gz_header FAR *gz_headerp;
if the decompressor wants to decompress everything in a single step). if the decompressor wants to decompress everything in a single step).
*/ */
/* constants */ /* constants */
#define Z_NO_FLUSH 0 #define Z_NO_FLUSH 0
#define Z_PARTIAL_FLUSH 1 #define Z_PARTIAL_FLUSH 1
@ -236,9 +238,9 @@ typedef gz_header FAR *gz_headerp;
/* for compatibility with versions < 1.0.2 */ /* for compatibility with versions < 1.0.2 */
/* basic functions */ /* basic functions */
ZEXTERN const char * ZEXPORT zlibVersion OF((void)); ZEXTERN const char* ZEXPORT zlibVersion OF((void));
/* The application can compare zlibVersion and ZLIB_VERSION for consistency. /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
If the first character differs, the library code actually used is not If the first character differs, the library code actually used is not
compatible with the zlib.h header file used by the application. This check compatible with the zlib.h header file used by the application. This check
@ -542,7 +544,7 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
*/ */
/* Advanced functions */ /* Advanced functions */
/* /*
The following functions are needed only in some special applications. The following functions are needed only in some special applications.
@ -610,8 +612,8 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
*/ */
ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
const Bytef *dictionary, const Bytef* dictionary,
uInt dictLength)); uInt dictLength));
/* /*
Initializes the compression dictionary from the given byte sequence Initializes the compression dictionary from the given byte sequence
without producing any compressed output. When using the zlib format, this without producing any compressed output. When using the zlib format, this
@ -736,8 +738,8 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
*/ */
ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
unsigned *pending, unsigned* pending,
int *bits)); int* bits));
/* /*
deflatePending() returns the number of bytes and bits of output that have deflatePending() returns the number of bytes and bits of output that have
been generated, but not yet provided in the available output. The bytes not been generated, but not yet provided in the available output. The bytes not
@ -768,7 +770,7 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
*/ */
ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
gz_headerp head)); gz_headerp head));
/* /*
deflateSetHeader() provides gzip header information for when a gzip deflateSetHeader() provides gzip header information for when a gzip
stream is requested by deflateInit2(). deflateSetHeader() may be called stream is requested by deflateInit2(). deflateSetHeader() may be called
@ -842,8 +844,8 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
*/ */
ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
const Bytef *dictionary, const Bytef* dictionary,
uInt dictLength)); uInt dictLength));
/* /*
Initializes the decompression dictionary from the given uncompressed byte Initializes the decompression dictionary from the given uncompressed byte
sequence. This function must be called immediately after a call of inflate, sequence. This function must be called immediately after a call of inflate,
@ -971,7 +973,7 @@ ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
*/ */
ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
gz_headerp head)); gz_headerp head));
/* /*
inflateGetHeader() requests that gzip header information be stored in the inflateGetHeader() requests that gzip header information be stored in the
provided gz_header structure. inflateGetHeader() may be called after provided gz_header structure. inflateGetHeader() may be called after
@ -1032,12 +1034,12 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
the version of the header file. the version of the header file.
*/ */
typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); typedef unsigned(*in_func) OF((void FAR*, unsigned char FAR* FAR*));
typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); typedef int (*out_func) OF((void FAR*, unsigned char FAR*, unsigned));
ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
in_func in, void FAR *in_desc, in_func in, void FAR* in_desc,
out_func out, void FAR *out_desc)); out_func out, void FAR* out_desc));
/* /*
inflateBack() does a raw inflate with a single call using a call-back inflateBack() does a raw inflate with a single call using a call-back
interface for input and output. This is more efficient than inflate() for interface for input and output. This is more efficient than inflate() for
@ -1155,7 +1157,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
#ifndef Z_SOLO #ifndef Z_SOLO
/* utility functions */ /* utility functions */
/* /*
The following utility functions are implemented on top of the basic The following utility functions are implemented on top of the basic
@ -1165,8 +1167,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
you need special options. you need special options.
*/ */
ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, ZEXTERN int ZEXPORT compress OF((Bytef* dest, uLongf* destLen,
const Bytef *source, uLong sourceLen)); const Bytef* source, uLong sourceLen));
/* /*
Compresses the source buffer into the destination buffer. sourceLen is Compresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total size the byte length of the source buffer. Upon entry, destLen is the total size
@ -1179,8 +1181,8 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
buffer. buffer.
*/ */
ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, ZEXTERN int ZEXPORT compress2 OF((Bytef* dest, uLongf* destLen,
const Bytef *source, uLong sourceLen, const Bytef* source, uLong sourceLen,
int level)); int level));
/* /*
Compresses the source buffer into the destination buffer. The level Compresses the source buffer into the destination buffer. The level
@ -1202,8 +1204,8 @@ ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
compress() or compress2() call to allocate the destination buffer. compress() or compress2() call to allocate the destination buffer.
*/ */
ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, ZEXTERN int ZEXPORT uncompress OF((Bytef* dest, uLongf* destLen,
const Bytef *source, uLong sourceLen)); const Bytef* source, uLong sourceLen));
/* /*
Decompresses the source buffer into the destination buffer. sourceLen is Decompresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total size the byte length of the source buffer. Upon entry, destLen is the total size
@ -1220,7 +1222,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
buffer with the uncompressed data up to that point. buffer with the uncompressed data up to that point.
*/ */
/* gzip file access functions */ /* gzip file access functions */
/* /*
This library supports reading and writing files in gzip (.gz) format with This library supports reading and writing files in gzip (.gz) format with
@ -1229,7 +1231,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
wrapper, documented in RFC 1952, wrapped around a deflate stream. wrapper, documented in RFC 1952, wrapped around a deflate stream.
*/ */
typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ typedef struct gzFile_s* gzFile; /* semi-opaque gzip file descriptor */
/* /*
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
@ -1269,7 +1271,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
file could not be opened. file could not be opened.
*/ */
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char* mode));
/* /*
gzdopen associates a gzFile with the file descriptor fd. File descriptors gzdopen associates a gzFile with the file descriptor fd. File descriptors
are obtained from calls like open, dup, creat, pipe or fileno (if the file are obtained from calls like open, dup, creat, pipe or fileno (if the file
@ -1354,7 +1356,7 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
error. error.
*/ */
ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char* format, ...));
/* /*
Converts, formats, and writes the arguments to the compressed file under Converts, formats, and writes the arguments to the compressed file under
control of the format string, as in fprintf. gzprintf returns the number of control of the format string, as in fprintf. gzprintf returns the number of
@ -1369,7 +1371,7 @@ ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
zlibCompileFlags(). zlibCompileFlags().
*/ */
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char* s));
/* /*
Writes the given null-terminated string to the compressed file, excluding Writes the given null-terminated string to the compressed file, excluding
the terminating null character. the terminating null character.
@ -1377,7 +1379,7 @@ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
gzputs returns the number of characters written, or -1 in case of error. gzputs returns the number of characters written, or -1 in case of error.
*/ */
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); ZEXTERN char* ZEXPORT gzgets OF((gzFile file, char* buf, int len));
/* /*
Reads bytes from the compressed file until len-1 characters are read, or a Reads bytes from the compressed file until len-1 characters are read, or a
newline character is read and transferred to buf, or an end-of-file newline character is read and transferred to buf, or an end-of-file
@ -1549,7 +1551,7 @@ ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
zlib library. zlib library.
*/ */
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); ZEXTERN const char* ZEXPORT gzerror OF((gzFile file, int* errnum));
/* /*
Returns the error message for the last error which occurred on the given Returns the error message for the last error which occurred on the given
compressed file. errnum is set to zlib error number. If an error occurred compressed file. errnum is set to zlib error number. If an error occurred
@ -1574,7 +1576,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
#endif /* !Z_SOLO */ #endif /* !Z_SOLO */
/* checksum functions */ /* checksum functions */
/* /*
These functions are not related to compression but are exported These functions are not related to compression but are exported
@ -1582,7 +1584,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
library. library.
*/ */
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef* buf, uInt len));
/* /*
Update a running Adler-32 checksum with the bytes buf[0..len-1] and Update a running Adler-32 checksum with the bytes buf[0..len-1] and
return the updated checksum. If buf is Z_NULL, this function returns the return the updated checksum. If buf is Z_NULL, this function returns the
@ -1613,7 +1615,7 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
negative, the result has no meaning or utility. negative, the result has no meaning or utility.
*/ */
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef* buf, uInt len));
/* /*
Update a running CRC-32 with the bytes buf[0..len-1] and return the Update a running CRC-32 with the bytes buf[0..len-1] and return the
updated CRC-32. If buf is Z_NULL, this function returns the required updated CRC-32. If buf is Z_NULL, this function returns the required
@ -1641,25 +1643,25 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
*/ */
/* various hacks, don't look :) */ /* various hacks, don't look :) */
/* deflateInit and inflateInit are macros to allow checking the zlib version /* deflateInit and inflateInit are macros to allow checking the zlib version
* and the compiler's view of z_stream: * and the compiler's view of z_stream:
*/ */
ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
const char *version, int stream_size)); const char* version, int stream_size));
ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
const char *version, int stream_size)); const char* version, int stream_size));
ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
int windowBits, int memLevel, int windowBits, int memLevel,
int strategy, const char *version, int strategy, const char* version,
int stream_size)); int stream_size));
ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
const char *version, int stream_size)); const char* version, int stream_size));
ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
unsigned char FAR *window, unsigned char FAR* window,
const char *version, const char* version,
int stream_size)); int stream_size));
#define deflateInit(strm, level) \ #define deflateInit(strm, level) \
deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
#define inflateInit(strm) \ #define inflateInit(strm) \
@ -1683,9 +1685,10 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
* behavior could change in the future, perhaps even capriciously. They can * behavior could change in the future, perhaps even capriciously. They can
* only be used by the gzgetc() macro. You have been warned. * only be used by the gzgetc() macro. You have been warned.
*/ */
struct gzFile_s { struct gzFile_s
{
unsigned have; unsigned have;
unsigned char *next; unsigned char* next;
z_off64_t pos; z_off64_t pos;
}; };
ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
@ -1705,12 +1708,12 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
* without large file support, _LFS64_LARGEFILE must also be true * without large file support, _LFS64_LARGEFILE must also be true
*/ */
#ifdef Z_LARGE64 #ifdef Z_LARGE64
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN gzFile ZEXPORT gzopen64 OF((const char*, const char*));
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
#endif #endif
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
@ -1730,44 +1733,44 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
# define crc32_combine crc32_combine64 # define crc32_combine crc32_combine64
# endif # endif
# ifndef Z_LARGE64 # ifndef Z_LARGE64
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN gzFile ZEXPORT gzopen64 OF((const char*, const char*));
ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
# endif # endif
#else #else
ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); ZEXTERN gzFile ZEXPORT gzopen OF((const char*, const char*));
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
#endif #endif
#else /* Z_SOLO */ #else /* Z_SOLO */
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
#endif /* !Z_SOLO */ #endif /* !Z_SOLO */
/* hack for buggy compilers */ /* hack for buggy compilers */
#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
struct internal_state {int dummy;}; struct internal_state {int dummy;};
#endif #endif
/* undocumented functions */ /* undocumented functions */
ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN const char* ZEXPORT zError OF((int));
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); ZEXTERN const z_crc_t FAR* ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
#if defined(_WIN32) && !defined(Z_SOLO) #if defined(_WIN32) && !defined(Z_SOLO)
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t* path,
const char *mode)); const char* mode));
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

232
extern/zlib/zutil.c vendored
View File

@ -14,20 +14,22 @@
struct internal_state {int dummy;}; /* for buggy compilers */ struct internal_state {int dummy;}; /* for buggy compilers */
#endif #endif
const char * const z_errmsg[10] = { const char* const z_errmsg[10] =
"need dictionary", /* Z_NEED_DICT 2 */ {
"stream end", /* Z_STREAM_END 1 */ "need dictionary", /* Z_NEED_DICT 2 */
"", /* Z_OK 0 */ "stream end", /* Z_STREAM_END 1 */
"file error", /* Z_ERRNO (-1) */ "", /* Z_OK 0 */
"stream error", /* Z_STREAM_ERROR (-2) */ "file error", /* Z_ERRNO (-1) */
"data error", /* Z_DATA_ERROR (-3) */ "stream error", /* Z_STREAM_ERROR (-2) */
"insufficient memory", /* Z_MEM_ERROR (-4) */ "data error", /* Z_DATA_ERROR (-3) */
"buffer error", /* Z_BUF_ERROR (-5) */ "insufficient memory", /* Z_MEM_ERROR (-4) */
"incompatible version",/* Z_VERSION_ERROR (-6) */ "buffer error", /* Z_BUF_ERROR (-5) */
""}; "incompatible version",/* Z_VERSION_ERROR (-6) */
""
};
const char * ZEXPORT zlibVersion() const char* ZEXPORT zlibVersion()
{ {
return ZLIB_VERSION; return ZLIB_VERSION;
} }
@ -37,30 +39,75 @@ uLong ZEXPORT zlibCompileFlags()
uLong flags; uLong flags;
flags = 0; flags = 0;
switch ((int)(sizeof(uInt))) {
case 2: break; switch ((int)(sizeof(uInt)))
case 4: flags += 1; break; {
case 8: flags += 2; break; case 2:
default: flags += 3; break;
case 4:
flags += 1;
break;
case 8:
flags += 2;
break;
default:
flags += 3;
} }
switch ((int)(sizeof(uLong))) {
case 2: break; switch ((int)(sizeof(uLong)))
case 4: flags += 1 << 2; break; {
case 8: flags += 2 << 2; break; case 2:
default: flags += 3 << 2; break;
case 4:
flags += 1 << 2;
break;
case 8:
flags += 2 << 2;
break;
default:
flags += 3 << 2;
} }
switch ((int)(sizeof(voidpf))) {
case 2: break; switch ((int)(sizeof(voidpf)))
case 4: flags += 1 << 4; break; {
case 8: flags += 2 << 4; break; case 2:
default: flags += 3 << 4; break;
case 4:
flags += 1 << 4;
break;
case 8:
flags += 2 << 4;
break;
default:
flags += 3 << 4;
} }
switch ((int)(sizeof(z_off_t))) {
case 2: break; switch ((int)(sizeof(z_off_t)))
case 4: flags += 1 << 6; break; {
case 8: flags += 2 << 6; break; case 2:
default: flags += 3 << 6; break;
case 4:
flags += 1 << 6;
break;
case 8:
flags += 2 << 6;
break;
default:
flags += 3 << 6;
} }
#ifdef DEBUG #ifdef DEBUG
flags += 1 << 8; flags += 1 << 8;
#endif #endif
@ -122,8 +169,8 @@ uLong ZEXPORT zlibCompileFlags()
# endif # endif
int ZLIB_INTERNAL z_verbose = verbose; int ZLIB_INTERNAL z_verbose = verbose;
void ZLIB_INTERNAL z_error (m) void ZLIB_INTERNAL z_error(m)
char *m; char* m;
{ {
fprintf(stderr, "%s\n", m); fprintf(stderr, "%s\n", m);
exit(1); exit(1);
@ -134,57 +181,65 @@ void ZLIB_INTERNAL z_error (m)
* uncompress() * uncompress()
*/ */
#ifdef WIN32 #ifdef WIN32
const char * ZEXPORT zError(int err) const char* ZEXPORT zError(int err)
#else #else
const char * ZEXPORT zError(err) const char* ZEXPORT zError(err)
int err; int err;
#endif #endif
{ {
return ERR_MSG(err); return ERR_MSG(err);
} }
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
/* The Microsoft C Run-Time Library for Windows CE doesn't have /* The Microsoft C Run-Time Library for Windows CE doesn't have
* errno. We define it as a global variable to simplify porting. * errno. We define it as a global variable to simplify porting.
* Its value is always 0 and should not be used. * Its value is always 0 and should not be used.
*/ */
int errno = 0; int errno = 0;
#endif #endif
#ifndef HAVE_MEMCPY #ifndef HAVE_MEMCPY
void ZLIB_INTERNAL zmemcpy(dest, source, len) void ZLIB_INTERNAL zmemcpy(dest, source, len)
Bytef* dest; Bytef* dest;
const Bytef* source; const Bytef* source;
uInt len; uInt len;
{ {
if (len == 0) return; if (len == 0) return;
do {
do
{
*dest++ = *source++; /* ??? to be unrolled */ *dest++ = *source++; /* ??? to be unrolled */
} while (--len != 0); }
while (--len != 0);
} }
int ZLIB_INTERNAL zmemcmp(s1, s2, len) int ZLIB_INTERNAL zmemcmp(s1, s2, len)
const Bytef* s1; const Bytef* s1;
const Bytef* s2; const Bytef* s2;
uInt len; uInt len;
{ {
uInt j; uInt j;
for (j = 0; j < len; j++) { for (j = 0; j < len; j++)
if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; {
if (s1[j] != s2[j]) return 2 * (s1[j] > s2[j]) - 1;
} }
return 0; return 0;
} }
void ZLIB_INTERNAL zmemzero(dest, len) void ZLIB_INTERNAL zmemzero(dest, len)
Bytef* dest; Bytef* dest;
uInt len; uInt len;
{ {
if (len == 0) return; if (len == 0) return;
do {
do
{
*dest++ = 0; /* ??? to be unrolled */ *dest++ = 0; /* ??? to be unrolled */
} while (--len != 0); }
while (--len != 0);
} }
#endif #endif
@ -208,7 +263,8 @@ void ZLIB_INTERNAL zmemzero(dest, len)
local int next_ptr = 0; local int next_ptr = 0;
typedef struct ptr_table_s { typedef struct ptr_table_s
{
voidpf org_ptr; voidpf org_ptr;
voidpf new_ptr; voidpf new_ptr;
} ptr_table; } ptr_table;
@ -221,48 +277,62 @@ local ptr_table table[MAX_PTR];
* a protected system like OS/2. Use Microsoft C instead. * a protected system like OS/2. Use Microsoft C instead.
*/ */
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
{ {
voidpf buf = opaque; /* just to make some compilers happy */ voidpf buf = opaque; /* just to make some compilers happy */
ulg bsize = (ulg)items*size; ulg bsize = (ulg)items * size;
/* If we allocate less than 65520 bytes, we assume that farmalloc /* If we allocate less than 65520 bytes, we assume that farmalloc
* will return a usable pointer which doesn't have to be normalized. * will return a usable pointer which doesn't have to be normalized.
*/ */
if (bsize < 65520L) { if (bsize < 65520L)
{
buf = farmalloc(bsize); buf = farmalloc(bsize);
if (*(ush*)&buf != 0) return buf; if (*(ush*)&buf != 0) return buf;
} else { }
else
{
buf = farmalloc(bsize + 16L); buf = farmalloc(bsize + 16L);
} }
if (buf == NULL || next_ptr >= MAX_PTR) return NULL; if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
table[next_ptr].org_ptr = buf; table[next_ptr].org_ptr = buf;
/* Normalize the pointer to seg:0 */ /* Normalize the pointer to seg:0 */
*((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; *((ush*)&buf + 1) += ((ush)((uch*)buf - 0) + 15) >> 4;
*(ush*)&buf = 0; *(ush*)&buf = 0;
table[next_ptr++].new_ptr = buf; table[next_ptr++].new_ptr = buf;
return buf; return buf;
} }
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
{ {
int n; int n;
if (*(ush*)&ptr != 0) { /* object < 64K */
if (*(ush*)&ptr != 0) /* object < 64K */
{
farfree(ptr); farfree(ptr);
return; return;
} }
/* Find the original pointer */ /* Find the original pointer */
for (n = 0; n < next_ptr; n++) { for (n = 0; n < next_ptr; n++)
{
if (ptr != table[n].new_ptr) continue; if (ptr != table[n].new_ptr) continue;
farfree(table[n].org_ptr); farfree(table[n].org_ptr);
while (++n < next_ptr) {
table[n-1] = table[n]; while (++n < next_ptr)
{
table[n - 1] = table[n];
} }
next_ptr--; next_ptr--;
return; return;
} }
ptr = opaque; /* just to make some compilers happy */ ptr = opaque; /* just to make some compilers happy */
Assert(0, "zcfree: ptr not found"); Assert(0, "zcfree: ptr not found");
} }
@ -280,15 +350,17 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
# define _hfree hfree # define _hfree hfree
#endif #endif
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size)
{ {
if (opaque) opaque = 0; /* to make compiler happy */ if (opaque) opaque = 0; /* to make compiler happy */
return _halloc((long)items, size); return _halloc((long)items, size);
} }
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
{ {
if (opaque) opaque = 0; /* to make compiler happy */ if (opaque) opaque = 0; /* to make compiler happy */
_hfree(ptr); _hfree(ptr);
} }
@ -306,28 +378,30 @@ extern void free OF((voidpf ptr));
#endif #endif
#ifdef WIN32 #ifdef WIN32
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
#else #else
voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) voidpf ZLIB_INTERNAL zcalloc(opaque, items, size)
voidpf opaque; voidpf opaque;
unsigned items; unsigned items;
unsigned size; unsigned size;
#endif #endif
{ {
if (opaque) items += size - size; /* make compiler happy */ if (opaque) items += size - size; /* make compiler happy */
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
(voidpf)calloc(items, size); (voidpf)calloc(items, size);
} }
#ifdef WIN32 #ifdef WIN32
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
#else #else
void ZLIB_INTERNAL zcfree (opaque, ptr) void ZLIB_INTERNAL zcfree(opaque, ptr)
voidpf opaque; voidpf opaque;
voidpf ptr; voidpf ptr;
#endif #endif
{ {
free(ptr); free(ptr);
if (opaque) return; /* make compiler happy */ if (opaque) return; /* make compiler happy */
} }

54
extern/zlib/zutil.h vendored
View File

@ -30,7 +30,7 @@
#endif #endif
#ifdef Z_SOLO #ifdef Z_SOLO
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
#endif #endif
#ifndef local #ifndef local
@ -44,7 +44,7 @@ typedef unsigned short ush;
typedef ush FAR ushf; typedef ush FAR ushf;
typedef unsigned long ulg; typedef unsigned long ulg;
extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ extern const char* const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */ /* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
@ -53,7 +53,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
return (strm->msg = (char*)ERR_MSG(err), (err)) return (strm->msg = (char*)ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */ /* To be used only when the state is known to be valid */
/* common constants */ /* common constants */
#ifndef DEF_WBITS #ifndef DEF_WBITS
# define DEF_WBITS MAX_WBITS # define DEF_WBITS MAX_WBITS
@ -78,16 +78,16 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
/* target dependencies */ /* target dependencies */
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
# define OS_CODE 0x00 # define OS_CODE 0x00
# ifndef Z_SOLO # ifndef Z_SOLO
# if defined(__TURBOC__) || defined(__BORLANDC__) # if defined(__TURBOC__) || defined(__BORLANDC__)
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */ /* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block ); void _Cdecl farfree(void* block);
void *_Cdecl farmalloc( unsigned long nbytes ); void* _Cdecl farmalloc(unsigned long nbytes);
# else # else
# include <alloc.h> # include <alloc.h>
# endif # endif
@ -153,7 +153,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# if defined(_WIN32_WCE) # if defined(_WIN32_WCE)
# define fdopen(fd,mode) NULL /* No fdopen() */ # define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED # ifndef _PTRDIFF_T_DEFINED
typedef int ptrdiff_t; typedef int ptrdiff_t;
# define _PTRDIFF_T_DEFINED # define _PTRDIFF_T_DEFINED
# endif # endif
# else # else
@ -162,18 +162,18 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif #endif
#if defined(__BORLANDC__) && !defined(MSDOS) #if defined(__BORLANDC__) && !defined(MSDOS)
#pragma warn -8004 #pragma warn -8004
#pragma warn -8008 #pragma warn -8008
#pragma warn -8066 #pragma warn -8066
#endif #endif
/* provide prototypes for these when building zlib without LFS */ /* provide prototypes for these when building zlib without LFS */
#if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) #if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
#endif #endif
/* common defaults */ /* common defaults */
#ifndef OS_CODE #ifndef OS_CODE
# define OS_CODE 0x03 /* assume Unix */ # define OS_CODE 0x03 /* assume Unix */
@ -183,16 +183,16 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define F_OPEN(name, mode) fopen((name), (mode)) # define F_OPEN(name, mode) fopen((name), (mode))
#endif #endif
/* functions */ /* functions */
#if defined(pyr) || defined(Z_SOLO) #if defined(pyr) || defined(Z_SOLO)
# define NO_MEMCPY # define NO_MEMCPY
#endif #endif
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
/* Use our own functions for small and medium model with MSC <= 5.0. /* Use our own functions for small and medium model with MSC <= 5.0.
* You may have to use the same strategy for Borland C (untested). * You may have to use the same strategy for Borland C (untested).
* The __SC__ check is for Symantec. * The __SC__ check is for Symantec.
*/ */
# define NO_MEMCPY # define NO_MEMCPY
#endif #endif
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
@ -209,16 +209,16 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define zmemzero(dest, len) memset(dest, 0, len) # define zmemzero(dest, len) memset(dest, 0, len)
# endif # endif
#else #else
void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
#endif #endif
/* Diagnostic functions */ /* Diagnostic functions */
#ifdef DEBUG #ifdef DEBUG
# include <stdio.h> # include <stdio.h>
extern int ZLIB_INTERNAL z_verbose; extern int ZLIB_INTERNAL z_verbose;
extern void ZLIB_INTERNAL z_error OF((char *m)); extern void ZLIB_INTERNAL z_error OF((char* m));
# define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Assert(cond,msg) {if(!(cond)) z_error(msg);}
# define Trace(x) {if (z_verbose>=0) fprintf x ;} # define Trace(x) {if (z_verbose>=0) fprintf x ;}
# define Tracev(x) {if (z_verbose>0) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;}
@ -235,9 +235,9 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif #endif
#ifndef Z_SOLO #ifndef Z_SOLO
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
unsigned size)); unsigned size));
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
#endif #endif
#define ZALLOC(strm, items, size) \ #define ZALLOC(strm, items, size) \

View File

@ -337,7 +337,8 @@ public:
* \brief setCrystals * \brief setCrystals
* \param val * \param val
*/ */
void setCrystals(ALTTPCrystals val);\ void setCrystals(ALTTPCrystals val);
\
/*! /*!
* \brief crystals * \brief crystals

View File

@ -26,34 +26,34 @@ namespace Athena
struct ALTTPRoomFlags struct ALTTPRoomFlags
{ {
bool Chest1:1; bool Chest1: 1;
bool Chest2:1; bool Chest2: 1;
bool Chest3:1; bool Chest3: 1;
bool Chest4:1; bool Chest4: 1;
bool Quadrant1:1; bool Quadrant1: 1;
bool Quadrant2:1; bool Quadrant2: 1;
bool Quadrant3:1; bool Quadrant3: 1;
bool Quadrant4:1; bool Quadrant4: 1;
bool Door1:1; bool Door1: 1;
bool Door2:1; bool Door2: 1;
bool Door3:1; bool Door3: 1;
bool Door4:1; bool Door4: 1;
bool BossBattleWon:1; bool BossBattleWon: 1;
bool Key:1; bool Key: 1;
bool KeyOrChest:1; bool KeyOrChest: 1;
bool ChestOrTile:1; bool ChestOrTile: 1;
}; };
struct ALTTPOverworldEvent struct ALTTPOverworldEvent
{ {
bool Unused1:1; bool Unused1: 1;
bool HeartPiece:1; bool HeartPiece: 1;
bool Overlay:1; bool Overlay: 1;
bool Unused2:1; bool Unused2: 1;
bool Unused3:1; bool Unused3: 1;
bool Unused4:1; bool Unused4: 1;
bool Set:1; bool Set: 1;
bool Unused5:1; bool Unused5: 1;
}; };
struct ALTTPInventory struct ALTTPInventory
@ -93,14 +93,14 @@ struct ALTTPInventory
*/ */
struct ALTTPLightDarkWorldIndicator struct ALTTPLightDarkWorldIndicator
{ {
bool Unused1:1; bool Unused1: 1;
bool Unused2:1; bool Unused2: 1;
bool Unused3:1; bool Unused3: 1;
bool Unused4:1; bool Unused4: 1;
bool Unused5:1; bool Unused5: 1;
bool Unused6:1; bool Unused6: 1;
bool IsDarkWorld:1; bool IsDarkWorld: 1;
bool Unused7:1; bool Unused7: 1;
}; };
@ -110,14 +110,14 @@ struct ALTTPDungeonItemFlags
{ {
struct struct
{ {
bool Unused1:1; bool Unused1: 1;
bool Unused2:1; bool Unused2: 1;
bool GanonsTower:1; bool GanonsTower: 1;
bool TurtleRock:1; bool TurtleRock: 1;
bool GargoylesDomain:1; bool GargoylesDomain: 1;
bool TowerOfHera:1; bool TowerOfHera: 1;
bool IcePalace:1; bool IcePalace: 1;
bool SkullWoods:1; bool SkullWoods: 1;
}; };
atUint8 flags1; atUint8 flags1;
}; };
@ -126,14 +126,14 @@ struct ALTTPDungeonItemFlags
{ {
struct struct
{ {
bool MiseryMire:1; bool MiseryMire: 1;
bool DarkPalace:1; bool DarkPalace: 1;
bool SwampPalace:1; bool SwampPalace: 1;
bool HyruleCastle2:1; // unused in orignal game bool HyruleCastle2: 1; // unused in orignal game
bool DesertPalace:1; bool DesertPalace: 1;
bool EasternPalace:1; bool EasternPalace: 1;
bool HyruleCastle:1; // unused exist in original game bool HyruleCastle: 1; // unused exist in original game
bool SewerPassage:1; // unused exist in original game bool SewerPassage: 1; // unused exist in original game
}; };
atUint8 flags2; atUint8 flags2;
}; };
@ -141,75 +141,75 @@ struct ALTTPDungeonItemFlags
struct ALTTPPendants struct ALTTPPendants
{ {
bool Courage:1; bool Courage: 1;
bool Wisdom:1; bool Wisdom: 1;
bool Power:1; bool Power: 1;
bool Unused1:1; bool Unused1: 1;
bool Unused2:1; bool Unused2: 1;
bool Unused3:1; bool Unused3: 1;
bool Unused4:1; bool Unused4: 1;
bool Unused5:1; bool Unused5: 1;
}; };
struct ALTTPAbilities struct ALTTPAbilities
{ {
bool Nothing:1; //? bool Nothing: 1; //?
bool Swim:1; bool Swim: 1;
bool Dash:1; bool Dash: 1;
bool Pull:1; bool Pull: 1;
bool Unknown1:1; //--- bool Unknown1: 1; //---
bool Talk:1; bool Talk: 1;
bool Read:1; bool Read: 1;
bool Unknown2:1; //--- bool Unknown2: 1; //---
}; };
struct ALTTPCrystals struct ALTTPCrystals
{ {
bool MiseryMire:1; bool MiseryMire: 1;
bool DarkPalace:1; bool DarkPalace: 1;
bool IcePalace:1; bool IcePalace: 1;
bool TurtleRock:1; bool TurtleRock: 1;
bool SwampPalace:1; bool SwampPalace: 1;
bool GargoyleDomain:1; bool GargoyleDomain: 1;
bool SkullWoods:1; bool SkullWoods: 1;
}; };
struct ALTTPMagicUsage struct ALTTPMagicUsage
{ {
bool Normal:1; bool Normal: 1;
bool Half:1; bool Half: 1;
bool Quarter:1; bool Quarter: 1;
bool Unused1:1; bool Unused1: 1;
bool Unused2:1; bool Unused2: 1;
bool Unused3:1; bool Unused3: 1;
bool Unused4:1; bool Unused4: 1;
bool Unused5:1; bool Unused5: 1;
}; };
struct ALTTPProgressFlags1 struct ALTTPProgressFlags1
{ {
bool UncleSecretPassage:1; bool UncleSecretPassage: 1;
bool DyingPriest:1; //? bool DyingPriest: 1; //?
bool ZeldaSanctuary:1; //? bool ZeldaSanctuary: 1; //?
bool Unused1:1; bool Unused1: 1;
bool UncleLeftHouse:1; bool UncleLeftHouse: 1;
bool BookOfMudora:1;//? Math says it's a guess need to investigate bool BookOfMudora: 1; //? Math says it's a guess need to investigate
bool DwarfPartner:1; //? bool DwarfPartner: 1; //?
bool Unused2:1; bool Unused2: 1;
}; };
struct ALTTPProgressFlags2 struct ALTTPProgressFlags2
{ {
bool BottleFromBum:1; bool BottleFromBum: 1;
bool BottleFromSalesMen:1; bool BottleFromSalesMen: 1;
bool Unused1:1; //? bool Unused1: 1; //?
bool FluteBoy:1; bool FluteBoy: 1;
bool ThiefsChest:1; bool ThiefsChest: 1;
bool SavedSmithPartner:1; bool SavedSmithPartner: 1;
bool Unused2:1; //? bool Unused2: 1; //?
bool SmithsHaveSword:1; bool SmithsHaveSword: 1;
}; };
} }

View File

@ -45,7 +45,8 @@ public:
m_message(message), m_message(message),
m_file(file), m_file(file),
m_function(function), m_function(function),
m_line(line) m_line(line),
m_exceptionName("Exception")
{ {
} }
@ -54,7 +55,7 @@ public:
*/ */
inline std::string message() const inline std::string message() const
{ {
return m_message; return m_exceptionName + (m_message.empty() ? "" : ": " + m_message);
} }
inline std::string file() const inline std::string file() const
@ -74,28 +75,57 @@ public:
inline std::string formattedMessage() const inline std::string formattedMessage() const
{ {
return Athena::utility::sprintf("%s : %s (%i) %s", m_file.c_str(), m_function.c_str(), m_line, m_message.c_str()); return Athena::utility::sprintf("%s : %s (%i) %s", m_file.c_str(), m_function.c_str(), m_line, message().c_str());
} }
protected: protected:
std::string m_message; //!< The error message string std::string m_message; //!< The error message string
std::string m_file; std::string m_file;
std::string m_function; std::string m_function;
int m_line; int m_line;
std::string m_exceptionName;
}; };
} // error } // error
} // Athena } // Athena
#ifdef _MSC_VER #ifdef _MSC_VER
#define THROW_EXCEPTION(args,...) \ #define THROW_EXCEPTION(args,...) \
do { \ do { \
std::string msg = Athena::utility::sprintf(args, __VA_ARGS__); \ if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, __VA_ARGS__); return; \
} else { std::string msg = Athena::utility::sprintf(__VA_ARGS__); \
throw Athena::error::Exception(std::string("Exception: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \ throw Athena::error::Exception(std::string("Exception: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0) } \
} while(0)
#elif defined(__GNUC__) #elif defined(__GNUC__)
#define THROW_EXCEPTION(args...) \ #define THROW_EXCEPTION(args...) \
do { \ do { \
if (atGetExceptionHandler()) { atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, args); return; \
} else { \
std::string msg = Athena::utility::sprintf(args); \ std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::Exception(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} \
} while(0)
#endif
#ifdef _MSC_VER
#define THROW_EXCEPTION_RETURN(ret, args,...) \
do { \
if (atGetExceptionHandler()) \
{ \
atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, __VA_ARGS__); \
return ret; \
} else { \
std::string msg = Athena::utility::sprintf(__VA_ARGS__); \
throw Athena::error::Exception(std::string("Exception: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \ throw Athena::error::Exception(std::string("Exception: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0) } \
} while(0)
#elif defined(__GNUC__)
#define THROW_EXCEPTION_RETURN(ret, args...) \
do { \
if (atGetExceptionHandler()) { atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, args); return ret; \
} else { \
std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::Exception(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} \
} while(0)
#endif #endif
#endif // EXCEPTION_HPP #endif // EXCEPTION_HPP

View File

@ -39,7 +39,9 @@ public:
inline FileNotFoundException(const std::string& filename, const std::string& file, const std::string& function, const int line) : inline FileNotFoundException(const std::string& filename, const std::string& file, const std::string& function, const int line) :
Exception(std::string("FileNotFoundException: Could not find file \"") + filename + std::string("\", please check that it exists."), file, function, line), Exception(std::string("FileNotFoundException: Could not find file \"") + filename + std::string("\", please check that it exists."), file, function, line),
m_filename(filename) m_filename(filename)
{} {
m_exceptionName = "FileNotFoundException";
}
/*! \brief Returns the path of the offending file. /*! \brief Returns the path of the offending file.
* \return std::string The filename of the file including the path. * \return std::string The filename of the file including the path.
@ -51,7 +53,31 @@ private:
} // error } // error
} // Athena } // Athena
#ifndef THROW_FILE_NOT_FOUND_EXCEPTION
#define THROW_FILE_NOT_FOUND_EXCEPTION(msg) \ #define THROW_FILE_NOT_FOUND_EXCEPTION(msg) \
do { throw Athena::error::FileNotFoundException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); } while(0) do { \
if (atGetExceptionHandler()) \
{ \
atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, msg); \
return; \
} \
else \
throw Athena::error::FileNotFoundException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0)
#endif
#ifndef THROW_FILE_NOT_FOUND_EXCEPTION_RETURN
#define THROW_FILE_NOT_FOUND_EXCEPTION_RETURN(ret, msg) \
do { \
if (atGetExceptionHandler()) \
{ \
atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, msg); \
return ret; \
} \
else \
throw Athena::error::FileNotFoundException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0)
#endif
#endif // FILENOTFOUNDEXCEPTION_HPP #endif // FILENOTFOUNDEXCEPTION_HPP

View File

@ -42,21 +42,21 @@ public:
atUint64 position() const; atUint64 position() const;
atUint64 length() const; atUint64 length() const;
void writeBit (bool val); void writeBit(bool val);
void seekBit (int bit); void seekBit(int bit);
void writeUByte (atUint8 val); void writeUByte(atUint8 val);
void writeByte (atInt8 val); void writeByte(atInt8 val);
void writeUBytes(atUint8* data, atUint64 len); void writeUBytes(atUint8* data, atUint64 len);
void writeBytes (atInt8* data, atUint64 len); void writeBytes(atInt8* data, atUint64 len);
void writeUint16(atUint16 val); void writeUint16(atUint16 val);
void writeInt16 (atInt16 val); void writeInt16(atInt16 val);
void writeUint32(atUint32 val); void writeUint32(atUint32 val);
void writeInt32 (atInt32 val); void writeInt32(atInt32 val);
void writeUint64(atUint64 val); void writeUint64(atUint64 val);
void writeInt64 (atInt64 val); void writeInt64(atInt64 val);
void writeDouble(double val); void writeDouble(double val);
void writeFloat (float val); void writeFloat(float val);
void writeBool (bool val); void writeBool(bool val);
void writeString(const std::string& val); void writeString(const std::string& val);
void writeUnicode(const std::string& str); void writeUnicode(const std::string& str);
void fill(atInt8 byte, atUint64 len); void fill(atInt8 byte, atUint64 len);

View File

@ -116,6 +116,11 @@ typedef Vector2D<float> Vector2Df;
#endif // ATHENA_NO_SAKURA #endif // ATHENA_NO_SAKURA
} // Athena } // Athena
typedef void (*atEXCEPTION_HANDLER)(const std::string& file, const std::string& function, int line, const std::string&, ...);
atEXCEPTION_HANDLER atGetExceptionHandler();
void atSetExceptionHandler(atEXCEPTION_HANDLER func);
std::ostream& operator<<(std::ostream& os, const Athena::SeekOrigin& origin); std::ostream& operator<<(std::ostream& os, const Athena::SeekOrigin& origin);
std::ostream& operator<<(std::ostream& os, const Athena::Endian& endian); std::ostream& operator<<(std::ostream& os, const Athena::Endian& endian);
#endif // GLOBAL_HPP #endif // GLOBAL_HPP

View File

@ -41,7 +41,9 @@ public:
*/ */
inline IOException(const std::string& message, const std::string& file, const std::string& function, const int line) : inline IOException(const std::string& message, const std::string& file, const std::string& function, const int line) :
Exception(message, file, function, line) Exception(message, file, function, line)
{} {
m_exceptionName = "IOException";
}
}; };
} // error } // error
@ -50,14 +52,45 @@ public:
#ifdef _MSC_VER #ifdef _MSC_VER
#define THROW_IO_EXCEPTION(args, ...) \ #define THROW_IO_EXCEPTION(args, ...) \
do { \ do { \
std::string msg = Athena::utility::sprintf(args, __VA_ARGS__); \ if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, __VA_ARGS__); return; \
throw Athena::error::IOException(std::string("IOException: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \ } else {
} while(0) std::string msg = Athena::utility::sprintf(args, __VA_ARGS__);
\
throw Athena::error::IOException(std::string("IOException: ") + msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__);
\
} \
} while (0)
#elif defined(__GNUC__) #elif defined(__GNUC__)
#define THROW_IO_EXCEPTION(args...) \ #define THROW_IO_EXCEPTION(args...) \
do { \ do { \
std::string msg = Athena::utility::sprintf(args); \ if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, args); return; \
throw Athena::error::IOException(std::string("IOException: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \ } else { std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::IOException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} \
} while(0)
#endif
#ifdef _MSC_VER
#define THROW_IO_EXCEPTION_RETURN(ret, args, ...) \
do { \
if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, __VA_ARGS__); return ret; \
} else {
std::string msg = Athena::utility::sprintf(args, __VA_ARGS__);
\
throw Athena::error::IOException(std::string("IOException: ") + msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__);
\
} \
} while (0)
#elif defined(__GNUC__)
#define THROW_IO_EXCEPTION_RETURN(ret, args...) \
do { \
if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, args); return ret; \
} else { std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::IOException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} \
} while(0) } while(0)
#endif #endif

View File

@ -31,15 +31,15 @@ public:
virtual ~IStream() {} virtual ~IStream() {}
virtual void setEndian(Endian) = 0; virtual void setEndian(Endian) = 0;
virtual Endian endian() const= 0; virtual Endian endian() const = 0;
virtual bool isBigEndian() const= 0; virtual bool isBigEndian() const = 0;
virtual bool isLittleEndian()const= 0; virtual bool isLittleEndian()const = 0;
virtual bool isOpen() const= 0; virtual bool isOpen() const = 0;
virtual void seek(atInt64, SeekOrigin)=0; virtual void seek(atInt64, SeekOrigin) = 0;
virtual bool atEnd() const= 0; virtual bool atEnd() const = 0;
virtual atUint64 position() const= 0; virtual atUint64 position() const = 0;
virtual atUint64 length() const= 0; virtual atUint64 length() const = 0;
virtual void seekBit (int)=0; virtual void seekBit(int) = 0;
}; };
} }
} }

Some files were not shown because too many files have changed in this diff Show More