diff mbox

[2/9] arm: do not place huge encoder tables on stack when it is too small

Message ID 1435094387-20146-3-git-send-email-pawelo@king.net.pl
State New
Headers show

Commit Message

Paul Osmialowski June 23, 2015, 9:19 p.m. UTC
Since stack on Cortex-M3 is too small, we need configuration option
to avoid using it for huge encoder tables of zlib.

Signed-off-by: Paul Osmialowski <pawelo@king.net.pl>
---
 arch/arm/Kconfig-nommu     | 4 ++++
 lib/zlib_inflate/inflate.c | 5 +++++
 2 files changed, 9 insertions(+)
diff mbox

Patch

diff --git a/arch/arm/Kconfig-nommu b/arch/arm/Kconfig-nommu
index aed66d5..965ca97 100644
--- a/arch/arm/Kconfig-nommu
+++ b/arch/arm/Kconfig-nommu
@@ -62,3 +62,7 @@  config ARM_MPU
 
          If your CPU has an MPU then you should choose 'y' here unless you
          know that you do not want to use the MPU.
+
+config ZLIB_INFLATE_STACK_SAVING
+	bool 'Do not place huge encoder tables on stack' if ZLIB_INFLATE
+	depends on ZLIB_INFLATE
diff --git a/lib/zlib_inflate/inflate.c b/lib/zlib_inflate/inflate.c
index 58a733b..917b7cf 100644
--- a/lib/zlib_inflate/inflate.c
+++ b/lib/zlib_inflate/inflate.c
@@ -75,9 +75,14 @@  int zlib_inflateInit2(z_streamp strm, int windowBits)
    Return state with length and distance decoding tables and index sizes set to
    fixed code decoding.  This returns fixed tables from inffixed.h.
  */
+#ifdef CONFIG_ZLIB_INFLATE_STACK_SAVING
+#   include "inffixed.h"
+#endif
 static void zlib_fixedtables(struct inflate_state *state)
 {
+#ifndef CONFIG_ZLIB_INFLATE_STACK_SAVING
 #   include "inffixed.h"
+#endif
     state->lencode = lenfix;
     state->lenbits = 9;
     state->distcode = distfix;