summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwez <wez@1665872d-e22b-0410-9e5d-a57ad4215e6d>2007-08-03 15:05:00 +0000
committerwez <wez@1665872d-e22b-0410-9e5d-a57ad4215e6d>2007-08-03 15:05:00 +0000
commitf879627fb37b8b8f72132d7e7c5b32347c67a67d (patch)
tree15e84c7aa26f02a3992db20e046c109fc5e1ea72
parentf5af16a685fffa230a1aa67528bce772c4e4551b (diff)
downloadportableumem-f879627fb37b8b8f72132d7e7c5b32347c67a67d.tar.gz
fixup malloc replacement on 64-bit systems; was missing a configure check.
git-svn-id: https://labs.omniti.com/portableumem/trunk@45 1665872d-e22b-0410-9e5d-a57ad4215e6d
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac19
-rw-r--r--umem_test3.c21
3 files changed, 39 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
index 4a9de2b..ddcbbf8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,7 +10,7 @@ umem_test2_SOURCES = umem_test2.c
umem_test2_LDADD = -lumem
umem_test3_SOURCES = umem_test3.c
-umem_test3_LDADD = -lumem
+umem_test3_LDADD = -lumem -lumem_malloc
libumem_la_SOURCES = init_lib.c \
umem_agent_support.c \
diff --git a/configure.ac b/configure.ac
index b56d557..6166f4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,8 +7,23 @@ AC_PROG_LIBTOOL
AC_C_INLINE
-AC_CHECK_HEADERS([sys/mman.h sys/sysmacros.h sys/time.h])
-AC_CHECK_FUNCS([issetugid])
+AC_MSG_CHECKING([whether pthread_mutex_t is larger than 24 bytes])
+AC_TRY_RUN(
+ [
+#include <pthread.h>
+int main(void){return (sizeof(pthread_mutex_t) > 24);}
+ ],
+ [AC_MSG_RESULT(yes)],
+ [
+ AC_MSG_RESULT(no)
+ AC_DEFINE(UMEM_PTHREAD_MUTEX_TOO_BIG, [1], [need bigger cache])
+ AC_MSG_WARN([*** increasing umem cpu cache size to compensate.])
+ ]
+)
+
+
+AC_CHECK_HEADERS([sys/mman.h sys/sysmacros.h sys/time.h malloc.h])
+AC_CHECK_FUNCS([issetugid mallinfo malloc_stats])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile Doxyfile umem.spec])
diff --git a/umem_test3.c b/umem_test3.c
index bcbb231..88845d1 100644
--- a/umem_test3.c
+++ b/umem_test3.c
@@ -1,14 +1,35 @@
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
+#include <malloc.h>
+#endif
+
+static void minfo(void)
+{
+#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
+ struct mallinfo mi;
+ mi = mallinfo();
+ printf(" fordblks = %d\n", mi.fordblks);
+ malloc_stats();
+ printf("\n");
+#endif
+}
+
int
main (void)
{
char *p;
+ minfo();
p = malloc(10);
free(p);
+ minfo();
return EXIT_SUCCESS;
}
+
+/* vim:ts=2:sw=2:et:
+ */