diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2022-11-19 19:06:13 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2022-11-19 19:06:13 +0200 |
commit | d327743bb547a53364e5951a16e5f1663fe4b9ff (patch) | |
tree | 161f141e97f7946e05541ad92f141c3deeb2dc28 /src/xz/args.c | |
parent | CMake: Adds test_memlimit to CMake tests (diff) | |
download | xz-d327743bb547a53364e5951a16e5f1663fe4b9ff.tar.xz |
xz: Add support --threads=+N so that -T+1 gives threaded mode.
Diffstat (limited to '')
-rw-r--r-- | src/xz/args.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/xz/args.c b/src/xz/args.c index 639c811a..8953aa59 100644 --- a/src/xz/args.c +++ b/src/xz/args.c @@ -258,11 +258,23 @@ parse_real(args_info *args, int argc, char **argv) suffix_set(optarg); break; - case 'T': + case 'T': { + // Since xz 5.4.0: Ignore leading '+' first. + const char *s = optarg; + if (optarg[0] == '+') + ++s; + // The max is from src/liblzma/common/common.h. - hardware_threads_set(str_to_uint64("threads", - optarg, 0, 16384)); + uint32_t t = str_to_uint64("threads", s, 0, 16384); + + // If leading '+' was used then use multi-threaded + // mode even if exactly one thread was specified. + if (t == 1 && optarg[0] == '+') + t = UINT32_MAX; + + hardware_threads_set(t); break; + } // --version case 'V': |