aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-10-02 14:35:56 +0300
committerLasse Collin <lasse.collin@tukaani.org>2009-10-02 14:35:56 +0300
commit29fd321033276261b87da7be5223db33d879a4c7 (patch)
tree0f8d551186d41e06a72e291a8db6ed66cd78bb3a
parentUse unaligned access (if possible) on both endiannesses (diff)
downloadxz-29fd321033276261b87da7be5223db33d879a4c7.tar.xz
Add support for --enable-assume-ram=SIZE.
-rw-r--r--INSTALL16
-rw-r--r--configure.ac24
-rw-r--r--src/xz/hardware.c7
-rw-r--r--src/xzdec/xzdec.c5
4 files changed, 46 insertions, 6 deletions
diff --git a/INSTALL b/INSTALL
index f6bc4502..48ba0ff4 100644
--- a/INSTALL
+++ b/INSTALL
@@ -237,6 +237,22 @@ XZ Utils Installation
to optimize for size. You need to add -Os or equivalent
flag(s) to CFLAGS manually.
+ --enable-assume-ram=SIZE
+ On the most common operating systems, XZ Utils is able to
+ detect the amount of physical memory on the system. This
+ information is used to set the default memory usage limit.
+
+ On some systems, there is no code to detect the amount of
+ RAM though. Using --enable-assume-ram one can set how much
+ memory to assume on these systems. SIZE is given as MiB.
+ The default is 32 MiB, which is probably too low for most
+ systems, but it is enough to allow decompressing .xz files
+ created with the default settings.
+
+ Feel free to send patches to add support for detecting
+ the amount of RAM on the operating system you use. See
+ src/common/tuklib_physmem.c for details.
+
--disable-threads
Disable threading support. This makes some things
thread-unsafe, meaning that if multithreaded application
diff --git a/configure.ac b/configure.ac
index c576d224..d4a51ffd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -380,6 +380,30 @@ AC_MSG_RESULT([$enable_threads])
# We use the actual result a little later.
+#########################
+# Assumed amount of RAM #
+#########################
+
+# We use 32 MiB as default, because it should be small enough for most
+# cases and allows decompressing files compressed with the default settings.
+# Probably it is too small for most systems, but it's safer to guess too low.
+AC_MSG_CHECKING([how much RAM to assume if the real amount is unknown])
+AC_ARG_ENABLE([assume-ram], AC_HELP_STRING([--enable-assume-ram=SIZE],
+ [If and only if the real amount of RAM cannot be determined,
+ assume SIZE MiB. The default is 32 MiB. This affects the
+ default memory usage limit.]),
+ [], [enable_assume_ram=32])
+assume_ram_check=`echo "$enable_assume_ram" | tr -d 0123456789`
+if test -z "$enable_assume_ram" || test -n "$assume_ram_check"; then
+ AC_MSG_RESULT([])
+ AC_MSG_ERROR([--enable-assume-ram accepts only an integer argument])
+fi
+AC_MSG_RESULT([$enable_assume_ram MiB])
+AC_DEFINE_UNQUOTED([ASSUME_RAM], [$enable_assume_ram],
+ [How many MiB of RAM to assume if the real amount cannot
+ be determined.])
+
+
############################################
# xz/xzdec/lzmadec linkage against liblzma #
############################################
diff --git a/src/xz/hardware.c b/src/xz/hardware.c
index cb094abd..d5f4b9b4 100644
--- a/src/xz/hardware.c
+++ b/src/xz/hardware.c
@@ -68,11 +68,10 @@ hardware_memlimit_set_percentage(uint32_t percentage)
uint64_t mem = tuklib_physmem();
- // If we cannot determine the amount of RAM, assume 32 MiB. Maybe
- // even that is too much on some systems. But on most systems it's
- // far too little, and can be annoying.
+ // If we cannot determine the amount of RAM, use the assumption
+ // defined by the configure script.
if (mem == 0)
- mem = UINT64_C(32) * 1024 * 1024;
+ mem = (uint64_t)(ASSUME_RAM) * 1024 * 1024;
memlimit = percentage * mem / 100;
return;
diff --git a/src/xzdec/xzdec.c b/src/xzdec/xzdec.c
index 18bdb04e..4f40f1d6 100644
--- a/src/xzdec/xzdec.c
+++ b/src/xzdec/xzdec.c
@@ -106,9 +106,10 @@ memlimit_set_percentage(uint32_t percentage)
{
uint64_t mem = tuklib_physmem();
- // If we cannot determine the amount of RAM, assume 32 MiB.
+ // If we cannot determine the amount of RAM, use the assumption
+ // set by the configure script.
if (mem == 0)
- mem = UINT64_C(32) * 1024 * 1024;
+ mem = (uint64_t)(ASSUME_RAM) * 1024 * 1024;
memlimit = percentage * mem / 100;
return;