Frederic Delley <fdelley@cisco.com>.
This required also adding VG_(arena_payload_szB)().
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1540
extern void* VG_(arena_malloc_aligned) ( ArenaId aid, Int req_alignB,
Int req_pszB );
+extern Int VG_(arena_payload_szB) ( ArenaId aid, void* payload );
+
extern void VG_(mallocSanityCheckAll) ( void );
extern void VG_(show_all_arena_stats) ( void );
return & fw[3 + a->rz_szW];
}
-/* Given the addr of the first word of a the payload of a block,
+/* Given the addr of the first word of the payload of a block,
return the addr of the first word of the block. */
static __inline__
Word* payload_to_first ( Arena* a, WordF* payload )
}
-/* Convert pointer size in words to block size in words, and back. */
+/* Convert payload size in words to block size in words, and back. */
static __inline__
Int pszW_to_bszW ( Arena* a, Int pszW )
{
return pszW;
}
+Int VG_(arena_payload_szB) ( ArenaId aid, void* ptr )
+{
+ Arena* a = arenaId_to_ArenaP(aid);
+ Word* fw = payload_to_first(a, (WordF*)ptr);
+ Int pszW = bszW_to_pszW(a, get_bszW_lo(fw));
+ return VKI_BYTES_PER_WORD * pszW;
+}
+
+
/*------------------------------------------------------------*/
/*--- Functions for working with freelists. ---*/
/*------------------------------------------------------------*/
return VKI_ENOMEM /*12*/ /*ENOMEM*/;
}
+Int malloc_usable_size ( void* p )
+{
+ Int pszB;
+
+ MALLOC_TRACE("malloc_usable_size[simd=%d](%p)",
+ (UInt)VG_(is_running_on_simd_CPU)(), p );
+ if (NULL == p)
+ return 0;
+
+ if (VG_(is_running_on_simd_CPU)()) {
+ pszB = (Int)VALGRIND_NON_SIMD_CALL2( VG_(arena_payload_szB),
+ VG_AR_CLIENT, p );
+ } else {
+ pszB = VG_(arena_payload_szB)(VG_AR_CLIENT, p);
+ }
+ MALLOC_TRACE(" = %d\n", pszB );
+
+ return pszB;
+}
+
/* Bomb out if we get any of these. */
/* HACK: We shouldn't call VG_(core_panic) or VG_(message) on the simulated
{ VG_(core_panic)("call to pvalloc\n"); }
void malloc_stats ( void )
{ VG_(core_panic)("call to malloc_stats\n"); }
-void malloc_usable_size ( void )
-{ VG_(core_panic)("call to malloc_usable_size\n"); }
+
void malloc_trim ( void )
{ VG_(core_panic)("call to malloc_trim\n"); }
void malloc_get_state ( void )