[uClibc-cvs] CVS update of uClibc/libc/stdlib (malloc-simple/alloc.c malloc-standard/malloc.c malloc-standard/malloc.h malloc/malloc.c)

Erik Andersen andersen at codepoet.org
Thu Jul 15 08:06:26 UTC 2004


    Date: Thursday, July 15, 2004 @ 02:06:25
  Author: andersen
    Path: /var/cvs/uClibc/libc/stdlib

Modified: malloc-simple/alloc.c (1.15 -> 1.16) malloc-standard/malloc.c
          (1.1 -> 1.2) malloc-standard/malloc.h (1.1 -> 1.2)
          malloc/malloc.c (1.36 -> 1.37)

Use MAP_PRIVATE whenever __ARCH_HAS_MMU__ is set.
Only use MAP_SHARED when mmu-less.


Index: uClibc/libc/stdlib/malloc-simple/alloc.c
diff -u uClibc/libc/stdlib/malloc-simple/alloc.c:1.15 uClibc/libc/stdlib/malloc-simple/alloc.c:1.16
--- uClibc/libc/stdlib/malloc-simple/alloc.c:1.15	Fri Jan 16 06:43:08 2004
+++ uClibc/libc/stdlib/malloc-simple/alloc.c	Thu Jul 15 02:06:24 2004
@@ -33,14 +33,14 @@
 
 #ifdef __ARCH_HAS_MMU__
     result = mmap((void *) 0, size + sizeof(size_t), PROT_READ | PROT_WRITE,
-	    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+	    MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
     if (result == MAP_FAILED)
 	return 0;
     * (size_t *) result = size;
     return(result + sizeof(size_t));
 #else
     result = mmap((void *) 0, size, PROT_READ | PROT_WRITE,
-	    MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+	    MAP_SHARED | MAP_ANONYMOUS, 0, 0);
     if (result == MAP_FAILED)
 	return 0;
     return(result);
Index: uClibc/libc/stdlib/malloc-standard/malloc.c
diff -u uClibc/libc/stdlib/malloc-standard/malloc.c:1.1 uClibc/libc/stdlib/malloc-standard/malloc.c:1.2
--- uClibc/libc/stdlib/malloc-standard/malloc.c:1.1	Tue Dec 30 03:40:49 2003
+++ uClibc/libc/stdlib/malloc-standard/malloc.c	Thu Jul 15 02:06:25 2004
@@ -406,7 +406,7 @@
 	/* Don't try if size wraps around 0 */
 	if ((unsigned long)(size) > (unsigned long)(nb)) {
 
-	    mm = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE));
+	    mm = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE));
 
 	    if (mm != (char*)(MORECORE_FAILURE)) {
 
@@ -526,7 +526,7 @@
 	/* Don't try if size wraps around 0 */
 	if ((unsigned long)(size) > (unsigned long)(nb)) {
 
-	    brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE));
+	    brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE));
 
 	    if (brk != (char*)(MORECORE_FAILURE)) {
 
Index: uClibc/libc/stdlib/malloc-standard/malloc.h
diff -u uClibc/libc/stdlib/malloc-standard/malloc.h:1.1 uClibc/libc/stdlib/malloc-standard/malloc.h:1.2
--- uClibc/libc/stdlib/malloc-standard/malloc.h:1.1	Tue Dec 30 03:40:49 2003
+++ uClibc/libc/stdlib/malloc-standard/malloc.h	Thu Jul 15 02:06:25 2004
@@ -350,8 +350,17 @@
 #define MAP_ANONYMOUS MAP_ANON
 #endif
 
-#define MMAP(addr, size, prot, flags) \
- (mmap((addr), (size), (prot), (flags)|MAP_ANONYMOUS, -1, 0))
+#ifdef __ARCH_HAS_MMU__
+
+#define MMAP(addr, size, prot) \
+ (mmap((addr), (size), (prot), MAP_PRIVATE|MAP_ANONYMOUS, 0, 0))
+
+#else
+
+#define MMAP(addr, size, prot) \
+ (mmap((addr), (size), (prot), MAP_SHARED|MAP_ANONYMOUS, 0, 0))
+
+#endif
 
 
 /* -----------------------  Chunk representations ----------------------- */
Index: uClibc/libc/stdlib/malloc/malloc.c
diff -u uClibc/libc/stdlib/malloc/malloc.c:1.36 uClibc/libc/stdlib/malloc/malloc.c:1.37
--- uClibc/libc/stdlib/malloc/malloc.c:1.36	Thu Oct 16 04:12:45 2003
+++ uClibc/libc/stdlib/malloc/malloc.c	Thu Jul 15 02:06:24 2004
@@ -103,8 +103,13 @@
 #else /* !MALLOC_USE_SBRK */
 
       /* Otherwise, use mmap.  */
-      block = mmap (0, block_size, PROT_READ | PROT_WRITE,
+#ifdef __ARCH_HAS_MMU__
+      block = mmap ((void *)0, block_size, PROT_READ | PROT_WRITE,
+		    MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+#else
+      block = mmap ((void *)0, block_size, PROT_READ | PROT_WRITE,
 		    MAP_SHARED | MAP_ANONYMOUS, 0, 0);
+#endif
 
 #endif /* MALLOC_USE_SBRK */
 



More information about the uClibc-cvs mailing list