Only use multi thread support with liblzma >= 5.2.0
Merged-by: Vitaly Chikunov <vt@altlinux.org>
This commit is contained in:
parent
c23872d713
commit
0263f6ebbd
@ -2754,6 +2754,10 @@ FDIO_t bzdio = /*@-compmempass@*/ &bzdio_s /*@=compmempass@*/ ;
|
||||
#include <sys/types.h>
|
||||
#include <inttypes.h>
|
||||
#include <lzma.h>
|
||||
/* Multithreading support in stable API since xz 5.2.0 */
|
||||
#if LZMA_VERSION >= 50020002
|
||||
#define HAVE_LZMA_MT
|
||||
#endif
|
||||
|
||||
#define kBufferSize (1 << 15)
|
||||
|
||||
@ -2780,8 +2784,9 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
|
||||
LZFILE *lzfile;
|
||||
lzma_ret ret;
|
||||
uint64_t mem_limit = rpmExpandNumeric("%{_xz_memlimit}");
|
||||
#ifdef HAVE_LZMA_MT
|
||||
int threads = 0;
|
||||
|
||||
#endif
|
||||
for (; *mode; mode++) {
|
||||
if (*mode == 'w')
|
||||
encoding = 1;
|
||||
@ -2791,14 +2796,18 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
|
||||
level = *mode - '0';
|
||||
else if (*mode == 'T') {
|
||||
if (isdigit(*(mode+1))) {
|
||||
#ifdef HAVE_LZMA_MT
|
||||
threads = atoi(++mode);
|
||||
#endif
|
||||
/* skip past rest of digits in string that atoi()
|
||||
* should've processed
|
||||
* */
|
||||
while(isdigit(*++mode));
|
||||
}
|
||||
#ifdef HAVE_LZMA_MT
|
||||
else
|
||||
threads = -1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (fd != -1)
|
||||
@ -2835,8 +2844,11 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
|
||||
lzfile->filters[0].options = &lzfile->options;
|
||||
lzfile->filters[1].id = LZMA_VLI_UNKNOWN;
|
||||
/* xz(1) uses CRC64 by default */
|
||||
#ifdef HAVE_LZMA_MT
|
||||
if (!threads) {
|
||||
#endif
|
||||
ret = lzma_stream_encoder(&lzfile->strm, lzfile->filters, LZMA_CHECK_CRC64);
|
||||
#ifdef HAVE_LZMA_MT
|
||||
} else {
|
||||
if (threads == -1)
|
||||
threads = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
@ -2851,6 +2863,7 @@ static LZFILE *lzopen_internal(const char *path, const char *mode, int fd, int x
|
||||
|
||||
ret = lzma_stream_encoder_mt(&lzfile->strm, &mt_options);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
ret = lzma_alone_encoder(&lzfile->strm, &lzfile->options);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user