diff --git a/adaptive_compress.c b/adaptive_compress.c index c492f4f..13991a2 100644 --- a/adaptive_compress.c +++ b/adaptive_compress.c @@ -44,31 +44,31 @@ static unsigned int bzip2_count = 0; static unsigned int bsc_count = 0; static unsigned int ppmd_count = 0; -extern int lzma_compress(void *src, size_t srclen, void *dst, - size_t *destlen, int level, uchar_t chdr, void *data); -extern int bzip2_compress(void *src, size_t srclen, void *dst, - size_t *destlen, int level, uchar_t chdr, void *data); -extern int ppmd_compress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int libbsc_compress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); +extern int lzma_compress(void *src, uint64_t srclen, void *dst, + uint64_t *destlen, int level, uchar_t chdr, void *data); +extern int bzip2_compress(void *src, uint64_t srclen, void *dst, + uint64_t *destlen, int level, uchar_t chdr, void *data); +extern int ppmd_compress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int libbsc_compress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); -extern int lzma_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int bzip2_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int ppmd_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int libbsc_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); +extern int lzma_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int bzip2_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int ppmd_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int libbsc_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); -extern int lzma_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int lzma_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); extern int lzma_deinit(void **data); -extern int ppmd_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int ppmd_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); extern int ppmd_deinit(void **data); -extern int libbsc_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int libbsc_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); extern int libbsc_deinit(void **data); @@ -96,13 +96,13 @@ adapt_stats(int show) } void -adapt_props(algo_props_t *data, int level, ssize_t chunksize) +adapt_props(algo_props_t *data, int level, int64_t chunksize) { data->delta2_stride = 200; } int -adapt_init(void **data, int *level, int nthreads, ssize_t chunksize, +adapt_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op) { struct adapt_data *adat = (struct adapt_data *)(*data); @@ -125,7 +125,7 @@ adapt_init(void **data, int *level, int nthreads, ssize_t chunksize, } int -adapt2_init(void **data, int *level, int nthreads, ssize_t chunksize, +adapt2_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op) { struct adapt_data *adat = (struct adapt_data *)(*data); @@ -173,12 +173,12 @@ adapt_deinit(void **data) } int -adapt_compress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data) +adapt_compress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data) { struct adapt_data *adat = (struct adapt_data *)(data); uchar_t *src1 = (uchar_t *)src; - size_t i, tot8b, tagcnt; + uint64_t i, tot8b, tagcnt; int rv, tag; /* @@ -232,8 +232,8 @@ adapt_compress(void *src, size_t srclen, void *dst, } int -adapt_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data) +adapt_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data) { struct adapt_data *adat = (struct adapt_data *)(data); uchar_t cmp_flags; diff --git a/allocator.c b/allocator.c index 6efa4dc..c9b9fff 100644 --- a/allocator.c +++ b/allocator.c @@ -80,7 +80,7 @@ static const unsigned int bv[] = { struct slabentry { struct bufentry *avail; struct slabentry *next; - size_t sz; + uint64_t sz; uint64_t allocs, hits; pthread_mutex_t slab_lock; }; @@ -103,7 +103,7 @@ void slab_init() { int i; - size_t slab_sz; + uint64_t slab_sz; int nprocs; /* Check bypass env variable. */ @@ -263,7 +263,7 @@ slab_cleanup(int quiet) } void * -slab_calloc(void *p, size_t items, size_t size) { +slab_calloc(void *p, uint64_t items, uint64_t size) { void *ptr; if (bypass) return(calloc(items, size)); @@ -305,7 +305,7 @@ find_slot(unsigned int v) } static void * -try_dynamic_slab(size_t size) +try_dynamic_slab(uint64_t size) { uint32_t sindx; struct slabentry *slab; @@ -325,7 +325,7 @@ try_dynamic_slab(size_t size) } int -slab_cache_add(size_t size) +slab_cache_add(uint64_t size) { uint32_t sindx; struct slabentry *slab; @@ -359,11 +359,11 @@ slab_cache_add(size_t size) } void * -slab_alloc(void *p, size_t size) +slab_alloc(void *p, uint64_t size) { - size_t slab_sz = SLAB_START_SZ; + uint64_t slab_sz = SLAB_START_SZ; int i; - size_t div; + uint64_t div; void *ptr; struct slabentry *slab; @@ -491,13 +491,13 @@ void slab_cleanup(int quiet) {} void -*slab_alloc(void *p, size_t size) +*slab_alloc(void *p, uint64_t size) { return (malloc(size)); } void -*slab_calloc(void *p, size_t items, size_t size) +*slab_calloc(void *p, uint64_t items, uint64_t size) { return (calloc(items, size)); } @@ -509,6 +509,6 @@ slab_free(void *p, void *address) } int -slab_cache_add(size_t size) {} +slab_cache_add(uint64_t size) {} #endif diff --git a/allocator.h b/allocator.h index eb21cee..ec1f36e 100644 --- a/allocator.h +++ b/allocator.h @@ -25,13 +25,14 @@ #define __ALLOCATOR_H__ #include +#include void slab_init(); void slab_cleanup(int quiet); -void *slab_alloc(void *p, size_t size); -void *slab_calloc(void *p, size_t items, size_t size); +void *slab_alloc(void *p, uint64_t size); +void *slab_calloc(void *p, uint64_t items, uint64_t size); void slab_free(void *p, void *address); -int slab_cache_add(size_t size); +int slab_cache_add(uint64_t size); #endif diff --git a/bzip2_compress.c b/bzip2_compress.c index 711019f..a3896a7 100644 --- a/bzip2_compress.c +++ b/bzip2_compress.c @@ -37,7 +37,7 @@ static void * slab_alloc_i(void *p, int items, int size) { void *ptr; - size_t tot = (size_t)items * (size_t)size; + uint64_t tot = (uint64_t)items * (uint64_t)size; ptr = slab_alloc(p, tot); return (ptr); @@ -49,12 +49,12 @@ bzip2_stats(int show) } void -bzip2_props(algo_props_t *data, int level, ssize_t chunksize) { +bzip2_props(algo_props_t *data, int level, int64_t chunksize) { data->delta2_stride = 200; } int -bzip2_init(void **data, int *level, int nthreads, ssize_t chunksize, +bzip2_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op) { if (*level > 9) *level = 9; @@ -92,14 +92,14 @@ bzerr(int err) } int -bzip2_compress(void *src, size_t srclen, void *dst, size_t *dstlen, +bzip2_compress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { bz_stream bzs; int ret, ending; unsigned int slen, dlen; - size_t _srclen = srclen; - size_t _dstlen = *dstlen; + uint64_t _srclen = srclen; + uint64_t _dstlen = *dstlen; uchar_t *dst1 = dst; uchar_t *src1 = src; @@ -161,14 +161,14 @@ bzip2_compress(void *src, size_t srclen, void *dst, size_t *dstlen, } int -bzip2_decompress(void *src, size_t srclen, void *dst, size_t *dstlen, +bzip2_decompress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { bz_stream bzs; int ret; unsigned int slen, dlen; - size_t _srclen = srclen; - size_t _dstlen = *dstlen; + uint64_t _srclen = srclen; + uint64_t _dstlen = *dstlen; uchar_t *dst1 = dst; uchar_t *src1 = src; diff --git a/crypto/crypto_utils.c b/crypto/crypto_utils.c index caebdf4..125c648 100644 --- a/crypto/crypto_utils.c +++ b/crypto/crypto_utils.c @@ -69,12 +69,12 @@ static struct { static int cksum_provider = PROVIDER_OPENSSL, ossl_inited = 0; -extern uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc); -extern uint64_t lzma_crc64_8bchk(const uint8_t *buf, size_t size, +extern uint64_t lzma_crc64(const uint8_t *buf, uint64_t size, uint64_t crc); +extern uint64_t lzma_crc64_8bchk(const uint8_t *buf, uint64_t size, uint64_t crc, uint64_t *cnt); int -compute_checksum(uchar_t *cksum_buf, int cksum, uchar_t *buf, ssize_t bytes) +compute_checksum(uchar_t *cksum_buf, int cksum, uchar_t *buf, int64_t bytes) { if (cksum == CKSUM_CRC64) { uint64_t *ck = (uint64_t *)cksum_buf; @@ -345,7 +345,7 @@ hmac_reinit(mac_ctx_t *mctx) } int -hmac_update(mac_ctx_t *mctx, uchar_t *data, size_t len) +hmac_update(mac_ctx_t *mctx, uchar_t *data, uint64_t len) { int cksum = mctx->mac_cksum; @@ -529,7 +529,7 @@ init_crypto(crypto_ctx_t *cctx, uchar_t *pwd, int pwd_len, int crypto_alg, } int -crypto_buf(crypto_ctx_t *cctx, uchar_t *from, uchar_t *to, ssize_t bytes, uint64_t id) +crypto_buf(crypto_ctx_t *cctx, uchar_t *from, uchar_t *to, int64_t bytes, uint64_t id) { if (cctx->crypto_alg == CRYPTO_ALG_AES) { if (cctx->enc_dec == ENCRYPT_FLAG) { @@ -569,9 +569,9 @@ static int geturandom_bytes(uchar_t rbytes[32]) { int fd; - ssize_t lenread; + int64_t lenread; uchar_t * buf = rbytes; - size_t buflen = 32; + uint64_t buflen = 32; /* Open /dev/urandom. */ if ((fd = open("/dev/urandom", O_RDONLY)) == -1) diff --git a/crypto/crypto_utils.h b/crypto/crypto_utils.h index 16f9ec4..0163193 100644 --- a/crypto/crypto_utils.h +++ b/crypto/crypto_utils.h @@ -74,7 +74,7 @@ typedef struct { /* * Generic message digest functions. */ -int compute_checksum(uchar_t *cksum_buf, int cksum, uchar_t *buf, ssize_t bytes); +int compute_checksum(uchar_t *cksum_buf, int cksum, uchar_t *buf, int64_t bytes); int get_checksum_props(char *name, int *cksum, int *cksum_bytes, int *mac_bytes); void serialize_checksum(uchar_t *checksum, uchar_t *buf, int cksum_bytes); void deserialize_checksum(uchar_t *checksum, uchar_t *buf, int cksum_bytes); @@ -84,7 +84,7 @@ void deserialize_checksum(uchar_t *checksum, uchar_t *buf, int cksum_bytes); */ int init_crypto(crypto_ctx_t *cctx, uchar_t *pwd, int pwd_len, int crypto_alg, uchar_t *salt, int saltlen, uint64_t nonce, int enc_dec); -int crypto_buf(crypto_ctx_t *cctx, uchar_t *from, uchar_t *to, ssize_t bytes, uint64_t id); +int crypto_buf(crypto_ctx_t *cctx, uchar_t *from, uchar_t *to, int64_t bytes, uint64_t id); uint64_t crypto_nonce(crypto_ctx_t *cctx); void crypto_clean_pkey(crypto_ctx_t *cctx); void cleanup_crypto(crypto_ctx_t *cctx); @@ -95,7 +95,7 @@ int get_pw_string(char pw[MAX_PW_LEN], char *prompt, int twice); */ int hmac_init(mac_ctx_t *mctx, int cksum, crypto_ctx_t *cctx); int hmac_reinit(mac_ctx_t *mctx); -int hmac_update(mac_ctx_t *mctx, uchar_t *data, size_t len); +int hmac_update(mac_ctx_t *mctx, uchar_t *data, uint64_t len); int hmac_cleanup(mac_ctx_t *mctx); #ifdef __cplusplus diff --git a/delta2/delta2.c b/delta2/delta2.c index a8060ca..c125d30 100644 --- a/delta2/delta2.c +++ b/delta2/delta2.c @@ -60,7 +60,7 @@ #define DELTA_HDR (1 + (sizeof (uint64_t)) * 3) int -delta2_encode(uchar_t *src, size_t srclen, uchar_t *dst, size_t *dstlen, int rle_thresh) +delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int rle_thresh) { uint64_t snum, gtot1, gtot2, tot; uint64_t cnt, val, sval; @@ -234,7 +234,7 @@ delta2_encode(uchar_t *src, size_t srclen, uchar_t *dst, size_t *dstlen, int rle } int -delta2_decode(uchar_t *src, size_t srclen, uchar_t *dst, size_t *dstlen) +delta2_decode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen) { uchar_t *pos, *pos1, *last; uint64_t olen, val, sval, delta, rcnt, cnt, out; diff --git a/delta2/delta2.h b/delta2/delta2.h index 42225df..8abc3ad 100644 --- a/delta2/delta2.h +++ b/delta2/delta2.h @@ -30,8 +30,8 @@ extern "C" { #endif -int delta2_encode(uchar_t *src, size_t srclen, uchar_t *dst, size_t *dstlen, int rle_thresh); -int delta2_decode(uchar_t *src, size_t srclen, uchar_t *dst, size_t *dstlen); +int delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int rle_thresh); +int delta2_decode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen); #define ULL_MAX (18446744073709551615ULL) diff --git a/libbsc_compress.c b/libbsc_compress.c index a3babf2..a7620e5 100644 --- a/libbsc_compress.c +++ b/libbsc_compress.c @@ -72,7 +72,7 @@ libbsc_stats(int show) * when compressing entire file in a single chunk. */ void -libbsc_props(algo_props_t *data, int level, ssize_t chunksize) { +libbsc_props(algo_props_t *data, int level, int64_t chunksize) { data->compress_mt_capable = 0; data->decompress_mt_capable = 0; data->single_chunk_mt_capable = 1; @@ -83,7 +83,7 @@ libbsc_props(algo_props_t *data, int level, ssize_t chunksize) { } int -libbsc_init(void **data, int *level, int nthreads, ssize_t chunksize, +libbsc_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op) { struct libbsc_params *bscdat; @@ -141,7 +141,7 @@ libbsc_deinit(void **data) } int -libbsc_compress(void *src, size_t srclen, void *dst, size_t *dstlen, +libbsc_compress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { int rv; @@ -158,7 +158,7 @@ libbsc_compress(void *src, size_t srclen, void *dst, size_t *dstlen, } int -libbsc_decompress(void *src, size_t srclen, void *dst, size_t *dstlen, +libbsc_decompress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { int rv; diff --git a/lz4_compress.c b/lz4_compress.c index 2db9f7c..b8dfbdf 100644 --- a/lz4_compress.c +++ b/lz4_compress.c @@ -44,7 +44,7 @@ lz4_stats(int show) } int -lz4_buf_extra(ssize_t buflen) +lz4_buf_extra(int64_t buflen) { if (buflen > LZ4_MAX_CHUNK) buflen = LZ4_MAX_CHUNK; @@ -52,7 +52,7 @@ lz4_buf_extra(ssize_t buflen) } void -lz4_props(algo_props_t *data, int level, ssize_t chunksize) { +lz4_props(algo_props_t *data, int level, int64_t chunksize) { data->compress_mt_capable = 0; data->decompress_mt_capable = 0; data->buf_extra = lz4_buf_extra(chunksize); @@ -60,7 +60,7 @@ lz4_props(algo_props_t *data, int level, ssize_t chunksize) { } int -lz4_init(void **data, int *level, int nthreads, ssize_t chunksize, +lz4_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op) { struct lz4_params *lzdat; @@ -95,7 +95,7 @@ lz4_deinit(void **data) } int -lz4_compress(void *src, size_t srclen, void *dst, size_t *dstlen, +lz4_compress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { int rv; @@ -131,7 +131,7 @@ lz4_compress(void *src, size_t srclen, void *dst, size_t *dstlen, } int -lz4_decompress(void *src, size_t srclen, void *dst, size_t *dstlen, +lz4_decompress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { int rv; diff --git a/lzfx_compress.c b/lzfx_compress.c index 2dc3a1d..1319936 100644 --- a/lzfx_compress.c +++ b/lzfx_compress.c @@ -40,12 +40,12 @@ lz_fx_stats(int show) } void -lz_fx_props(algo_props_t *data, int level, ssize_t chunksize) { +lz_fx_props(algo_props_t *data, int level, int64_t chunksize) { data->delta2_stride = 50; } int -lz_fx_init(void **data, int *level, int nthreads, ssize_t chunksize, +lz_fx_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op) { struct lzfx_params *lzdat; @@ -100,7 +100,7 @@ lz_fx_err(int err) } int -lz_fx_compress(void *src, size_t srclen, void *dst, size_t *dstlen, +lz_fx_compress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { int rv; @@ -120,7 +120,7 @@ lz_fx_compress(void *src, size_t srclen, void *dst, size_t *dstlen, } int -lz_fx_decompress(void *src, size_t srclen, void *dst, size_t *dstlen, +lz_fx_decompress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { int rv; diff --git a/lzma_compress.c b/lzma_compress.c index ba36b81..c7f77f9 100644 --- a/lzma_compress.c +++ b/lzma_compress.c @@ -47,7 +47,7 @@ lzma_stats(int show) } void -lzma_mt_props(algo_props_t *data, int level, ssize_t chunksize) { +lzma_mt_props(algo_props_t *data, int level, int64_t chunksize) { data->compress_mt_capable = 1; data->decompress_mt_capable = 0; data->buf_extra = 0; @@ -56,7 +56,7 @@ lzma_mt_props(algo_props_t *data, int level, ssize_t chunksize) { } void -lzma_props(algo_props_t *data, int level, ssize_t chunksize) { +lzma_props(algo_props_t *data, int level, int64_t chunksize) { data->compress_mt_capable = 0; data->decompress_mt_capable = 0; data->buf_extra = 0; @@ -67,7 +67,7 @@ lzma_props(algo_props_t *data, int level, ssize_t chunksize) { * The two functions below are not thread-safe, by design. */ int -lzma_init(void **data, int *level, int nthreads, ssize_t chunksize, +lzma_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op) { if (!p && op == COMPRESS) { @@ -188,10 +188,10 @@ lzerr(int err, int cmp) * our chunk header. */ int -lzma_compress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data) +lzma_compress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data) { - size_t props_len = LZMA_PROPS_SIZE; + uint64_t props_len = LZMA_PROPS_SIZE; SRes res; Byte *_dst; CLzmaEncProps *props = (CLzmaEncProps *)data; @@ -217,10 +217,10 @@ lzma_compress(void *src, size_t srclen, void *dst, } int -lzma_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data) +lzma_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data) { - size_t _srclen; + uint64_t _srclen; const uchar_t *_src; SRes res; ELzmaStatus status; diff --git a/lzp/lzp.c b/lzp/lzp.c index 1c5328d..45ea6ff 100644 --- a/lzp/lzp.c +++ b/lzp/lzp.c @@ -49,7 +49,7 @@ See also the bsc and libbsc web site: #define LZP_MATCH_FLAG 0xf2 static -inline int bsc_lzp_num_blocks(ssize_t n) +inline int bsc_lzp_num_blocks(int64_t n) { int nb; @@ -231,7 +231,7 @@ int bsc_lzp_decode_block(const unsigned char * input, const unsigned char * inpu } static -ssize_t bsc_lzp_compress_serial(const unsigned char * input, unsigned char * output, ssize_t n, int hashSize, int minLen) +int64_t bsc_lzp_compress_serial(const unsigned char * input, unsigned char * output, int64_t n, int hashSize, int minLen) { if (bsc_lzp_num_blocks(n) == 1) { @@ -244,7 +244,7 @@ ssize_t bsc_lzp_compress_serial(const unsigned char * input, unsigned char * out int nBlocks = bsc_lzp_num_blocks(n); int chunkSize; int blockId; - ssize_t outputPtr = 1 + 8 * nBlocks; + int64_t outputPtr = 1 + 8 * nBlocks; if (n > LZP_MAX_BLOCK) chunkSize = LZP_MAX_BLOCK; @@ -254,7 +254,7 @@ ssize_t bsc_lzp_compress_serial(const unsigned char * input, unsigned char * out output[0] = nBlocks; for (blockId = 0; blockId < nBlocks; ++blockId) { - ssize_t inputStart = blockId * chunkSize; + int64_t inputStart = blockId * chunkSize; int inputSize = blockId != nBlocks - 1 ? chunkSize : n - inputStart; int outputSize = inputSize; if (outputSize > n - outputPtr) outputSize = n - outputPtr; @@ -277,7 +277,7 @@ ssize_t bsc_lzp_compress_serial(const unsigned char * input, unsigned char * out #ifdef LZP_OPENMP static -int bsc_lzp_compress_parallel(const unsigned char * input, unsigned char * output, ssize_t n, int hashSize, int minLen) +int bsc_lzp_compress_parallel(const unsigned char * input, unsigned char * output, int64_t n, int hashSize, int minLen) { if (unsigned char * buffer = (unsigned char *)bsc_malloc(n * sizeof(unsigned char))) { @@ -356,7 +356,7 @@ int bsc_lzp_compress_parallel(const unsigned char * input, unsigned char * outpu #endif -ssize_t lzp_compress(const unsigned char * input, unsigned char * output, ssize_t n, int hashSize, int minLen, int features) +int64_t lzp_compress(const unsigned char * input, unsigned char * output, int64_t n, int hashSize, int minLen, int features) { #ifdef LZP_OPENMP @@ -371,7 +371,7 @@ ssize_t lzp_compress(const unsigned char * input, unsigned char * output, ssize_ return bsc_lzp_compress_serial(input, output, n, hashSize, minLen); } -ssize_t lzp_decompress(const unsigned char * input, unsigned char * output, ssize_t n, int hashSize, int minLen, int features) +int64_t lzp_decompress(const unsigned char * input, unsigned char * output, int64_t n, int hashSize, int minLen, int features) { int nBlocks = input[0]; @@ -416,8 +416,8 @@ ssize_t lzp_decompress(const unsigned char * input, unsigned char * output, ssiz for (blockId = 0; blockId < nBlocks; ++blockId) { - ssize_t inputPtr = 0; for (p = 0; p < blockId; ++p) inputPtr += *(int *)(input + 1 + 8 * p + 4); - ssize_t outputPtr = 0; for (p = 0; p < blockId; ++p) outputPtr += *(int *)(input + 1 + 8 * p + 0); + int64_t inputPtr = 0; for (p = 0; p < blockId; ++p) inputPtr += *(int *)(input + 1 + 8 * p + 4); + int64_t outputPtr = 0; for (p = 0; p < blockId; ++p) outputPtr += *(int *)(input + 1 + 8 * p + 0); inputPtr += 1 + 8 * nBlocks; @@ -435,7 +435,7 @@ ssize_t lzp_decompress(const unsigned char * input, unsigned char * output, ssiz } } - ssize_t dataSize = 0; + int64_t dataSize = 0; int result = LZP_NO_ERROR; int blockId; for (blockId = 0; blockId < nBlocks; ++blockId) diff --git a/lzp/lzp.h b/lzp/lzp.h index 4f8ddac..c7443c9 100644 --- a/lzp/lzp.h +++ b/lzp/lzp.h @@ -63,7 +63,7 @@ extern "C" { * @param features - the set of additional features. * @return The length of preprocessed memory block if no error occurred, error code otherwise. */ - ssize_t lzp_compress(const unsigned char * input, unsigned char * output, ssize_t n, int hashSize, int minLen, int features); + int64_t lzp_compress(const unsigned char * input, unsigned char * output, int64_t n, int hashSize, int minLen, int features); /** * Reconstructs the original memory block after LZP algorithm. @@ -75,7 +75,7 @@ extern "C" { * @param features - the set of additional features. * @return The length of original memory block if no error occurred, error code otherwise. */ - ssize_t lzp_decompress(const unsigned char * input, unsigned char * output, ssize_t n, int hashSize, int minLen, int features); + int64_t lzp_decompress(const unsigned char * input, unsigned char * output, int64_t n, int hashSize, int minLen, int features); int lzp_hash_size(int level); #ifdef __cplusplus diff --git a/main.c b/main.c index 3bbbbbf..424ad55 100644 --- a/main.c +++ b/main.c @@ -57,13 +57,13 @@ struct wdata { struct cmp_data **dary; int wfd; int nprocs; - ssize_t chunksize; + int64_t chunksize; }; static void * writer_thread(void *dat); static int init_algo(const char *algo, int bail); -extern uint32_t lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc); +extern uint32_t lzma_crc32(const uint8_t *buf, uint64_t size, uint32_t crc); static compress_func_ptr _compress_func; static compress_func_ptr _decompress_func; @@ -190,11 +190,11 @@ show_compression_stats(uint64_t chunksize) * is not allowed. */ int -preproc_compress(compress_func_ptr cmp_func, void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data, algo_props_t *props) +preproc_compress(compress_func_ptr cmp_func, void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data, algo_props_t *props) { uchar_t *dest = (uchar_t *)dst, type = 0; - ssize_t result, _dstlen; + int64_t result, _dstlen; if (lzp_preprocess) { int hashsize; @@ -240,11 +240,11 @@ preproc_compress(compress_func_ptr cmp_func, void *src, size_t srclen, void *dst } int -preproc_decompress(compress_func_ptr dec_func, void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data, algo_props_t *props) +preproc_decompress(compress_func_ptr dec_func, void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data, algo_props_t *props) { uchar_t *sorc = (uchar_t *)src, type; - ssize_t result; + int64_t result; uint64_t _dstlen = *dstlen; type = *sorc; @@ -296,8 +296,8 @@ static void * perform_decompress(void *dat) { struct cmp_data *tdat = (struct cmp_data *)dat; - ssize_t _chunksize; - ssize_t dedupe_index_sz, dedupe_data_sz, dedupe_index_sz_cmp, dedupe_data_sz_cmp; + int64_t _chunksize; + int64_t dedupe_index_sz, dedupe_data_sz, dedupe_index_sz_cmp, dedupe_data_sz_cmp; int type, rv; unsigned int blknum; uchar_t checksum[CKSUM_MAX_BYTES]; @@ -330,7 +330,7 @@ redo: tdat->rbytes -= ORIGINAL_CHUNKSZ; tdat->len_cmp -= ORIGINAL_CHUNKSZ; rseg = tdat->compressed_chunk + tdat->rbytes; - _chunksize = ntohll(*((ssize_t *)rseg)); + _chunksize = ntohll(*((int64_t *)rseg)); } /* @@ -569,7 +569,7 @@ start_decompress(const char *filename, const char *to_filename) int uncompfd = -1, err, np, bail; int nprocs, thread = 0, level; short version, flags; - ssize_t chunksize, compressed_chunksize; + int64_t chunksize, compressed_chunksize; struct cmp_data **dary, *tdat; pthread_t writer_thr; algo_props_t props; @@ -944,7 +944,7 @@ start_decompress(const char *filename, const char *to_filename) np = 0; bail = 0; while (!bail) { - ssize_t rb; + int64_t rb; if (main_cancel) break; for (p = 0; p < nprocs; p++) { @@ -1097,7 +1097,7 @@ perform_compress(void *dat) { typeof (tdat->chunksize) _chunksize, len_cmp, dedupe_index_sz, index_size_cmp; int type, rv; uchar_t *compressed_chunk; - ssize_t rbytes; + int64_t rbytes; redo: sem_wait(&tdat->start_sem); @@ -1326,7 +1326,7 @@ writer_thread(void *dat) { int p; struct wdata *w = (struct wdata *)dat; struct cmp_data *tdat; - ssize_t wbytes; + int64_t wbytes; repeat: for (p = 0; p < w->nprocs; p++) { @@ -1374,8 +1374,8 @@ start_compress(const char *filename, uint64_t chunksize, int level) struct wdata w; char tmpfile1[MAXPATHLEN]; char to_filename[MAXPATHLEN]; - ssize_t compressed_chunksize; - ssize_t n_chunksize, rbytes, rabin_count; + int64_t compressed_chunksize; + int64_t n_chunksize, rbytes, rabin_count; short version, flags; struct stat sbuf; int compfd = -1, uncompfd = -1, err; @@ -2046,7 +2046,7 @@ main(int argc, char *argv[]) { char *filename = NULL; char *to_filename = NULL; - ssize_t chunksize = DEFAULT_CHUNKSIZE; + int64_t chunksize = DEFAULT_CHUNKSIZE; int opt, level, num_rem, err; exec_name = get_execname(argv[0]); diff --git a/none_compress.c b/none_compress.c index 7533112..39e0bc6 100644 --- a/none_compress.c +++ b/none_compress.c @@ -37,7 +37,7 @@ none_stats(int show) } int -none_init(void **data, int *level, int nthreads, ssize_t chunksize, +none_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op) { return (0); @@ -50,7 +50,7 @@ none_deinit(void **data) } int -none_compress(void *src, size_t srclen, void *dst, size_t *dstlen, +none_compress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { memcpy(dst, src, srclen); @@ -58,7 +58,7 @@ none_compress(void *src, size_t srclen, void *dst, size_t *dstlen, } int -none_decompress(void *src, size_t srclen, void *dst, size_t *dstlen, +none_decompress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { memcpy(dst, src, srclen); diff --git a/pcompress.h b/pcompress.h index ab01585..a6c44f7 100644 --- a/pcompress.h +++ b/pcompress.h @@ -77,70 +77,70 @@ extern "C" { #define COMPRESS_BSC 4 #define CHDR_ALGO_MASK 7 -extern uint32_t zlib_buf_extra(ssize_t buflen); -extern int lz4_buf_extra(ssize_t buflen); +extern uint32_t zlib_buf_extra(int64_t buflen); +extern int lz4_buf_extra(int64_t buflen); -extern int zlib_compress(void *src, size_t srclen, void *dst, - size_t *destlen, int level, uchar_t chdr, void *data); -extern int lzma_compress(void *src, size_t srclen, void *dst, - size_t *destlen, int level, uchar_t chdr, void *data); -extern int bzip2_compress(void *src, size_t srclen, void *dst, - size_t *destlen, int level, uchar_t chdr, void *data); -extern int adapt_compress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int ppmd_compress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int lz_fx_compress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int lz4_compress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int none_compress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); +extern int zlib_compress(void *src, uint64_t srclen, void *dst, + uint64_t *destlen, int level, uchar_t chdr, void *data); +extern int lzma_compress(void *src, uint64_t srclen, void *dst, + uint64_t *destlen, int level, uchar_t chdr, void *data); +extern int bzip2_compress(void *src, uint64_t srclen, void *dst, + uint64_t *destlen, int level, uchar_t chdr, void *data); +extern int adapt_compress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int ppmd_compress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int lz_fx_compress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int lz4_compress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int none_compress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); -extern int zlib_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int lzma_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int bzip2_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int adapt_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int ppmd_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int lz_fx_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int lz4_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int none_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); +extern int zlib_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int lzma_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int bzip2_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int adapt_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int ppmd_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int lz_fx_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int lz4_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int none_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); -extern int adapt_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int adapt_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); -extern int adapt2_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int adapt2_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); -extern int lzma_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int lzma_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); -extern int ppmd_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int ppmd_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); -extern int bzip2_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int bzip2_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); -extern int zlib_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int zlib_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); -extern int lz_fx_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int lz_fx_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); -extern int lz4_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int lz4_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); -extern int none_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int none_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); -extern void lzma_props(algo_props_t *data, int level, ssize_t chunksize); -extern void lzma_mt_props(algo_props_t *data, int level, ssize_t chunksize); -extern void lz4_props(algo_props_t *data, int level, ssize_t chunksize); -extern void zlib_props(algo_props_t *data, int level, ssize_t chunksize); -extern void ppmd_props(algo_props_t *data, int level, ssize_t chunksize); -extern void lz_fx_props(algo_props_t *data, int level, ssize_t chunksize); -extern void bzip2_props(algo_props_t *data, int level, ssize_t chunksize); -extern void adapt_props(algo_props_t *data, int level, ssize_t chunksize); +extern void lzma_props(algo_props_t *data, int level, int64_t chunksize); +extern void lzma_mt_props(algo_props_t *data, int level, int64_t chunksize); +extern void lz4_props(algo_props_t *data, int level, int64_t chunksize); +extern void zlib_props(algo_props_t *data, int level, int64_t chunksize); +extern void ppmd_props(algo_props_t *data, int level, int64_t chunksize); +extern void lz_fx_props(algo_props_t *data, int level, int64_t chunksize); +extern void bzip2_props(algo_props_t *data, int level, int64_t chunksize); +extern void adapt_props(algo_props_t *data, int level, int64_t chunksize); extern int zlib_deinit(void **data); extern int adapt_deinit(void **data); @@ -160,13 +160,13 @@ extern void lz4_stats(int show); extern void none_stats(int show); #ifdef ENABLE_PC_LIBBSC -extern int libbsc_compress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int libbsc_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); -extern int libbsc_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int libbsc_compress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int libbsc_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); +extern int libbsc_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); -extern void libbsc_props(algo_props_t *data, int level, ssize_t chunksize); +extern void libbsc_props(algo_props_t *data, int level, int64_t chunksize); extern int libbsc_deinit(void **data); extern void libbsc_stats(int show); #endif @@ -179,9 +179,9 @@ struct cmp_data { uchar_t *compressed_chunk; uchar_t *uncompressed_chunk; dedupe_context_t *rctx; - ssize_t rbytes; - ssize_t chunksize; - ssize_t len_cmp, len_cmp_be; + int64_t rbytes; + int64_t chunksize; + int64_t len_cmp, len_cmp_be; uchar_t checksum[CKSUM_MAX_BYTES]; int level; unsigned int id; diff --git a/ppmd_compress.c b/ppmd_compress.c index 2ff391b..4bb50f9 100644 --- a/ppmd_compress.c +++ b/ppmd_compress.c @@ -62,12 +62,12 @@ ppmd_stats(int show) } void -ppmd_props(algo_props_t *data, int level, ssize_t chunksize) { +ppmd_props(algo_props_t *data, int level, int64_t chunksize) { data->delta2_stride = 100; } int -ppmd_init(void **data, int *level, int nthreads, ssize_t chunksize, +ppmd_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op) { CPpmd8 *_ppmd; @@ -105,8 +105,8 @@ ppmd_deinit(void **data) } int -ppmd_compress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data) +ppmd_compress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data) { CPpmd8 *_ppmd = (CPpmd8 *)data; uchar_t *_src = (uchar_t *)src; @@ -129,13 +129,13 @@ ppmd_compress(void *src, size_t srclen, void *dst, } int -ppmd_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data) +ppmd_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data) { CPpmd8 *_ppmd = (CPpmd8 *)data; Byte *_src = (Byte *)src; Byte *_dst = (Byte *)dst; - size_t i; + uint64_t i; int res; _ppmd->buf = (Byte *)_src; diff --git a/rabin/rabin_dedup.c b/rabin/rabin_dedup.c index 754cbae..e7d051b 100755 --- a/rabin/rabin_dedup.c +++ b/rabin/rabin_dedup.c @@ -71,12 +71,12 @@ #define FIFTY_PCNT(x) ((x) >> 1) #define SIXTY_PCNT(x) (((x) >> 1) + ((x) >> 3)) -extern int lzma_init(void **data, int *level, int nthreads, ssize_t chunksize, +extern int lzma_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); -extern int lzma_compress(void *src, size_t srclen, void *dst, - size_t *destlen, int level, uchar_t chdr, void *data); -extern int lzma_decompress(void *src, size_t srclen, void *dst, - size_t *dstlen, int level, uchar_t chdr, void *data); +extern int lzma_compress(void *src, uint64_t srclen, void *dst, + uint64_t *destlen, int level, uchar_t chdr, void *data); +extern int lzma_decompress(void *src, uint64_t srclen, void *dst, + uint64_t *dstlen, int level, uchar_t chdr, void *data); extern int lzma_deinit(void **data); extern int bsdiff(u_char *old, bsize_t oldsize, u_char *new, bsize_t newsize, u_char *diff, u_char *scratch, bsize_t scratchsize); @@ -279,9 +279,9 @@ destroy_dedupe_context(dedupe_context_t *ctx) * from 4K-128K. */ uint32_t -dedupe_compress(dedupe_context_t *ctx, uchar_t *buf, ssize_t *size, ssize_t offset, ssize_t *rabin_pos) +dedupe_compress(dedupe_context_t *ctx, uchar_t *buf, int64_t *size, int64_t offset, int64_t *rabin_pos) { - ssize_t i, last_offset, j, ary_sz; + int64_t i, last_offset, j, ary_sz; uint32_t blknum; char *buf1 = (char *)buf; uint32_t length; @@ -379,7 +379,7 @@ dedupe_compress(dedupe_context_t *ctx, uchar_t *buf, ssize_t *size, ssize_t offs j = 0; for (i=offset; i<*size; i++) { - ssize_t pc[4]; + int64_t pc[4]; uchar_t cur_byte = buf1[i]; uint64_t pushed_out = ctx->current_window_data[ctx->window_pos]; ctx->current_window_data[ctx->window_pos] = cur_byte; @@ -460,7 +460,7 @@ dedupe_compress(dedupe_context_t *ctx, uchar_t *buf, ssize_t *size, ssize_t offs if (ctx->delta_flag) { uint64_t cur_sketch; - ssize_t pc[3]; + int64_t pc[3]; if (j > 1) { pc[1] = SIXTY_PCNT(j); @@ -487,10 +487,10 @@ process_blocks: DEBUG_STAT_EN(printf("Original size: %" PRId64 ", blknum: %u\n", *size, blknum)); DEBUG_STAT_EN(printf("Number of maxlen blocks: %u\n", max_count)); if (blknum > 2) { - ssize_t pos, matchlen, pos1; + int64_t pos, matchlen, pos1; int valid = 1; uint32_t *dedupe_index; - ssize_t dedupe_index_sz; + int64_t dedupe_index_sz; rabin_blockentry_t *be; DEBUG_STAT_EN(uint32_t delta_calls, delta_fails, merge_count, hash_collisions); DEBUG_STAT_EN(delta_calls = 0); @@ -607,7 +607,7 @@ process_blocks: } DEBUG_STAT_EN(printf("Total Hashtable bucket collisions: %u\n", hash_collisions)); - dedupe_index_sz = (ssize_t)blknum * RABIN_ENTRY_SIZE; + dedupe_index_sz = (int64_t)blknum * RABIN_ENTRY_SIZE; if (matchlen < dedupe_index_sz) { ctx->valid = 0; return; @@ -645,7 +645,7 @@ process_blocks: * Final pass update dedupe index and copy data. */ blknum = pos; - dedupe_index_sz = (ssize_t)blknum * RABIN_ENTRY_SIZE; + dedupe_index_sz = (int64_t)blknum * RABIN_ENTRY_SIZE; pos1 = dedupe_index_sz + RABIN_HDR_SIZE; matchlen = ctx->real_chunksize - *size; for (i=0; icbuf; - ssize_t *entries; + int64_t *entries; *((uint32_t *)cbuf) = htonl(blknum); cbuf += sizeof (uint32_t); - entries = (ssize_t *)cbuf; + entries = (int64_t *)cbuf; entries[0] = htonll(*size); entries[1] = 0; entries[2] = htonll(pos1 - dedupe_index_sz - RABIN_HDR_SIZE); @@ -710,41 +710,41 @@ cont: } void -update_dedupe_hdr(uchar_t *buf, ssize_t dedupe_index_sz_cmp, ssize_t dedupe_data_sz_cmp) +update_dedupe_hdr(uchar_t *buf, int64_t dedupe_index_sz_cmp, int64_t dedupe_data_sz_cmp) { - ssize_t *entries; + int64_t *entries; buf += sizeof (uint32_t); - entries = (ssize_t *)buf; + entries = (int64_t *)buf; entries[1] = htonll(dedupe_index_sz_cmp); entries[3] = htonll(dedupe_data_sz_cmp); } void -parse_dedupe_hdr(uchar_t *buf, uint32_t *blknum, ssize_t *dedupe_index_sz, - ssize_t *dedupe_data_sz, ssize_t *dedupe_index_sz_cmp, - ssize_t *dedupe_data_sz_cmp, ssize_t *deduped_size) +parse_dedupe_hdr(uchar_t *buf, uint32_t *blknum, int64_t *dedupe_index_sz, + int64_t *dedupe_data_sz, int64_t *dedupe_index_sz_cmp, + int64_t *dedupe_data_sz_cmp, int64_t *deduped_size) { - ssize_t *entries; + int64_t *entries; *blknum = ntohl(*((uint32_t *)(buf))); buf += sizeof (uint32_t); - entries = (ssize_t *)buf; + entries = (int64_t *)buf; *dedupe_data_sz = ntohll(entries[0]); - *dedupe_index_sz = (ssize_t)(*blknum) * RABIN_ENTRY_SIZE; + *dedupe_index_sz = (int64_t)(*blknum) * RABIN_ENTRY_SIZE; *dedupe_index_sz_cmp = ntohll(entries[1]); *deduped_size = ntohll(entries[2]); *dedupe_data_sz_cmp = ntohll(entries[3]); } void -dedupe_decompress(dedupe_context_t *ctx, uchar_t *buf, ssize_t *size) +dedupe_decompress(dedupe_context_t *ctx, uchar_t *buf, int64_t *size) { uint32_t blknum, blk, oblk, len; uint32_t *dedupe_index; - ssize_t data_sz, sz, indx_cmp, data_sz_cmp, deduped_sz; - ssize_t dedupe_index_sz, pos1, i; + int64_t data_sz, sz, indx_cmp, data_sz_cmp, deduped_sz; + int64_t dedupe_index_sz, pos1, i; uchar_t *pos2; parse_dedupe_hdr(buf, &blknum, &dedupe_index_sz, &data_sz, &indx_cmp, &data_sz_cmp, &deduped_sz); @@ -837,7 +837,7 @@ dedupe_decompress(dedupe_context_t *ctx, uchar_t *buf, ssize_t *size) * TODO: Consolidate rabin dedup and compression/decompression in functions here rather than * messy code in main program. int -rabin_compress(dedupe_context_t *ctx, uchar_t *from, ssize_t fromlen, uchar_t *to, ssize_t *tolen, +rabin_compress(dedupe_context_t *ctx, uchar_t *from, int64_t fromlen, uchar_t *to, int64_t *tolen, int level, char chdr, void *data, compress_func_ptr cmp) { } diff --git a/rabin/rabin_dedup.h b/rabin/rabin_dedup.h index 45104e7..275c32a 100644 --- a/rabin/rabin_dedup.h +++ b/rabin/rabin_dedup.h @@ -89,7 +89,7 @@ // Header for a chunk deduped using Rabin // Number of rabin blocks, size of original data chunk, size of compressed index, // size of deduped data, size of compressed data -#define RABIN_HDR_SIZE (sizeof (unsigned int) + sizeof (ssize_t) + sizeof (ssize_t) + sizeof (ssize_t) + sizeof (ssize_t)) +#define RABIN_HDR_SIZE (sizeof (unsigned int) + sizeof (int64_t) + sizeof (int64_t) + sizeof (int64_t) + sizeof (int64_t)) // Maximum number of dedup blocks supported (2^30 - 1) #define RABIN_MAX_BLOCKS (0x3FFFFFFFUL) @@ -135,7 +135,7 @@ #define FP_POLY 0xbfe6b8a5bf378d83ULL typedef struct rab_blockentry { - ssize_t offset; + int64_t offset; uint32_t similarity_hash; uint32_t hash; uint32_t index; @@ -167,13 +167,13 @@ extern dedupe_context_t *create_dedupe_context(uint64_t chunksize, uint64_t real compress_op_t op); extern void destroy_dedupe_context(dedupe_context_t *ctx); extern unsigned int dedupe_compress(dedupe_context_t *ctx, unsigned char *buf, - ssize_t *size, ssize_t offset, ssize_t *rabin_pos); -extern void dedupe_decompress(dedupe_context_t *ctx, uchar_t *buf, ssize_t *size); -extern void parse_dedupe_hdr(uchar_t *buf, unsigned int *blknum, ssize_t *dedupe_index_sz, - ssize_t *dedupe_data_sz, ssize_t *rabin_index_sz_cmp, - ssize_t *dedupe_data_sz_cmp, ssize_t *deduped_size); -extern void update_dedupe_hdr(uchar_t *buf, ssize_t dedupe_index_sz_cmp, - ssize_t dedupe_data_sz_cmp); + int64_t *size, int64_t offset, int64_t *rabin_pos); +extern void dedupe_decompress(dedupe_context_t *ctx, uchar_t *buf, int64_t *size); +extern void parse_dedupe_hdr(uchar_t *buf, unsigned int *blknum, int64_t *dedupe_index_sz, + int64_t *dedupe_data_sz, int64_t *rabin_index_sz_cmp, + int64_t *dedupe_data_sz_cmp, int64_t *deduped_size); +extern void update_dedupe_hdr(uchar_t *buf, int64_t dedupe_index_sz_cmp, + int64_t dedupe_data_sz_cmp); extern void reset_dedupe_context(dedupe_context_t *ctx); extern uint32_t dedupe_buf_extra(uint64_t chunksize, int rab_blk_sz, const char *algo, int delta_flag); diff --git a/utils/utils.c b/utils/utils.c index b4e8414..ffa2590 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -96,13 +96,13 @@ get_execname(const char *argv0) * m - Megabyte * g - Gigabyte * - * The number should fit in an ssize_t data type. + * The number should fit in an int64_t data type. * Numeric overflow is also checked. The routine parse_numeric() returns * 1 if there was a numeric overflow. */ static int -raise_by_multiplier(ssize_t *val, int mult, int power) { - ssize_t result; +raise_by_multiplier(int64_t *val, int mult, int power) { + int64_t result; while (power-- > 0) { result = *val * mult; @@ -114,7 +114,7 @@ raise_by_multiplier(ssize_t *val, int mult, int power) { } int -parse_numeric(ssize_t *val, const char *str) +parse_numeric(int64_t *val, const char *str) { int i, ovr; char *mult; @@ -178,10 +178,10 @@ bytes_to_size(uint64_t bytes) * Additionally can be given an offset in the buf where the data * should be inserted. */ -ssize_t -Read(int fd, void *buf, size_t count) +int64_t +Read(int fd, void *buf, uint64_t count) { - ssize_t rcount, rem; + int64_t rcount, rem; uchar_t *cbuf; va_list args; @@ -203,11 +203,11 @@ Read(int fd, void *buf, size_t count) * The request buffer may have some data at the beginning carried over from * after the previous rabin boundary. */ -ssize_t -Read_Adjusted(int fd, uchar_t *buf, size_t count, ssize_t *rabin_count, void *ctx) +int64_t +Read_Adjusted(int fd, uchar_t *buf, uint64_t count, int64_t *rabin_count, void *ctx) { char *buf2; - ssize_t rcount; + int64_t rcount; dedupe_context_t *rctx = (dedupe_context_t *)ctx; if (!ctx) return (Read(fd, buf, count)); @@ -230,10 +230,10 @@ Read_Adjusted(int fd, uchar_t *buf, size_t count, ssize_t *rabin_count, void *ct return (rcount); } -ssize_t -Write(int fd, const void *buf, size_t count) +int64_t +Write(int fd, const void *buf, uint64_t count) { - ssize_t wcount, rem; + int64_t wcount, rem; uchar_t *cbuf; rem = count; diff --git a/utils/utils.h b/utils/utils.h index bd04771..81f2c95 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -50,7 +50,7 @@ extern "C" { # endif #endif typedef unsigned long uintptr_t; -typedef ssize_t bsize_t; +typedef int64_t bsize_t; #undef WORDS_BIGENDIAN #if BYTE_ORDER == BIG_ENDIAN @@ -134,19 +134,19 @@ typedef struct { extern void err_exit(int show_errno, const char *format, ...); extern const char *get_execname(const char *); -extern int parse_numeric(ssize_t *val, const char *str); +extern int parse_numeric(int64_t *val, const char *str); extern char *bytes_to_size(uint64_t bytes); -extern ssize_t Read(int fd, void *buf, size_t count); -extern ssize_t Read_Adjusted(int fd, uchar_t *buf, size_t count, - ssize_t *rabin_count, void *ctx); -extern ssize_t Write(int fd, const void *buf, size_t count); +extern int64_t Read(int fd, void *buf, uint64_t count); +extern int64_t Read_Adjusted(int fd, uchar_t *buf, uint64_t count, + int64_t *rabin_count, void *ctx); +extern int64_t Write(int fd, const void *buf, uint64_t count); extern void set_threadcounts(algo_props_t *props, int *nthreads, int nprocs, algo_threads_type_t typ); extern uint64_t get_total_ram(); /* Pointer type for compress and decompress functions. */ -typedef int (*compress_func_ptr)(void *src, size_t srclen, void *dst, - size_t *destlen, int level, uchar_t chdr, void *data); +typedef int (*compress_func_ptr)(void *src, uint64_t srclen, void *dst, + uint64_t *destlen, int level, uchar_t chdr, void *data); typedef enum { COMPRESS, @@ -154,11 +154,11 @@ typedef enum { } compress_op_t; /* Pointer type for algo specific init/deinit/stats functions. */ -typedef int (*init_func_ptr)(void **data, int *level, int nthreads, ssize_t chunksize, +typedef int (*init_func_ptr)(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op); typedef int (*deinit_func_ptr)(void **data); typedef void (*stats_func_ptr)(int show); -typedef void (*props_func_ptr)(algo_props_t *data, int level, ssize_t chunksize); +typedef void (*props_func_ptr)(algo_props_t *data, int level, int64_t chunksize); /* diff --git a/zlib_compress.c b/zlib_compress.c index 232a006..5bbb000 100644 --- a/zlib_compress.c +++ b/zlib_compress.c @@ -39,14 +39,14 @@ static void zerr(int ret, int cmp); static void * slab_alloc_ui(void *p, unsigned int items, unsigned int size) { void *ptr; - size_t tot = (size_t)items * (size_t)size; + uint64_t tot = (uint64_t)items * (uint64_t)size; ptr = slab_alloc(p, tot); return (ptr); } uint32_t -zlib_buf_extra(ssize_t buflen) +zlib_buf_extra(int64_t buflen) { if (buflen > SINGLE_CALL_MAX) buflen = SINGLE_CALL_MAX; @@ -54,7 +54,7 @@ zlib_buf_extra(ssize_t buflen) } int -zlib_init(void **data, int *level, int nthreads, ssize_t chunksize, +zlib_init(void **data, int *level, int nthreads, int64_t chunksize, int file_version, compress_op_t op) { z_stream *zs; @@ -90,7 +90,7 @@ zlib_stats(int show) } void -zlib_props(algo_props_t *data, int level, ssize_t chunksize) { +zlib_props(algo_props_t *data, int level, int64_t chunksize) { data->delta2_stride = 50; } @@ -137,13 +137,13 @@ void zerr(int ret, int cmp) } int -zlib_compress(void *src, size_t srclen, void *dst, size_t *dstlen, +zlib_compress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { int ret, ending; unsigned int slen, dlen; - size_t _srclen = srclen; - size_t _dstlen = *dstlen; + uint64_t _srclen = srclen; + uint64_t _dstlen = *dstlen; uchar_t *dst1 = dst; uchar_t *src1 = src; z_stream *zs = (z_stream *)data; @@ -200,13 +200,13 @@ zlib_compress(void *src, size_t srclen, void *dst, size_t *dstlen, } int -zlib_decompress(void *src, size_t srclen, void *dst, size_t *dstlen, +zlib_decompress(void *src, uint64_t srclen, void *dst, uint64_t *dstlen, int level, uchar_t chdr, void *data) { int err; unsigned int slen, dlen; - size_t _srclen = srclen; - size_t _dstlen = *dstlen; + uint64_t _srclen = srclen; + uint64_t _dstlen = *dstlen; uchar_t *dst1 = dst; uchar_t *src1 = src; z_stream *zs = (z_stream *)data;