aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--config.make.in3
-rwxr-xr-xconfigure504
-rw-r--r--configure.in28
-rw-r--r--malloc/Makefile20
-rw-r--r--malloc/memprof.c596
-rw-r--r--malloc/memprofstat.c612
7 files changed, 1577 insertions, 196 deletions
diff --git a/ChangeLog b/ChangeLog
index 072c2363fe..e37c010bbe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+1999-10-03 Ulrich Drepper <drepper@cygnus.com>
+
+ * configure.in: Accept --with-gd option and set all libgd-LDFLAGS,
+ CFLAGS-memprofstat.c, and LIBGD variables.
+ * config.make.in: Add LIBGD.
+ * malloc/Makefile: Add rules to generate libmemprof.so and
+ memprofstat.
+ * malloc/memprof.c: New file.
+ * malloc/memprofstat.c: New file.
+
1999-10-02 Ulrich Drepper <drepper@cygnus.com>
* resolv/nsap_addr.c (inet_nsap_addr): Little optimization.
diff --git a/config.make.in b/config.make.in
index f24ffdaaad..4ba8143f4d 100644
--- a/config.make.in
+++ b/config.make.in
@@ -86,4 +86,7 @@ KSH = @KSH@
AWK = @AWK@
PERL = @PERL@
+# Additional libraries.
+LIBGD = @LIBGD@
+
# More variables may be inserted below by configure.
diff --git a/configure b/configure
index a947ea3381..dd7a1964b9 100755
--- a/configure
+++ b/configure
@@ -12,7 +12,7 @@
# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13
+# Generated automatically using autoconf version 2.14.1
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
@@ -27,6 +27,8 @@ ac_help="$ac_help
ac_help="$ac_help
--with-gettext=DIR find GNU gettext source code in DIR (not needed)"
ac_help="$ac_help
+ --with-gd=DIR find libgd include dir and library with prefix DIR"
+ac_help="$ac_help
--with-fp if using floating-point hardware [default=yes]"
ac_help="$ac_help
--with-binutils=PATH specify location of binutils (as and ld)"
@@ -388,7 +390,7 @@ EOF
verbose=yes ;;
-version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.13"
+ echo "configure generated by autoconf version 2.14.1"
exit 0 ;;
-with-* | --with-*)
@@ -548,7 +550,7 @@ done
if test -r "$cache_file"; then
echo "loading cache $cache_file"
- . $cache_file
+ test -f "$cache_file" && . $cache_file
else
echo "creating cache $cache_file"
> $cache_file
@@ -600,9 +602,9 @@ done
if test -z "$ac_aux_dir"; then
{ echo "configure: error: can not find install-sh or install.sh in scripts $srcdir/scripts" 1>&2; exit 1; }
fi
-ac_config_guess=$ac_aux_dir/config.guess
-ac_config_sub=$ac_aux_dir/config.sub
-ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
# This will get text that should go into config.make.
@@ -636,6 +638,22 @@ esac
fi
+# Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
+# Check whether --with-gd or --without-gd was given.
+if test "${with_gd+set}" = set; then
+ withval="$with_gd"
+ case "$with_gd" in
+yes|''|no) config_vars="$config_vars
+libgd-LDFLAGS =" ;;
+*) config_vars="$config_vars
+CFLAGS-memprofstat.c = -I$withval/include
+libgd-LDFLAGS = -L$withval/lib"
+ libgd_include="-I$withval/include"
+ libgd_ldflags="-L$withval/lib" ;;
+esac
+
+fi
+
# Check whether --with-fp or --without-fp was given.
if test "${with_fp+set}" = set; then
@@ -804,31 +822,45 @@ fi
+echo $ac_n "checking host system type""... $ac_c" 1>&6
+echo "configure:827: checking host system type" >&5
+if test "x$ac_cv_host" = "x" || (test "x$host" != "xNONE" && test "x$host" != "x$ac_cv_host_alias"); then
+
# Make sure we can run config.sub.
-if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
-else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+ if $ac_config_sub sun4 >/dev/null 2>&1; then :
+ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+ fi
+
+ ac_cv_host_alias=$host
+ case "$ac_cv_host_alias" in
+ NONE)
+ case $nonopt in
+ NONE)
+ if ac_cv_host_alias=`$ac_config_guess`; then :
+ else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
+ fi ;;
+ *) ac_cv_host_alias=$nonopt ;;
+ esac ;;
+ esac
+
+ ac_cv_host=`$ac_config_sub $ac_cv_host_alias`
+ ac_cv_host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+ ac_cv_host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+ ac_cv_host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+else
+ echo $ac_n "(cached) $ac_c" 1>&6
fi
-echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:814: checking host system type" >&5
+echo "$ac_t""$ac_cv_host" 1>&6
+
+host=$ac_cv_host
+host_alias=$ac_cv_host_alias
+host_cpu=$ac_cv_host_cpu
+host_vendor=$ac_cv_host_vendor
+host_os=$ac_cv_host_os
+
-host_alias=$host
-case "$host_alias" in
-NONE)
- case $nonopt in
- NONE)
- if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
- else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
- fi ;;
- *) host_alias=$nonopt ;;
- esac ;;
-esac
-host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
-host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$host" 1>&6
# The way shlib-versions is used to generate soversions.mk uses a
@@ -935,7 +967,7 @@ fi
# This can take a while to compute.
sysdep_dir=$srcdir/sysdeps
echo $ac_n "checking sysdep dirs""... $ac_c" 1>&6
-echo "configure:939: checking sysdep dirs" >&5
+echo "configure:971: checking sysdep dirs" >&5
# Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
@@ -1139,9 +1171,9 @@ echo "$ac_t""$default_sysnames" 1>&6
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1143: checking for a BSD compatible install" >&5
+echo "configure:1175: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+if eval "test \"\${ac_cv_path_install+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
@@ -1159,6 +1191,10 @@ else
grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
:
+ elif test $ac_prog = install &&
+ grep pwplus $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
else
ac_cv_path_install="$ac_dir/$ac_prog -c"
break 2
@@ -1187,7 +1223,7 @@ echo "$ac_t""$INSTALL" 1>&6
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
@@ -1196,8 +1232,8 @@ if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
INSTALL='\$(..)./scripts/install-sh -c'
fi
echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:1200: checking whether ln -s works" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
+echo "configure:1236: checking whether ln -s works" >&5
+if eval "test \"\${ac_cv_prog_LN_S+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
rm -f conftestdata
@@ -1218,23 +1254,45 @@ fi
# These programs are version sensitive.
+
echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:1223: checking build system type" >&5
-
-build_alias=$build
-case "$build_alias" in
-NONE)
- case $nonopt in
- NONE) build_alias=$host_alias ;;
- *) build_alias=$nonopt ;;
- esac ;;
-esac
+echo "configure:1260: checking build system type" >&5
+if test "x$ac_cv_build" = "x" || (test "x$build" != "xNONE" && test "x$build" != "x$ac_cv_build_alias"); then
+
+# Make sure we can run config.sub.
+ if $ac_config_sub sun4 >/dev/null 2>&1; then :
+ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+ fi
+
+ ac_cv_build_alias=$build
+ case "$ac_cv_build_alias" in
+ NONE)
+ case $nonopt in
+ NONE)
+ ac_cv_build_alias=$host_alias ;;
+
+ *) ac_cv_build_alias=$nonopt ;;
+ esac ;;
+ esac
+
+ ac_cv_build=`$ac_config_sub $ac_cv_build_alias`
+ ac_cv_build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+ ac_cv_build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+ ac_cv_build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+else
+ echo $ac_n "(cached) $ac_c" 1>&6
+fi
+
+echo "$ac_t""$ac_cv_build" 1>&6
+
+build=$ac_cv_build
+build_alias=$ac_cv_build_alias
+build_cpu=$ac_cv_build_cpu
+build_vendor=$ac_cv_build_vendor
+build_os=$ac_cv_build_os
+
+
-build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
-build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$build" 1>&6
if test $host != $build; then
ac_tool_prefix=${host_alias}-
@@ -1247,8 +1305,8 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1251: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+echo "configure:1309: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_prog_CC+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
@@ -1281,7 +1339,7 @@ if test -z "$CC"; then
else
# Found it, now check the version.
echo $ac_n "checking version of $CC""... $ac_c" 1>&6
-echo "configure:1285: checking version of $CC" >&5
+echo "configure:1343: checking version of $CC" >&5
ac_prog_version=`$CC -v 2>&1 | sed -n 's/^.*version \([egcygnustp-]*[0-9.]*\).*$/\1/p'`
case $ac_prog_version in
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
@@ -1301,8 +1359,8 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1305: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_MAKE'+set}'`\" = set"; then
+echo "configure:1363: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_prog_MAKE+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$MAKE"; then
@@ -1335,7 +1393,7 @@ if test -z "$MAKE"; then
else
# Found it, now check the version.
echo $ac_n "checking version of $MAKE""... $ac_c" 1>&6
-echo "configure:1339: checking version of $MAKE" >&5
+echo "configure:1397: checking version of $MAKE" >&5
ac_prog_version=`$MAKE --version 2>&1 | sed -n 's/^.*GNU Make[^0-9]*\([0-9][0-9.]*\).*$/\1/p'`
case $ac_prog_version in
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
@@ -1356,8 +1414,8 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1360: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_MSGFMT'+set}'`\" = set"; then
+echo "configure:1418: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_prog_MSGFMT+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$MSGFMT"; then
@@ -1390,7 +1448,7 @@ if test -z "$MSGFMT"; then
else
# Found it, now check the version.
echo $ac_n "checking version of $MSGFMT""... $ac_c" 1>&6
-echo "configure:1394: checking version of $MSGFMT" >&5
+echo "configure:1452: checking version of $MSGFMT" >&5
ac_prog_version=`$MSGFMT --version 2>&1 | sed -n 's/^.*GNU gettext.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
case $ac_prog_version in
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
@@ -1410,8 +1468,8 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1414: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then
+echo "configure:1472: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_prog_MAKEINFO+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$MAKEINFO"; then
@@ -1444,7 +1502,7 @@ if test -z "$MAKEINFO"; then
else
# Found it, now check the version.
echo $ac_n "checking version of $MAKEINFO""... $ac_c" 1>&6
-echo "configure:1448: checking version of $MAKEINFO" >&5
+echo "configure:1506: checking version of $MAKEINFO" >&5
ac_prog_version=`$MAKEINFO --version 2>&1 | sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'`
case $ac_prog_version in
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
@@ -1477,8 +1535,8 @@ CCVERSION=`$CC -v 2>&1 | sed -n 's/gcc version //p'`
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1481: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_cc_works'+set}'`\" = set"; then
+echo "configure:1539: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+if eval "test \"\${ac_cv_prog_cc_works+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1491,12 +1549,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
-#line 1495 "configure"
+#line 1553 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:1500: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1558: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -1527,8 +1585,8 @@ else
cross_linkable=yes
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1531: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_cc_cross'+set}'`\" = set"; then
+echo "configure:1589: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+if eval "test \"\${ac_cv_prog_cc_cross+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
:
@@ -1539,8 +1597,8 @@ echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1543: checking whether we are using GNU C" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+echo "configure:1601: checking whether we are using GNU C" >&5
+if eval "test \"\${ac_cv_prog_gcc+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
@@ -1548,7 +1606,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1552: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1610: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -1560,23 +1618,45 @@ if test $ac_cv_prog_gcc != yes; then
{ echo "configure: error: GNU libc must be compiled using GNU CC" 1>&2; exit 1; }
fi
+
echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:1565: checking build system type" >&5
-
-build_alias=$build
-case "$build_alias" in
-NONE)
- case $nonopt in
- NONE) build_alias=$host_alias ;;
- *) build_alias=$nonopt ;;
- esac ;;
-esac
+echo "configure:1624: checking build system type" >&5
+if test "x$ac_cv_build" = "x" || (test "x$build" != "xNONE" && test "x$build" != "x$ac_cv_build_alias"); then
+
+# Make sure we can run config.sub.
+ if $ac_config_sub sun4 >/dev/null 2>&1; then :
+ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+ fi
+
+ ac_cv_build_alias=$build
+ case "$ac_cv_build_alias" in
+ NONE)
+ case $nonopt in
+ NONE)
+ ac_cv_build_alias=$host_alias ;;
+
+ *) ac_cv_build_alias=$nonopt ;;
+ esac ;;
+ esac
+
+ ac_cv_build=`$ac_config_sub $ac_cv_build_alias`
+ ac_cv_build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+ ac_cv_build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+ ac_cv_build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+else
+ echo $ac_n "(cached) $ac_c" 1>&6
+fi
+
+echo "$ac_t""$ac_cv_build" 1>&6
+
+build=$ac_cv_build
+build_alias=$ac_cv_build_alias
+build_cpu=$ac_cv_build_cpu
+build_vendor=$ac_cv_build_vendor
+build_os=$ac_cv_build_os
+
+
-build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
-build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$build" 1>&6
if test $host != $build; then
for ac_prog in gcc cc
@@ -1584,8 +1664,8 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1588: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_BUILD_CC'+set}'`\" = set"; then
+echo "configure:1668: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_prog_BUILD_CC+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$BUILD_CC"; then
@@ -1616,13 +1696,13 @@ done
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1620: checking how to run the C preprocessor" >&5
+echo "configure:1700: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+if eval "test \"\${ac_cv_prog_CPP+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# This must be in double quotes, not single quotes, because CPP may get
@@ -1631,13 +1711,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1635 "configure"
+#line 1715 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1641: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1721: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1648,13 +1728,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1652 "configure"
+#line 1732 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1658: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1738: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1665,13 +1745,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1669 "configure"
+#line 1749 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1675: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1755: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1714,8 +1794,8 @@ if test $RANLIB = ranlib; then
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1718: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+echo "configure:1798: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_prog_RANLIB+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$RANLIB"; then
@@ -1746,8 +1826,8 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1750: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+echo "configure:1830: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_prog_RANLIB+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$RANLIB"; then
@@ -1783,8 +1863,8 @@ fi
# Determine whether we are using GNU binutils.
echo $ac_n "checking whether $AS is GNU as""... $ac_c" 1>&6
-echo "configure:1787: checking whether $AS is GNU as" >&5
-if eval "test \"`echo '$''{'libc_cv_prog_as_gnu'+set}'`\" = set"; then
+echo "configure:1867: checking whether $AS is GNU as" >&5
+if eval "test \"\${libc_cv_prog_as_gnu+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Most GNU programs take a -v and spit out some text including
@@ -1802,8 +1882,8 @@ rm -f a.out
gnu_as=$libc_cv_prog_as_gnu
echo $ac_n "checking whether $LD is GNU ld""... $ac_c" 1>&6
-echo "configure:1806: checking whether $LD is GNU ld" >&5
-if eval "test \"`echo '$''{'libc_cv_prog_ld_gnu'+set}'`\" = set"; then
+echo "configure:1886: checking whether $LD is GNU ld" >&5
+if eval "test \"\${libc_cv_prog_ld_gnu+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
# Most GNU programs take a -v and spit out some text including
@@ -1822,8 +1902,8 @@ gnu_ld=$libc_cv_prog_ld_gnu
# Extract the first word of "${ac_tool_prefix}mig", so it can be a program name with args.
set dummy ${ac_tool_prefix}mig; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1826: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_MIG'+set}'`\" = set"; then
+echo "configure:1906: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_prog_MIG+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$MIG"; then
@@ -1863,8 +1943,8 @@ fi
# check if ranlib is necessary
echo $ac_n "checking whether ranlib is necessary""... $ac_c" 1>&6
-echo "configure:1867: checking whether ranlib is necessary" >&5
-if eval "test \"`echo '$''{'libc_cv_ranlib_necessary'+set}'`\" = set"; then
+echo "configure:1947: checking whether ranlib is necessary" >&5
+if eval "test \"\${libc_cv_ranlib_necessary+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
@@ -1897,7 +1977,7 @@ fi
# - two terminals occur directly after each other
# - the path contains an element with a dot in it
echo $ac_n "checking LD_LIBRARY_PATH variable""... $ac_c" 1>&6
-echo "configure:1901: checking LD_LIBRARY_PATH variable" >&5
+echo "configure:1981: checking LD_LIBRARY_PATH variable" >&5
case ${LD_LIBRARY_PATH} in
[:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
ld_library_path_setting="contains current directory"
@@ -1917,8 +1997,8 @@ fi
# Extract the first word of "bash", so it can be a program name with args.
set dummy bash; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1921: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_path_BASH'+set}'`\" = set"; then
+echo "configure:2001: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_path_BASH+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
case "$BASH" in
@@ -1963,8 +2043,8 @@ if test "$BASH" = no; then
# Extract the first word of "ksh", so it can be a program name with args.
set dummy ksh; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1967: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_path_KSH'+set}'`\" = set"; then
+echo "configure:2047: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_path_KSH+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
case "$KSH" in
@@ -2013,8 +2093,8 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2017: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
+echo "configure:2097: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_prog_AWK+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$AWK"; then
@@ -2045,8 +2125,8 @@ done
# Extract the first word of "perl", so it can be a program name with args.
set dummy perl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2049: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
+echo "configure:2129: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_path_PERL+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
case "$PERL" in
@@ -2082,8 +2162,8 @@ fi
# Extract the first word of "install-info", so it can be a program name with args.
set dummy install-info; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2086: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_path_INSTALL_INFO'+set}'`\" = set"; then
+echo "configure:2166: checking for $ac_word" >&5
+if eval "test \"\${ac_cv_path_INSTALL_INFO+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
case "$INSTALL_INFO" in
@@ -2118,8 +2198,8 @@ fi
if test "$INSTALL_INFO" != "no"; then
echo $ac_n "checking for old Debian install-info""... $ac_c" 1>&6
-echo "configure:2122: checking for old Debian install-info" >&5
-if eval "test \"`echo '$''{'libc_cv_old_debian_install_info'+set}'`\" = set"; then
+echo "configure:2202: checking for old Debian install-info" >&5
+if eval "test \"\${libc_cv_old_debian_install_info+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
mkdir conftest.d
@@ -2151,8 +2231,8 @@ fi
echo $ac_n "checking for signed size_t type""... $ac_c" 1>&6
-echo "configure:2155: checking for signed size_t type" >&5
-if eval "test \"`echo '$''{'libc_cv_signed_size_t'+set}'`\" = set"; then
+echo "configure:2235: checking for signed size_t type" >&5
+if eval "test \"\${libc_cv_signed_size_t+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
echo '#include <stddef.h>
@@ -2175,12 +2255,12 @@ EOF
fi
echo $ac_n "checking for libc-friendly stddef.h""... $ac_c" 1>&6
-echo "configure:2179: checking for libc-friendly stddef.h" >&5
-if eval "test \"`echo '$''{'libc_cv_friendly_stddef'+set}'`\" = set"; then
+echo "configure:2259: checking for libc-friendly stddef.h" >&5
+if eval "test \"\${libc_cv_friendly_stddef+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2184 "configure"
+#line 2264 "configure"
#include "confdefs.h"
#define __need_size_t
#define __need_wchar_t
@@ -2195,7 +2275,7 @@ size_t size; wchar_t wchar;
if (&size == NULL || &wchar == NULL) abort ();
; return 0; }
EOF
-if { (eval echo configure:2199: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2279: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
libc_cv_friendly_stddef=yes
else
@@ -2214,8 +2294,8 @@ override stddef.h = # The installed <stddef.h> seems to be libc-friendly."
fi
echo $ac_n "checking whether we need to use -P to assemble .S files""... $ac_c" 1>&6
-echo "configure:2218: checking whether we need to use -P to assemble .S files" >&5
-if eval "test \"`echo '$''{'libc_cv_need_minus_P'+set}'`\" = set"; then
+echo "configure:2298: checking whether we need to use -P to assemble .S files" >&5
+if eval "test \"\${libc_cv_need_minus_P+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.S <<EOF
@@ -2237,8 +2317,8 @@ asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives."
fi
echo $ac_n "checking for assembler global-symbol directive""... $ac_c" 1>&6
-echo "configure:2241: checking for assembler global-symbol directive" >&5
-if eval "test \"`echo '$''{'libc_cv_asm_global_directive'+set}'`\" = set"; then
+echo "configure:2321: checking for assembler global-symbol directive" >&5
+if eval "test \"\${libc_cv_asm_global_directive+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
libc_cv_asm_global_directive=UNKNOWN
@@ -2267,8 +2347,8 @@ EOF
fi
echo $ac_n "checking for .set assembler directive""... $ac_c" 1>&6
-echo "configure:2271: checking for .set assembler directive" >&5
-if eval "test \"`echo '$''{'libc_cv_asm_set_directive'+set}'`\" = set"; then
+echo "configure:2351: checking for .set assembler directive" >&5
+if eval "test \"\${libc_cv_asm_set_directive+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.s <<EOF
@@ -2301,8 +2381,8 @@ EOF
fi
echo $ac_n "checking for .symver assembler directive""... $ac_c" 1>&6
-echo "configure:2305: checking for .symver assembler directive" >&5
-if eval "test \"`echo '$''{'libc_cv_asm_symver_directive'+set}'`\" = set"; then
+echo "configure:2385: checking for .symver assembler directive" >&5
+if eval "test \"\${libc_cv_asm_symver_directive+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.s <<EOF
@@ -2320,8 +2400,8 @@ fi
echo "$ac_t""$libc_cv_asm_symver_directive" 1>&6
echo $ac_n "checking for ld --version-script""... $ac_c" 1>&6
-echo "configure:2324: checking for ld --version-script" >&5
-if eval "test \"`echo '$''{'libc_cv_ld_version_script_option'+set}'`\" = set"; then
+echo "configure:2404: checking for ld --version-script" >&5
+if eval "test \"\${libc_cv_ld_version_script_option+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test $libc_cv_asm_symver_directive = yes; then
@@ -2343,7 +2423,7 @@ EOF
if { ac_try='${CC-cc} $CFLAGS -shared -o conftest.so conftest.o
-nostartfiles -nostdlib
-Wl,--version-script,conftest.map
- 1>&5'; { (eval echo configure:2347: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
+ 1>&5'; { (eval echo configure:2427: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
then
libc_cv_ld_version_script_option=yes
else
@@ -2381,15 +2461,15 @@ if test $VERSIONING = no; then
fi
if test $elf = yes; then
echo $ac_n "checking for .previous assembler directive""... $ac_c" 1>&6
-echo "configure:2385: checking for .previous assembler directive" >&5
-if eval "test \"`echo '$''{'libc_cv_asm_previous_directive'+set}'`\" = set"; then
+echo "configure:2465: checking for .previous assembler directive" >&5
+if eval "test \"\${libc_cv_asm_previous_directive+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.s <<EOF
.section foo_section
.previous
EOF
- if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2393: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2473: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_asm_previous_directive=yes
else
libc_cv_asm_previous_directive=no
@@ -2405,15 +2485,15 @@ EOF
else
echo $ac_n "checking for .popsection assembler directive""... $ac_c" 1>&6
-echo "configure:2409: checking for .popsection assembler directive" >&5
-if eval "test \"`echo '$''{'libc_cv_asm_popsection_directive'+set}'`\" = set"; then
+echo "configure:2489: checking for .popsection assembler directive" >&5
+if eval "test \"\${libc_cv_asm_popsection_directive+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.s <<EOF
.pushsection foo_section
.popsection
EOF
- if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2417: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2497: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_asm_popsection_directive=yes
else
libc_cv_asm_popsection_directive=no
@@ -2433,12 +2513,12 @@ fi
if test $elf != yes; then
echo $ac_n "checking for .init and .fini sections""... $ac_c" 1>&6
-echo "configure:2437: checking for .init and .fini sections" >&5
-if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then
+echo "configure:2517: checking for .init and .fini sections" >&5
+if eval "test \"\${libc_cv_have_initfini+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2442 "configure"
+#line 2522 "configure"
#include "confdefs.h"
int main() {
@@ -2447,7 +2527,7 @@ asm (".section .init");
asm (".text");
; return 0; }
EOF
-if { (eval echo configure:2451: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2531: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
libc_cv_have_initfini=yes
else
@@ -2475,19 +2555,19 @@ if test $elf = yes; then
else
if test $ac_cv_prog_cc_works = yes; then
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6
-echo "configure:2479: checking for _ prefix on C symbol names" >&5
-if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
+echo "configure:2559: checking for _ prefix on C symbol names" >&5
+if eval "test \"\${libc_cv_asm_underscores+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2484 "configure"
+#line 2564 "configure"
#include "confdefs.h"
asm ("_glibc_foobar:");
int main() {
glibc_foobar ();
; return 0; }
EOF
-if { (eval echo configure:2491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2571: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
libc_cv_asm_underscores=yes
else
@@ -2502,17 +2582,17 @@ fi
echo "$ac_t""$libc_cv_asm_underscores" 1>&6
else
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6
-echo "configure:2506: checking for _ prefix on C symbol names" >&5
-if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
+echo "configure:2586: checking for _ prefix on C symbol names" >&5
+if eval "test \"\${libc_cv_asm_underscores+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2511 "configure"
+#line 2591 "configure"
#include "confdefs.h"
void underscore_test(void) {
return; }
EOF
-if { (eval echo configure:2516: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2596: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if grep _underscore_test conftest* >/dev/null; then
rm -f conftest*
libc_cv_asm_underscores=yes
@@ -2544,8 +2624,8 @@ if test $elf = yes; then
fi
echo $ac_n "checking for assembler .weak directive""... $ac_c" 1>&6
-echo "configure:2548: checking for assembler .weak directive" >&5
-if eval "test \"`echo '$''{'libc_cv_asm_weak_directive'+set}'`\" = set"; then
+echo "configure:2628: checking for assembler .weak directive" >&5
+if eval "test \"\${libc_cv_asm_weak_directive+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.s <<EOF
@@ -2567,8 +2647,8 @@ echo "$ac_t""$libc_cv_asm_weak_directive" 1>&6
if test $libc_cv_asm_weak_directive = no; then
echo $ac_n "checking for assembler .weakext directive""... $ac_c" 1>&6
-echo "configure:2571: checking for assembler .weakext directive" >&5
-if eval "test \"`echo '$''{'libc_cv_asm_weakext_directive'+set}'`\" = set"; then
+echo "configure:2651: checking for assembler .weakext directive" >&5
+if eval "test \"\${libc_cv_asm_weakext_directive+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.s <<EOF
@@ -2605,8 +2685,8 @@ EOF
fi
echo $ac_n "checking for ld --no-whole-archive""... $ac_c" 1>&6
-echo "configure:2609: checking for ld --no-whole-archive" >&5
-if eval "test \"`echo '$''{'libc_cv_ld_no_whole_archive'+set}'`\" = set"; then
+echo "configure:2689: checking for ld --no-whole-archive" >&5
+if eval "test \"\${libc_cv_ld_no_whole_archive+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<\EOF
@@ -2616,7 +2696,7 @@ __throw () {}
EOF
if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -Wl,--no-whole-archive
- -o conftest conftest.c 1>&5'; { (eval echo configure:2620: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c 1>&5'; { (eval echo configure:2700: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_ld_no_whole_archive=yes
else
libc_cv_ld_no_whole_archive=no
@@ -2630,8 +2710,8 @@ if test $libc_cv_ld_no_whole_archive = yes; then
fi
echo $ac_n "checking for gcc -fexceptions""... $ac_c" 1>&6
-echo "configure:2634: checking for gcc -fexceptions" >&5
-if eval "test \"`echo '$''{'libc_cv_gcc_exceptions'+set}'`\" = set"; then
+echo "configure:2714: checking for gcc -fexceptions" >&5
+if eval "test \"\${libc_cv_gcc_exceptions+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<\EOF
@@ -2641,7 +2721,7 @@ __throw () {}
EOF
if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -fexceptions
- -o conftest conftest.c 1>&5'; { (eval echo configure:2645: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c 1>&5'; { (eval echo configure:2725: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_exceptions=yes
else
libc_cv_gcc_exceptions=no
@@ -2656,14 +2736,14 @@ fi
if test "$base_machine" = alpha ; then
echo $ac_n "checking for function ..ng prefix""... $ac_c" 1>&6
-echo "configure:2660: checking for function ..ng prefix" >&5
-if eval "test \"`echo '$''{'libc_cv_gcc_alpha_ng_prefix'+set}'`\" = set"; then
+echo "configure:2740: checking for function ..ng prefix" >&5
+if eval "test \"\${libc_cv_gcc_alpha_ng_prefix+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<\EOF
foo () { }
EOF
-if { ac_try='${CC-cc} -S conftest.c -o - | fgrep "\$foo..ng" > /dev/null'; { (eval echo configure:2667: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
+if { ac_try='${CC-cc} -S conftest.c -o - | fgrep "\$foo..ng" > /dev/null'; { (eval echo configure:2747: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
then
libc_cv_gcc_alpha_ng_prefix=yes
else
@@ -2690,19 +2770,19 @@ if test "$host_cpu" = powerpc ; then
# Check for a bug present in at least versions 2.8.x of GCC
# and versions 1.0.x of EGCS.
echo $ac_n "checking whether clobbering cr0 causes problems""... $ac_c" 1>&6
-echo "configure:2694: checking whether clobbering cr0 causes problems" >&5
-if eval "test \"`echo '$''{'libc_cv_c_asmcr0_bug'+set}'`\" = set"; then
+echo "configure:2774: checking whether clobbering cr0 causes problems" >&5
+if eval "test \"\${libc_cv_c_asmcr0_bug+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2699 "configure"
+#line 2779 "configure"
#include "confdefs.h"
int tester(int x) { asm ("" : : : "cc"); return x & 123; }
int main() {
; return 0; }
EOF
-if { (eval echo configure:2706: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2786: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
libc_cv_c_asmcr0_bug='no'
else
@@ -2724,12 +2804,12 @@ fi
fi
echo $ac_n "checking for DWARF2 unwind info support""... $ac_c" 1>&6
-echo "configure:2728: checking for DWARF2 unwind info support" >&5
-if eval "test \"`echo '$''{'libc_cv_gcc_dwarf2_unwind_info'+set}'`\" = set"; then
+echo "configure:2808: checking for DWARF2 unwind info support" >&5
+if eval "test \"\${libc_cv_gcc_dwarf2_unwind_info+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
-#line 2733 "configure"
+#line 2813 "configure"
static char __EH_FRAME_BEGIN__;
_start ()
{
@@ -2756,7 +2836,7 @@ __bzero () {}
EOF
if { ac_try='${CC-cc} $CFLAGS -DCHECK__register_frame_info
-nostdlib -nostartfiles
- -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2760: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2840: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_dwarf2_unwind_info=static
else
libc_cv_gcc_dwarf2_unwind_info=no
@@ -2764,7 +2844,7 @@ fi
if test $libc_cv_gcc_dwarf2_unwind_info = no; then
if { ac_try='${CC-cc} $CFLAGS -DCHECK__register_frame
-nostdlib -nostartfiles
- -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2768: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2848: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_dwarf2_unwind_info=yes
else
libc_cv_gcc_dwarf2_unwind_info=no
@@ -2794,12 +2874,12 @@ EOF
esac
echo $ac_n "checking for __builtin_expect""... $ac_c" 1>&6
-echo "configure:2798: checking for __builtin_expect" >&5
-if eval "test \"`echo '$''{'libc_cv_gcc_builtin_expect'+set}'`\" = set"; then
+echo "configure:2878: checking for __builtin_expect" >&5
+if eval "test \"\${libc_cv_gcc_builtin_expect+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
-#line 2803 "configure"
+#line 2883 "configure"
int foo (int a)
{
a = __builtin_expect (a, 10);
@@ -2807,7 +2887,7 @@ int foo (int a)
}
EOF
if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles
- -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2891: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_builtin_expect=yes
else
libc_cv_gcc_builtin_expect=no
@@ -2824,12 +2904,12 @@ EOF
fi
echo $ac_n "checking for local label subtraction""... $ac_c" 1>&6
-echo "configure:2828: checking for local label subtraction" >&5
-if eval "test \"`echo '$''{'libc_cv_gcc_subtract_local_labels'+set}'`\" = set"; then
+echo "configure:2908: checking for local label subtraction" >&5
+if eval "test \"\${libc_cv_gcc_subtract_local_labels+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
-#line 2833 "configure"
+#line 2913 "configure"
int foo (int a)
{
static const int ar[] = { &&l1 - &&l1, &&l2 - &&l1 };
@@ -2842,7 +2922,7 @@ int foo (int a)
}
EOF
if { ac_try='${CC-cc} $CFLAGS -nostdlib -nostartfiles
- -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2846: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2926: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_subtract_local_labels=yes
else
libc_cv_gcc_subtract_local_labels=no
@@ -2858,6 +2938,37 @@ EOF
fi
+echo $ac_n "checking for libgd""... $ac_c" 1>&6
+echo "configure:2943: checking for libgd" >&5
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $libgd_include"
+old_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS $libgd_ldflags"
+old_LIBS="$LIBS"
+LIBS="$LIBS -lgd -lpng -lz"
+cat > conftest.$ac_ext <<EOF
+#line 2951 "configure"
+#include "confdefs.h"
+#include <gd.h>
+int main() {
+gdImagePng (0, 0)
+; return 0; }
+EOF
+if { (eval echo configure:2958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ LIBGD=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ LIBGD=no
+fi
+rm -f conftest*
+CFLAGS="$old_CFLAGS"
+LDFLAGS="$old_LDFLAGS"
+LIBS="$old_LIBS"
+echo "$ac_t""$LIBGD" 1>&6
+
### End of automated tests.
### Now run sysdeps configure fragments.
@@ -2904,8 +3015,8 @@ if test "$uname" = "sysdeps/generic"; then
fi
echo $ac_n "checking OS release for uname""... $ac_c" 1>&6
-echo "configure:2908: checking OS release for uname" >&5
-if eval "test \"`echo '$''{'libc_cv_uname_release'+set}'`\" = set"; then
+echo "configure:3019: checking OS release for uname" >&5
+if eval "test \"\${libc_cv_uname_release+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
kernel_release=`echo "$kernel_id" | sed 's/^[^0-9.]*\([0-9.]*\).*$/\1/'`
@@ -2926,8 +3037,8 @@ echo "$ac_t""$libc_cv_uname_release" 1>&6
uname_release="$libc_cv_uname_release"
echo $ac_n "checking OS version for uname""... $ac_c" 1>&6
-echo "configure:2930: checking OS version for uname" >&5
-if eval "test \"`echo '$''{'libc_cv_uname_version'+set}'`\" = set"; then
+echo "configure:3041: checking OS version for uname" >&5
+if eval "test \"\${libc_cv_uname_version+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
kernel_version=`echo "$kernel_id" | sed 's/^[^#]*#\([0-9]*\).*$/\1/'`
@@ -2948,7 +3059,7 @@ else
fi
echo $ac_n "checking stdio selection""... $ac_c" 1>&6
-echo "configure:2952: checking stdio selection" >&5
+echo "configure:3063: checking stdio selection" >&5
case $stdio in
libio) cat >> confdefs.h <<\EOF
@@ -2962,7 +3073,7 @@ echo "$ac_t""$stdio" 1>&6
# Test for old glibc 2.0.x headers so that they can be removed properly
# Search only in includedir.
echo $ac_n "checking for old glibc 2.0.x headers""... $ac_c" 1>&6
-echo "configure:2966: checking for old glibc 2.0.x headers" >&5
+echo "configure:3077: checking for old glibc 2.0.x headers" >&5
if eval test -f "${includedir}/elfclass.h" -a -f "${includedir}/fcntlbits.h"
then
old_glibc_headers=yes
@@ -3016,8 +3127,8 @@ if test $shared = default; then
fi
echo $ac_n "checking whether -fPIC is default""... $ac_c" 1>&6
-echo "configure:3020: checking whether -fPIC is default" >&5
-if eval "test \"`echo '$''{'pic_default'+set}'`\" = set"; then
+echo "configure:3131: checking whether -fPIC is default" >&5
+if eval "test \"\${pic_default+set}\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
pic_default=yes
@@ -3154,7 +3265,7 @@ do
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ echo "$CONFIG_STATUS generated by autoconf version 2.14.1"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;;
@@ -3241,6 +3352,7 @@ s%@VERSIONING@%$VERSIONING%g
s%@libc_cv_have_initfini@%$libc_cv_have_initfini%g
s%@no_whole_archive@%$no_whole_archive%g
s%@exceptions@%$exceptions%g
+s%@LIBGD@%$LIBGD%g
s%@uname_sysname@%$uname_sysname%g
s%@uname_release@%$uname_release%g
s%@uname_version@%$uname_version%g
@@ -3532,7 +3644,7 @@ exit 0
EOF
chmod +x $CONFIG_STATUS
rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1
if test "$no_recursion" != yes; then
@@ -3596,7 +3708,7 @@ if test "$no_recursion" != yes; then
# Check for guested configure; otherwise get Cygnus style configure.
if test -f $ac_sub_srcdir/configure; then
- ac_sub_configure=$ac_sub_srcdir/configure
+ ac_sub_configure="$SHELL $ac_sub_srcdir/configure"
elif test -f $ac_sub_srcdir/configure.in; then
ac_sub_configure=$ac_configure
else
@@ -3618,9 +3730,9 @@ if test "$no_recursion" != yes; then
*) INSTALL="$ac_dots$ac_given_INSTALL" ;;
esac
- echo "running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir"
+ echo "running $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir"
# The eval makes quoting arguments work.
- if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir
+ if eval $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir
then :
else
{ echo "configure: error: $ac_sub_configure failed for $ac_config_dir" 1>&2; exit 1; }
diff --git a/configure.in b/configure.in
index 2c363cce0d..38900397ae 100644
--- a/configure.in
+++ b/configure.in
@@ -32,6 +32,20 @@ yes)
gettext-srcdir = $withval" ;;
esac
])
+# Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
+AC_ARG_WITH(gd, dnl
+ --with-gd=DIR find libgd include dir and library with prefix DIR,
+ [dnl
+case "$with_gd" in
+yes|''|no) config_vars="$config_vars
+libgd-LDFLAGS =" ;;
+*) config_vars="$config_vars
+CFLAGS-memprofstat.c = -I$withval/include
+libgd-LDFLAGS = -L$withval/lib"
+ libgd_include="-I$withval/include"
+ libgd_ldflags="-L$withval/lib" ;;
+esac
+])
dnl Arguments to specify presence of other packages/features.
AC_ARG_WITH(fp, dnl
@@ -1083,6 +1097,20 @@ if test "$libc_cv_gcc_subtract_local_labels" = yes; then
AC_DEFINE(HAVE_SUBTRACT_LOCAL_LABELS)
fi
+dnl Check whether we have the gd library available.
+AC_MSG_CHECKING(for libgd)
+old_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $libgd_include"
+old_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS $libgd_ldflags"
+old_LIBS="$LIBS"
+LIBS="$LIBS -lgd -lpng -lz"
+AC_TRY_LINK([#include <gd.h>], [gdImagePng (0, 0)], LIBGD=yes, LIBGD=no)
+CFLAGS="$old_CFLAGS"
+LDFLAGS="$old_LDFLAGS"
+LIBS="$old_LIBS"
+AC_MSG_RESULT($LIBGD)
+AC_SUBST(LIBGD)
### End of automated tests.
### Now run sysdeps configure fragments.
diff --git a/malloc/Makefile b/malloc/Makefile
index 4cd76cf680..68f5d10aeb 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -38,6 +38,13 @@ routines = $(dist-routines) obstack
install-lib := libmcheck.a
non-lib.a := libmcheck.a
+# Additional library.
+extra-libs = libmemprof
+extra-libs-others = $(extra-libs)
+
+libmemprof-routines = memprof
+libmemprof-inhibit-o = $(filter-out .os,$(object-suffixes))
+
# These should be removed by `make clean'.
extra-objs = mcheck-init.o libmcheck.a
@@ -60,6 +67,19 @@ address-width=18
endif
endif
+# If the gd library is available we build the `memprofstat' program.
+ifneq ($(LIBGD),no)
+install-bin += memprofstat
+endif
+
+# Another goal which can be used to override the configure decision.
+.PHONY: do-memprofstat
+do-memprofstat: $(objpfx)memprofstat
+
+memprofstat-modules = memprofstat
+$(objpfx)memprofstat: $(memprofstat-modules:%=$(objpfx)%.o)
+ $(LINK.o) -o $@ $^ $(libgd-LDFLAGS) -lgd -lpng -lz
+
include ../Rules
$(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
diff --git a/malloc/memprof.c b/malloc/memprof.c
new file mode 100644
index 0000000000..1830d33ae6
--- /dev/null
+++ b/malloc/memprof.c
@@ -0,0 +1,596 @@
+/* Profile heap and stack memory usage of running program.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+/* Pointer to the real functions. These are determined used `dlsym'
+ when really needed. */
+static void *(*mallocp) (size_t);
+static void *(*reallocp) (void *, size_t);
+static void *(*callocp) (size_t, size_t);
+static void (*freep) (void *);
+
+enum
+{
+ idx_malloc = 0,
+ idx_realloc,
+ idx_calloc,
+ idx_free,
+ idx_last
+};
+
+
+struct header
+{
+ size_t length;
+ size_t magic;
+};
+
+#define MAGIC 0xfeedbeaf
+
+
+static unsigned long int calls[idx_last];
+static unsigned long int failed[idx_last];
+static unsigned long long int total[idx_last];
+static unsigned long long int grand_total;
+static unsigned long int histogram[65536 / 16];
+static unsigned long int large;
+static unsigned long int calls_total;
+static unsigned long int inplace;
+static unsigned long int decreasing;
+static long int current_use[2];
+static long int peak_use[3];
+static uintptr_t start_sp;
+
+/* A few macros to make the source more readable. */
+#define current_heap current_use[0]
+#define current_stack current_use[1]
+#define peak_heap peak_use[0]
+#define peak_stack peak_use[1]
+#define peak_total peak_use[2]
+
+#ifdef __i386__
+# define GETSP() ({ register uintptr_t stack_ptr asm ("esp"); stack_ptr; })
+#endif
+#ifdef __alpha__
+# define GETSP() ({ register uintptr_t stack_ptr asm ("$30"); stack_ptr; })
+#endif
+#ifdef __sparc__
+# define GETSP() ({ register uintptr_t stack_ptr asm ("%sp"); stack_ptr; })
+#endif
+
+#ifdef __i386__
+# define GETTIME(low,high) asm ("rdtsc" : "=a" (low), "=d" (high))
+#endif
+#ifndef GETTIME
+# define GETTIME(low,high) \
+ { \
+ struct timeval tval; \
+ uint64_t usecs; \
+ gettimeofday (&tval, NULL); \
+ usecs = (uint64_t) tval.tv_usec + (uint64_t) tval_usec * 1000000; \
+ low = usecs & 0xffffffff; \
+ high = usecs >> 32; \
+ }
+#endif
+
+#define DEFAULT_BUFFER_SIZE 1024
+static size_t buffer_size;
+
+static int fd = -1;
+
+static int not_me;
+extern const char *__progname;
+
+struct entry
+{
+ size_t heap;
+ size_t stack;
+ uint32_t time_low;
+ uint32_t time_high;
+};
+
+static struct entry buffer[DEFAULT_BUFFER_SIZE];
+static size_t buffer_cnt;
+static struct entry first;
+
+
+/* Update the global data after a successful function call. */
+static void
+update_data (struct header *result, size_t len, size_t old_len)
+{
+ long int total_use;
+
+ if (result != NULL)
+ {
+ /* Record the information we need and mark the block using a
+ magic number. */
+ result->length = len;
+ result->magic = MAGIC;
+ }
+
+ /* Compute current heap usage and compare it with the maximum value. */
+ current_heap += len - old_len;
+ if (current_heap > peak_heap)
+ peak_heap = current_heap;
+
+ /* Compute current stack usage and compare it with the maximum value. */
+ current_stack = start_sp - GETSP ();
+ if (current_stack > peak_stack)
+ peak_stack = current_stack;
+
+ /* Add up heap and stack usage and compare it with the maximum value. */
+ total_use = current_heap + current_stack;
+ if (total_use > peak_total)
+ peak_total = total_use;
+
+ /* Store the value only if we are writing to a file. */
+ if (fd != -1)
+ {
+ buffer[buffer_cnt].heap = current_heap;
+ buffer[buffer_cnt].stack = current_stack;
+ GETTIME (buffer[buffer_cnt].time_low, buffer[buffer_cnt].time_high);
+ ++buffer_cnt;
+
+ /* Write out buffer if it is full. */
+ if (buffer_cnt == buffer_size)
+ {
+ write (fd, buffer, buffer_cnt * sizeof (struct entry));
+ buffer_cnt = 0;
+ }
+ }
+}
+
+
+/* Interrupt handler. */
+static void
+int_handler (int signo)
+{
+ /* Nothing gets allocated. Just record the stack pointer position. */
+ update_data (NULL, 0, 0);
+}
+
+
+/* Record the initial stack position. */
+static void
+__attribute__ ((constructor))
+init (void)
+{
+ start_sp = GETSP ();
+}
+
+
+/* Find out whether this is the program we are supposed to profile.
+ For this the name in the variable `__progname' must match the one
+ given in the environment variable MEMPROF_PROG_NAME. If the variable
+ is not present every program assumes it should be profiling.
+
+ If this is the program open a file descriptor to the output file.
+ We will write to it whenever the buffer overflows. The name of the
+ output file is determined by the environment variable MEMPROF_OUTPUT.
+
+ If the environment variable MEMPROF_BUFFER_SIZE is set its numerical
+ value determines the size of the internal buffer. The number gives
+ the number of elements in the buffer. By setting the number to one
+ one effectively selects unbuffered operation.
+
+ If MEMPROF_NO_TIMER is not present an alarm handler is installed
+ which at the highest possible frequency records the stack pointer. */
+static void
+me (void)
+{
+ const char *env = getenv ("MEMPROF_PROG_NAME");
+ size_t prog_len = strlen (__progname);
+ if (env != NULL)
+ {
+ /* Check for program name. */
+ size_t len = strlen (env);
+ if (len > prog_len || strcmp (env, &__progname[prog_len - len]) != 0
+ || (prog_len != len && __progname[prog_len - len - 1] != '/'))
+ not_me = 1;
+ }
+
+ /* Only open the file if it's really us. */
+ if (!not_me && fd == -1)
+ {
+ const char *outname = getenv ("MEMPROF_OUTPUT");
+ if (outname != NULL)
+ {
+ fd = creat (outname, 0666);
+
+ if (fd == -1)
+ /* Don't do anything in future calls if we cannot write to
+ the output file. */
+ not_me = 1;
+ else
+ {
+ /* Write the first entry. */
+ first.heap = 0;
+ first.stack = 0;
+ GETTIME (first.time_low, first.time_high);
+ /* Write it two times since we need the starting and end time. */
+ write (fd, &first, sizeof (first));
+
+ /* Determine the buffer size. We use the default if the
+ environment variable is not present. */
+ buffer_size = DEFAULT_BUFFER_SIZE;
+ if (getenv ("MEMPROF_BUFFER_SIZE") != NULL)
+ {
+ buffer_size = atoi (getenv ("MEMPROF_BUFFER_SIZE"));
+ if (buffer_size == 0 || buffer_size > DEFAULT_BUFFER_SIZE)
+ buffer_size = DEFAULT_BUFFER_SIZE;
+ }
+
+ /* Possibly enable timer-based stack pointer retrieval. */
+ if (getenv ("MEMPROF_NO_TIMER") == NULL)
+ {
+ struct sigaction act;
+
+ act.sa_handler = (sighandler_t) &int_handler;
+ act.sa_flags = SA_RESTART;
+ sigfillset (&act.sa_mask);
+
+ if (sigaction (SIGPROF, &act, NULL) >= 0)
+ {
+ struct itimerval timer;
+
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = 1;
+ timer.it_interval = timer.it_value;
+ setitimer (ITIMER_PROF, &timer, NULL);
+ }
+ }
+ }
+ }
+ }
+}
+
+
+/* `malloc' replacement. We keep track of the memory usage if this is the
+ correct program. */
+void *
+malloc (size_t len)
+{
+ struct header *result = NULL;
+
+ /* Determine real implementation if not already happened. */
+ if (mallocp == NULL)
+ {
+ me ();
+ mallocp = (void *(*) (size_t)) dlsym (RTLD_NEXT, "malloc");
+ }
+
+ /* If this is not the correct program just use the normal function. */
+ if (not_me)
+ return (*mallocp) (len);
+
+ /* Keep track of number of calls. */
+ ++calls[idx_malloc];
+ /* Keep track of total memory consumption for `malloc'. */
+ total[idx_malloc] += len;
+ /* Keep track of total memory requirement. */
+ grand_total += len;
+ /* Remember the size of the request. */
+ if (len < 65536)
+ ++histogram[len / 16];
+ else
+ ++large;
+ /* Total number of calls of any of the functions. */
+ ++calls_total;
+
+ /* Do the real work. */
+ result = (struct header *) (*mallocp) (len + sizeof (struct header));
+
+ if (result == NULL)
+ ++failed[idx_malloc];
+ else
+ /* Update the allocation data and write out the records if necessary. */
+ update_data (result, len, 0);
+
+ /* Return the pointer to the user buffer. */
+ return result ? (void *) (result + 1) : NULL;
+}
+
+
+/* `realloc' replacement. We keep track of the memory usage if this is the
+ correct program. */
+void *
+realloc (void *old, size_t len)
+{
+ struct header *result = NULL;
+ struct header *real;
+ size_t old_len;
+
+ /* Determine real implementation if not already happened. */
+ if (reallocp == NULL)
+ {
+ me ();
+ reallocp = (void *(*) (void *, size_t)) dlsym (RTLD_NEXT, "realloc");
+ }
+
+ /* If this is not the correct program just use the normal function. */
+ if (not_me)
+ return (*reallocp) (old, len);
+
+ if (old == NULL)
+ {
+ /* This is really a `malloc' call. */
+ real = NULL;
+ old_len = 0;
+ }
+ else
+ {
+ real = ((struct header *) old) - 1;
+ if (real->magic != MAGIC)
+ /* This is no memory allocated here. */
+ return (*reallocp) (old, len);
+ old_len = real->length;
+ }
+
+ /* Keep track of number of calls. */
+ ++calls[idx_realloc];
+ /* Keep track of total memory consumption for `realloc'. */
+ total[idx_realloc] += len;
+ /* Keep track of total memory requirement. */
+ grand_total += len;
+ /* Remember the size of the request. */
+ if (len < 65536)
+ ++histogram[len / 16];
+ else
+ ++large;
+ /* Total number of calls of any of the functions. */
+ ++calls_total;
+
+ /* Do the real work. */
+ result = (struct header *) (*reallocp) (real, len + sizeof (struct header));
+
+ if (result == NULL)
+ ++failed[idx_realloc];
+ else
+ {
+ /* Record whether the reduction/increase happened in place. */
+ if (real == result)
+ ++inplace;
+ /* Was the buffer increased? */
+ if (old_len > len)
+ ++decreasing;
+
+ /* Update the allocation data and write out the records if necessary. */
+ update_data (result, len, old_len);
+ }
+
+ /* Return the pointer to the user buffer. */
+ return result ? (void *) (result + 1) : NULL;
+}
+
+
+/* `calloc' replacement. We keep track of the memory usage if this is the
+ correct program. */
+void *
+calloc (size_t n, size_t len)
+{
+ struct header *result;
+ size_t size = n * len;
+
+ /* Determine real implementation if not already happened. We are
+ searching for the `malloc' implementation since it is not always
+ efficiently possible to use `calloc' because we have to add a bit
+ room to the allocation to put the header in. */
+ if (mallocp == NULL)
+ {
+ me ();
+ mallocp = (void *(*) (size_t)) dlsym (RTLD_NEXT, "malloc");
+ }
+
+ /* If this is not the correct program just use the normal function. */
+ if (not_me)
+ {
+ callocp = (void *(*) (size_t, size_t)) dlsym (RTLD_NEXT, "calloc");
+
+ return (*callocp) (n, len);
+ }
+
+ /* Keep track of number of calls. */
+ ++calls[idx_calloc];
+ /* Keep track of total memory consumption for `calloc'. */
+ total[idx_calloc] += size;
+ /* Keep track of total memory requirement. */
+ grand_total += size;
+ /* Remember the size of the request. */
+ if (size < 65536)
+ ++histogram[size / 16];
+ else
+ ++large;
+ /* Total number of calls of any of the functions. */
+ ++calls_total;
+
+ /* Do the real work. */
+ result = (struct header *) (*mallocp) (size + sizeof (struct header));
+ if (result != NULL)
+ memset (result + 1, '\0', size);
+
+ if (result == NULL)
+ ++failed[idx_calloc];
+ else
+ /* Update the allocation data and write out the records if necessary. */
+ update_data (result, size, 0);
+
+ /* Return the pointer to the user buffer. */
+ return result ? (void *) (result + 1) : NULL;
+}
+
+
+/* `free' replacement. We keep track of the memory usage if this is the
+ correct program. */
+void
+free (void *ptr)
+{
+ struct header *real;
+
+ /* `free (NULL)' has no effect. */
+ if (ptr == NULL)
+ {
+ ++calls[idx_free];
+ return;
+ }
+
+ /* Determine real implementation if not already happened. */
+ if (freep == NULL)
+ {
+ me ();
+ freep = (void (*) (void *)) dlsym (RTLD_NEXT, "free");
+ }
+
+ /* If this is not the correct program just use the normal function. */
+ if (not_me)
+ {
+ (*freep) (ptr);
+ return;
+ }
+
+ /* Determine the pointer to the header. */
+ real = ((struct header *) ptr) - 1;
+ if (real->magic != MAGIC)
+ {
+ /* This block wasn't allocated here. */
+ (*freep) (ptr);
+ return;
+ }
+
+ /* Keep track of number of calls. */
+ ++calls[idx_free];
+ /* Keep track of total memory freed using `free'. */
+ total[idx_free] += real->length;
+
+ /* Update the allocation data and write out the records if necessary. */
+ update_data (NULL, 0, real->length);
+
+ /* Do the real work. */
+ (*freep) (real);
+}
+
+
+/* Write some statistics to standard error. */
+static void
+__attribute__ ((destructor))
+dest (void)
+{
+ int percent, cnt;
+ unsigned long int maxcalls;
+
+ /* If we haven't done anything here just return. */
+ if (not_me)
+ return;
+ /* If we should call any of the memory functions don't do any profiling. */
+ not_me = 1;
+
+ /* Finish the output file. */
+ if (fd != -1)
+ {
+ /* Write the partially filled buffer. */
+ write (fd, buffer, buffer_cnt * sizeof (struct entry));
+ /* Go back to the beginning of the file. We allocated two records
+ here when we opened the file. */
+ lseek (fd, 0, SEEK_SET);
+ /* Write out a record containing the total size. */
+ first.stack = peak_total;
+ write (fd, &first, sizeof (struct entry));
+ /* Write out another record containing the maximum for heap and
+ stack. */
+ first.heap = peak_heap;
+ first.stack = peak_stack;
+ GETTIME (first.time_low, first.time_high);
+ write (fd, &first, sizeof (struct entry));
+
+ /* Close the file. */
+ close (fd);
+ fd = -1;
+ }
+
+ /* Write a colorful statistic. */
+ fprintf (stderr, "\n\
+\e[01;32mMemory usage summary:\e[0;0m heap total: %llu, heap peak: %lu, stack peak: %lu\n\
+\e[04;34m total calls total memory failed calls\e[0m\n\
+\e[00;34m malloc|\e[0m %10lu %12llu %s%12lu\e[00;00m\n\
+\e[00;34mrealloc|\e[0m %10lu %12llu %s%12lu\e[00;00m (in place: %ld, dec: %ld)\n\
+\e[00;34m calloc|\e[0m %10lu %12llu %s%12lu\e[00;00m\n\
+\e[00;34m free|\e[0m %10lu %12llu\n",
+ grand_total, (unsigned long int) peak_heap,
+ (unsigned long int) peak_stack,
+ calls[idx_malloc], total[idx_malloc],
+ failed[idx_malloc] ? "\e[01;41m" : "", failed[idx_malloc],
+ calls[idx_realloc], total[idx_realloc],
+ failed[idx_realloc] ? "\e[01;41m" : "", failed[idx_realloc],
+ inplace, decreasing,
+ calls[idx_calloc], total[idx_calloc],
+ failed[idx_calloc] ? "\e[01;41m" : "", failed[idx_calloc],
+ calls[idx_free], total[idx_free]);
+
+ /* Write out a histoogram of the sizes of the allocations. */
+ fprintf (stderr, "\e[01;32mHistogram for block sizes:\e[0;0m\n");
+
+ /* Determine the maximum of all calls for each size range. */
+ maxcalls = large;
+ for (cnt = 0; cnt < 65536; cnt += 16)
+ if (histogram[cnt / 16] > maxcalls)
+ maxcalls = histogram[cnt / 16];
+
+ for (cnt = 0; cnt < 65536; cnt += 16)
+ /* Only write out the nonzero entries. */
+ if (histogram[cnt / 16] != 0)
+ {
+ percent = (histogram[cnt / 16] * 100) / calls_total;
+ fprintf (stderr, "%5d-%-5d%12lu ", cnt, cnt + 15,
+ histogram[cnt / 16]);
+ if (percent == 0)
+ fputs (" <1% \e[41;37m", stderr);
+ else
+ fprintf (stderr, "%3d%% \e[41;37m", percent);
+
+ /* Draw a bar with a length corresponding to the current
+ percentage. */
+ percent = (histogram[cnt / 16] * 50) / maxcalls;
+ while (percent-- > 0)
+ fputc ('=', stderr);
+ fputs ("\e[0;0m\n", stderr);
+ }
+
+ if (large != 0)
+ {
+ percent = (large * 100) / calls_total;
+ fprintf (stderr, " large %12lu ", large);
+ if (percent == 0)
+ fputs (" <1% \e[41;37m", stderr);
+ else
+ fprintf (stderr, "%3d%% \e[41;37m", percent);
+ percent = (large * 50) / maxcalls;
+ while (percent-- > 0)
+ fputc ('=', stderr);
+ fputs ("\e[0;0m\n", stderr);
+ }
+}
diff --git a/malloc/memprofstat.c b/malloc/memprofstat.c
new file mode 100644
index 0000000000..638b3beb73
--- /dev/null
+++ b/malloc/memprofstat.c
@@ -0,0 +1,612 @@
+/* Generate graphic from memory profiling data.
+ Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <argp.h>
+#include <assert.h>
+#include <errno.h>
+#include <error.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <inttypes.h>
+#include <libintl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <gd.h>
+#include <gdfontl.h>
+#include <gdfonts.h>
+
+
+/* Default size of the generated image. */
+#define XSIZE 800
+#define YSIZE 600
+
+#ifndef N_
+# define N_(Arg) Arg
+#endif
+
+
+/* Definitions of arguments for argp functions. */
+static const struct argp_option options[] =
+{
+ { "output", 'o', "FILE", 0, N_("Name output file") },
+ { "string", 's', "STRING", 0, N_("Title string used in output graphic") },
+ { "time", 't', NULL, 0, N_("Generate output linear to time (default is linear to number of function calls)") },
+ { "total", 'T', NULL, 0,
+ N_("Also draw graph for total memory consumption") },
+ { "x-size", 'x', "VALUE", 0, N_("make output graphic VALUE pixel wide") },
+ { "y-size", 'y', "VALUE", 0, N_("make output graphic VALUE pixel high") },
+ { NULL, 0, NULL, 0, NULL }
+};
+
+/* Short description of program. */
+static const char doc[] = N_("Generate graphic from memory profiling data");
+
+/* Strings for arguments in help texts. */
+static const char args_doc[] = N_("DATAFILE [OUTFILE]");
+
+/* Prototype for option handler. */
+static error_t parse_opt (int key, char *arg, struct argp_state *state);
+
+/* Function to print some extra text in the help message. */
+static char *more_help (int key, const char *text, void *input);
+
+/* Data structure to communicate with argp functions. */
+static struct argp argp =
+{
+ options, parse_opt, args_doc, doc, NULL, more_help
+};
+
+
+struct entry
+{
+ size_t heap;
+ size_t stack;
+ uint32_t time_low;
+ uint32_t time_high;
+};
+
+
+/* Size of the image. */
+static size_t xsize;
+static size_t ysize;
+
+/* Name of the output file. */
+static char *outname;
+
+/* Title string for the graphic. */
+static const char *string;
+
+/* Nonzero if graph should be generated linear in time. */
+static int time_based;
+
+/* Nonzero if graph to display total use of memory should be drawn as well. */
+static int also_total = 0;
+
+
+int
+main (int argc, char *argv[])
+{
+ int remaining;
+ const char *inname;
+ gdImagePtr im_out;
+ int grey, blue, red, green, yellow, black;
+ int fd;
+ struct stat st;
+ size_t maxsize_heap;
+ size_t maxsize_stack;
+ size_t maxsize_total;
+ uint64_t total;
+ uint64_t cnt, cnt2;
+ FILE *outfile;
+ char buf[30];
+ size_t last_heap;
+ size_t last_stack;
+ size_t last_total;
+ struct entry headent[2];
+ uint64_t start_time;
+ uint64_t end_time;
+ uint64_t total_time;
+
+ outname = NULL;
+ xsize = XSIZE;
+ ysize = YSIZE;
+ string = NULL;
+
+ /* Parse and process arguments. */
+ argp_parse (&argp, argc, argv, 0, &remaining, NULL);
+
+ if (remaining >= argc || remaining + 2 < argc)
+ {
+ argp_help (&argp, stdout, ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR,
+ program_invocation_short_name);
+ exit (1);
+ }
+
+ inname = argv[remaining++];
+
+ if (remaining < argc)
+ outname = argv[remaining];
+ else if (outname == NULL)
+ {
+ size_t len = strlen (inname);
+ outname = alloca (len + 5);
+ stpcpy (stpcpy (outname, inname), ".png");
+ }
+
+ /* Open for read/write since we try to repair the file in case the
+ application hasn't terminated cleanly. */
+ fd = open (inname, O_RDWR);
+ if (fd == -1)
+ error (EXIT_FAILURE, errno, "cannot open input file");
+ if (fstat (fd, &st) != 0)
+ {
+ close (fd);
+ error (EXIT_FAILURE, errno, "cannot get size of input file");
+ }
+ /* Test whether the file contains only full records. */
+ if ((st.st_size % sizeof (struct entry)) != 0
+ /* The file must at least contain the two administrative records. */
+ || st.st_size < 2 * sizeof (struct entry))
+ {
+ close (fd);
+ error (EXIT_FAILURE, 0, "input file as incorrect size");
+ }
+ /* Compute number of data entries. */
+ total = st.st_size / sizeof (struct entry) - 2;
+
+ /* Read the administrative information. */
+ read (fd, headent, sizeof (headent));
+ maxsize_heap = headent[1].heap;
+ maxsize_stack = headent[1].stack;
+ maxsize_total = headent[0].stack;
+ if (also_total)
+ {
+ /* We use one scale and since we also draw the total amount of
+ memory used we have to adapt the maximum. */
+ maxsize_heap = maxsize_total;
+ maxsize_stack = maxsize_total;
+ }
+
+ if (maxsize_heap == 0 && maxsize_stack == 0)
+ {
+ /* The program aborted before memprof was able to write the
+ information about the maximum heap and stack use. Repair
+ the file now. */
+ struct entry next;
+
+ while (1)
+ {
+ if (read (fd, &next, sizeof (next)) == 0)
+ break;
+ if (next.heap > headent[1].heap)
+ headent[1].heap = next.heap;
+ if (next.stack > headent[1].stack)
+ headent[1].stack = next.stack;
+ }
+
+ headent[1].time_low = next.time_low;
+ headent[1].time_high = next.time_high;
+
+ /* Write the computed values in the file. */
+ lseek (fd, sizeof (struct entry), SEEK_SET);
+ write (fd, &headent[1], sizeof (struct entry));
+ }
+
+ start_time = ((uint64_t) headent[0].time_high) << 32 | headent[0].time_low;
+ end_time = ((uint64_t) headent[1].time_high) << 32 | headent[1].time_low;
+ total_time = end_time - start_time;
+
+ if (xsize < 100)
+ xsize = 100;
+ if (ysize < 80)
+ ysize = 80;
+
+ /* Create output image with the specified size. */
+ im_out = gdImageCreate (xsize, ysize);
+
+ /* First color allocated is background. */
+ grey = gdImageColorAllocate (im_out, 224, 224, 224);
+
+ /* Set transparent color. */
+ gdImageColorTransparent (im_out, grey);
+
+ /* These are all the other colors we need (in the moment). */
+ red = gdImageColorAllocate (im_out, 255, 0, 0);
+ green = gdImageColorAllocate (im_out, 0, 130, 0);
+ blue = gdImageColorAllocate (im_out, 0, 0, 255);
+ yellow = gdImageColorAllocate (im_out, 154, 205, 50);
+ black = gdImageColorAllocate (im_out, 0, 0, 0);
+
+ gdImageRectangle (im_out, 40, 20, xsize - 40, ysize - 20, blue);
+
+ gdImageString (im_out, gdFontSmall, 38, ysize - 14, (unsigned char *) "0",
+ blue);
+ gdImageString (im_out, gdFontSmall, maxsize_heap < 1024 ? 32 : 26,
+ ysize - 26,
+ (unsigned char *) (maxsize_heap < 1024 ? "0" : "0k"), red);
+ gdImageString (im_out, gdFontSmall, xsize - 37, ysize - 26,
+ (unsigned char *) (maxsize_stack < 1024 ? "0" : "0k"), green);
+
+ if (string != NULL)
+ gdImageString (im_out, gdFontLarge, (xsize - strlen (string) * 8) / 2,
+ 2, (char *) string, green);
+
+ gdImageStringUp (im_out, gdFontSmall, 1, ysize / 2 - 10,
+ (unsigned char *) "allocated", red);
+ gdImageStringUp (im_out, gdFontSmall, 11, ysize / 2 - 10,
+ (unsigned char *) "memory", red);
+
+ gdImageStringUp (im_out, gdFontSmall, xsize - 39, ysize / 2 - 10,
+ (unsigned char *) "used", green);
+ gdImageStringUp (im_out, gdFontSmall, xsize - 27, ysize / 2 - 10,
+ (unsigned char *) "stack", green);
+
+ if (maxsize_heap < 1024)
+ {
+ snprintf (buf, sizeof (buf), "%Zu", maxsize_heap);
+ gdImageString (im_out, gdFontSmall, 39 - strlen (buf) * 6, 14, buf, red);
+ }
+ else
+ {
+ snprintf (buf, sizeof (buf), "%Zuk", maxsize_heap / 1024);
+ gdImageString (im_out, gdFontSmall, 39 - strlen (buf) * 6, 14, buf, red);
+ }
+ if (maxsize_stack < 1024)
+ {
+ snprintf (buf, sizeof (buf), "%Zu", maxsize_stack);
+ gdImageString (im_out, gdFontSmall, xsize - 37, 14, buf, green);
+ }
+ else
+ {
+ snprintf (buf, sizeof (buf), "%Zuk", maxsize_stack / 1024);
+ gdImageString (im_out, gdFontSmall, xsize - 37, 14, buf, green);
+ }
+
+
+ if (maxsize_heap < 1024)
+ {
+ cnt = ((ysize - 40) * (maxsize_heap / 4)) / maxsize_heap;
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt, xsize - 40,
+ ysize - 20 - cnt, red);
+ snprintf (buf, sizeof (buf), "%Zu", maxsize_heap / 4);
+ gdImageString (im_out, gdFontSmall, 39 - strlen (buf) * 6,
+ ysize - 26 - cnt, buf, red);
+ }
+ else
+ {
+ cnt = ((ysize - 40) * (maxsize_heap / 4096)) / (maxsize_heap / 1024);
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt, xsize - 40,
+ ysize - 20 - cnt, red);
+ snprintf (buf, sizeof (buf), "%Zuk", maxsize_heap / 4096);
+ gdImageString (im_out, gdFontSmall, 39 - strlen (buf) * 6,
+ ysize - 26 - cnt, buf, red);
+ }
+ if (maxsize_stack < 1024)
+ {
+ cnt2 = ((ysize - 40) * (maxsize_stack / 4)) / maxsize_stack;
+ if (cnt != cnt2)
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt2, xsize - 40,
+ ysize - 20 - cnt2, green);
+ snprintf (buf, sizeof (buf), "%Zu", maxsize_stack / 4);
+ gdImageString (im_out, gdFontSmall, xsize - 37, ysize - 26 - cnt2,
+ buf, green);
+ }
+ else
+ {
+ cnt2 = ((ysize - 40) * (maxsize_stack / 4096)) / (maxsize_stack / 1024);
+ if (cnt != cnt2)
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt2, xsize - 40,
+ ysize - 20 - cnt2, green);
+ snprintf (buf, sizeof (buf), "%Zuk", maxsize_stack / 4096);
+ gdImageString (im_out, gdFontSmall, xsize - 37, ysize - 26 - cnt2,
+ buf, green);
+ }
+
+ if (maxsize_heap < 1024)
+ {
+ cnt = ((ysize - 40) * (maxsize_heap / 2)) / maxsize_heap;
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt, xsize - 40,
+ ysize - 20 - cnt, red);
+ snprintf (buf, sizeof (buf), "%Zu", maxsize_heap / 2);
+ gdImageString (im_out, gdFontSmall, 39 - strlen (buf) * 6,
+ ysize - 26 - cnt, buf, red);
+ }
+ else
+ {
+ cnt = ((ysize - 40) * (maxsize_heap / 2048)) / (maxsize_heap / 1024);
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt, xsize - 40,
+ ysize - 20 - cnt, red);
+ snprintf (buf, sizeof (buf), "%Zuk", maxsize_heap / 2048);
+ gdImageString (im_out, gdFontSmall, 39 - strlen (buf) * 6,
+ ysize - 26 - cnt, buf, red);
+ }
+ if (maxsize_stack < 1024)
+ {
+ cnt2 = ((ysize - 40) * (maxsize_stack / 2)) / maxsize_stack;
+ if (cnt != cnt2)
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt2, xsize - 40,
+ ysize - 20 - cnt2, green);
+ snprintf (buf, sizeof (buf), "%Zu", maxsize_stack / 2);
+ gdImageString (im_out, gdFontSmall, xsize - 37, ysize - 26 - cnt2,
+ buf, green);
+ }
+ else
+ {
+ cnt2 = ((ysize - 40) * (maxsize_stack / 2048)) / (maxsize_stack / 1024);
+ if (cnt != cnt2)
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt2, xsize - 40,
+ ysize - 20 - cnt2, green);
+ snprintf (buf, sizeof (buf), "%Zuk", maxsize_stack / 2048);
+ gdImageString (im_out, gdFontSmall, xsize - 37, ysize - 26 - cnt2,
+ buf, green);
+ }
+
+ if (maxsize_heap < 1024)
+ {
+ cnt = ((ysize - 40) * ((3 * maxsize_heap) / 4)) / maxsize_heap;
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt, xsize - 40,
+ ysize - 20 - cnt, red);
+ snprintf (buf, sizeof (buf), "%Zu", (3 * maxsize_heap) / 4);
+ gdImageString (im_out, gdFontSmall, 39 - strlen (buf) * 6,
+ ysize - 26 - cnt, buf, red);
+ }
+ else
+ {
+ cnt = ((ysize - 40) * ((3 * maxsize_heap) / 4096)) / (maxsize_heap
+ / 1024);
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt, xsize - 40,
+ ysize - 20 - cnt, red);
+ snprintf (buf, sizeof (buf), "%Zuk", (3 * maxsize_heap) / 4096);
+ gdImageString (im_out, gdFontSmall, 39 - strlen (buf) * 6,
+ ysize - 26 - cnt, buf, red);
+ }
+ if (maxsize_stack < 1024)
+ {
+ cnt2 = ((ysize - 40) * ((3 * maxsize_stack) / 4)) / maxsize_stack;
+ if (cnt != cnt2)
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt2, xsize - 40,
+ ysize - 20 - cnt2, green);
+ snprintf (buf, sizeof (buf), "%Zu", (3 * maxsize_stack) / 4);
+ gdImageString (im_out, gdFontSmall, xsize - 37, ysize - 26 - cnt2,
+ buf, green);
+ }
+ else
+ {
+ cnt2 = (((ysize - 40) * ((3 * maxsize_stack) / 4096))
+ / (maxsize_stack / 1024));
+ if (cnt != cnt2)
+ gdImageDashedLine (im_out, 40, ysize - 20 - cnt2, xsize - 40,
+ ysize - 20 - cnt2, green);
+ snprintf (buf, sizeof (buf), "%Zuk", (3 * maxsize_stack) / 4096);
+ gdImageString (im_out, gdFontSmall, xsize - 37, ysize - 26 - cnt2,
+ buf, green);
+ }
+
+
+ snprintf (buf, sizeof (buf), "%llu", total);
+ gdImageString (im_out, gdFontSmall, xsize - 50, ysize - 14, buf, blue);
+
+ if (!time_based)
+ {
+ uint64_t previously = start_time;
+
+ gdImageString (im_out, gdFontSmall, 40 + (xsize - 32 * 6 - 80) / 2,
+ ysize - 12,
+ (unsigned char *) "# memory handling function calls",
+ blue);
+
+
+ last_stack = last_heap = last_total = ysize - 20;
+ for (cnt = 1; cnt <= total; ++cnt)
+ {
+ struct entry entry;
+ size_t new[2];
+ uint64_t now;
+
+ read (fd, &entry, sizeof (entry));
+
+ now = ((uint64_t) entry.time_high) << 32 | entry.time_low;
+
+ if ((((previously - start_time) * 100) / total_time) % 10 < 5)
+ gdImageFilledRectangle (im_out,
+ 40 + ((cnt - 1) * (xsize - 80)) / total,
+ ysize - 19,
+ 39 + (cnt * (xsize - 80)) / total,
+ ysize - 14, yellow);
+ previously = now;
+
+ if (also_total)
+ {
+ size_t new3;
+
+ new3 = (ysize - 20) - ((((unsigned long long int) (ysize - 40))
+ * (entry.heap + entry.stack))
+ / maxsize_heap);
+ gdImageLine (im_out, 40 + ((xsize - 80) * (cnt - 1)) / total,
+ last_total,
+ 40 + ((xsize - 80) * cnt) / total, new3,
+ black);
+ last_total = new3;
+ }
+
+ // assert (entry.heap <= maxsize_heap);
+ new[0] = (ysize - 20) - ((((unsigned long long int) (ysize - 40))
+ * entry.heap) / maxsize_heap);
+ gdImageLine (im_out, 40 + ((xsize - 80) * (cnt - 1)) / total,
+ last_heap, 40 + ((xsize - 80) * cnt) / total, new[0],
+ red);
+ last_heap = new[0];
+
+ // assert (entry.stack <= maxsize_stack);
+ new[1] = (ysize - 20) - ((((unsigned long long int) (ysize - 40))
+ * entry.stack) / maxsize_stack);
+ gdImageLine (im_out, 40 + ((xsize - 80) * (cnt - 1)) / total,
+ last_stack, 40 + ((xsize - 80) * cnt) / total, new[1],
+ green);
+ last_stack = new[1];
+ }
+
+ cnt = 0;
+ while (cnt < total)
+ {
+ gdImageLine (im_out, 40 + ((xsize - 80) * cnt) / total, ysize - 20,
+ 40 + ((xsize - 80) * cnt) / total, ysize - 15, blue);
+ cnt += MAX (1, total / 20);
+ }
+ gdImageLine (im_out, xsize - 40, ysize - 20, xsize - 40, ysize - 15,
+ blue);
+ }
+ else
+ {
+ uint64_t next_tick = MAX (1, total / 20);
+ size_t last_xpos = 40;
+
+ gdImageString (im_out, gdFontSmall, 40 + (xsize - 39 * 6 - 80) / 2,
+ ysize - 12,
+ (unsigned char *) "\
+# memory handling function calls / time", blue);
+
+ for (cnt = 0; cnt < 20; cnt += 2)
+ gdImageFilledRectangle (im_out,
+ 40 + (cnt * (xsize - 80)) / 20, ysize - 19,
+ 39 + ((cnt + 1) * (xsize - 80)) / 20,
+ ysize - 14, yellow);
+
+ last_stack = last_heap = last_total = ysize - 20;
+ for (cnt = 1; cnt <= total; ++cnt)
+ {
+ struct entry entry;
+ size_t new[2];
+ size_t xpos;
+ uint64_t now;
+
+ read (fd, &entry, sizeof (entry));
+
+ now = ((uint64_t) entry.time_high) << 32 | entry.time_low;
+ xpos = 40 + ((xsize - 80) * (now - start_time)) / total_time;
+
+ if (cnt == next_tick)
+ {
+ gdImageLine (im_out, xpos, ysize - 20, xpos, ysize - 15, blue);
+ next_tick += MAX (1, total / 20);
+ }
+
+ if (also_total)
+ {
+ size_t new3;
+
+ new3 = (ysize - 20) - ((((unsigned long long int) (ysize - 40))
+ * (entry.heap + entry.stack))
+ / maxsize_heap);
+ gdImageLine (im_out, last_xpos, last_total, xpos, new3, black);
+ last_total = new3;
+ }
+
+ new[0] = (ysize - 20) - ((((unsigned long long int) (ysize - 40))
+ * entry.heap) / maxsize_heap);
+ gdImageLine (im_out, last_xpos, last_heap, xpos, new[0], red);
+ last_heap = new[0];
+
+ // assert (entry.stack <= maxsize_stack);
+ new[1] = (ysize - 20) - ((((unsigned long long int) (ysize - 40))
+ * entry.stack) / maxsize_stack);
+ gdImageLine (im_out, last_xpos, last_stack, xpos, new[1], green);
+ last_stack = new[1];
+
+ last_xpos = xpos;
+ }
+ }
+
+ /* Write out the result. */
+ outfile = fopen (outname, "w");
+ if (outfile == NULL)
+ error (EXIT_FAILURE, errno, "cannot open output file");
+
+ gdImagePng (im_out, outfile);
+
+ fclose (outfile);
+
+ gdImageDestroy (im_out);
+
+ exit (0);
+}
+
+
+/* Handle program arguments. */
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+ switch (key)
+ {
+ case 'o':
+ outname = arg;
+ break;
+ case 's':
+ string = arg;
+ break;
+ case 't':
+ time_based = 1;
+ break;
+ case 'T':
+ also_total = 1;
+ break;
+ case 'x':
+ xsize = atoi (arg);
+ if (xsize == 0)
+ xsize = XSIZE;
+ break;
+ case 'y':
+ ysize = atoi (arg);
+ if (ysize == 0)
+ ysize = XSIZE;
+ break;
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+
+static char *
+more_help (int key, const char *text, void *input)
+{
+ char *orig;
+ char *cp;
+
+ switch (key)
+ {
+ case ARGP_KEY_HELP_EXTRA:
+ /* We print some extra information. */
+ orig = gettext ("\
+Report bugs using the `glibcbug' script to <bugs@gnu.org>.\n");
+ cp = strdup (orig);
+ if (cp == NULL)
+ cp = orig;
+ return cp;
+ default:
+ break;
+ }
+ return (char *) text;
+}