From c67670e4e0fcfe6cdeb860f7f91770acb594676f Mon Sep 17 00:00:00 2001 From: Martin Stjernholm <mast@lysator.liu.se> Date: Wed, 9 Aug 2006 20:52:05 +0200 Subject: [PATCH] Fixes to make malloc.c jibe with the system malloc.h. Rev: src/configure.in:1.994 Rev: src/malloc.c:1.3 --- src/configure.in | 28 ++++++++++++++++++++++++---- src/malloc.c | 15 +++++++++++++-- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/configure.in b/src/configure.in index b79824a331..3c942c489b 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1,4 +1,4 @@ -AC_REVISION("$Id: configure.in,v 1.993 2006/08/09 17:00:50 grubba Exp $") +AC_REVISION("$Id: configure.in,v 1.994 2006/08/09 18:52:05 mast Exp $") AC_INIT(interpret.c) AC_CONFIG_HEADER(machine.h) @@ -2295,7 +2295,7 @@ if test "x$PIKE_PATH_TRANSLATE" = "x"; then # MinGW system. cat <<\EOF #!/bin/sh -# Automatically generated by $Id: configure.in,v 1.993 2006/08/09 17:00:50 grubba Exp $. +# Automatically generated by $Id: configure.in,v 1.994 2006/08/09 18:52:05 mast Exp $. # MinGW-version. Do NOT edit. posix_name="`cat`" posix_prefix="/" @@ -2333,7 +2333,7 @@ EOF # Native POSIX system. cat <<\EOF #!/bin/sh -# Automatically generated by $Id: configure.in,v 1.993 2006/08/09 17:00:50 grubba Exp $. +# Automatically generated by $Id: configure.in,v 1.994 2006/08/09 18:52:05 mast Exp $. # POSIX-version. Do NOT edit. cat EOF @@ -2342,7 +2342,7 @@ else # rntcl-style cat <<\EOF #!/bin/sh -# Automatically generated by $Id: configure.in,v 1.993 2006/08/09 17:00:50 grubba Exp $. +# Automatically generated by $Id: configure.in,v 1.994 2006/08/09 18:52:05 mast Exp $. # RNTCL-version. Do NOT edit. sed -e "$PIKE_PATH_TRANSLATE" EOF @@ -4459,6 +4459,26 @@ AC_MSG_RESULT($pike_cv_has_struct_sockaddr_in6) ############################################################################# +if test $ac_cv_header_malloc_h = yes; then + AC_MSG_CHECKING(struct mallinfo in malloc.h) + AC_CACHE_VAL(pike_cv_struct_mallinfo, [ + AC_TRY_LINK([ +#ifdef HAVE_MALLOC_H +#include <malloc.h> +#endif + ], [ + struct mallinfo foo; + ], pike_cv_struct_mallinfo=yes, pike_cv_struct_mallinfo=no) + ]) + if test $pike_cv_struct_mallinfo = yes; then + AC_DEFINE(HAVE_STRUCT_MALLINFO, 1, + [Defined if malloc.h contains a struct mallinfo.]) + fi + AC_MSG_RESULT($pike_cv_struct_mallinfo) +fi + +############################################################################# + if test "x$ac_cv_func_strtol" = "xyes"; then AC_MSG_CHECKING(if strtol works for large hexadecimal constants) AC_CACHE_VAL(pike_cv_func_strtol_works, [ diff --git a/src/malloc.c b/src/malloc.c index 43a1dd4d11..034e644204 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -4,8 +4,7 @@ #include "global.h" #define USE_LOCKS 1 #define USE_DL_PREFIX 1 -#define NO_MALLINFO 1 -/* Further pike changes below: PMOD_EXPORT */ +/* Further pike changes below: PMOD_EXPORTs and lines marked "PIKE". */ /* End pike preamble */ /* @@ -589,9 +588,15 @@ DEFAULT_MMAP_THRESHOLD default: 256K malloc does support the following options. */ +#ifndef M_TRIM_THRESHOLD /* PIKE change */ #define M_TRIM_THRESHOLD (-1) +#endif /* PIKE change */ +#ifndef M_GRANULARITY /* PIKE change */ #define M_GRANULARITY (-2) +#endif /* PIKE change */ +#ifndef M_MMAP_THRESHOLD /* PIKE change */ #define M_MMAP_THRESHOLD (-3) +#endif /* PIKE change */ /* ------------------------ Mallinfo declarations ------------------------ */ @@ -622,6 +627,12 @@ DEFAULT_MMAP_THRESHOLD default: 256K #ifdef HAVE_USR_INCLUDE_MALLOC_H #include "/usr/include/malloc.h" + +/* PIKE change start */ +#elif defined (HAVE_MALLOC_H) && defined (HAVE_STRUCT_MALLINFO) +#include <malloc.h> +/* PIKE change end */ + #else /* HAVE_USR_INCLUDE_MALLOC_H */ struct mallinfo { -- GitLab