From ab27905ae7cd337cf30711fd36d287db1c1b92bb Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Tue, 23 Apr 2024 14:59:27 +0200 Subject: [PATCH] zstd: Implement core detection on Windows Fixes #2071 Co-authored-by: Mostyn Bramley-Moore --- libarchive/archive_write_add_filter_zstd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libarchive/archive_write_add_filter_zstd.c b/libarchive/archive_write_add_filter_zstd.c index b49f45310..7ea3d18c9 100644 --- a/libarchive/archive_write_add_filter_zstd.c +++ b/libarchive/archive_write_add_filter_zstd.c @@ -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); -- 2.47.2