diff options
Diffstat (limited to 'src/xz/hardware.c')
-rw-r--r-- | src/xz/hardware.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/xz/hardware.c b/src/xz/hardware.c index d45d6ade..18eee7ec 100644 --- a/src/xz/hardware.c +++ b/src/xz/hardware.c @@ -17,6 +17,10 @@ /// the --threads=NUM command line option. static uint32_t threads_max = 1; +/// True when the number of threads is automatically determined based +/// on the available hardware threads. +static bool threads_are_automatic = false; + /// Memory usage limit for compression static uint64_t memlimit_compress = 0; @@ -48,6 +52,8 @@ hardware_threads_set(uint32_t n) { if (n == 0) { // Automatic number of threads was requested. + threads_are_automatic = true; + // If threading support was enabled at build time, // use the number of available CPU cores. Otherwise // use one thread since disabling threading support @@ -61,6 +67,7 @@ hardware_threads_set(uint32_t n) #endif } else { threads_max = n; + threads_are_automatic = false; } return; @@ -74,6 +81,13 @@ hardware_threads_get(void) } +extern bool +hardware_threads_is_mt(void) +{ + return threads_max > 1 || threads_are_automatic; +} + + extern void hardware_memlimit_set(uint64_t new_memlimit, bool set_compress, bool set_decompress, bool set_mtdec, |