Support for platforms /wo malloc_usable_size
authorCampbell Barton <ideasman42@gmail.com>
Sun, 21 Jun 2015 02:29:20 +0000 (12:29 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 21 Jun 2015 02:33:55 +0000 (12:33 +1000)
Was only used for stats, netbsd doesn't define this function.

intern/guardedalloc/intern/mallocn_guarded_impl.c
intern/guardedalloc/intern/mallocn_intern.h

index 88d6f35d4380b2810af39ec8e0203e6904c1105b..1933e9d3ee372bc4f1f5b1556c2353093111a49d 100644 (file)
@@ -711,10 +711,12 @@ void MEM_guarded_printmemlist_stats(void)
                totpb++;
                pb++;
 
+#ifdef USE_MALLOC_USABLE_SIZE
                if (!membl->mmap && membl->alignment == 0) {
                        mem_in_use_slop += (sizeof(MemHead) + sizeof(MemTail) +
                                            malloc_usable_size((void *)membl)) - membl->len;
                }
+#endif
 
                if (membl->next)
                        membl = MEMNEXT(membl->next);
index 6cab1f01b70e49f8f13d68dfadd25d8d61bb1a27..3f7e462c1c7f41a0a13d60cfee0056d11a16a087 100644 (file)
@@ -50,6 +50,7 @@
 #endif
 
 #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__)
 #  include <malloc.h>
@@ -63,7 +64,8 @@
 #  include <malloc.h>
 #  define malloc_usable_size _msize
 #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
 
 /* Blame Microsoft for LLP64 and no inttypes.h, quick workaround needed: */