Change the prototype of VG_(am_extend_into_adjacent_reservation_client)
to match VG_(am_extend_map_client) for consistency.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14965 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_aspacemgr/aspacemgr-linux.c b/coregrind/m_aspacemgr/aspacemgr-linux.c
index 32ac842..d0a49eb 100644
--- a/coregrind/m_aspacemgr/aspacemgr-linux.c
+++ b/coregrind/m_aspacemgr/aspacemgr-linux.c
@@ -2777,8 +2777,8 @@
 }
 
 
-/* Let SEG be an anonymous client mapping.  This fn extends the
-   mapping by DELTA bytes, taking the space from a reservation section
+/* ADDR is the start address of an anonymous client mapping.  This fn extends
+   the mapping by DELTA bytes, taking the space from a reservation section
    which must be adjacent.  If DELTA is positive, the segment is
    extended forwards in the address space, and the reservation must be
    the next one along.  If DELTA is negative, the segment is extended
@@ -2786,25 +2786,20 @@
    previous one.  DELTA must be page aligned.  abs(DELTA) must not
    exceed the size of the reservation segment minus one page, that is,
    the reservation segment after the operation must be at least one
-   page long. */
+   page long. The function returns a pointer to the resized segment. */
 
-Bool VG_(am_extend_into_adjacent_reservation_client) ( const NSegment* seg, 
-                                                       SSizeT    delta )
+const NSegment *VG_(am_extend_into_adjacent_reservation_client)( Addr addr, 
+                                                                 SSizeT delta )
 {
    Int    segA, segR;
    UInt   prot;
    SysRes sres;
 
-   /* Find the segment array index for SEG.  If the assertion fails it
-      probably means you passed in a bogus SEG. */
-   aspacem_assert(seg != NULL);
-   segA = segAddr_to_index( seg );
-
-   if (nsegments[segA].kind != SkAnonC)
-      return False;
+   segA = find_nsegment_idx(addr);
+   aspacem_assert(nsegments[segA].kind == SkAnonC);
 
    if (delta == 0)
-      return True;
+      return nsegments + segA;
 
    prot =   (nsegments[segA].hasR ? VKI_PROT_READ : 0)
           | (nsegments[segA].hasW ? VKI_PROT_WRITE : 0)
@@ -2822,7 +2817,7 @@
           || nsegments[segR].start != nsegments[segA].end + 1
           || delta + VKI_PAGE_SIZE 
                 > (nsegments[segR].end - nsegments[segR].start + 1))
-        return False;
+        return NULL;
         
       /* Extend the kernel's mapping. */
       // DDD: #warning GrP fixme MAP_FIXED can clobber memory!
@@ -2833,11 +2828,11 @@
                 0, 0 
              );
       if (sr_isError(sres))
-         return False; /* kernel bug if this happens? */
+         return NULL; /* kernel bug if this happens? */
       if (sr_Res(sres) != nsegments[segR].start) {
          /* kernel bug if this happens? */
         (void)ML_(am_do_munmap_NO_NOTIFY)( sr_Res(sres), delta );
-        return False;
+        return NULL;
       }
 
       /* Ok, success with the kernel.  Update our structures. */
@@ -2858,7 +2853,7 @@
           || nsegments[segR].end + 1 != nsegments[segA].start
           || delta + VKI_PAGE_SIZE 
                 > (nsegments[segR].end - nsegments[segR].start + 1))
-        return False;
+        return NULL;
         
       /* Extend the kernel's mapping. */
       // DDD: #warning GrP fixme MAP_FIXED can clobber memory!
@@ -2869,11 +2864,11 @@
                 0, 0 
              );
       if (sr_isError(sres))
-         return False; /* kernel bug if this happens? */
+         return NULL; /* kernel bug if this happens? */
       if (sr_Res(sres) != nsegments[segA].start-delta) {
          /* kernel bug if this happens? */
         (void)ML_(am_do_munmap_NO_NOTIFY)( sr_Res(sres), delta );
-        return False;
+        return NULL;
       }
 
       /* Ok, success with the kernel.  Update our structures. */
@@ -2884,7 +2879,7 @@
    }
 
    AM_SANITY_CHECK;
-   return True;
+   return nsegments + segA;
 }
 
 
diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c
index f6f3254..deecebe 100644
--- a/coregrind/m_signals.c
+++ b/coregrind/m_signals.c
@@ -2280,7 +2280,7 @@
                     "extending a stack base 0x%llx down by %lld\n",
                     (ULong)seg_next->start, (ULong)udelta);
    if (! VG_(am_extend_into_adjacent_reservation_client)
-            ( seg_next, -(SSizeT)udelta )) {
+            ( seg_next->start, -(SSizeT)udelta )) {
       VG_(debugLog)(1, "signals", "extending a stack base: FAILED\n");
       return False;
    }
diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c
index eaf29d0..d6a460b 100644
--- a/coregrind/m_syswrap/syswrap-generic.c
+++ b/coregrind/m_syswrap/syswrap-generic.c
@@ -1190,7 +1190,6 @@
    NSegment const* rseg;
    Addr newbrkP;
    SizeT delta;
-   Bool ok;
    Bool debug = False;
 
    if (debug)
@@ -1266,8 +1265,8 @@
    vg_assert(delta > 0);
    vg_assert(VG_IS_PAGE_ALIGNED(delta));
    
-   ok = VG_(am_extend_into_adjacent_reservation_client)( aseg, delta );
-   if (!ok) goto bad;
+   if (! VG_(am_extend_into_adjacent_reservation_client)( aseg->start, delta ))
+      goto bad;
 
    VG_(brk_limit) = newbrk;
    return newbrk;
diff --git a/coregrind/pub_core_aspacemgr.h b/coregrind/pub_core_aspacemgr.h
index 7db4141..c156d4d 100644
--- a/coregrind/pub_core_aspacemgr.h
+++ b/coregrind/pub_core_aspacemgr.h
@@ -271,8 +271,8 @@
 extern Bool VG_(am_create_reservation) 
    ( Addr start, SizeT length, ShrinkMode smode, SSizeT extra );
 
-/* Let SEG be an anonymous client mapping.  This fn extends the
-   mapping by DELTA bytes, taking the space from a reservation section
+/* ADDR is the start address of an anonymous client mapping.  This fn extends
+   the mapping by DELTA bytes, taking the space from a reservation section
    which must be adjacent.  If DELTA is positive, the segment is
    extended forwards in the address space, and the reservation must be
    the next one along.  If DELTA is negative, the segment is extended
@@ -280,9 +280,9 @@
    previous one.  DELTA must be page aligned.  abs(DELTA) must not
    exceed the size of the reservation segment minus one page, that is,
    the reservation segment after the operation must be at least one
-   page long. */
-extern Bool VG_(am_extend_into_adjacent_reservation_client) 
-   ( const NSegment* seg, SSizeT delta );
+   page long. The function returns a pointer to the resized segment. */
+extern const NSegment *VG_(am_extend_into_adjacent_reservation_client) 
+   ( Addr addr, SSizeT delta );
 
 /* --- --- --- resizing/move a mapping --- --- --- */