]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Added reduced memory configuration option to CMake and configure.
authorNathan Moinvaziri <nathan@nathanm.com>
Thu, 18 Mar 2021 06:00:44 +0000 (23:00 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 25 Jun 2021 18:27:48 +0000 (20:27 +0200)
CMakeLists.txt
configure

index 678f9e3e6809508b18449821911b065ebfc8177d..3ea40b502b4ea8ee967f5dabd8747a8e4329b50a 100644 (file)
@@ -76,6 +76,7 @@ option(ZLIB_ENABLE_TESTS "Build test binaries" ON)
 option(ZLIB_DUAL_LINK "Dual link tests against system zlib" OFF)
 option(WITH_FUZZERS "Build test/fuzz" OFF)
 option(WITH_OPTIM "Build with optimisation" ON)
+option(WITH_REDUCED_MEM "Reduced memory usage for special cases (reduces performance)" ON)
 option(WITH_NEW_STRATEGIES "Use new strategies" ON)
 option(WITH_NATIVE_INSTRUCTIONS
     "Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)" OFF)
@@ -109,6 +110,7 @@ option(INSTALL_UTILS "Copy minigzip and minideflate during install" OFF)
 
 mark_as_advanced(FORCE
     ZLIB_DUAL_LINK
+    WITH_REDUCED_MEM
     WITH_ACLE WITH_NEON
     WITH_DFLTCC_DEFLATE
     WITH_DFLTCC_INFLATE
@@ -469,6 +471,13 @@ if(WITH_INFLATE_ALLOW_INVALID_DIST)
     add_definitions(-DINFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR)
     message(STATUS "Inflate zero data for invalid distances enabled")
 endif()
+#
+# Enable reduced memory configuration
+#
+if(WITH_REDUCED_MEM)
+    add_definitions(-DHASH_SIZE=32768u -DGZBUFSIZE=8192)
+    message(STATUS "Configured for reduced memory environment")
+endif()
 
 
 set(ZLIB_ARCH_SRCS)
index 5d58e37cd3bfe07b64003b5e57792ac041a49106..911269254d4f3a6c90cfecf01cd7b567c9ffdfcc 100755 (executable)
--- a/configure
+++ b/configure
@@ -110,6 +110,7 @@ neonflag=
 noltoflag="-fno-lto"
 without_optimizations=0
 without_new_strategies=0
+reducedmem=0
 gcc=0
 warn=0
 debug=0
@@ -154,6 +155,7 @@ case "$1" in
       echo '    [--without-neon]            Compiles without ARM Neon SIMD instruction set' | tee -a configure.log
       echo '    [--with-dfltcc-deflate]     Use DEFLATE CONVERSION CALL instruction for compression on IBM Z' | tee -a configure.log
       echo '    [--with-dfltcc-inflate]     Use DEFLATE CONVERSION CALL instruction for decompression on IBM Z' | tee -a configure.log
+      echo '    [--with-reduced-mem]        Reduced memory usage for special cases (reduces performance)' | tee -a configure.log
       echo '    [--force-sse2]              Assume SSE2 instructions are always available (disabled by default on x86, enabled on x86_64)' | tee -a configure.log
       echo '    [--with-sanitizer]          Build with sanitizer (memory, address, undefined)' | tee -a configure.log
       echo '    [--with-fuzzers]            Build test/fuzz (disabled by default)' | tee -a configure.log
@@ -180,6 +182,7 @@ case "$1" in
     --without-neon) buildneon=0; shift ;;
     --with-dfltcc-deflate) builddfltccdeflate=1; shift ;;
     --with-dfltcc-inflate) builddfltccinflate=1; shift ;;
+    --with-reduced-mem) reducedmem=1; shift ;;
     --force-sse2) forcesse2=1; shift ;;
     -n | --native) native=1; shift ;;
     -a*=* | --archs=*) ARCHS=$(echo $1 | sed 's/.*=//'); shift ;;
@@ -843,6 +846,12 @@ if test $gzfileops -eq 1; then
   PIC_OBJC="${PIC_OBJC} \$(PIC_OBJG)"
 fi
 
+# enable reduced memory configuration
+if test $reducedmem -eq 1; then
+  echo "Configuring for reduced memory environment." | tee -a configure.log
+  CFLAGS="${CFLAGS} -DHASH_SIZE=32768u -DGZBUFSIZE=8192"
+fi
+
 # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
 if test $cover -eq 1; then
   CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"