equivalent effect to https://github.com/plougher/squashfs-tools/pull/69 but simpler Index: squashfs-tools/mksquashfs.c --- squashfs-tools/mksquashfs.c.orig +++ squashfs-tools/mksquashfs.c @@ -35,7 +35,10 @@ #include #include #include +#ifdef linux +#include #include +#endif #include #include #include @@ -50,7 +53,6 @@ #include #include #include -#include #ifndef linux #define __BYTE_ORDER BYTE_ORDER @@ -4348,6 +4350,7 @@ void initialise_threads(int readq, int fragq, int bwri sigemptyset(&sigmask); sigaddset(&sigmask, SIGQUIT); sigaddset(&sigmask, SIGHUP); + sigaddset(&sigmask, SIGALRM); if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) != 0) BAD_ERROR("Failed to set signal mask in intialise_threads\n"); @@ -4363,7 +4366,9 @@ void initialise_threads(int readq, int fragq, int bwri BAD_ERROR("Failed to set signal mask in intialise_threads\n"); if(processors == -1) { -#ifndef linux +#ifdef _SC_NPROCESSORS_ONLN + processors = sysconf(_SC_NPROCESSORS_ONLN); +#else int mib[2]; size_t len = sizeof(processors); @@ -4380,8 +4385,6 @@ void initialise_threads(int readq, int fragq, int bwri ERROR_EXIT(" Defaulting to 1\n"); processors = 1; } -#else - processors = sysconf(_SC_NPROCESSORS_ONLN); #endif } @@ -5195,6 +5198,7 @@ int get_physical_memory() long long page_size = sysconf(_SC_PAGESIZE); int phys_mem; +#ifdef linux if(num_pages == -1 || page_size == -1) { struct sysinfo sys; int res = sysinfo(&sys); @@ -5205,6 +5209,7 @@ int get_physical_memory() num_pages = sys.totalram; page_size = sys.mem_unit; } +#endif phys_mem = num_pages * page_size >> 20;