dnl all other uses of RUN_IFELSE are wrapped inside CACHE_CHECK which breaks on 2.64
AC_RUN_IFELSE([AC_LANG_SOURCE([[ int main(int argc, char **argv) { return 0; } ]])],[],[],[:])
-dnl This is a developer only option.. developers know how to set defines
-dnl
-dnl AC_ARG_ENABLE(xmalloc-debug,
-dnl [ --enable-xmalloc-debug Do some simple malloc debugging],
-dnl [ if test "$enableval" = "yes" ; then
-dnl AC_MSG_NOTICE([malloc debugging enabled])
-dnl AC_DEFINE(XMALLOC_DEBUG,1,[Define to do simple malloc debugging])
-dnl fi
-dnl ])
-
AH_TEMPLATE(XMALLOC_STATISTICS,[Define to have malloc statistics])
AC_ARG_ENABLE(xmalloc-statistics,
AS_HELP_STRING([--enable-xmalloc-statistics],
#endif
-#if XMALLOC_DEBUG
-#define DBG_ARRY_SZ (1<<11)
-#define DBG_ARRY_BKTS (1<<8)
-static void *(*malloc_ptrs)[DBG_ARRY_SZ];
-static int malloc_size[DBG_ARRY_BKTS][DBG_ARRY_SZ];
-static int dbg_initd = 0;
-
-#define DBG_HASH_BUCKET(ptr) (((((int)ptr)>>4)+(((int)ptr)>>12)+(((int)ptr)>>20))&0xFF)
-
-static void
-check_init(void)
-{
- int B = 0, I = 0;
- /* calloc the ptrs so that we don't see them when hunting lost memory */
- malloc_ptrs = calloc(DBG_ARRY_BKTS, sizeof(*malloc_ptrs));
-
- for (B = 0; B < DBG_ARRY_BKTS; ++B) {
- for (I = 0; I < DBG_ARRY_SZ; ++I) {
- malloc_ptrs[B][I] = NULL;
- malloc_size[B][I] = 0;
- }
- }
-
- dbg_initd = 1;
-}
-
-static void
-check_free(void *s)
-{
- int B, I;
- B = DBG_HASH_BUCKET(s);
-
- for (I = 0; I < DBG_ARRY_SZ; ++I) {
- if (malloc_ptrs[B][I] != s)
- continue;
-
- malloc_ptrs[B][I] = NULL;
- malloc_size[B][I] = 0;
- break;
- }
-
- if (I == DBG_ARRY_SZ) {
- static char msg[128];
- snprintf(msg, 128, "xfree: ERROR: s=%p not found!", s);
- if (failure_notify)
- (*failure_notify) (msg);
- else
- perror(msg);
- }
-}
-
-static void
-check_malloc(void *p, size_t sz)
-{
- void *P, *Q;
- int B, I;
-
- if (!dbg_initd)
- check_init();
-
- B = DBG_HASH_BUCKET(p);
-
- for (I = 0; I < DBG_ARRY_SZ; ++I) {
- if (!(P = malloc_ptrs[B][I]))
- continue;
-
- Q = P + malloc_size[B][I];
-
- if (P <= p && p < Q) {
- static char msg[128];
- snprintf(msg, 128, "xmalloc: ERROR: p=%p falls in P=%p+%d",
- p, P, malloc_size[B][I]);
- if (failure_notify)
- (*failure_notify) (msg);
- else
- perror(msg);
- }
- }
-
- for (I = 0; I < DBG_ARRY_SZ; ++I) {
- if (malloc_ptrs[B][I])
- continue;
-
- malloc_ptrs[B][I] = p;
- malloc_size[B][I] = (int) sz;
- break;
- }
-
- if (I == DBG_ARRY_SZ) {
- if (failure_notify)
- (*failure_notify) ("xmalloc: debug out of array space!");
- else
- perror("xmalloc: debug out of array space!");
- }
-}
-
-#endif
-