From 3aa16a1146c008ed07750a30dc2f68c3a7d010c5 Mon Sep 17 00:00:00 2001
From: Manuel Novoa III <mjn3@codepoet.org>
Date: Tue, 17 Feb 2004 10:40:47 +0000
Subject: Sigh... Fall back to alloca() if munmap is broken (uClinux).

---
 libc/unistd/exec.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/libc/unistd/exec.c b/libc/unistd/exec.c
index 666a8192b..21f335da9 100644
--- a/libc/unistd/exec.c
+++ b/libc/unistd/exec.c
@@ -17,6 +17,8 @@
 
 /* Jan 1, 2004
  *   Initial version of a SUSv3 compliant exec*() functions.
+ * Feb 17, 2004
+ *   Sigh... Fall back to alloca() if munmap() is broken on uClinux.
  */
 
 /* NOTE: Strictly speaking, there could be problems from accessing
@@ -41,10 +43,10 @@
 extern char *__strchrnul(const char *s, int c);
 
 /**********************************************************************/
-#ifdef __ARCH_HAS_MMU__
+#if defined(__ARCH_HAS_MMU__) || defined(__UCLIBC_UCLINUX_BROKEN_MUNMAP__)
 
 /* We have an MMU, so use alloca() to grab space for buffers and
- * arg lists. */
+ * arg lists.  Also fall back to alloca() if munmap() is broken. */
 
 # define EXEC_ALLOC_SIZE(VAR)	/* nothing to do */
 # define EXEC_ALLOC(SIZE,VAR)	alloca((SIZE))
@@ -65,11 +67,7 @@ extern char *__strchrnul(const char *s, int c);
 extern void *__exec_alloc(size_t size);
 extern void __exec_free(void *ptr, size_t size);
 
-#endif
-/**********************************************************************/
-#ifdef L___exec_alloc
-
-#ifndef __ARCH_HAS_MMU__
+# ifdef L___exec_alloc
 
 void *__exec_alloc(size_t size)
 {
@@ -87,7 +85,7 @@ void __exec_free(void *ptr, size_t size)
 	}
 }
 
-#endif
+# endif
 
 #endif
 /**********************************************************************/
-- 
cgit v1.2.3