]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
zstd: Implement core detection on Windows
authorMartin Matuska <martin@matuska.de>
Tue, 23 Apr 2024 12:59:27 +0000 (14:59 +0200)
committerMartin Matuska <martin@matuska.de>
Tue, 23 Apr 2024 13:24:31 +0000 (15:24 +0200)
Fixes #2071

Co-authored-by: Mostyn Bramley-Moore <mostyn@antipode.se>
libarchive/archive_write_add_filter_zstd.c

index b49f4531027e8a27acd8aa8e4b9e94b9dacb281d..7ea3d18c9b766c2240f97bc8074b91b3e8c11060 100644 (file)
@@ -277,6 +277,13 @@ archive_compressor_zstd_options(struct archive_write_filter *f, const char *key,
                if (threads == 0) {
                        threads = sysconf(_SC_NPROCESSORS_ONLN);
                }
+#elif !defined(__CYGWIN__) && defined(_WIN32_WINNT) && \
+    _WIN32_WINNT >= 0x0601 /* _WIN32_WINNT_WIN7 */
+               if (threads == 0) {
+                       DWORD winCores = GetActiveProcessorCount(
+                           ALL_PROCESSOR_GROUPS);
+                       threads = (intmax_t)winCores;
+               }
 #endif
                if (threads < 0 || threads > INT_MAX) {
                        return (ARCHIVE_WARN);