From ead0e541820a3e8564dcdb31d9b1f7c0ef4b5d5b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 7 Nov 2010 01:57:23 +1100 Subject: [PATCH] Drop the upper limit on lzma compression window on 64 bit. It is not necessary. zpaq will fail with windows bigger than 600MB on 32 bit due to failing testing the 3* malloc test, so limit it to 600MB as well as lzma on 32 bit. --- rzip.c | 4 ++-- rzip.h | 3 +++ stream.c | 13 ++++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/rzip.c b/rzip.c index 3235e39..452364a 100644 --- a/rzip.c +++ b/rzip.c @@ -718,7 +718,7 @@ static void rzip_chunk(struct rzip_state *st, int fd_in, int fd_out, i64 offset, } /* Needs to be less than 31 bits and page aligned on 32 bits */ -static const i64 two_gig = (1ull << 31) - 4096; +const i64 two_gig = (1ull << 31) - 4096; /* compress a whole file chunks at a time */ void rzip_fd(int fd_in, int fd_out) @@ -797,7 +797,7 @@ void rzip_fd(int fd_in, int fd_out) if (st->chunk_size > len && !STDIN) st->chunk_size = len; st->mmap_size = st->chunk_size; - if (sizeof(long) == 4 && st->mmap_size > two_gig) { + if (BITS32 && st->mmap_size > two_gig) { print_verbose("Limiting to 2GB due to 32 bit limitations\n"); st->mmap_size = two_gig; } diff --git a/rzip.h b/rzip.h index 0daa87b..6533450 100644 --- a/rzip.h +++ b/rzip.h @@ -211,6 +211,8 @@ static inline i64 get_ram(void) #define MAXRAM (control.flags & FLAG_MAXRAM) #define UNLIMITED (control.flags & FLAG_UNLIMITED) +#define BITS32 (sizeof(long) == 4) + #define CTYPE_NONE 3 #define CTYPE_BZIP2 4 #define CTYPE_LZO 5 @@ -272,6 +274,7 @@ ssize_t write_1g(int fd, void *buf, i64 len); ssize_t read_1g(int fd, void *buf, i64 len); void zpipe_compress(FILE *in, FILE *out, FILE *msgout, long long int buf_len, int progress); void zpipe_decompress(FILE *in, FILE *out, FILE *msgout, long long int buf_len, int progress); +const i64 two_gig; #define print_err(format, args...) do {\ fprintf(stderr, format, ##args); \ diff --git a/stream.c b/stream.c index c7ed1cd..187137c 100644 --- a/stream.c +++ b/stream.c @@ -583,15 +583,10 @@ void *open_stream_out(int f, int n, i64 limit) however, the larger the buffer, the better the compression so we make it as large as the window up to the limit the compressor will take */ - if (LZMA_COMPRESS) { - if (sizeof(long) == 4) { - /* Largest window supported on lzma 32bit is 600MB */ - if (!cwindow || cwindow > 6) - cwindow = 6; - } - /* Largest window supported on lzma 64bit is 4GB */ - if (!cwindow || cwindow > 40) - cwindow = 40; + if (BITS32) { + /* Largest window supported on 32bit is 600MB */ + if (!cwindow || cwindow > 6) + cwindow = 6; } if (LZMA_COMPRESS || ZPAQ_COMPRESS)