From: Nicholas Nethercote Date: Sun, 19 Jun 2005 21:57:54 +0000 (+0000) Subject: Move VG_(get_memory_from_mmap_for_client) out of m_aspacemgr into X-Git-Tag: svn/VALGRIND_3_0_0~356 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8fc121f908ae779bea6bbc1b3d7e894facddd63c;p=thirdparty%2Fvalgrind.git Move VG_(get_memory_from_mmap_for_client) out of m_aspacemgr into m_libcmman, next to VG_(get_memory_from_mmap). Removes the (direct) dependence of m_mallocfree on m_aspacemgr. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3962 --- diff --git a/coregrind/m_aspacemgr/aspacemgr.c b/coregrind/m_aspacemgr/aspacemgr.c index 2003660671..ef109d4205 100644 --- a/coregrind/m_aspacemgr/aspacemgr.c +++ b/coregrind/m_aspacemgr/aspacemgr.c @@ -1372,28 +1372,9 @@ Bool VG_(is_addressable)(Addr p, SizeT size, UInt prot) /*--------------------------------------------------------------------*/ -/*--- Manage allocation of memory on behalf of the client ---*/ +/*--- Random function that doesn't really belong here ---*/ /*--------------------------------------------------------------------*/ -// Returns 0 on failure. -Addr VG_(get_memory_from_mmap_for_client) - (Addr addr, SizeT len, UInt prot, UInt sf_flags) -{ - len = VG_PGROUNDUP(len); - - tl_assert(!(sf_flags & SF_FIXED)); - tl_assert(0 == addr); - - addr = (Addr)VG_(mmap)((void *)addr, len, prot, - VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS | VKI_MAP_CLIENT, - sf_flags | SF_CORE, -1, 0); - if ((Addr)-1 != addr) - return addr; - else - return 0; -} - - /* We'll call any RW mmaped memory segment, within the client address range, which isn't SF_CORE, a root. */ diff --git a/coregrind/m_libcmman.c b/coregrind/m_libcmman.c index 3499fe570a..9270eef888 100644 --- a/coregrind/m_libcmman.c +++ b/coregrind/m_libcmman.c @@ -166,6 +166,25 @@ void* VG_(get_memory_from_mmap) ( SizeT nBytes, Char* who ) VG_(exit)(1); } +// Returns 0 on failure. +Addr VG_(get_memory_from_mmap_for_client) + (Addr addr, SizeT len, UInt prot, UInt sf_flags) +{ + len = VG_PGROUNDUP(len); + + tl_assert(!(sf_flags & SF_FIXED)); + tl_assert(0 == addr); + + addr = (Addr)VG_(mmap)((void *)addr, len, prot, + VKI_MAP_PRIVATE | VKI_MAP_ANONYMOUS | VKI_MAP_CLIENT, + sf_flags | SF_CORE, -1, 0); + if ((Addr)-1 != addr) + return addr; + else + return 0; +} + + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/m_mallocfree.c b/coregrind/m_mallocfree.c index 28ea67cef1..35730c147d 100644 --- a/coregrind/m_mallocfree.c +++ b/coregrind/m_mallocfree.c @@ -30,7 +30,6 @@ */ #include "pub_core_basics.h" -#include "pub_core_aspacemgr.h" #include "pub_core_libcbase.h" #include "pub_core_libcassert.h" #include "pub_core_libcmman.h" diff --git a/coregrind/pub_core_aspacemgr.h b/coregrind/pub_core_aspacemgr.h index 8a36d436b3..26a92a3b5c 100644 --- a/coregrind/pub_core_aspacemgr.h +++ b/coregrind/pub_core_aspacemgr.h @@ -145,9 +145,6 @@ extern VGA_REGPARM(2) /* Return string for prot */ extern const HChar *VG_(prot_str)(UInt prot); -extern Addr VG_(get_memory_from_mmap_for_client) - (Addr base, SizeT len, UInt prot, UInt flags); - /* Parses /proc/self/maps, calling `record_mapping' for each entry. */ extern void VG_(parse_procselfmaps) ( diff --git a/coregrind/pub_core_libcmman.h b/coregrind/pub_core_libcmman.h index 1219a41eb2..a537405ac6 100644 --- a/coregrind/pub_core_libcmman.h +++ b/coregrind/pub_core_libcmman.h @@ -48,6 +48,9 @@ extern SysRes VG_(mmap_native) ( void* start, SizeT length, UInt prot, extern SysRes VG_(munmap_native) ( void* start, SizeT length ); extern SysRes VG_(mprotect_native) ( void *start, SizeT length, UInt prot ); +extern Addr VG_(get_memory_from_mmap_for_client) + (Addr base, SizeT len, UInt prot, UInt flags); + #endif // __PUB_CORE_LIBCMMAN_H /*--------------------------------------------------------------------*/