From: Florian Krohm Date: Thu, 26 Feb 2015 16:07:12 +0000 (+0000) Subject: Change the prototype of VG_(am_extend_into_adjacent_reservation_client) X-Git-Tag: svn/VALGRIND_3_11_0~627 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f8a625781c95671ebe04b676af7b4dd07ab0729e;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/coregrind/m_aspacemgr/aspacemgr-linux.c b/coregrind/m_aspacemgr/aspacemgr-linux.c index 32ac8424ae..d0a49eb3e7 100644 --- a/coregrind/m_aspacemgr/aspacemgr-linux.c +++ b/coregrind/m_aspacemgr/aspacemgr-linux.c @@ -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; } diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c index f6f3254f9d..deecebe27e 100644 --- a/coregrind/m_signals.c +++ b/coregrind/m_signals.c @@ -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; } diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index eaf29d0e76..d6a460bef8 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -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; diff --git a/coregrind/pub_core_aspacemgr.h b/coregrind/pub_core_aspacemgr.h index 7db41415b3..c156d4d314 100644 --- a/coregrind/pub_core_aspacemgr.h +++ b/coregrind/pub_core_aspacemgr.h @@ -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 --- --- --- */