From 9139c881c78bb1364217a4c039c8c58ec52a6a89 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Sun, 16 Oct 2005 14:33:22 +0000 Subject: [PATCH] Code to build and display device dependency tree. --- WHATS_NEW | 6 +- configure | 1227 ++++++++++++++++++++++++++++----------- configure.in | 1 + dmsetup/dmsetup.c | 449 +++++++++++++- include/.symlinks | 4 + include/lib.h | 4 + lib/.exported_symbols | 12 + lib/Makefile.in | 10 +- lib/datastruct/bitset.c | 95 +++ lib/datastruct/bitset.h | 52 ++ lib/datastruct/hash.c | 262 +++++++++ lib/datastruct/hash.h | 49 ++ lib/ioctl/libdm-iface.c | 119 +++- lib/libdevmapper.h | 65 ++- lib/libdm-common.c | 14 +- lib/libdm-deptree.c | 403 +++++++++++++ lib/mm/dbg_malloc.c | 247 ++++++++ lib/mm/dbg_malloc.h | 46 ++ lib/mm/pool-debug.c | 263 +++++++++ lib/mm/pool-fast.c | 235 ++++++++ lib/mm/pool.c | 52 ++ lib/mm/pool.h | 121 ++++ make.tmpl.in | 5 + 23 files changed, 3342 insertions(+), 399 deletions(-) create mode 100644 lib/datastruct/bitset.c create mode 100644 lib/datastruct/bitset.h create mode 100644 lib/datastruct/hash.c create mode 100644 lib/datastruct/hash.h create mode 100644 lib/libdm-deptree.c create mode 100644 lib/mm/dbg_malloc.c create mode 100644 lib/mm/dbg_malloc.h create mode 100644 lib/mm/pool-debug.c create mode 100644 lib/mm/pool-fast.c create mode 100644 lib/mm/pool.c create mode 100644 lib/mm/pool.h diff --git a/WHATS_NEW b/WHATS_NEW index d6fb807..3c06368 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,6 +1,8 @@ -Version 1.01.06 - +Version 1.02.00 - ============================= - Add dmsetup --nolockfs support for suspend/reload. + Added dependency tree functions to library. + Added ls --tree to dmsetup. + Added dmsetup --nolockfs support for suspend/reload. Version 1.01.05 - 26 Sep 2005 ============================= diff --git a/configure b/configure index d3d57ab..3ca2008 100755 --- a/configure +++ b/configure @@ -1,9 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.57. +# Generated by GNU Autoconf 2.59. # -# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 -# Free Software Foundation, Inc. +# Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## @@ -20,9 +19,10 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi +DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. -if (FOO=FOO; unset FOO) >/dev/null 2>&1; then +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false @@ -41,7 +41,7 @@ for as_var in \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do - if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var @@ -218,16 +218,17 @@ rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else + test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. -as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. -as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS @@ -668,7 +669,7 @@ done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir + localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo $ac_var` case $ac_val in @@ -708,10 +709,10 @@ if test -z "$srcdir"; then # Try the directory containing this script, then its parent. ac_confdir=`(dirname "$0") 2>/dev/null || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$0" : 'X\(//\)[^/]' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } @@ -803,9 +804,9 @@ _ACEOF cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] + [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] + [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify @@ -915,12 +916,45 @@ case $srcdir in ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac -# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be -# absolute. -ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` -ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` -ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac cd $ac_dir # Check for guested configure; otherwise get Cygnus style configure. @@ -931,7 +965,7 @@ ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` echo $SHELL $ac_srcdir/configure --help=recursive elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then + test -f $ac_srcdir/configure.in; then echo $ac_configure --help else @@ -945,8 +979,7 @@ test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 -Free Software Foundation, Inc. +Copyright (C) 2003 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -958,7 +991,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.57. Invocation command line was +generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1035,19 +1068,19 @@ do 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. + ac_must_keep_next=false # Got value, back to normal. else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac fi ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" # Get rid of the leading space. @@ -1081,12 +1114,12 @@ _ASBOX case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } @@ -1115,7 +1148,7 @@ _ASBOX for ac_var in $ac_subst_files do eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo fi @@ -1134,7 +1167,7 @@ _ASBOX echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 - rm -f core core.* *.core && + rm -f core *.core && rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 @@ -1214,7 +1247,7 @@ fi # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" @@ -1231,13 +1264,13 @@ echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then - { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} - { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} - ac_cache_corrupted=: + ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. @@ -1793,7 +1826,6 @@ ac_compiler=`set X $ac_compile; echo $2` (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -1813,8 +1845,8 @@ ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -echo "$as_me:$LINENO: checking for C compiler default output" >&5 -echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 @@ -1834,23 +1866,23 @@ do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; + ;; conftest.$ac_ext ) - # This is the source file. - ;; + # This is the source file. + ;; [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; + # We found the default executable, but exeext='' is most + # certainly right. + break;; *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext - break;; + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; * ) - break;; + break;; esac done else @@ -1924,8 +1956,8 @@ for ac_file in conftest.exe conftest conftest.*; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext - break;; + export ac_cv_exeext + break;; * ) break;; esac done @@ -1950,7 +1982,6 @@ if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2001,7 +2032,6 @@ if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2021,11 +2051,21 @@ main () _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2038,7 +2078,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi @@ -2054,7 +2094,6 @@ if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2071,11 +2110,21 @@ main () _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2088,7 +2137,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_prog_cc_g=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 @@ -2115,7 +2164,6 @@ else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2143,6 +2191,16 @@ static char *f (char * (*g) (char **, int), char **p, ...) va_end (v); return s; } + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std1 is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std1. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; @@ -2169,11 +2227,21 @@ do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2186,7 +2254,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.$ac_objext +rm -f conftest.err conftest.$ac_objext done rm -f conftest.$ac_ext conftest.$ac_objext CC=$ac_save_CC @@ -2214,19 +2282,28 @@ cat >conftest.$ac_ext <<_ACEOF _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ - ''\ - '#include ' \ + '' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ @@ -2234,14 +2311,13 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include $ac_declaration +#include int main () { @@ -2252,11 +2328,21 @@ exit (42); _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2269,9 +2355,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 continue fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2288,11 +2373,21 @@ exit (42); _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2304,7 +2399,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then @@ -2318,7 +2413,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -2354,7 +2449,6 @@ do # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2365,7 +2459,7 @@ cat >>conftest.$ac_ext <<_ACEOF #else # include #endif - Syntax error + Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -2377,6 +2471,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi @@ -2397,7 +2492,6 @@ rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2415,6 +2509,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi @@ -2461,7 +2556,6 @@ do # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2472,7 +2566,7 @@ cat >>conftest.$ac_ext <<_ACEOF #else # include #endif - Syntax error + Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -2484,6 +2578,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi @@ -2504,7 +2599,6 @@ rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2522,6 +2616,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi @@ -2584,7 +2679,6 @@ if test "${ac_cv_prog_gcc_traditional+set}" = set; then else ac_pattern="Autoconf.*'x'" cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2604,7 +2698,6 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2639,6 +2732,7 @@ fi # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 @@ -2655,6 +2749,7 @@ do case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. @@ -2662,20 +2757,20 @@ case $as_dir/ in # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then - if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then - # program-specific install script used by HP pwplus--don't use. - : - else - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" - break 3 - fi - fi + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi done done ;; @@ -2718,7 +2813,7 @@ fi echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2841,7 +2936,6 @@ if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2861,11 +2955,21 @@ return 0; _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2878,7 +2982,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 @@ -2901,7 +3005,6 @@ else ac_func_search_save_LIBS=$LIBS ac_cv_search_opendir=no cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2925,11 +3028,21 @@ opendir (); _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2941,12 +3054,12 @@ else sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_opendir" = no; then for ac_lib in dir; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2970,11 +3083,21 @@ opendir (); _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -2987,7 +3110,8 @@ else sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext done fi LIBS=$ac_func_search_save_LIBS @@ -3008,7 +3132,6 @@ else ac_func_search_save_LIBS=$LIBS ac_cv_search_opendir=no cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3032,11 +3155,21 @@ opendir (); _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3048,12 +3181,12 @@ else sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_opendir" = no; then for ac_lib in x; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3077,11 +3210,21 @@ opendir (); _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3094,7 +3237,8 @@ else sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext done fi LIBS=$ac_func_search_save_LIBS @@ -3114,7 +3258,6 @@ if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3135,11 +3278,21 @@ main () _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3152,12 +3305,11 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3179,7 +3331,6 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3204,7 +3355,6 @@ if test $ac_cv_header_stdc = yes; then : else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3216,9 +3366,9 @@ cat >>conftest.$ac_ext <<_ACEOF # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif @@ -3229,7 +3379,7 @@ main () int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) + || toupper (i) != TOUPPER (i)) exit(2); exit (0); } @@ -3254,7 +3404,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi -rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi @@ -3274,7 +3424,6 @@ if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3295,11 +3444,21 @@ return 0; _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3312,7 +3471,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_time=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6 @@ -3336,7 +3495,7 @@ fi for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h + inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_header" >&5 @@ -3345,7 +3504,6 @@ if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3357,11 +3515,21 @@ $ac_includes_default _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3374,7 +3542,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 @@ -3420,7 +3588,6 @@ else echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3431,11 +3598,21 @@ $ac_includes_default _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3448,7 +3625,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 @@ -3456,7 +3633,6 @@ echo "${ECHO_T}$ac_header_compiler" >&6 echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3474,6 +3650,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi @@ -3493,33 +3670,187 @@ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? -case $ac_header_compiler:$ac_header_preproc in - yes:no ) +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## ------------------------------------ ## -## Report this to bug-autoconf@gnu.org. ## -## ------------------------------------ ## +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; - no:yes ) +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +else + { { echo "$as_me:$LINENO: error: bailing out" >&5 +echo "$as_me: error: bailing out" >&2;} + { (exit 1); exit 1; }; } +fi + +done + + + +for ac_header in termios.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## ------------------------------------ ## -## Report this to bug-autoconf@gnu.org. ## -## ------------------------------------ ## +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -3530,7 +3861,7 @@ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - eval "$as_ac_Header=$ac_header_preproc" + eval "$as_ac_Header=\$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 @@ -3541,15 +3872,10 @@ if test `eval echo '${'$as_ac_Header'}'` = yes; then #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF -else - { { echo "$as_me:$LINENO: error: bailing out" >&5 -echo "$as_me: error: bailing out" >&2;} - { (exit 1); exit 1; }; } fi done - ################################################################################ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 @@ -3557,7 +3883,6 @@ if test "${ac_cv_c_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3620,11 +3945,21 @@ main () _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3637,7 +3972,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_const=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 echo "${ECHO_T}$ac_cv_c_const" >&6 @@ -3657,7 +3992,6 @@ else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3672,11 +4006,21 @@ $ac_kw foo_t foo () {return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3688,23 +4032,27 @@ else sed 's/^/| /' conftest.$ac_ext >&5 fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done fi echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 echo "${ECHO_T}$ac_cv_c_inline" >&6 + + case $ac_cv_c_inline in inline | yes) ;; - no) -cat >>confdefs.h <<\_ACEOF -#define inline -_ACEOF - ;; - *) cat >>confdefs.h <<_ACEOF -#define inline $ac_cv_c_inline + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif _ACEOF - ;; + ;; esac @@ -3714,7 +4062,6 @@ if test "${ac_cv_member_struct_stat_st_rdev+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3733,11 +4080,21 @@ return 0; _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3749,7 +4106,6 @@ else sed 's/^/| /' conftest.$ac_ext >&5 cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3768,11 +4124,21 @@ return 0; _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3785,9 +4151,9 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_member_struct_stat_st_rdev=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_rdev" >&5 echo "${ECHO_T}$ac_cv_member_struct_stat_st_rdev" >&6 @@ -3811,7 +4177,6 @@ if test "${ac_cv_type_off_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3831,11 +4196,21 @@ if (sizeof (off_t)) _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3848,7 +4223,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_off_t=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 echo "${ECHO_T}$ac_cv_type_off_t" >&6 @@ -3868,7 +4243,6 @@ if test "${ac_cv_type_pid_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3888,11 +4262,21 @@ if (sizeof (pid_t)) _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3905,7 +4289,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_pid_t=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 echo "${ECHO_T}$ac_cv_type_pid_t" >&6 @@ -3925,7 +4309,6 @@ if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -3952,11 +4335,21 @@ int i; _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -3969,7 +4362,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_signal=int fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 echo "${ECHO_T}$ac_cv_type_signal" >&6 @@ -3985,7 +4378,6 @@ if test "${ac_cv_type_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -4005,11 +4397,21 @@ if (sizeof (size_t)) _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4022,7 +4424,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_size_t=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 echo "${ECHO_T}$ac_cv_type_size_t" >&6 @@ -4055,21 +4457,28 @@ if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ + #ifdef __STDC__ # include #else # include #endif + +#undef $ac_func + /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" @@ -4100,11 +4509,21 @@ return f != $ac_func; _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4117,7 +4536,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 @@ -4142,7 +4562,6 @@ else ac_cv_func_closedir_void=yes else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -4182,7 +4601,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_closedir_void=yes fi -rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi echo "$as_me:$LINENO: result: $ac_cv_func_closedir_void" >&5 @@ -4212,7 +4631,6 @@ else echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -4223,11 +4641,21 @@ $ac_includes_default _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4240,7 +4668,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 @@ -4248,7 +4676,6 @@ echo "${ECHO_T}$ac_header_compiler" >&6 echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -4266,6 +4693,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi @@ -4285,33 +4713,32 @@ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? -case $ac_header_compiler:$ac_header_preproc in - yes:no ) +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------ ## -## Report this to bug-autoconf@gnu.org. ## -## ------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes ;; - no:yes ) + no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## ------------------------------------ ## -## Report this to bug-autoconf@gnu.org. ## -## ------------------------------------ ## +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -4322,7 +4749,7 @@ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - eval "$as_ac_Header=$ac_header_preproc" + eval "$as_ac_Header=\$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 @@ -4346,7 +4773,6 @@ else ac_cv_func_malloc_0_nonnull=no else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -4386,7 +4812,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_malloc_0_nonnull=no fi -rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 @@ -4402,7 +4828,14 @@ else #define HAVE_MALLOC 0 _ACEOF - LIBOBJS="$LIBOBJS malloc.$ac_objext" + case $LIBOBJS in + "malloc.$ac_objext" | \ + *" malloc.$ac_objext" | \ + "malloc.$ac_objext "* | \ + *" malloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; +esac + cat >>confdefs.h <<\_ACEOF #define malloc rpl_malloc @@ -4424,7 +4857,6 @@ if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then ac_cv_func_lstat_dereferences_slashed_symlink=no else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -4436,8 +4868,8 @@ main () { struct stat sbuf; /* Linux will dereference the symlink and fail. - That is better in the sense that it means we will not - have to compile and use the lstat wrapper. */ + That is better in the sense that it means we will not + have to compile and use the lstat wrapper. */ exit (lstat ("conftest.sym/", &sbuf) ? 0 : 1); ; return 0; @@ -4463,7 +4895,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_lstat_dereferences_slashed_symlink=no fi -rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi else # If the `ln -s' command failed, then we probably don't even @@ -4484,7 +4916,14 @@ _ACEOF if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then - LIBOBJS="$LIBOBJS lstat.$ac_objext" + case $LIBOBJS in + "lstat.$ac_objext" | \ + *" lstat.$ac_objext" | \ + "lstat.$ac_objext "* | \ + *" lstat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;; +esac + fi echo "$as_me:$LINENO: checking whether stat accepts an empty string" >&5 @@ -4496,7 +4935,6 @@ else ac_cv_func_stat_empty_string_bug=yes else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -4532,13 +4970,20 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_stat_empty_string_bug=no fi -rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5 echo "${ECHO_T}$ac_cv_func_stat_empty_string_bug" >&6 if test $ac_cv_func_stat_empty_string_bug = yes; then - LIBOBJS="$LIBOBJS stat.$ac_objext" + case $LIBOBJS in + "stat.$ac_objext" | \ + *" stat.$ac_objext" | \ + "stat.$ac_objext "* | \ + *" stat.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS stat.$ac_objext" ;; +esac + cat >>confdefs.h <<_ACEOF #define HAVE_STAT_EMPTY_STRING_BUG 1 @@ -4556,21 +5001,28 @@ if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ + #ifdef __STDC__ # include #else # include #endif + +#undef $ac_func + /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" @@ -4601,11 +5053,21 @@ return f != $ac_func; _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4618,7 +5080,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 @@ -4633,21 +5096,28 @@ if test "${ac_cv_func__doprnt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +/* Define _doprnt to an innocuous variant, in case declares _doprnt. + For example, HP-UX 11i declares gettimeofday. */ +#define _doprnt innocuous__doprnt + /* System header to define __stub macros and hopefully few prototypes, which can conflict with char _doprnt (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ + #ifdef __STDC__ # include #else # include #endif + +#undef _doprnt + /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" @@ -4678,11 +5148,21 @@ return f != _doprnt; _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4695,7 +5175,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func__doprnt=no fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 echo "${ECHO_T}$ac_cv_func__doprnt" >&6 @@ -4891,7 +5372,6 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lselinux $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -4915,11 +5395,21 @@ is_selinux_enabled (); _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 + (eval $ac_link) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest$ac_exeext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4932,7 +5422,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_selinux_is_selinux_enabled=no fi -rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_selinux_is_selinux_enabled" >&5 @@ -4971,7 +5462,6 @@ else echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -4982,11 +5472,21 @@ $ac_includes_default _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 + (eval $ac_compile) 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? @@ -4999,7 +5499,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi -rm -f conftest.$ac_objext conftest.$ac_ext +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 @@ -5007,7 +5507,6 @@ echo "${ECHO_T}$ac_header_compiler" >&6 echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -5025,6 +5524,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi @@ -5044,33 +5544,32 @@ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? -case $ac_header_compiler:$ac_header_preproc in - yes:no ) +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - ( - cat <<\_ASBOX -## ------------------------------------ ## -## Report this to bug-autoconf@gnu.org. ## -## ------------------------------------ ## -_ASBOX - ) | - sed "s/^/$as_me: WARNING: /" >&2 + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes ;; - no:yes ) + no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## ------------------------------------ ## -## Report this to bug-autoconf@gnu.org. ## -## ------------------------------------ ## +## ------------------------------------------ ## +## Report this to the AC_PACKAGE_NAME lists. ## +## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -5081,7 +5580,7 @@ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - eval "$as_ac_Header=$ac_header_preproc" + eval "$as_ac_Header=\$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 @@ -5340,13 +5839,13 @@ _ACEOF # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | @@ -5376,13 +5875,13 @@ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ + ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; +s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; -s/^[^=]*=[ ]*$//; +s/^[^=]*=[ ]*$//; }' fi @@ -5396,13 +5895,13 @@ fi cat >confdef2opt.sed <<\_ACEOF t clear : clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g t quote -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g t quote d : quote -s,[ `~#$^&*(){}\\|;'"<>?],\\&,g +s,[ `~#$^&*(){}\\|;'"<>?],\\&,g s,\[,\\&,g s,\],\\&,g s,\$,$$,g @@ -5424,7 +5923,7 @@ ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` # 2. Add them. ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' @@ -5468,9 +5967,10 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi +DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. -if (FOO=FOO; unset FOO) >/dev/null 2>&1; then +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false @@ -5489,7 +5989,7 @@ for as_var in \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do - if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var @@ -5668,16 +6168,17 @@ rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else + test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. -as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. -as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS @@ -5704,7 +6205,7 @@ _ASBOX cat >&5 <<_CSEOF This file was extended by $as_me, which was -generated by GNU Autoconf 2.57. Invocation command line was +generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -5748,7 +6249,7 @@ Usage: $0 [OPTIONS] [FILE]... -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] - instantiate the configuration file FILE + instantiate the configuration file FILE Configuration files: $config_files @@ -5759,11 +6260,10 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.57, +configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" -Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. +Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." srcdir=$srcdir @@ -6045,9 +6545,9 @@ _ACEOF (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr $ac_sed_frag + 1` ac_beg=$ac_end @@ -6065,21 +6565,21 @@ for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } @@ -6095,10 +6595,10 @@ echo X"$ac_file" | as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } @@ -6136,12 +6636,45 @@ case $srcdir in ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac -# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be -# absolute. -ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` -ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` -ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` -ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + +# Do not use `cd foo && pwd` to compute absolute paths, because +# the directories may not exist. +case `pwd` in +.) ac_abs_builddir="$ac_dir";; +*) + case "$ac_dir" in + .) ac_abs_builddir=`pwd`;; + [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; + *) ac_abs_builddir=`pwd`/"$ac_dir";; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_builddir=${ac_top_builddir}.;; +*) + case ${ac_top_builddir}. in + .) ac_abs_top_builddir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; + *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_srcdir=$ac_srcdir;; +*) + case $ac_srcdir in + .) ac_abs_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; + *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; + esac;; +esac +case $ac_abs_builddir in +.) ac_abs_top_srcdir=$ac_top_srcdir;; +*) + case $ac_top_srcdir in + .) ac_abs_top_srcdir=$ac_abs_builddir;; + [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; + *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; + esac;; +esac case $INSTALL in @@ -6163,7 +6696,7 @@ echo "$as_me: creating $ac_file" >&6;} configure_input="$ac_file. " fi configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." + sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. @@ -6172,24 +6705,24 @@ echo "$as_me: creating $ac_file" >&6;} case $f in -) echo $tmp/stdin ;; [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } - echo $f;; + echo "$f";; *) # Relative - if test -f "$f"; then - # Build tree - echo $f - elif test -f "$srcdir/$f"; then - # Source tree - echo $srcdir/$f - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 + if test -f "$f"; then + # Build tree + echo "$f" + elif test -f "$srcdir/$f"; then + # Source tree + echo "$srcdir/$f" + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } - fi;; + fi;; esac done` || { (exit 1); exit 1; } _ACEOF diff --git a/configure.in b/configure.in index c7f8bc5..9a8c23d 100644 --- a/configure.in +++ b/configure.in @@ -64,6 +64,7 @@ AC_HEADER_TIME AC_CHECK_HEADERS(ctype.h dirent.h errno.h fcntl.h getopt.h inttypes.h limits.h stdarg.h stdio.h stdlib.h string.h sys/ioctl.h sys/param.h sys/stat.h sys/types.h unistd.h,,AC_MSG_ERROR(bailing out)) +AC_CHECK_HEADERS(termios.h) ################################################################################ dnl -- Checks for typedefs, structures, and compiler characteristics. AC_C_CONST diff --git a/dmsetup/dmsetup.c b/dmsetup/dmsetup.c index 5740823..366d68e 100644 --- a/dmsetup/dmsetup.c +++ b/dmsetup/dmsetup.c @@ -1,9 +1,12 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * Copyright (C) 2005 NEC Corperation * * This file is part of the device-mapper userspace tools. * + * It includes tree drawing code based on pstree: http://psmisc.sourceforge.net/ + * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions * of the GNU General Public License v.2. @@ -30,6 +33,16 @@ #include #include #include +#include +#include + +#ifdef HAVE_SYS_IOCTL_H +# include +#endif + +#if HAVE_TERMIOS_H +# include +#endif #ifdef HAVE_GETOPTLONG # include @@ -81,6 +94,7 @@ enum { NOTABLE_ARG, OPTIONS_ARG, TARGET_ARG, + TREE_ARG, UUID_ARG, VERBOSE_ARG, VERSION_ARG, @@ -93,6 +107,7 @@ static char *_uuid; static char *_fields; static char *_target; static char *_command; +static struct deptree *_dtree; /* * Commands @@ -951,11 +966,348 @@ static int _display_name(int argc, char **argv, void *data) return 1; } +/* + * Tree drawing code + */ + +enum { + TR_DEVICE=0, /* display device major:minor number */ + TR_TABLE, + TR_STATUS, + TR_ACTIVE, + TR_RW, + TR_OPENCOUNT, + TR_UUID, + TR_COMPACT, + TR_TRUNCATE, + TR_BOTTOMUP, + NUM_TREEMODE, +}; + +static int _tree_switches[NUM_TREEMODE]; + +#define TR_PRINT_ATTRIBUTE ( _tree_switches[TR_ACTIVE] || \ + _tree_switches[TR_RW] || \ + _tree_switches[TR_OPENCOUNT] || \ + _tree_switches[TR_UUID] ) + +#define TR_PRINT_TARGETS ( _tree_switches[TR_TABLE] || \ + _tree_switches[TR_STATUS] ) + +/* Compact - fewer newlines */ +#define TR_PRINT_COMPACT (_tree_switches[TR_COMPACT] && \ + !TR_PRINT_ATTRIBUTE && \ + !TR_PRINT_TARGETS) + +/* FIXME Get rid of this */ +#define MAX_DEPTH 100 + +/* Drawing character definition from pstree */ +/* [pstree comment] UTF-8 defines by Johan Myreen, updated by Ben Winslow */ +#define UTF_V "\342\224\202" /* U+2502, Vertical line drawing char */ +#define UTF_VR "\342\224\234" /* U+251C, Vertical and right */ +#define UTF_H "\342\224\200" /* U+2500, Horizontal */ +#define UTF_UR "\342\224\224" /* U+2514, Up and right */ +#define UTF_HD "\342\224\254" /* U+252C, Horizontal and down */ + +#define VT_BEG "\033(0\017" /* use graphic chars */ +#define VT_END "\033(B" /* back to normal char set */ +#define VT_V "x" /* see UTF definitions above */ +#define VT_VR "t" +#define VT_H "q" +#define VT_UR "m" +#define VT_HD "w" + +static struct { + const char *empty_2; /* */ + const char *branch_2; /* |- */ + const char *vert_2; /* | */ + const char *last_2; /* `- */ + const char *single_3; /* --- */ + const char *first_3; /* -+- */ +} +_tsym_ascii = { + " ", + "|-", + "| ", + "`-", + "---", + "-+-" +}, +_tsym_utf = { + " ", + UTF_VR UTF_H, + UTF_V " ", + UTF_UR UTF_H, + UTF_H UTF_H UTF_H, + UTF_H UTF_HD UTF_H +}, +_tsym_vt100 = { + " ", + VT_BEG VT_VR VT_H VT_END, + VT_BEG VT_V VT_END " ", + VT_BEG VT_UR VT_H VT_END, + VT_BEG VT_H VT_H VT_H VT_END, + VT_BEG VT_H VT_HD VT_H VT_END +}, +*_tsym = &_tsym_ascii; + +/* + * Tree drawing functions. + */ +/* FIXME Get rid of these statics - use dynamic struct */ +/* FIXME Explain what these vars are for */ +static int _tree_width[MAX_DEPTH], _tree_more[MAX_DEPTH]; +static int _termwidth = 80; /* Maximum output width */ +static int _cur_x = 1; /* Current horizontal output position */ +static char _last_char = 0; + +static void _out_char(char c) +{ + /* Only first UTF-8 char counts */ + _cur_x += ((c & 0xc0) != 0x80); + + if (!_tree_switches[TR_TRUNCATE]) { + putchar(c); + return; + } + + /* Truncation? */ + if (_cur_x <= _termwidth) + putchar(c); + + if (_cur_x == _termwidth + 1 && ((c & 0xc0) != 0x80)) { + if (_last_char || (c & 0x80)) { + putchar('.'); + putchar('.'); + putchar('.'); + } else { + _last_char = c; + _cur_x--; + } + } +} + +static void _out_string(const char *str) +{ + while (*str) + _out_char(*str++); +} + +/* non-negative integers only */ +static unsigned _out_int(unsigned num) +{ + unsigned digits = 0; + unsigned divi; + + if (!num) { + _out_char('0'); + return 1; + } + + /* non zero case */ + for (divi = 1; num / divi; divi *= 10) + digits++; + + for (divi /= 10; divi; divi /= 10) + _out_char('0' + (num / divi) % 10); + + return digits; +} + +static void _out_newline(void) +{ + if (_last_char && _cur_x == _termwidth) + putchar(_last_char); + _last_char = 0; + putchar('\n'); + _cur_x = 1; +} + +static void _out_prefix(int depth) +{ + int x, d; + + for (d = 0; d < depth; d++) { + for (x = _tree_width[d] + 1; x > 0; x--) + _out_char(' '); + + _out_string(d == depth - 1 ? + !_tree_more[depth] ? _tsym->last_2 : _tsym->branch_2 + : _tree_more[d + 1] ? + _tsym->vert_2 : _tsym->empty_2); + } +} + +/* + * Display tree + */ +static void _display_tree_attributes(struct deptree_node *node) +{ + int attr = 0; + const char *uuid; + const struct dm_info *info; + + uuid = dm_deptree_node_get_uuid(node); + info = dm_deptree_node_get_info(node); + + if (!info->exists) + return; + + if (_tree_switches[TR_ACTIVE]) { + _out_string(attr++ ? ", " : " ["); + _out_string(info->suspended ? "SUSPENDED" : "ACTIVE"); + } + + if (_tree_switches[TR_RW]) { + _out_string(attr++ ? ", " : " ["); + _out_string(info->read_only ? "RO" : "RW"); + } + + if (_tree_switches[TR_OPENCOUNT]) { + _out_string(attr++ ? ", " : " ["); + (void) _out_int(info->open_count); + } + + if (_tree_switches[TR_UUID]) { + _out_string(attr++ ? ", " : " ["); + _out_string(uuid && *uuid ? uuid : ""); + } + + if (attr) + _out_char(']'); +} + +static void _display_tree_node(struct deptree_node *node, unsigned depth, + unsigned first_child, unsigned last_child, + unsigned has_children) +{ + int offset; + const char *name; + const struct dm_info *info; + int first_on_line = 0; + + /* Sub-tree for targets has 2 more depth */ + if (depth + 2 > MAX_DEPTH) + return; + + name = dm_deptree_node_get_name(node); + + if ((!name || !*name) && !_tree_switches[TR_DEVICE]) + return; + + /* Indicate whether there are more nodes at this depth */ + _tree_more[depth] = !last_child; + _tree_width[depth] = 0; + + if (_cur_x == 1) + first_on_line = 1; + + if (!TR_PRINT_COMPACT || first_on_line) + _out_prefix(depth); + + /* Remember the starting point for compact */ + offset = _cur_x; + + if (TR_PRINT_COMPACT && !first_on_line) + _out_string(_tree_more[depth] ? _tsym->first_3 : _tsym->single_3); + + /* display node */ + if (name) + _out_string(name); + + info = dm_deptree_node_get_info(node); + + if (_tree_switches[TR_DEVICE]) { + _out_string(name ? " (" : "("); + (void) _out_int(info->major); + _out_char(':'); + (void) _out_int(info->minor); + _out_char(')'); + } + + /* display additional info */ + if (TR_PRINT_ATTRIBUTE) + _display_tree_attributes(node); + + if (TR_PRINT_COMPACT) + _tree_width[depth] = _cur_x - offset; + + if (!TR_PRINT_COMPACT || !has_children) + _out_newline(); + + if (TR_PRINT_TARGETS) { + _tree_more[depth + 1] = has_children; + // FIXME _display_tree_targets(name, depth + 2); + } +} + +/* + * Walk the dependency tree + */ +static void _tree_walk_children(struct deptree_node *node, unsigned depth) +{ + struct deptree_node *child, *next_child; + void *handle = NULL; + uint32_t inverted = _tree_switches[TR_BOTTOMUP]; + unsigned first_child = 1; + unsigned has_children; + + next_child = dm_deptree_next_child(&handle, node, inverted); + + while ((child = next_child)) { + next_child = dm_deptree_next_child(&handle, node, inverted); + has_children = + dm_deptree_node_num_children(child, inverted) ? 1 : 0; + + _display_tree_node(child, depth, first_child, + next_child ? 0 : 1, has_children); + + if (has_children) + _tree_walk_children(child, depth + 1); + + first_child = 0; + } +} + +static int _add_dep(int argc, char **argv, void *data) +{ + struct dm_names *names = (struct dm_names *) data; + + if (!dm_deptree_add_dev(_dtree, MAJOR(names->dev), MINOR(names->dev))) + return 0; + + return 1; +} + +/* + * Create and walk dependency tree + */ +static int _tree(int argc, char **argv, void *data) +{ + if (!(_dtree = dm_deptree_create())) + return 0; + + if (!_process_all(argc, argv, _add_dep)) + return 0; + + _tree_walk_children(dm_deptree_find_node(_dtree, 0, 0), 0); + + dm_deptree_free(_dtree); + + return 1; +} + +/* + * List devices + */ static int _ls(int argc, char **argv, void *data) { if ((_switches[TARGET_ARG] && _target) || (_switches[EXEC_ARG] && _command)) return _status(argc, argv, data); + else if ((_switches[TREE_ARG])) + return _tree(argc, argv, data); else return _process_all(argc, argv, _display_name); } @@ -986,7 +1338,7 @@ static struct command _commands[] = { {"reload", " []", 0, 2, _load}, {"rename", " ", 1, 2, _rename}, {"message", " ", 2, -1, _message}, - {"ls", "[--target ] [--exec ]", 0, 0, _ls}, + {"ls", "[--target ] [--exec ] [--tree]", 0, 0, _ls}, {"info", "[]", 0, 1, _info}, {"deps", "[]", 0, 1, _deps}, {"status", "[] [--target ]", 0, 1, _status}, @@ -1024,6 +1376,72 @@ static struct command *_find_command(const char *name) return NULL; } +static int _process_tree_options(const char *options) +{ + const char *s, *end; + struct winsize winsz; + int len; + + /* Symbol set default */ + if (!strcmp(nl_langinfo(CODESET), "UTF-8")) + _tsym = &_tsym_utf; + else + _tsym = &_tsym_ascii; + + /* Default */ + _tree_switches[TR_DEVICE] = 1; + _tree_switches[TR_TRUNCATE] = 1; + + /* parse */ + for (s = options; s && *s; s++) { + len = 0; + for (end = s; *end && *end != ','; end++, len++) + ; + if (!strncmp(s, "device", len)) + _tree_switches[TR_DEVICE] = 1; + else if (!strncmp(s, "nodevice", len)) + _tree_switches[TR_DEVICE] = 0; + else if (!strncmp(s, "status", len)) + _tree_switches[TR_STATUS] = 1; + else if (!strncmp(s, "table", len)) + _tree_switches[TR_TABLE] = 1; + else if (!strncmp(s, "active", len)) + _tree_switches[TR_ACTIVE] = 1; + else if (!strncmp(s, "open", len)) + _tree_switches[TR_OPENCOUNT] = 1; + else if (!strncmp(s, "uuid", len)) + _tree_switches[TR_UUID] = 1; + else if (!strncmp(s, "rw", len)) + _tree_switches[TR_RW] = 1; + else if (!strncmp(s, "utf", len)) + _tsym = &_tsym_utf; + else if (!strncmp(s, "vt100", len)) + _tsym = &_tsym_vt100; + else if (!strncmp(s, "ascii", len)) + _tsym = &_tsym_ascii; + else if (!strncmp(s, "inverted", len)) + _tree_switches[TR_BOTTOMUP] = 1; + else if (!strncmp(s, "compact", len)) + _tree_switches[TR_COMPACT] = 1; + else if (!strncmp(s, "notrunc", len)) + _tree_switches[TR_TRUNCATE] = 0; + else { + fprintf(stderr, "Tree options not recognised: %s\n", s); + return 0; + } + if (!*end) + break; + s = end; + } + + /* Truncation doesn't work well with vt100 drawing char */ + if (_tsym != &_tsym_vt100) + if (ioctl(1, TIOCGWINSZ, &winsz) >= 0 && winsz.ws_col > 3) + _termwidth = winsz.ws_col - 3; + + return 1; +} + static int _process_switches(int *argc, char ***argv) { char *base, *namebase; @@ -1043,6 +1461,7 @@ static int _process_switches(int *argc, char ***argv) {"notable", 0, &ind, NOTABLE_ARG}, {"options", 1, &ind, OPTIONS_ARG}, {"target", 1, &ind, TARGET_ARG}, + {"tree", 0, &ind, TREE_ARG}, {"uuid", 1, &ind, UUID_ARG}, {"verbose", 1, &ind, VERBOSE_ARG}, {"version", 0, &ind, VERSION_ARG}, @@ -1134,6 +1553,8 @@ static int _process_switches(int *argc, char ***argv) _switches[NOLOCKFS_ARG]++; if ((ind == NOOPENCOUNT_ARG)) _switches[NOOPENCOUNT_ARG]++; + if ((ind == TREE_ARG)) + _switches[TREE_ARG]++; if ((ind == VERSION_ARG)) _switches[VERSION_ARG]++; } @@ -1148,11 +1569,15 @@ static int _process_switches(int *argc, char ***argv) return 0; } - if (_switches[OPTIONS_ARG] && strcmp(_fields, "name")) { + if (_switches[COLS_ARG] && _switches[OPTIONS_ARG] && + strcmp(_fields, "name")) { fprintf(stderr, "Only -o name is supported so far.\n"); return 0; } + if (_switches[TREE_ARG] && !_process_tree_options(_fields)) + return 0; + *argv += optind; *argc -= optind; return 1; @@ -1161,10 +1586,13 @@ static int _process_switches(int *argc, char ***argv) int main(int argc, char **argv) { struct command *c; + int r = 1; + + (void) setlocale(LC_ALL, ""); if (!_process_switches(&argc, &argv)) { fprintf(stderr, "Couldn't process command line.\n"); - exit(1); + goto out; } if (_switches[VERSION_ARG]) { @@ -1174,27 +1602,30 @@ int main(int argc, char **argv) if (argc == 0) { _usage(stderr); - exit(1); + goto out; } if (!(c = _find_command(argv[0]))) { fprintf(stderr, "Unknown command\n"); _usage(stderr); - exit(1); + goto out; } if (argc < c->min_args + 1 || (c->max_args >= 0 && argc > c->max_args + 1)) { fprintf(stderr, "Incorrect number of arguments\n"); _usage(stderr); - exit(1); + goto out; } doit: if (!c->fn(argc, argv, NULL)) { fprintf(stderr, "Command failed\n"); - exit(1); + goto out; } - return 0; + r = 0; + +out: + return r; } diff --git a/include/.symlinks b/include/.symlinks index 696e46d..f71ec84 100644 --- a/include/.symlinks +++ b/include/.symlinks @@ -1,5 +1,9 @@ +../lib/datastruct/bitset.h +../lib/datastruct/hash.h ../lib/libdevmapper.h ../lib/libdm-file.h ../lib/libdm-event.h +../lib/mm/dbg_malloc.h +../lib/mm/pool.h ../multilog/libmultilog.h ../po/pogen.h diff --git a/include/lib.h b/include/lib.h index 9b779dc..290ec0c 100644 --- a/include/lib.h +++ b/include/lib.h @@ -25,6 +25,7 @@ #include "log.h" #include "intl.h" +#include "dbg_malloc.h" #include #include @@ -34,4 +35,7 @@ #include #include +/* Define some portable printing types */ +#define PRIsize_t "zu" + #endif diff --git a/lib/.exported_symbols b/lib/.exported_symbols index 6893784..eadcd46 100644 --- a/lib/.exported_symbols +++ b/lib/.exported_symbols @@ -29,3 +29,15 @@ dm_dir dm_format_dev dm_lib_release dm_lib_exit +dm_deptree_create +dm_deptree_free +dm_deptree_add_dev +dm_deptree_node_get_name +dm_deptree_node_get_uuid +dm_deptree_node_get_info +dm_deptree_node_num_children +dm_deptree_node_num_parents +dm_deptree_find_node +dm_deptree_next_child +dm_deptree_next_parent +dm_is_dm_major diff --git a/lib/Makefile.in b/lib/Makefile.in index 4753fbf..d90a77b 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -25,7 +25,15 @@ ifeq ($(MAKECMDGOALS),distclean) SUBDIRS += event endif -SOURCES = libdm-common.c libdm-file.c $(interface)/libdm-iface.c +SOURCES =\ + datastruct/bitset.c \ + datastruct/hash.c \ + libdm-common.c \ + libdm-file.c \ + libdm-deptree.c \ + mm/dbg_malloc.c \ + mm/pool.c \ + $(interface)/libdm-iface.c INCLUDES = -I$(interface) diff --git a/lib/datastruct/bitset.c b/lib/datastruct/bitset.c new file mode 100644 index 0000000..4962245 --- /dev/null +++ b/lib/datastruct/bitset.c @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This file is part of the device-mapper userspace tools. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "lib.h" +#include "bitset.h" + +/* FIXME: calculate this. */ +#define INT_SHIFT 5 + +bitset_t bitset_create(struct pool *mem, unsigned num_bits) +{ + unsigned n = (num_bits / BITS_PER_INT) + 2; + size_t size = sizeof(int) * n; + bitset_t bs; + + if (mem) + bs = pool_zalloc(mem, size); + else + bs = dbg_malloc(size); + + if (!bs) + return NULL; + + *bs = num_bits; + + if (!mem) + bit_clear_all(bs); + + return bs; +} + +void bitset_destroy(bitset_t bs) +{ + dbg_free(bs); +} + +void bit_union(bitset_t out, bitset_t in1, bitset_t in2) +{ + int i; + for (i = (in1[0] / BITS_PER_INT) + 1; i; i--) + out[i] = in1[i] | in2[i]; +} + +/* + * FIXME: slow + */ +static inline int _test_word(uint32_t test, int bit) +{ + while (bit < BITS_PER_INT) { + if (test & (0x1 << bit)) + return bit; + bit++; + } + + return -1; +} + +int bit_get_next(bitset_t bs, int last_bit) +{ + int bit, word; + uint32_t test; + + last_bit++; /* otherwise we'll return the same bit again */ + + while (last_bit < bs[0]) { + word = last_bit >> INT_SHIFT; + test = bs[word + 1]; + bit = last_bit & (BITS_PER_INT - 1); + + if ((bit = _test_word(test, bit)) >= 0) + return (word * BITS_PER_INT) + bit; + + last_bit = last_bit - (last_bit & (BITS_PER_INT - 1)) + + BITS_PER_INT; + } + + return -1; +} + +int bit_get_first(bitset_t bs) +{ + return bit_get_next(bs, -1); +} diff --git a/lib/datastruct/bitset.h b/lib/datastruct/bitset.h new file mode 100644 index 0000000..939e493 --- /dev/null +++ b/lib/datastruct/bitset.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This file is part of the device-mapper userspace tools. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _LVM_BITSET_H +#define _LVM_BITSET_H + +#include "pool.h" + +#include + +typedef uint32_t *bitset_t; + +bitset_t bitset_create(struct pool *mem, unsigned num_bits); +void bitset_destroy(bitset_t bs); + +void bit_union(bitset_t out, bitset_t in1, bitset_t in2); +int bit_get_first(bitset_t bs); +int bit_get_next(bitset_t bs, int last_bit); + +#define BITS_PER_INT (sizeof(int) * CHAR_BIT) + +#define bit(bs, i) \ + (bs[(i / BITS_PER_INT) + 1] & (0x1 << (i & (BITS_PER_INT - 1)))) + +#define bit_set(bs, i) \ + (bs[(i / BITS_PER_INT) + 1] |= (0x1 << (i & (BITS_PER_INT - 1)))) + +#define bit_clear(bs, i) \ + (bs[(i / BITS_PER_INT) + 1] &= ~(0x1 << (i & (BITS_PER_INT - 1)))) + +#define bit_set_all(bs) \ + memset(bs + 1, -1, ((*bs / BITS_PER_INT) + 1) * sizeof(int)) + +#define bit_clear_all(bs) \ + memset(bs + 1, 0, ((*bs / BITS_PER_INT) + 1) * sizeof(int)) + +#define bit_copy(bs1, bs2) \ + memcpy(bs1 + 1, bs2 + 1, ((*bs1 / BITS_PER_INT) + 1) * sizeof(int)) + +#endif diff --git a/lib/datastruct/hash.c b/lib/datastruct/hash.c new file mode 100644 index 0000000..6753ca7 --- /dev/null +++ b/lib/datastruct/hash.c @@ -0,0 +1,262 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This file is part of the device-mapper userspace tools. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "lib.h" +#include "hash.h" + +struct hash_node { + struct hash_node *next; + void *data; + int keylen; + char key[0]; +}; + +struct hash_table { + int num_nodes; + int num_slots; + struct hash_node **slots; +}; + +/* Permutation of the Integers 0 through 255 */ +static unsigned char _nums[] = { + 1, 14, 110, 25, 97, 174, 132, 119, 138, 170, 125, 118, 27, 233, 140, 51, + 87, 197, 177, 107, 234, 169, 56, 68, 30, 7, 173, 73, 188, 40, 36, 65, + 49, 213, 104, 190, 57, 211, 148, 223, 48, 115, 15, 2, 67, 186, 210, 28, + 12, 181, 103, 70, 22, 58, 75, 78, 183, 167, 238, 157, 124, 147, 172, + 144, + 176, 161, 141, 86, 60, 66, 128, 83, 156, 241, 79, 46, 168, 198, 41, 254, + 178, 85, 253, 237, 250, 154, 133, 88, 35, 206, 95, 116, 252, 192, 54, + 221, + 102, 218, 255, 240, 82, 106, 158, 201, 61, 3, 89, 9, 42, 155, 159, 93, + 166, 80, 50, 34, 175, 195, 100, 99, 26, 150, 16, 145, 4, 33, 8, 189, + 121, 64, 77, 72, 208, 245, 130, 122, 143, 55, 105, 134, 29, 164, 185, + 194, + 193, 239, 101, 242, 5, 171, 126, 11, 74, 59, 137, 228, 108, 191, 232, + 139, + 6, 24, 81, 20, 127, 17, 91, 92, 251, 151, 225, 207, 21, 98, 113, 112, + 84, 226, 18, 214, 199, 187, 13, 32, 94, 220, 224, 212, 247, 204, 196, + 43, + 249, 236, 45, 244, 111, 182, 153, 136, 129, 90, 217, 202, 19, 165, 231, + 71, + 230, 142, 96, 227, 62, 179, 246, 114, 162, 53, 160, 215, 205, 180, 47, + 109, + 44, 38, 31, 149, 135, 0, 216, 52, 63, 23, 37, 69, 39, 117, 146, 184, + 163, 200, 222, 235, 248, 243, 219, 10, 152, 131, 123, 229, 203, 76, 120, + 209 +}; + +static struct hash_node *_create_node(const char *str, int len) +{ + struct hash_node *n = dbg_malloc(sizeof(*n) + len); + + if (n) { + memcpy(n->key, str, len); + n->keylen = len; + } + + return n; +} + +static unsigned _hash(const char *str, uint32_t len) +{ + unsigned long h = 0, g, i; + + for (i = 0; i < len; i++) { + h <<= 4; + h += _nums[(int) *str++]; + g = h & ((unsigned long) 0xf << 16u); + if (g) { + h ^= g >> 16u; + h ^= g >> 5u; + } + } + + return h; +} + +struct hash_table *hash_create(unsigned size_hint) +{ + size_t len; + unsigned new_size = 16u; + struct hash_table *hc = dbg_malloc(sizeof(*hc)); + + if (!hc) { + stack; + return 0; + } + + memset(hc, 0, sizeof(*hc)); + + /* round size hint up to a power of two */ + while (new_size < size_hint) + new_size = new_size << 1; + + hc->num_slots = new_size; + len = sizeof(*(hc->slots)) * new_size; + if (!(hc->slots = dbg_malloc(len))) { + stack; + goto bad; + } + memset(hc->slots, 0, len); + return hc; + + bad: + dbg_free(hc->slots); + dbg_free(hc); + return 0; +} + +static void _free_nodes(struct hash_table *t) +{ + struct hash_node *c, *n; + int i; + + for (i = 0; i < t->num_slots; i++) + for (c = t->slots[i]; c; c = n) { + n = c->next; + dbg_free(c); + } +} + +void hash_destroy(struct hash_table *t) +{ + _free_nodes(t); + dbg_free(t->slots); + dbg_free(t); +} + +static inline struct hash_node **_find(struct hash_table *t, const char *key, + uint32_t len) +{ + unsigned h = _hash(key, len) & (t->num_slots - 1); + struct hash_node **c; + + for (c = &t->slots[h]; *c; c = &((*c)->next)) + if (!memcmp(key, (*c)->key, len)) + break; + + return c; +} + +void *hash_lookup_binary(struct hash_table *t, const char *key, + uint32_t len) +{ + struct hash_node **c = _find(t, key, len); + return *c ? (*c)->data : 0; +} + +int hash_insert_binary(struct hash_table *t, const char *key, + uint32_t len, void *data) +{ + struct hash_node **c = _find(t, key, len); + + if (*c) + (*c)->data = data; + else { + struct hash_node *n = _create_node(key, len); + + if (!n) + return 0; + + n->data = data; + n->next = 0; + *c = n; + t->num_nodes++; + } + + return 1; +} + +void hash_remove_binary(struct hash_table *t, const char *key, + uint32_t len) +{ + struct hash_node **c = _find(t, key, len); + + if (*c) { + struct hash_node *old = *c; + *c = (*c)->next; + dbg_free(old); + t->num_nodes--; + } +} + +void *hash_lookup(struct hash_table *t, const char *key) +{ + return hash_lookup_binary(t, key, strlen(key) + 1); +} + +int hash_insert(struct hash_table *t, const char *key, void *data) +{ + return hash_insert_binary(t, key, strlen(key) + 1, data); +} + +void hash_remove(struct hash_table *t, const char *key) +{ + hash_remove_binary(t, key, strlen(key) + 1); +} + +unsigned hash_get_num_entries(struct hash_table *t) +{ + return t->num_nodes; +} + +void hash_iter(struct hash_table *t, iterate_fn f) +{ + struct hash_node *c; + int i; + + for (i = 0; i < t->num_slots; i++) + for (c = t->slots[i]; c; c = c->next) + f(c->data); +} + +void hash_wipe(struct hash_table *t) +{ + _free_nodes(t); + memset(t->slots, 0, sizeof(struct hash_node *) * t->num_slots); + t->num_nodes = 0; +} + +char *hash_get_key(struct hash_table *t, struct hash_node *n) +{ + return n->key; +} + +void *hash_get_data(struct hash_table *t, struct hash_node *n) +{ + return n->data; +} + +static struct hash_node *_next_slot(struct hash_table *t, unsigned s) +{ + struct hash_node *c = NULL; + int i; + + for (i = s; i < t->num_slots && !c; i++) + c = t->slots[i]; + + return c; +} + +struct hash_node *hash_get_first(struct hash_table *t) +{ + return _next_slot(t, 0); +} + +struct hash_node *hash_get_next(struct hash_table *t, struct hash_node *n) +{ + unsigned h = _hash(n->key, n->keylen) & (t->num_slots - 1); + return n->next ? n->next : _next_slot(t, h + 1); +} diff --git a/lib/datastruct/hash.h b/lib/datastruct/hash.h new file mode 100644 index 0000000..0f745e5 --- /dev/null +++ b/lib/datastruct/hash.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This file is part of the device-mapper userspace tools. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _LVM_HASH_H +#define _LVM_HASH_H + +struct hash_table; +struct hash_node; + +typedef void (*iterate_fn) (void *data); + +struct hash_table *hash_create(unsigned size_hint); +void hash_destroy(struct hash_table *t); +void hash_wipe(struct hash_table *t); + +void *hash_lookup(struct hash_table *t, const char *key); +int hash_insert(struct hash_table *t, const char *key, void *data); +void hash_remove(struct hash_table *t, const char *key); + +void *hash_lookup_binary(struct hash_table *t, const char *key, uint32_t len); +int hash_insert_binary(struct hash_table *t, const char *key, uint32_t len, + void *data); +void hash_remove_binary(struct hash_table *t, const char *key, uint32_t len); + +unsigned hash_get_num_entries(struct hash_table *t); +void hash_iter(struct hash_table *t, iterate_fn f); + +char *hash_get_key(struct hash_table *t, struct hash_node *n); +void *hash_get_data(struct hash_table *t, struct hash_node *n); +struct hash_node *hash_get_first(struct hash_table *t); +struct hash_node *hash_get_next(struct hash_table *t, struct hash_node *n); + +#define hash_iterate(v, h) \ + for (v = hash_get_first(h); v; \ + v = hash_get_next(h, v)) + +#endif diff --git a/lib/ioctl/libdm-iface.c b/lib/ioctl/libdm-iface.c index f7700d1..b034038 100644 --- a/lib/ioctl/libdm-iface.c +++ b/lib/ioctl/libdm-iface.c @@ -17,6 +17,7 @@ #include "libdm-targets.h" #include "libdm-common.h" #include "libdm-file.h" +#include "bitset.h" #ifdef DM_COMPAT # include "libdm-compat.h" @@ -56,10 +57,13 @@ #define PROC_DEVICES "/proc/devices" #define MISC_NAME "misc" +#define NUMBER_OF_MAJORS 4096 + /* dm major version no for running kernel */ static int _dm_version = DM_VERSION_MAJOR; static int _log_suppress = 0; +static bitset_t _dm_bitset = NULL; static int _control_fd = -1; static int _version_checked = 0; static int _version_ok = 1; @@ -119,12 +123,17 @@ static void *_align(void *ptr, unsigned int a) } #ifdef DM_IOCTLS +/* + * Set number to NULL to populate _dm_bitset - otherwise first + * match is returned. + */ static int _get_proc_number(const char *file, const char *name, uint32_t *number) { FILE *fl; char nm[256]; int c; + uint32_t num; if (!(fl = fopen(file, "r"))) { log_error("%s: fopen failed: %s", file, strerror(errno)); @@ -132,10 +141,14 @@ static int _get_proc_number(const char *file, const char *name, } while (!feof(fl)) { - if (fscanf(fl, "%d %255s\n", number, &nm[0]) == 2) { + if (fscanf(fl, "%d %255s\n", &num, &nm[0]) == 2) { if (!strcmp(name, nm)) { - fclose(fl); - return 1; + if (number) { + *number = num; + fclose(fl); + return 1; + } + bit_set(_dm_bitset, num); } } else do { c = fgetc(fl); @@ -143,8 +156,12 @@ static int _get_proc_number(const char *file, const char *name, } fclose(fl); - log_error("%s: No entry for %s found", file, name); - return 0; + if (number) { + log_error("%s: No entry for %s found", file, name); + return 0; + } + + return 1; } static int _control_device_number(uint32_t *major, uint32_t *minor) @@ -230,6 +247,35 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor) } #endif +static int _create_dm_bitset(void) +{ +#ifdef DM_IOCTLS + if (_dm_bitset) + return 1; + + if (!(_dm_bitset = bitset_create(NULL, NUMBER_OF_MAJORS))) + return 0; + + if (!_get_proc_number(PROC_DEVICES, DM_NAME, NULL)) { + bitset_destroy(_dm_bitset); + _dm_bitset = NULL; + return 0; + } + + return 1; +#else + return 0; +#endif +} + +int dm_is_dm_major(uint32_t major) +{ + if (!_create_dm_bitset()) + return 0; + + return bit(_dm_bitset, major) ? 1 : 0; +} + static int _open_control(void) { #ifdef DM_IOCTLS @@ -253,6 +299,11 @@ static int _open_control(void) goto error; } + if (!_create_dm_bitset()) { + log_error("Failed to set up list of device-mapper major numbers"); + return 0; + } + return 1; error: @@ -269,27 +320,27 @@ void dm_task_destroy(struct dm_task *dmt) for (t = dmt->head; t; t = n) { n = t->next; - free(t->params); - free(t->type); - free(t); + dbg_free(t->params); + dbg_free(t->type); + dbg_free(t); } if (dmt->dev_name) - free(dmt->dev_name); + dbg_free(dmt->dev_name); if (dmt->newname) - free(dmt->newname); + dbg_free(dmt->newname); if (dmt->message) - free(dmt->message); + dbg_free(dmt->message); if (dmt->dmi.v4) - free(dmt->dmi.v4); + dbg_free(dmt->dmi.v4); if (dmt->uuid) - free(dmt->uuid); + dbg_free(dmt->uuid); - free(dmt); + dbg_free(dmt); } /* @@ -470,7 +521,7 @@ static struct dm_ioctl_v1 *_flatten_v1(struct dm_task *dmt) if (len < min_size) len = min_size; - if (!(dmi = malloc(len))) + if (!(dmi = dbg_malloc(len))) return NULL; memset(dmi, 0, len); @@ -519,7 +570,7 @@ static struct dm_ioctl_v1 *_flatten_v1(struct dm_task *dmt) return dmi; bad: - free(dmi); + dbg_free(dmi); return NULL; } @@ -670,7 +721,7 @@ static int _dm_task_run_v1(struct dm_task *dmt) dmt->type = DM_DEVICE_INFO; if (!dm_task_run(dmt)) goto bad; - free(dmi); /* We'll use what info returned */ + dbg_free(dmi); /* We'll use what info returned */ return 1; } @@ -678,7 +729,7 @@ static int _dm_task_run_v1(struct dm_task *dmt) return 1; bad: - free(dmi); + dbg_free(dmi); return 0; } @@ -918,7 +969,7 @@ int dm_task_set_ro(struct dm_task *dmt) int dm_task_set_newname(struct dm_task *dmt, const char *newname) { - if (!(dmt->newname = strdup(newname))) { + if (!(dmt->newname = dbg_strdup(newname))) { log_error("dm_task_set_newname: strdup(%s) failed", newname); return 0; } @@ -928,7 +979,7 @@ int dm_task_set_newname(struct dm_task *dmt, const char *newname) int dm_task_set_message(struct dm_task *dmt, const char *message) { - if (!(dmt->message = strdup(message))) { + if (!(dmt->message = dbg_strdup(message))) { log_error("dm_task_set_message: strdup(%s) failed", message); return 0; } @@ -967,7 +1018,7 @@ int dm_task_set_event_nr(struct dm_task *dmt, uint32_t event_nr) struct target *create_target(uint64_t start, uint64_t len, const char *type, const char *params) { - struct target *t = malloc(sizeof(*t)); + struct target *t = dbg_malloc(sizeof(*t)); if (!t) { log_error("create_target: malloc(%d) failed", sizeof(*t)); @@ -976,12 +1027,12 @@ struct target *create_target(uint64_t start, uint64_t len, const char *type, memset(t, 0, sizeof(*t)); - if (!(t->params = strdup(params))) { + if (!(t->params = dbg_strdup(params))) { log_error("create_target: strdup(params) failed"); goto bad; } - if (!(t->type = strdup(type))) { + if (!(t->type = dbg_strdup(type))) { log_error("create_target: strdup(type) failed"); goto bad; } @@ -991,9 +1042,9 @@ struct target *create_target(uint64_t start, uint64_t len, const char *type, return t; bad: - free(t->params); - free(t->type); - free(t); + dbg_free(t->params); + dbg_free(t->type); + dbg_free(t); return NULL; } @@ -1091,7 +1142,7 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count) while (repeat_count--) len *= 2; - if (!(dmi = malloc(len))) + if (!(dmi = dbg_malloc(len))) return NULL; memset(dmi, 0, len); @@ -1149,7 +1200,7 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count) return dmi; bad: - free(dmi); + dbg_free(dmi); return NULL; } @@ -1284,7 +1335,7 @@ static int _create_and_load_v4(struct dm_task *dmt) /* Use the original structure last so the info will be correct */ dmt->type = DM_DEVICE_RESUME; - free(dmt->uuid); + dbg_free(dmt->uuid); dmt->uuid = NULL; r = dm_task_run(dmt); @@ -1332,7 +1383,7 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command, log_error("device-mapper ioctl " "cmd %d failed: %s", _IOC_NR(command), strerror(errno)); - free(dmi); + dbg_free(dmi); return NULL; } } @@ -1384,7 +1435,7 @@ repeat_ioctl: case DM_DEVICE_TABLE: case DM_DEVICE_WAITEVENT: _ioctl_buffer_double_factor++; - free(dmi); + dbg_free(dmi); goto repeat_ioctl; default: log_error("Warning: libdevmapper buffer too small for data"); @@ -1430,7 +1481,7 @@ repeat_ioctl: return 1; bad: - free(dmi); + dbg_free(dmi); return 0; } @@ -1446,6 +1497,10 @@ void dm_lib_release(void) void dm_lib_exit(void) { dm_lib_release(); + if (_dm_bitset) + bitset_destroy(_dm_bitset); + _dm_bitset = NULL; + dump_memory(); _version_ok = 1; _version_checked = 0; } diff --git a/lib/libdevmapper.h b/lib/libdevmapper.h index adb60ae..cfee262 100644 --- a/lib/libdevmapper.h +++ b/lib/libdevmapper.h @@ -165,8 +165,71 @@ int dm_task_run(struct dm_task *dmt); int dm_set_dev_dir(const char *dir); const char *dm_dir(void); -/* Release library resources */ +/* + * Determine whether a major number belongs to device-mapper or not. + */ +int dm_is_dm_major(uint32_t major); + +/* + * Release library resources + */ void dm_lib_release(void); void dm_lib_exit(void) __attribute((destructor)); +/***************************** + * Dependency tree functions * + *****************************/ +struct deptree; +struct deptree_node; + +/* + * Initialise an empty dependency tree. + * + * The tree consists of a root node together with one node for each mapped + * device which has child nodes for each device referenced in its table. + * + * Every node in the tree has one or more children and one or more parents. + * + * The root node is the parent/child of every node that doesn't have other + * parents/children. + */ +struct deptree *dm_deptree_create(void); +void dm_deptree_free(struct deptree *deptree); + +/* + * Add nodes to the tree for a given device and all the devices it uses. + */ +int dm_deptree_add_dev(struct deptree *deptree, uint32_t major, uint32_t minor); + +/* + * Search for a node in the tree. + * Set major and minor to 0 to get the root node. + */ +struct deptree_node *dm_deptree_find_node(struct deptree *deptree, + uint32_t major, + uint32_t minor); + +/* + * Use this to walk through all children of a given node. + * Set handle to NULL in first call. + * Returns NULL after the last child. + * Set inverted to use inverted tree. + */ +struct deptree_node *dm_deptree_next_child(void **handle, + struct deptree_node *parent, + uint32_t inverted); + +/* + * Get properties of a node. + */ +const char *dm_deptree_node_get_name(struct deptree_node *node); +const char *dm_deptree_node_get_uuid(struct deptree_node *node); +const struct dm_info *dm_deptree_node_get_info(struct deptree_node *node); + +/* + * Returns the number of children of the given node (excluding the root node). + * Set inverted for the number of parents. + */ +int dm_deptree_node_num_children(struct deptree_node *node, uint32_t inverted); + #endif /* LIB_DEVICE_MAPPER_H */ diff --git a/lib/libdm-common.c b/lib/libdm-common.c index 20f2702..e9ea1bc 100644 --- a/lib/libdm-common.c +++ b/lib/libdm-common.c @@ -93,7 +93,7 @@ int dm_get_library_version(char *version, size_t size) struct dm_task *dm_task_create(int type) { - struct dm_task *dmt = malloc(sizeof(*dmt)); + struct dm_task *dmt = dbg_malloc(sizeof(*dmt)); if (!dmt) { log_error("dm_task_create: malloc(%d) failed", sizeof(*dmt)); @@ -123,7 +123,7 @@ int dm_task_set_name(struct dm_task *dmt, const char *name) struct stat st1, st2; if (dmt->dev_name) { - free(dmt->dev_name); + dbg_free(dmt->dev_name); dmt->dev_name = NULL; } @@ -143,7 +143,7 @@ int dm_task_set_name(struct dm_task *dmt, const char *name) name = pos + 1; } - if (!(dmt->dev_name = strdup(name))) { + if (!(dmt->dev_name = dbg_strdup(name))) { log_error("dm_task_set_name: strdup(%s) failed", name); return 0; } @@ -154,11 +154,11 @@ int dm_task_set_name(struct dm_task *dmt, const char *name) int dm_task_set_uuid(struct dm_task *dmt, const char *uuid) { if (dmt->uuid) { - free(dmt->uuid); + dbg_free(dmt->uuid); dmt->uuid = NULL; } - if (!(dmt->uuid = strdup(uuid))) { + if (!(dmt->uuid = dbg_strdup(uuid))) { log_error("dm_task_set_uuid: strdup(%s) failed", uuid); return 0; } @@ -381,7 +381,7 @@ static int _stack_node_op(node_op_t type, const char *dev_name, uint32_t major, size_t len = strlen(dev_name) + strlen(old_name) + 2; char *pos; - if (!(nop = malloc(sizeof(*nop) + len))) { + if (!(nop = dbg_malloc(sizeof(*nop) + len))) { log_error("Insufficient memory to stack mknod operation"); return 0; } @@ -412,7 +412,7 @@ static void _pop_node_ops(void) _do_node_op(nop->type, nop->dev_name, nop->major, nop->minor, nop->uid, nop->gid, nop->mode, nop->old_name); list_del(&nop->list); - free(nop); + dbg_free(nop); } } diff --git a/lib/libdm-deptree.c b/lib/libdm-deptree.c new file mode 100644 index 0000000..daa5936 --- /dev/null +++ b/lib/libdm-deptree.c @@ -0,0 +1,403 @@ +/* + * Copyright (C) 2005 Red Hat, Inc. All rights reserved. + * + * This file is part of the device-mapper userspace tools. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "lib.h" +#include "libdm-targets.h" +#include "libdm-common.h" +#include "list.h" +#include "kdev_t.h" +#include "pool.h" +#include "hash.h" + +#include +#include + +#include + +struct deptree_node { + struct deptree *deptree; + + const char *name; + const char *uuid; + struct dm_info info; + + struct list uses; /* Nodes this node uses */ + struct list used_by; /* Nodes that use this node */ +}; + +struct deptree { + struct pool *mem; + struct hash_table *devs; + struct deptree_node root; +}; + +struct deptree_link { + struct list list; + struct deptree_node *node; +}; + +struct deptree *dm_deptree_create(void) +{ + struct deptree *deptree; + + if (!(deptree = dbg_malloc(sizeof(*deptree)))) { + log_error("dm_deptree_create malloc failed"); + return NULL; + } + + memset(deptree, 0, sizeof(*deptree)); + deptree->root.deptree = deptree; + list_init(&deptree->root.uses); + list_init(&deptree->root.used_by); + + if (!(deptree->mem = pool_create("deptree", 1024))) { + log_error("deptree pool creation failed"); + dbg_free(deptree); + return NULL; + } + + if (!(deptree->devs = hash_create(8))) { + log_error("deptree hash creation failed"); + pool_destroy(deptree->mem); + dbg_free(deptree); + return NULL; + } + + return deptree; +} + +void dm_deptree_free(struct deptree *deptree) +{ + if (!deptree) + return; + + hash_destroy(deptree->devs); + pool_destroy(deptree->mem); + dbg_free(deptree); +} + +static int _nodes_are_linked(struct deptree_node *parent, + struct deptree_node *child) +{ + struct deptree_link *dlink; + + list_iterate_items(dlink, &parent->uses) { + if (dlink->node == child) + return 1; + } + + return 0; +} + +static int _link(struct list *list, struct deptree_node *node) +{ + struct deptree_link *dlink; + + if (!(dlink = pool_alloc(node->deptree->mem, sizeof(*dlink)))) { + log_error("deptree link allocation failed"); + return 0; + } + + dlink->node = node; + list_add(list, &dlink->list); + + return 1; +} + +static int _link_nodes(struct deptree_node *parent, + struct deptree_node *child) +{ + if (_nodes_are_linked(parent, child)) + return 1; + + if (!_link(&parent->uses, child)) + return 0; + + if (!_link(&child->used_by, parent)) + return 0; + + return 1; +} + +static void _unlink(struct list *list, struct deptree_node *node) +{ + struct deptree_link *dlink; + + list_iterate_items(dlink, list) { + if (dlink->node == node) { + list_del(&dlink->list); + break; + } + } +} + +static void _unlink_nodes(struct deptree_node *parent, + struct deptree_node *child) +{ + if (!_nodes_are_linked(parent, child)) + return; + + _unlink(&parent->uses, child); + _unlink(&child->used_by, parent); +} + +static void _remove_from_toplevel(struct deptree_node *node) +{ + return _unlink_nodes(&node->deptree->root, node); +} + +static int _add_to_bottomlevel(struct deptree_node *node) +{ + return _link_nodes(node, &node->deptree->root); +} + +static struct deptree_node *_create_deptree_node(struct deptree *deptree, + struct deptree_node *parent, + const char *name, + const char *uuid, + struct dm_info *info) +{ + struct deptree_node *node; + uint64_t dev; + + if (!(node = pool_zalloc(deptree->mem, sizeof(*node)))) { + log_error("_create_deptree_node alloc failed"); + return NULL; + } + + node->deptree = deptree; + + node->name = name; + node->uuid = uuid; + node->info = *info; + + list_init(&node->uses); + list_init(&node->used_by); + + dev = MKDEV(info->major, info->minor); + + if (!hash_insert_binary(deptree->devs, (const char *) &dev, + sizeof(dev), node)) { + log_error("deptree node hash insertion failed"); + pool_free(deptree->mem, node); + return NULL; + } + + return node; +} + +static struct deptree_node *_find_deptree_node(struct deptree *deptree, + uint32_t major, uint32_t minor) +{ + uint64_t dev = MKDEV(major, minor); + + return hash_lookup_binary(deptree->devs, (const char *) &dev, + sizeof(dev)); +} + +static int _deps(struct dm_task **dmt, struct pool *mem, uint32_t major, uint32_t minor, + const char **name, const char **uuid, + struct dm_info *info, struct dm_deps **deps) +{ + memset(info, 0, sizeof(*info)); + + if (!dm_is_dm_major(major)) { + *name = ""; + *uuid = ""; + *deps = NULL; + info->major = major; + info->minor = minor; + info->exists = 0; + return 1; + } + + if (!(*dmt = dm_task_create(DM_DEVICE_DEPS))) { + log_error("deps dm_task creation failed"); + return 0; + } + + if (!dm_task_set_major(*dmt, major)) + goto failed; + + if (!dm_task_set_minor(*dmt, minor)) + goto failed; + + if (!dm_task_run(*dmt)) + goto failed; + + if (!dm_task_get_info(*dmt, info)) + goto failed; + + if (!info->exists) { + *name = ""; + *uuid = ""; + *deps = NULL; + } else { + if (info->major != major) { + log_error("Inconsistent deptree major number: %u != %u", + major, info->major); + goto failed; + } + if (info->minor != minor) { + log_error("Inconsistent deptree minor number: %u != %u", + minor, info->minor); + goto failed; + } + if (!(*name = pool_strdup(mem, dm_task_get_name(*dmt)))) { + log_error("name pool_strdup failed"); + goto failed; + } + if (!(*uuid = pool_strdup(mem, dm_task_get_uuid(*dmt)))) { + log_error("uuid pool_strdup failed"); + goto failed; + } + *deps = dm_task_get_deps(*dmt); + } + + return 1; + +failed: + dm_task_destroy(*dmt); + return 0; +} + +static int _add_dev(struct deptree *deptree, struct deptree_node *parent, + uint32_t major, uint32_t minor) +{ + struct dm_task *dmt = NULL; + struct dm_info info; + struct dm_deps *deps = NULL; + const char *name = NULL; + const char *uuid = NULL; + struct deptree_node *node; + uint32_t i; + int r = 0; + int new = 0; + + /* Already in tree? */ + if (!(node = _find_deptree_node(deptree, major, minor))) { + if (!_deps(&dmt, deptree->mem, major, minor, &name, &uuid, &info, &deps)) + return 0; + + if (!(node = _create_deptree_node(deptree, node, name, uuid, + &info))) + goto out; + new = 1; + } + + /* If new parent not root node, remove any existing root node parent */ + if (parent != &deptree->root) + _remove_from_toplevel(node); + + /* Create link to parent. Use root node only if no other parents. */ + if ((parent != &deptree->root) || !dm_deptree_node_num_children(node, 1)) + if (!_link_nodes(parent, node)) + goto out; + + /* If node was already in tree, no need to recurse. */ + if (!new) + return 1; + + /* Can't recurse if not a mapped device or there are no dependencies */ + if (!node->info.exists || !deps->count) { + if (!_add_to_bottomlevel(node)) + goto out; + return 1; + } + + /* Add dependencies to tree */ + for (i = 0; i < deps->count; i++) + if (!_add_dev(deptree, node, MAJOR(deps->device[i]), + MINOR(deps->device[i]))) + goto out; + + r = 1; +out: + if (dmt) + dm_task_destroy(dmt); + + return r; +} + +int dm_deptree_add_dev(struct deptree *deptree, uint32_t major, uint32_t minor) +{ + return _add_dev(deptree, &deptree->root, major, minor); +} + +const char *dm_deptree_node_get_name(struct deptree_node *node) +{ + return node->info.exists ? node->name : ""; +} + +const char *dm_deptree_node_get_uuid(struct deptree_node *node) +{ + return node->info.exists ? node->uuid : ""; +} + +const struct dm_info *dm_deptree_node_get_info(struct deptree_node *node) +{ + return &node->info; +} + +int dm_deptree_node_num_children(struct deptree_node *node, uint32_t inverted) +{ + if (inverted) { + if (_nodes_are_linked(&node->deptree->root, node)) + return 0; + return list_size(&node->used_by); + } + + if (_nodes_are_linked(node, &node->deptree->root)) + return 0; + + return list_size(&node->uses); +} + +/* + * Set major and minor to zero for root of tree. + */ +struct deptree_node *dm_deptree_find_node(struct deptree *deptree, + uint32_t major, + uint32_t minor) +{ + if (!major && !minor) + return &deptree->root; + + return _find_deptree_node(deptree, major, minor); +} + +/* + * First time set *handle to NULL. + * Set inverted to invert the tree. + */ +struct deptree_node *dm_deptree_next_child(void **handle, + struct deptree_node *parent, + uint32_t inverted) +{ + struct list **dlink = (struct list **) handle; + struct list *use_list; + + if (inverted) + use_list = &parent->used_by; + else + use_list = &parent->uses; + + if (!*dlink) + *dlink = list_first(use_list); + else + *dlink = list_next(use_list, *dlink); + + return (*dlink) ? list_item(*dlink, struct deptree_link)->node : NULL; +} + diff --git a/lib/mm/dbg_malloc.c b/lib/mm/dbg_malloc.c new file mode 100644 index 0000000..6c2b4d1 --- /dev/null +++ b/lib/mm/dbg_malloc.c @@ -0,0 +1,247 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This file is part of the device-mapper userspace tools. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "lib.h" +#include "dbg_malloc.h" + +#include +#include + +char *dbg_strdup(const char *str) +{ + char *ret = dbg_malloc(strlen(str) + 1); + + if (ret) + strcpy(ret, str); + + return ret; +} + +#ifdef DEBUG_MEM + +struct memblock { + struct memblock *prev, *next; /* All allocated blocks are linked */ + size_t length; /* Size of the requested block */ + int id; /* Index of the block */ + const char *file; /* File that allocated */ + int line; /* Line that allocated */ + void *magic; /* Address of this block */ +}; + +static struct { + unsigned block_serialno;/* Non-decreasing serialno of block */ + unsigned blocks_allocated; /* Current number of blocks allocated */ + unsigned blocks_max; /* Max no of concurrently-allocated blocks */ + unsigned int bytes, mbytes; + +} _mem_stats = { +0, 0, 0, 0, 0}; + +static struct memblock *_head = 0; +static struct memblock *_tail = 0; + +void *malloc_aux(size_t s, const char *file, int line) +{ + struct memblock *nb; + size_t tsize = s + sizeof(*nb) + sizeof(unsigned long); + + if (s > 50000000) { + log_error("Huge memory allocation (size %" PRIsize_t + ") rejected - metadata corruption?", s); + return 0; + } + + if (!(nb = malloc(tsize))) { + log_error("couldn't allocate any memory, size = %" PRIsize_t, + s); + return 0; + } + + /* set up the file and line info */ + nb->file = file; + nb->line = line; + +#ifdef BOUNDS_CHECK + bounds_check(); +#endif + + /* setup fields */ + nb->magic = nb + 1; + nb->length = s; + nb->id = ++_mem_stats.block_serialno; + nb->next = 0; + nb->prev = _tail; + + /* link to tail of the list */ + if (!_head) + _head = _tail = nb; + else { + _tail->next = nb; + _tail = nb; + } + + /* stomp a pretty pattern across the new memory + and fill in the boundary bytes */ + { + char *ptr = (char *) (nb + 1); + size_t i; + for (i = 0; i < s; i++) + *ptr++ = i & 0x1 ? (char) 0xba : (char) 0xbe; + + for (i = 0; i < sizeof(unsigned long); i++) + *ptr++ = (char) nb->id; + } + + _mem_stats.blocks_allocated++; + if (_mem_stats.blocks_allocated > _mem_stats.blocks_max) + _mem_stats.blocks_max = _mem_stats.blocks_allocated; + + _mem_stats.bytes += s; + if (_mem_stats.bytes > _mem_stats.mbytes) + _mem_stats.mbytes = _mem_stats.bytes; + + /* log_debug("Allocated: %u %u %u", nb->id, _mem_stats.blocks_allocated, + _mem_stats.bytes); */ + + return nb + 1; +} + +void free_aux(void *p) +{ + char *ptr; + size_t i; + struct memblock *mb = ((struct memblock *) p) - 1; + if (!p) + return; + +#ifdef BOUNDS_CHECK + bounds_check(); +#endif + + /* sanity check */ + assert(mb->magic == p); + + /* check data at the far boundary */ + ptr = ((char *) mb) + sizeof(struct memblock) + mb->length; + for (i = 0; i < sizeof(unsigned long); i++) + if (*ptr++ != (char) mb->id) + assert(!"Damage at far end of block"); + + /* have we freed this before ? */ + assert(mb->id != 0); + mb->id = 0; + + /* stomp a different pattern across the memory */ + ptr = ((char *) mb) + sizeof(struct memblock); + for (i = 0; i < mb->length; i++) + *ptr++ = i & 1 ? (char) 0xde : (char) 0xad; + + /* unlink */ + if (mb->prev) + mb->prev->next = mb->next; + else + _head = mb->next; + + if (mb->next) + mb->next->prev = mb->prev; + else + _tail = mb->prev; + + assert(_mem_stats.blocks_allocated); + _mem_stats.blocks_allocated--; + _mem_stats.bytes -= mb->length; + + /* free the memory */ + free(mb); +} + +void *realloc_aux(void *p, unsigned int s, const char *file, int line) +{ + void *r; + struct memblock *mb = ((struct memblock *) p) - 1; + + r = malloc_aux(s, file, line); + + if (p) { + memcpy(r, p, mb->length); + free_aux(p); + } + + return r; +} + +int dump_memory(void) +{ + unsigned long tot = 0; + struct memblock *mb; + char str[32]; + size_t c; + + if (_head) + log_very_verbose("You have a memory leak:"); + + for (mb = _head; mb; mb = mb->next) { + for (c = 0; c < sizeof(str) - 1; c++) { + if (c >= mb->length) + str[c] = ' '; + else if (*(char *)(mb->magic + c) == '\0') + str[c] = '\0'; + else if (*(char *)(mb->magic + c) < ' ') + str[c] = '?'; + else + str[c] = *(char *)(mb->magic + c); + } + str[sizeof(str) - 1] = '\0'; + + _log(_LOG_INFO, mb->file, mb->line, + "block %d at %p, size %" PRIsize_t "\t [%s]", + mb->id, mb->magic, mb->length, str); + tot += mb->length; + } + + if (_head) + log_very_verbose("%ld bytes leaked in total", tot); + + return 1; +} + +void bounds_check(void) +{ + struct memblock *mb = _head; + while (mb) { + size_t i; + char *ptr = ((char *) (mb + 1)) + mb->length; + for (i = 0; i < sizeof(unsigned long); i++) + if (*ptr++ != (char) mb->id) + assert(!"Memory smash"); + + mb = mb->next; + } +} + +#else + +void *malloc_aux(size_t s, const char *file, int line) +{ + if (s > 50000000) { + log_error("Huge memory allocation (size %" PRIsize_t + ") rejected - metadata corruption?", s); + return 0; + } + + return malloc(s); +} + +#endif diff --git a/lib/mm/dbg_malloc.h b/lib/mm/dbg_malloc.h new file mode 100644 index 0000000..3f6d08d --- /dev/null +++ b/lib/mm/dbg_malloc.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This file is part of the device-mapper userspace tools. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _LVM_DBG_MALLOC_H +#define _LVM_DBG_MALLOC_H + +#include +#include + +void *malloc_aux(size_t s, const char *file, int line); +#define dbg_malloc(s) malloc_aux((s), __FILE__, __LINE__) + +char *dbg_strdup(const char *str); + +#ifdef DEBUG_MEM + +void free_aux(void *p); +void *realloc_aux(void *p, unsigned int s, const char *file, int line); +int dump_memory(void); +void bounds_check(void); + +# define dbg_free(p) free_aux(p) +# define dbg_realloc(p, s) realloc_aux(p, s, __FILE__, __LINE__) + +#else + +# define dbg_free(p) free(p) +# define dbg_realloc(p, s) realloc(p, s) +# define dump_memory() +# define bounds_check() + +#endif + +#endif diff --git a/lib/mm/pool-debug.c b/lib/mm/pool-debug.c new file mode 100644 index 0000000..de3525d --- /dev/null +++ b/lib/mm/pool-debug.c @@ -0,0 +1,263 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This file is part of the device-mapper userspace tools. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "lib.h" +#include "pool.h" + +struct block { + struct block *next; + size_t size; + void *data; +}; + +typedef struct { + unsigned block_serialno; /* Non-decreasing serialno of block */ + unsigned blocks_allocated; /* Current number of blocks allocated */ + unsigned blocks_max; /* Max no of concurrently-allocated blocks */ + unsigned int bytes, maxbytes; +} pool_stats; + +struct pool { + const char *name; + + int begun; + struct block *object; + + struct block *blocks; + struct block *tail; + + pool_stats stats; +}; + +/* by default things come out aligned for doubles */ +#define DEFAULT_ALIGNMENT __alignof__ (double) + +struct pool *pool_create(const char *name, size_t chunk_hint) +{ + struct pool *mem = dbg_malloc(sizeof(*mem)); + + if (!mem) { + log_error("Couldn't create memory pool %s (size %" + PRIsize_t ")", name, sizeof(*mem)); + return NULL; + } + + mem->name = name; + mem->begun = 0; + mem->object = 0; + mem->blocks = mem->tail = NULL; + + mem->stats.block_serialno = 0; + mem->stats.blocks_allocated = 0; + mem->stats.blocks_max = 0; + mem->stats.bytes = 0; + mem->stats.maxbytes = 0; + +#ifdef DEBUG_POOL + log_debug("Created mempool %s", name); +#endif + + return mem; +} + +static void _free_blocks(struct pool *p, struct block *b) +{ + struct block *n; + + while (b) { + p->stats.bytes -= b->size; + p->stats.blocks_allocated--; + + n = b->next; + dbg_free(b->data); + dbg_free(b); + b = n; + } +} + +static void _pool_stats(struct pool *p, const char *action) +{ +#ifdef DEBUG_POOL + log_debug("%s mempool %s: %u/%u bytes, %u/%u blocks, " + "%u allocations)", action, p->name, p->stats.bytes, + p->stats.maxbytes, p->stats.blocks_allocated, + p->stats.blocks_max, p->stats.block_serialno); +#else + ; +#endif +} + +void pool_destroy(struct pool *p) +{ + _pool_stats(p, "Destroying"); + _free_blocks(p, p->blocks); + dbg_free(p); +} + +void *pool_alloc(struct pool *p, size_t s) +{ + return pool_alloc_aligned(p, s, DEFAULT_ALIGNMENT); +} + +static void _append_block(struct pool *p, struct block *b) +{ + if (p->tail) { + p->tail->next = b; + p->tail = b; + } else + p->blocks = p->tail = b; + + p->stats.block_serialno++; + p->stats.blocks_allocated++; + if (p->stats.blocks_allocated > p->stats.blocks_max) + p->stats.blocks_max = p->stats.blocks_allocated; + + p->stats.bytes += b->size; + if (p->stats.bytes > p->stats.maxbytes) + p->stats.maxbytes = p->stats.bytes; +} + +static struct block *_new_block(size_t s, unsigned alignment) +{ + static const char *_oom = "Out of memory"; + + /* FIXME: I'm currently ignoring the alignment arg. */ + size_t len = sizeof(struct block) + s; + struct block *b = dbg_malloc(len); + + /* + * Too lazy to implement alignment for debug version, and + * I don't think LVM will use anything but default + * align. + */ + assert(alignment == DEFAULT_ALIGNMENT); + + if (!b) { + log_err(_oom); + return NULL; + } + + if (!(b->data = dbg_malloc(s))) { + log_err(_oom); + dbg_free(b); + return NULL; + } + + b->next = NULL; + b->size = s; + + return b; +} + +void *pool_alloc_aligned(struct pool *p, size_t s, unsigned alignment) +{ + struct block *b = _new_block(s, alignment); + + if (!b) + return NULL; + + _append_block(p, b); + + return b->data; +} + +void pool_empty(struct pool *p) +{ + _pool_stats(p, "Emptying"); + _free_blocks(p, p->blocks); + p->blocks = p->tail = NULL; +} + +void pool_free(struct pool *p, void *ptr) +{ + struct block *b, *prev = NULL; + + _pool_stats(p, "Freeing (before)"); + + for (b = p->blocks; b; b = b->next) { + if (b->data == ptr) + break; + prev = b; + } + + /* + * If this fires then you tried to free a + * pointer that either wasn't from this + * pool, or isn't the start of a block. + */ + assert(b); + + _free_blocks(p, b); + + if (prev) { + p->tail = prev; + prev->next = NULL; + } else + p->blocks = p->tail = NULL; + + _pool_stats(p, "Freeing (after)"); +} + +int pool_begin_object(struct pool *p, size_t init_size) +{ + assert(!p->begun); + p->begun = 1; + return 1; +} + +int pool_grow_object(struct pool *p, const void *buffer, size_t delta) +{ + struct block *new; + size_t size = delta; + + assert(p->begun); + + if (p->object) + size += p->object->size; + + if (!(new = _new_block(size, DEFAULT_ALIGNMENT))) { + log_err("Couldn't extend object."); + return 0; + } + + if (p->object) { + memcpy(new->data, p->object->data, p->object->size); + dbg_free(p->object->data); + dbg_free(p->object); + } + p->object = new; + + memcpy(new->data + size - delta, buffer, delta); + + return 1; +} + +void *pool_end_object(struct pool *p) +{ + assert(p->begun); + _append_block(p, p->object); + + p->begun = 0; + p->object = NULL; + return p->tail->data; +} + +void pool_abandon_object(struct pool *p) +{ + assert(p->begun); + dbg_free(p->object); + p->begun = 0; + p->object = NULL; +} diff --git a/lib/mm/pool-fast.c b/lib/mm/pool-fast.c new file mode 100644 index 0000000..56102e5 --- /dev/null +++ b/lib/mm/pool-fast.c @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This file is part of the device-mapper userspace tools. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "lib.h" +#include "pool.h" + +struct chunk { + char *begin, *end; + struct chunk *prev; +}; + +struct pool { + struct chunk *chunk, *spare_chunk; /* spare_chunk is a one entry free + list to stop 'bobbling' */ + size_t chunk_size; + size_t object_len; + unsigned object_alignment; +}; + +void _align_chunk(struct chunk *c, unsigned alignment); +struct chunk *_new_chunk(struct pool *p, size_t s); + +/* by default things come out aligned for doubles */ +#define DEFAULT_ALIGNMENT __alignof__ (double) + +struct pool *pool_create(const char *name, size_t chunk_hint) +{ + size_t new_size = 1024; + struct pool *p = dbg_malloc(sizeof(*p)); + + if (!p) { + log_error("Couldn't create memory pool %s (size %" + PRIsize_t ")", name, sizeof(*p)); + return 0; + } + memset(p, 0, sizeof(*p)); + + /* round chunk_hint up to the next power of 2 */ + p->chunk_size = chunk_hint + sizeof(struct chunk); + while (new_size < p->chunk_size) + new_size <<= 1; + p->chunk_size = new_size; + return p; +} + +void pool_destroy(struct pool *p) +{ + struct chunk *c, *pr; + dbg_free(p->spare_chunk); + c = p->chunk; + while (c) { + pr = c->prev; + dbg_free(c); + c = pr; + } + + dbg_free(p); +} + +void *pool_alloc(struct pool *p, size_t s) +{ + return pool_alloc_aligned(p, s, DEFAULT_ALIGNMENT); +} + +void *pool_alloc_aligned(struct pool *p, size_t s, unsigned alignment) +{ + struct chunk *c = p->chunk; + void *r; + + /* realign begin */ + if (c) + _align_chunk(c, alignment); + + /* have we got room ? */ + if (!c || (c->begin > c->end) || (c->end - c->begin < s)) { + /* allocate new chunk */ + int needed = s + alignment + sizeof(struct chunk); + c = _new_chunk(p, (needed > p->chunk_size) ? + needed : p->chunk_size); + + if (!c) + return NULL; + + _align_chunk(c, alignment); + } + + r = c->begin; + c->begin += s; + return r; +} + +void pool_empty(struct pool *p) +{ + struct chunk *c; + + for (c = p->chunk; c && c->prev; c = c->prev) + ; + + if (c) + pool_free(p, (char *) (c + 1)); +} + +void pool_free(struct pool *p, void *ptr) +{ + struct chunk *c = p->chunk; + + while (c) { + if (((char *) c < (char *) ptr) && + ((char *) c->end > (char *) ptr)) { + c->begin = ptr; + break; + } + + if (p->spare_chunk) + dbg_free(p->spare_chunk); + p->spare_chunk = c; + c = c->prev; + } + + if (!c) + log_error("Internal error: pool_free asked to free pointer " + "not in pool"); + else + p->chunk = c; +} + +int pool_begin_object(struct pool *p, size_t hint) +{ + struct chunk *c = p->chunk; + const size_t align = DEFAULT_ALIGNMENT; + + p->object_len = 0; + p->object_alignment = align; + + if (c) + _align_chunk(c, align); + + if (!c || (c->begin > c->end) || (c->end - c->begin < hint)) { + /* allocate a new chunk */ + c = _new_chunk(p, + hint > (p->chunk_size - sizeof(struct chunk)) ? + hint + sizeof(struct chunk) + align : + p->chunk_size); + + if (!c) + return 0; + + _align_chunk(c, align); + } + + return 1; +} + +int pool_grow_object(struct pool *p, const void *extra, size_t n) +{ + struct chunk *c = p->chunk, *nc; + + if (c->end - (c->begin + p->object_len) < n) { + /* move into a new chunk */ + if (p->object_len + n > (p->chunk_size / 2)) + nc = _new_chunk(p, (p->object_len + n) * 2); + else + nc = _new_chunk(p, p->chunk_size); + + if (!nc) + return 0; + + _align_chunk(p->chunk, p->object_alignment); + memcpy(p->chunk->begin, c->begin, p->object_len); + c = p->chunk; + } + + memcpy(c->begin + p->object_len, extra, n); + p->object_len += n; + return 1; +} + +void *pool_end_object(struct pool *p) +{ + struct chunk *c = p->chunk; + void *r = c->begin; + c->begin += p->object_len; + p->object_len = 0u; + p->object_alignment = DEFAULT_ALIGNMENT; + return r; +} + +void pool_abandon_object(struct pool *p) +{ + p->object_len = 0; + p->object_alignment = DEFAULT_ALIGNMENT; +} + +void _align_chunk(struct chunk *c, unsigned alignment) +{ + c->begin += alignment - ((unsigned long) c->begin & (alignment - 1)); +} + +struct chunk *_new_chunk(struct pool *p, size_t s) +{ + struct chunk *c; + + if (p->spare_chunk && + ((p->spare_chunk->end - (char *) p->spare_chunk) >= s)) { + /* reuse old chunk */ + c = p->spare_chunk; + p->spare_chunk = 0; + } else { + if (!(c = dbg_malloc(s))) { + log_error("Out of memory. Requested %" PRIsize_t + " bytes.", s); + return NULL; + } + + c->end = (char *) c + s; + } + + c->prev = p->chunk; + c->begin = (char *) (c + 1); + p->chunk = c; + + return c; +} diff --git a/lib/mm/pool.c b/lib/mm/pool.c new file mode 100644 index 0000000..daefcf8 --- /dev/null +++ b/lib/mm/pool.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This file is part of the device-mapper userspace tools. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef DEBUG_POOL +#include "pool-debug.c" +#else +#include "pool-fast.c" +#endif + +char *pool_strdup(struct pool *p, const char *str) +{ + char *ret = pool_alloc(p, strlen(str) + 1); + + if (ret) + strcpy(ret, str); + + return ret; +} + +char *pool_strndup(struct pool *p, const char *str, size_t n) +{ + char *ret = pool_alloc(p, n + 1); + + if (ret) { + strncpy(ret, str, n); + ret[n] = '\0'; + } + + return ret; +} + +void *pool_zalloc(struct pool *p, size_t s) +{ + void *ptr = pool_alloc(p, s); + + if (ptr) + memset(ptr, 0, s); + + return ptr; +} diff --git a/lib/mm/pool.h b/lib/mm/pool.h new file mode 100644 index 0000000..0170046 --- /dev/null +++ b/lib/mm/pool.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. + * + * This file is part of the device-mapper userspace tools. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _LVM_POOL_H +#define _LVM_POOL_H + +#include +#include + +/* + * The pool allocator is useful when you are going to allocate + * lots of memory, use the memory for a bit, and then free the + * memory in one go. A surprising amount of code has this usage + * profile. + * + * You should think of the pool as an infinite, contiguous chunk + * of memory. The front of this chunk of memory contains + * allocated objects, the second half is free. pool_alloc grabs + * the next 'size' bytes from the free half, in effect moving it + * into the allocated half. This operation is very efficient. + * + * pool_free frees the allocated object *and* all objects + * allocated after it. It is important to note this semantic + * difference from malloc/free. This is also extremely + * efficient, since a single pool_free can dispose of a large + * complex object. + * + * pool_destroy frees all allocated memory. + * + * eg, If you are building a binary tree in your program, and + * know that you are only ever going to insert into your tree, + * and not delete (eg, maintaining a symbol table for a + * compiler). You can create yourself a pool, allocate the nodes + * from it, and when the tree becomes redundant call pool_destroy + * (no nasty iterating through the tree to free nodes). + * + * eg, On the other hand if you wanted to repeatedly insert and + * remove objects into the tree, you would be better off + * allocating the nodes from a free list; you cannot free a + * single arbitrary node with pool. + */ + +struct pool; + +/* constructor and destructor */ +struct pool *pool_create(const char *name, size_t chunk_hint); +void pool_destroy(struct pool *p); + +/* simple allocation/free routines */ +void *pool_alloc(struct pool *p, size_t s); +void *pool_alloc_aligned(struct pool *p, size_t s, unsigned alignment); +void pool_empty(struct pool *p); +void pool_free(struct pool *p, void *ptr); + +/* + * Object building routines: + * + * These allow you to 'grow' an object, useful for + * building strings, or filling in dynamic + * arrays. + * + * It's probably best explained with an example: + * + * char *build_string(struct pool *mem) + * { + * int i; + * char buffer[16]; + * + * if (!pool_begin_object(mem, 128)) + * return NULL; + * + * for (i = 0; i < 50; i++) { + * snprintf(buffer, sizeof(buffer), "%d, ", i); + * if (!pool_grow_object(mem, buffer, strlen(buffer))) + * goto bad; + * } + * + * // add null + * if (!pool_grow_object(mem, "\0", 1)) + * goto bad; + * + * return pool_end_object(mem); + * + * bad: + * + * pool_abandon_object(mem); + * return NULL; + *} + * + * So start an object by calling pool_begin_object + * with a guess at the final object size - if in + * doubt make the guess too small. + * + * Then append chunks of data to your object with + * pool_grow_object. Finally get your object with + * a call to pool_end_object. + * + */ +int pool_begin_object(struct pool *p, size_t hint); +int pool_grow_object(struct pool *p, const void *extra, size_t delta); +void *pool_end_object(struct pool *p); +void pool_abandon_object(struct pool *p); + +/* utilities */ +char *pool_strdup(struct pool *p, const char *str); +char *pool_strndup(struct pool *p, const char *str, size_t n); +void *pool_zalloc(struct pool *p, size_t s); + +#endif diff --git a/make.tmpl.in b/make.tmpl.in index 96b20fc..2ff3fe4 100644 --- a/make.tmpl.in +++ b/make.tmpl.in @@ -24,6 +24,7 @@ INSTALL = @INSTALL@ MSGFMT = @MSGFMT@ LN_S = @LN_S@ LIBS = @LIBS@ +CFLAGS += @DEFS@ CFLAGS += @CFLAGS@ CLDFLAGS += @CLDFLAGS@ LDDEPS += @LDDEPS@ @@ -64,6 +65,7 @@ CFLAGS += @COPTIMISE_FLAG@ ifeq ("@DEBUG@", "yes") CFLAGS += -g -fno-omit-frame-pointer -DDEBUG + CFLAGS += -DDEBUG_MEM endif ifeq ("@INTL@", "yes") @@ -80,6 +82,9 @@ ifeq ("@DMIOCTLS@", "yes") CFLAGS += -DDM_IOCTLS endif +#CFLAGS += -DDEBUG_POOL +#CFLAGS += -DBOUNDS_CHECK + #CFLAGS += -pg #LDFLAGS += -pg -- 2.43.5