X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fcompress_parallel.c;h=c99c0a86826bc66b841a45ffe1224f57e195f6ab;hp=376e59d6a2fdca8a05fae9486d58fc0f51bba08d;hb=affa6147e5c4c72bb22778368743e7203ea8fd79;hpb=41f15b937564a3ae58f199c27e8290a1b1a40856 diff --git a/src/compress_parallel.c b/src/compress_parallel.c index 376e59d6..c99c0a86 100644 --- a/src/compress_parallel.c +++ b/src/compress_parallel.c @@ -43,6 +43,9 @@ #include #include #include +#ifdef HAVE_SYS_SYSCTL_H +# include +#endif struct message_queue { struct list_head list; @@ -116,12 +119,19 @@ get_avail_memory(void) if (phys_bytes == 0) goto default_size; return phys_bytes; -#else +#elif defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES) long page_size = sysconf(_SC_PAGESIZE); long num_pages = sysconf(_SC_PHYS_PAGES); if (page_size <= 0 || num_pages <= 0) goto default_size; return ((u64)page_size * (u64)num_pages); +#else + int mib[2] = {CTL_HW, HW_MEMSIZE}; + u64 memsize; + size_t len = sizeof(memsize); + if (sysctl(mib, ARRAY_LEN(mib), &memsize, &len, NULL, 0) < 0 || len != 8) + goto default_size; + return memsize; #endif default_size: @@ -521,7 +531,9 @@ new_parallel_chunk_compressor(int out_ctype, u32 out_chunk_size, if (ret) { errno = ret; ret = WIMLIB_ERR_NOMEM; - WARNING_WITH_ERRNO("Failed to create compressor thread %u of %u"); + WARNING_WITH_ERRNO("Failed to create compressor thread %u of %u", + ctx->num_started_threads + 1, + num_threads); goto err; } }