Support for platforms /wo malloc_usable_size

Was only used for stats, netbsd doesn't define this function.
This commit is contained in:
Campbell Barton 2015-06-21 12:29:20 +10:00
parent e3d6269ec4
commit 8d752141ce
2 changed files with 5 additions and 1 deletions

@ -711,10 +711,12 @@ void MEM_guarded_printmemlist_stats(void)
totpb++; totpb++;
pb++; pb++;
#ifdef USE_MALLOC_USABLE_SIZE
if (!membl->mmap && membl->alignment == 0) { if (!membl->mmap && membl->alignment == 0) {
mem_in_use_slop += (sizeof(MemHead) + sizeof(MemTail) + mem_in_use_slop += (sizeof(MemHead) + sizeof(MemTail) +
malloc_usable_size((void *)membl)) - membl->len; malloc_usable_size((void *)membl)) - membl->len;
} }
#endif
if (membl->next) if (membl->next)
membl = MEMNEXT(membl->next); membl = MEMNEXT(membl->next);

@ -50,6 +50,7 @@
#endif #endif
#undef HAVE_MALLOC_STATS #undef HAVE_MALLOC_STATS
#define USE_MALLOC_USABLE_SIZE /* internal, when we have malloc_usable_size() */
#if defined(__linux__) || (defined(__FreeBSD_kernel__) && !defined(__FreeBSD__)) || defined(__GLIBC__) #if defined(__linux__) || (defined(__FreeBSD_kernel__) && !defined(__FreeBSD__)) || defined(__GLIBC__)
# include <malloc.h> # include <malloc.h>
@ -63,7 +64,8 @@
# include <malloc.h> # include <malloc.h>
# define malloc_usable_size _msize # define malloc_usable_size _msize
#else #else
# error "We don't know how to use malloc_usable_size on your platform" # pragma message "We don't know how to use malloc_usable_size on your platform"
# undef USE_MALLOC_USABLE_SIZE
#endif #endif
/* Blame Microsoft for LLP64 and no inttypes.h, quick workaround needed: */ /* Blame Microsoft for LLP64 and no inttypes.h, quick workaround needed: */