]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Change the prototype of VG_(am_extend_into_adjacent_reservation_client)
authorFlorian Krohm <florian@eich-krohm.de>
Thu, 26 Feb 2015 16:07:12 +0000 (16:07 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Thu, 26 Feb 2015 16:07:12 +0000 (16:07 +0000)
to match VG_(am_extend_map_client) for consistency.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14965

coregrind/m_aspacemgr/aspacemgr-linux.c
coregrind/m_signals.c
coregrind/m_syswrap/syswrap-generic.c
coregrind/pub_core_aspacemgr.h

index 32ac8424ae2e9d4d43ba6b908025c0f36891856b..d0a49eb3e73695bfbca1c635d9db0db0ac646999 100644 (file)
@@ -2777,8 +2777,8 @@ Bool VG_(am_create_reservation) ( Addr start, SizeT length,
 }
 
 
-/* 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 @@ Bool VG_(am_create_reservation) ( Addr start, SizeT length,
    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 @@ Bool VG_(am_extend_into_adjacent_reservation_client) ( const NSegment* seg,
           || 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 @@ Bool VG_(am_extend_into_adjacent_reservation_client) ( const NSegment* seg,
                 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 @@ Bool VG_(am_extend_into_adjacent_reservation_client) ( const NSegment* seg,
           || 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 @@ Bool VG_(am_extend_into_adjacent_reservation_client) ( const NSegment* seg,
                 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 @@ Bool VG_(am_extend_into_adjacent_reservation_client) ( const NSegment* seg,
    }
 
    AM_SANITY_CHECK;
-   return True;
+   return nsegments + segA;
 }
 
 
index f6f3254f9df7bb592efd5b07f557eae81e50c5be..deecebe27e4870e25b69d9f9954a0ba0c5ab8eeb 100644 (file)
@@ -2280,7 +2280,7 @@ Bool VG_(extend_stack)(Addr addr, UInt maxsize)
                     "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;
    }
index eaf29d0e769ef2ad6559058ca90eb902e038d8f4..d6a460bef8a0c6f5cbc73f205de96d099bce6fd4 100644 (file)
@@ -1190,7 +1190,6 @@ static Addr do_brk ( Addr newbrk )
    NSegment const* rseg;
    Addr newbrkP;
    SizeT delta;
-   Bool ok;
    Bool debug = False;
 
    if (debug)
@@ -1266,8 +1265,8 @@ static Addr do_brk ( Addr newbrk )
    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;
index 7db41415b393297929b2a76fddf561fcb9b0b500..c156d4d314c370708221c5511289ebaa41c64edf 100644 (file)
@@ -271,8 +271,8 @@ extern void VG_(am_set_segment_hasT_if_client_segment)( const NSegment* );
 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 @@ extern Bool VG_(am_create_reservation)
    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 --- --- --- */