Fixed bug in userspace brk
authorAndrew Waterman <waterman@ros-dev.(none)>
Fri, 9 Apr 2010 01:36:13 +0000 (18:36 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:35:41 +0000 (17:35 -0700)
The current break should be set to what the user *thinks* the break
is, not the internal, page-aligned break.

tools/compilers/gcc-glibc/glibc-2.11.1-ros/sysdeps/ros/sbrk.c

index 64346cc..00ee990 100644 (file)
@@ -46,28 +46,18 @@ __internal_setbrk (uintptr_t addr)
     if(real_new_brk > BRK_END)
       return -1;
 
-       /* Set the new curbrk on success, return -1 o/w */
     if (mmap((void*)real_brk, real_new_brk-real_brk,
              PROT_READ | PROT_WRITE | PROT_EXEC,
-             MAP_FIXED | MAP_ANONYMOUS, -1, 0) == (void*)real_brk) {
-               curbrk = real_new_brk;
-               return 0;
-       } else {
-               return -1;
-       }
+             MAP_FIXED | MAP_ANONYMOUS, -1, 0) != (void*)real_brk)
+      return -1;
   }
   else if(real_new_brk < real_brk)
   {
     if(real_new_brk < (uintptr_t)__procinfo.heap_bottom)
       return -1;
 
-       /* Set the new curbrk on success, return -1 o/w */
-    if (!munmap((void*)real_new_brk, real_brk - real_new_brk)) {
-               curbrk = real_new_brk;
-               return 0;
-       } else {
-               return -1;
-       }
+    if (!munmap((void*)real_new_brk, real_brk - real_new_brk))
+      return -1;
   }
 
   curbrk = addr;