ports/sysutils/squashfs-tools/patches/patch-squashfs-tools_mksquashfs_c

70 lines
1.8 KiB
Text
Raw Normal View History

2023-08-16 22:26:55 +00:00
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 <stddef.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef linux
+#include <sys/sysinfo.h>
#include <sys/sysmacros.h>
+#endif
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
@@ -50,7 +53,6 @@
#include <sys/wait.h>
#include <limits.h>
#include <ctype.h>
-#include <sys/sysinfo.h>
#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;