configure.in (MAKEINFO, PERL): Detect these.

* configure.in (MAKEINFO, PERL): Detect these.
(--enable-maintainer-mode): Add.
* configure: Regenerate.
* Makefile.in (MAKEINFO, PERL): Define.
(libiberty.info, libiberty.dvi, libiberty.html): New.
(CFILES): Add bsearch.c.
(CONFIGURED_OFILES): New, list of objects configure might add.
(maint-missing, maint-buildall): New, for maintainers only.
(clean, mostlyclean): Add info/dvi/html files.
* libiberty.texi, copying-lib.texi, obstacks.texi, functions.texi: New.
* gather-docs: New, for maintainers.
* maint-tool: New, for maintainers.
* alloca.c, atexit.c, basename.c, bcmp.c, bcopy.c, bsearch.c,
bzero.c, calloc.c, clock.c, configure.in, configure, getcwd.c,
getpagesize.c, getpwd.c, index.c, memchr.c, memcmp.c, memcpy.c,
memmove.c, memset.c, putenv.c, rename.c, rindex.c, setenv.c,
sigsetmask.c, strcasecmp.c, strchr.c, strdup.c, strerror.c,
strncasecmp.c, strncmp.c, strrchr.c, strstr.c, strtod.c, strtol.c,
tmpnam.c, vfork.c, vprintf.c, waitpid.c, xatexit.c, xexit.c,
xmalloc.c, xmemdup.c, xstrdup.c, xstrerror.c: Add or update
documentation.

Co-Authored-By: Phil Edwards <pedwards@disaster.jaj.com>

From-SVN: r45828
This commit is contained in:
DJ Delorie 2001-09-26 14:16:17 -04:00 committed by DJ Delorie
parent b8af0ca5c7
commit aaa5f039eb
53 changed files with 3241 additions and 350 deletions

View File

@ -1,3 +1,28 @@
2001-09-20 DJ Delorie <dj@redhat.com>
Phil Edwards <pedwards@disaster.jaj.com>
* configure.in (MAKEINFO, PERL): Detect these.
(--enable-maintainer-mode): Add.
* configure: Regenerate.
* Makefile.in (MAKEINFO, PERL): Define.
(libiberty.info, libiberty.dvi, libiberty.html): New.
(CFILES): Add bsearch.c.
(CONFIGURED_OFILES): New, list of objects configure might add.
(maint-missing, maint-buildall): New, for maintainers only.
(clean, mostlyclean): Add info/dvi/html files.
* libiberty.texi, copying-lib.texi, obstacks.texi, functions.texi: New.
* gather-docs: New, for maintainers.
* maint-tool: New, for maintainers.
* alloca.c, atexit.c, basename.c, bcmp.c, bcopy.c, bsearch.c,
bzero.c, calloc.c, clock.c, configure.in, configure, getcwd.c,
getpagesize.c, getpwd.c, index.c, memchr.c, memcmp.c, memcpy.c,
memmove.c, memset.c, putenv.c, rename.c, rindex.c, setenv.c,
sigsetmask.c, strcasecmp.c, strchr.c, strdup.c, strerror.c,
strncasecmp.c, strncmp.c, strrchr.c, strstr.c, strtod.c, strtol.c,
tmpnam.c, vfork.c, vprintf.c, waitpid.c, xatexit.c, xexit.c,
xmalloc.c, xmemdup.c, xstrdup.c, xstrerror.c: Add or update
documentation.
2001-09-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* concat.c (reconcat): Fix for traditional C.

View File

@ -1,6 +1,6 @@
#
# Makefile
# Copyright (C) 1990, 91-99, 2000
# Copyright (C) 1990, 91-99, 2000, 2001
# Free Software Foundation
#
# This file is part of the libiberty library.
@ -56,6 +56,8 @@ CC = @CC@
CFLAGS = @CFLAGS@
LIBCFLAGS = $(CFLAGS)
RANLIB = @RANLIB@
MAKEINFO = @MAKEINFO@
PERL = @PERL@
PICFLAG =
@ -94,6 +96,7 @@ FLAGS_TO_PASS = \
# Subdirectories to recurse into. We need to override this during cleaning
SUBDIRS = testsuite
# FIXME: add @BUILD_INFO@ once we're sure it works for everyone.
all: stamp-picdir $(TARGETLIB) needed-list required-list all-subdir
@$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
@ -112,16 +115,11 @@ COMPILE.c = $(CC) -c @DEFS@ $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES) @ac_libiber
else true; fi
$(COMPILE.c) $<
info: info-subdir
install-info: install-info-subdir
clean-info: clean-info-subdir
dvi: dvi-subdir
# NOTE: If you add new files to the library, add them to this list
# (alphabetical), and add them to REQUIRED_OFILES or funcs in
# configure.in.
CFILES = asprintf.c alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c \
bzero.c calloc.c choose-temp.c clock.c concat.c cplus-dem.c \
bsearch.c bzero.c calloc.c choose-temp.c clock.c concat.c cplus-dem.c \
cp-demangle.c dyn-string.c fdmatch.c fnmatch.c ffs.c getcwd.c \
getpwd.c getopt.c getopt1.c getpagesize.c getruntime.c \
floatformat.c hashtab.c hex.c index.c insque.c lbasename.c \
@ -144,12 +142,55 @@ REQUIRED_OFILES = argv.o alloca.o choose-temp.o concat.o cplus-dem.o \
splay-tree.o strerror.o strsignal.o xatexit.o xexit.o xmalloc.o \
xmemdup.o xstrdup.o xstrerror.o ternary.o fibheap.o
# These are all the objects that configure may add to the library via
# $funcs. This list exists here only for "make maint-missing".
CONFIGURED_OFILES = asprintf.o atexit.o basename.o bcmp.o bcopy.o \
bsearch.o bzero.o calloc.o clock.o ffs.o getcwd.o \
getpagesize.o index.o insque.o memchr.o memcmp.o memcpy.o \
memmove.o memset.o mkstemps.o putenv.o random.o rename.o \
rindex.o setenv.o sigsetmask.o strcasecmp.o strchr.o strdup.o \
strncasecmp.o strncmp.o strrchr.o strstr.o strtod.o strtol.o \
strtoul.o tmpnam.o vasprintf.o vfork.o vfprintf.o vprintf.o \
vsprintf.o waitpid.o
$(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
-rm -f $(TARGETLIB)
$(AR) $(AR_FLAGS) $(TARGETLIB) \
$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
$(RANLIB) $(TARGETLIB)
info: libiberty.info info-subdir
install-info: install-info-subdir
clean-info: clean-info-subdir
dvi: libiberty.dvi dvi-subdir
html: libiberty.html
TEXISRC = \
$(srcdir)/libiberty.texi \
$(srcdir)/copying-lib.texi \
$(srcdir)/obstacks.texi \
$(srcdir)/functions.texi
# Additional files that have texi snippets that need to be collected
# and sorted.
TEXIFILES =
libiberty.info : $(srcdir)/libiberty.texi $(TEXISRC)
$(MAKEINFO) -I$(srcdir) $(srcdir)/libiberty.texi
libiberty.dvi : $(srcdir)/libiberty.texi $(TEXISRC)
texi2dvi $(srcdir)/libiberty.texi
libiberty.html : $(srcdir)/libiberty.texi $(TEXISRC)
$(MAKEINFO) --html -I$(srcdir) $(srcdir)/libiberty.texi
@MAINT@$(srcdir)/functions.texi : stamp-functions
@MAINT@ @true
@MAINT@stamp-functions : $(CFILES) $(TEXIFILES) $(srcdir)/gather-docs Makefile
@MAINT@@HAVE_PERL@ $(PERL) $(srcdir)/gather-docs $(srcdir) $(srcdir)/functions.texi $(CFILES) $(TEXIFILES)
@MAINT@ echo stamp > stamp-functions
INSTALL_DEST = @INSTALL_DEST@
install: install_to_$(INSTALL_DEST) install-subdir
@ -208,6 +249,14 @@ demangle:
ls:
@echo Makefile $(CFILES)
# Various targets for maintainers.
maint-missing :
@$(PERL) $(srcdir)/maint-tool -s $(srcdir) missing $(CFILES) $(REQUIRED_OFILES) $(CONFIGURED_OFILES)
maint-buildall : $(REQUIRED_OFILES) $(CONFIGURED_OFILES)
@true
# Need to deal with profiled libraries, too.
# Cleaning has to be done carefully to ensure that we don't clean our SUBDIRS
@ -216,10 +265,15 @@ mostlyclean: mostlyclean-subdir
-rm -rf *.o pic core errs \#* *.E a.out
-rm -f needed.awk needed2.awk errors dummy needed-list config.h stamp-*
-rm -f $(CONFIG_H) $(NEEDED_LIST) stamp-picdir
-rm -f libiberty.aux libiberty.cp libiberty.cps libiberty.fn libiberty.ky
-rm -f libiberty.log libiberty.tmp libiberty.tps libiberty.pg
-rm -f libiberty.pgs libiberty.toc libiberty.tp libiberty.tpl libiberty.vr
-rm -f libtexi.stamp
@$(MULTICLEAN) multi-clean DO=mostlyclean
clean: clean-subdir
$(MAKE) SUBDIRS="" mostlyclean
-rm -f *.a required-list tmpmulti.out
-rm -f libiberty.dvi libiberty.info* libiberty.html
@$(MULTICLEAN) multi-clean DO=clean
distclean: distclean-subdir
$(MAKE) SUBDIRS="" clean

View File

@ -21,6 +21,27 @@
allocating any. It is a good idea to use alloca(0) in
your main control loop, etc. to force garbage collection. */
/*
@deftypefn Replacement void* alloca (size_t)
This function allocates memory which will be automatically reclaimed
after the procedure exits. The @libib{} implementation does not free
the memory immediately but will do so eventually during subsequent
calls to this function. Memory is allocated using @code{xmalloc} under
normal circumstances.
The header file @file{alloca-conf.h} can be used in conjunction with the
GNU Autoconf test @code{AC_FUNC_ALLOCA} to test for and properly make
available this function. The @code{AC_FUNC_ALLOCA} test requires that
client code use a block of preprocessor code to be safe (see the Autoconf
manual for more); this header incorporates that logic and more, including
the possibility of a GCC builtin function.
@end deftypefn
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

View File

@ -1,6 +1,16 @@
/* Wrapper to implement ANSI C's atexit using SunOS's on_exit. */
/* This function is in the public domain. --Mike Stump. */
/*
@deftypefn Supplemental int atexit (void (*@var{f})())
Causes function @var{f} to be called at exit. Returns 0.
@end deftypefn
*/
#include "config.h"
#ifdef HAVE_ON_EXIT

View File

@ -2,20 +2,14 @@
This file is in the public domain. */
/*
NAME
basename -- return pointer to last component of a pathname
SYNOPSIS
char *basename (const char *name)
@deftypefn Supplemental char* basename (const char *@var{name})
DESCRIPTION
Given a pointer to a string containing a typical pathname
(/usr/src/cmd/ls/ls.c for example), returns a pointer to the
last component of the pathname ("ls.c" in this case).
Returns a pointer to the last component of pathname @var{name}.
Behavior is undefined if the pathname ends in a directory separator.
@end deftypefn
BUGS
Presumes a UNIX or DOS/Windows style path with UNIX or DOS/Windows
style separators.
*/
#include "ansidecl.h"

View File

@ -3,28 +3,15 @@
/*
NAME
@deftypefn Supplemental int bcmp (char *@var{x}, char *@var{y}, int @var{count})
bcmp -- compare two memory regions
Compares the first @var{count} bytes of two areas of memory. Returns
zero if they are the same, non-zero otherwise. Returns zero if
@var{count} is zero. A non-zero result only indicates a difference,
it does not indicate any sorting order (say, by having a positive
result mean @var{x} sorts before @var{y}).
SYNOPSIS
int bcmp (char *from, char *to, int count)
DESCRIPTION
Compare two memory regions and return zero if they are identical,
non-zero otherwise. If count is zero, return zero.
NOTES
No guarantee is made about the non-zero returned value. In
particular, the results may be signficantly different than
strcmp(), where the return value is guaranteed to be less than,
equal to, or greater than zero, according to lexicographical
sorting of the compared regions.
BUGS
@end deftypefn
*/

View File

@ -1,19 +1,11 @@
/* bcopy -- copy memory regions of arbitary length
NAME
bcopy -- copy memory regions of arbitrary length
@deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
SYNOPSIS
void bcopy (char *in, char *out, int length)
Copies @var{length} bytes from memory region @var{in} to region
@var{out}. The use of @code{bcopy} is deprecated in new programs.
DESCRIPTION
Copy LENGTH bytes from memory region pointed to by IN to memory
region pointed to by OUT.
BUGS
Significant speed improvements can be made in some cases by
implementing copies of multiple bytes simultaneously, or unrolling
the copy loop.
@end deftypefn
*/

View File

@ -28,6 +28,23 @@
* SUCH DAMAGE.
*/
/*
@deftypefn Supplemental void* bsearch (const void *@var{key}, const void *@var{base}, size_t @var{nmemb}, size_t @var{size}, int (*@var{compar})(const void *, const void *))
Performs a search over an array of @var{nmemb} elements pointed to by
@var{base} for a member that matches the object pointed to by @var{key}.
The size of each member is specified by @var{size}. The array contents
should be sorted in ascending order according to the @var{compar}
comparison function. This routine should take two arguments pointing to
the @var{key} and to an array member, in that order, and should return an
integer less than, equal to, or greater than zero if the @var{key} object
is respectively less than, matching, or greater than the array member.
@end deftypefn
*/
#include "config.h"
#include "ansidecl.h"
#include <sys/types.h> /* size_t */

View File

@ -2,19 +2,13 @@
This function is in the public domain. */
/*
NAME
bzero -- zero the contents of a specified memory region
SYNOPSIS
void bzero (char *to, int count)
@deftypefn Supplemental void bzero (char *@var{mem}, int @var{count})
DESCRIPTION
Zero COUNT bytes of memory pointed to by TO.
Zeros @var{count} bytes starting at @var{mem}. Use of this function
is deprecated in favor of @code{memset}.
BUGS
Significant speed enhancements may be made in some environments
by zeroing more than a single byte at a time, or by unrolling the
loop.
@end deftypefn
*/

View File

@ -1,5 +1,16 @@
/* calloc -- allocate memory which has been initialized to zero.
This function is in the public domain. */
/*
@deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize})
Uses @code{malloc} to allocate storage for @var{nelem} objects of
@var{elsize} bytes each, then zeros the memory.
@end deftypefn
*/
#include "ansidecl.h"
#include "libiberty.h"

View File

@ -22,6 +22,18 @@ the resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
/*
@deftypefn Supplemental long clock ()
Returns an approximation of the CPU time used by the process as a
@code{clock_t}; divide this number by @samp{CLOCKS_PER_SEC} to get the
number of seconds used.
@end deftypefn
*/
#include "config.h"
#ifdef HAVE_GETRUSAGE

328
libiberty/configure vendored
View File

@ -17,6 +17,10 @@ ac_help="$ac_help
--with-cross-host=HOST Configuring with a cross compiler"
ac_help="$ac_help
--with-newlib Configuring with newlib"
ac_help="$ac_help
--enable-maintainer-mode
enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer"
# Initialize some variables set by options.
# The variables have the same names as the options, with
@ -581,13 +585,113 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
echo "configure:590: checking whether to enable maintainer-specific portions of Makefiles" >&5
# Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
if test "${enable_maintainer_mode+set}" = set; then
enableval="$enable_maintainer_mode"
maintainer_mode=$enableval
else
maintainer_mode=no
fi
echo "$ac_t""$maintainer_mode" 1>&6
if test "$maintainer_mode" = "yes"; then
MAINT=''
NOTMAINT='#'
else
MAINT='#'
NOTMAINT=''
fi
# Do we have a single-tree copy of texinfo?
if test -f $srcdir/../texinfo/Makefile.in; then
MAKEINFO='$(objdir)/../texinfo/makeinfo/makeinfo'
echo "$ac_t""Using makeinfo from the unified source tree." 1>&6
else
# Extract the first word of "makeinfo", so it can be a program name with args.
set dummy makeinfo; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:618: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$MAKEINFO"; then
ac_cv_prog_MAKEINFO="$MAKEINFO" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_MAKEINFO="makeinfo"
break
fi
done
IFS="$ac_save_ifs"
fi
fi
MAKEINFO="$ac_cv_prog_MAKEINFO"
if test -n "$MAKEINFO"; then
echo "$ac_t""$MAKEINFO" 1>&6
else
echo "$ac_t""no" 1>&6
fi
fi
if test x"$MAKEINFO" = x""; then
BUILD_INFO=
else
BUILD_INFO=info
fi
# Extract the first word of "perl", so it can be a program name with args.
set dummy perl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:655: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_PERL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$PERL"; then
ac_cv_prog_PERL="$PERL" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_PERL="perl"
break
fi
done
IFS="$ac_save_ifs"
fi
fi
PERL="$ac_cv_prog_PERL"
if test -n "$PERL"; then
echo "$ac_t""$PERL" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test x"$PERL" = x""; then
HAVE_PERL='#'
else
HAVE_PERL=''
fi
# Make sure we can run config.sub.
if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
echo "configure:591: checking host system type" >&5
echo "configure:695: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@ -610,7 +714,7 @@ echo "$ac_t""$host" 1>&6
echo $ac_n "checking build system type""... $ac_c" 1>&6
echo "configure:614: checking build system type" >&5
echo "configure:718: checking build system type" >&5
build_alias=$build
case "$build_alias" in
@ -636,7 +740,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:640: checking for $ac_word" >&5
echo "configure:744: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -668,7 +772,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:672: checking for $ac_word" >&5
echo "configure:776: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -700,7 +804,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:704: checking for $ac_word" >&5
echo "configure:808: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -737,7 +841,7 @@ fi
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:741: checking for $ac_word" >&5
echo "configure:845: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -767,7 +871,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:771: checking for $ac_word" >&5
echo "configure:875: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -816,7 +920,7 @@ fi
fi
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
echo "configure:820: checking whether we are using GNU C" >&5
echo "configure:924: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -825,7 +929,7 @@ else
yes;
#endif
EOF
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:829: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:933: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@ -841,7 +945,7 @@ if test $ac_cv_prog_gcc = yes; then
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
echo "configure:845: checking whether ${CC-cc} accepts -g" >&5
echo "configure:949: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -872,7 +976,7 @@ fi
echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
echo "configure:876: checking for POSIXized ISC" >&5
echo "configure:980: checking for POSIXized ISC" >&5
if test -d /etc/conf/kconfig.d &&
grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
then
@ -893,12 +997,12 @@ else
fi
echo $ac_n "checking for working const""... $ac_c" 1>&6
echo "configure:897: checking for working const" >&5
echo "configure:1001: checking for working const" >&5
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 902 "configure"
#line 1006 "configure"
#include "confdefs.h"
int main() {
@ -947,7 +1051,7 @@ ccp = (char const *const *) p;
; return 0; }
EOF
if { (eval echo configure:951: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1055: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
@ -968,21 +1072,21 @@ EOF
fi
echo $ac_n "checking for inline""... $ac_c" 1>&6
echo "configure:972: checking for inline" >&5
echo "configure:1076: checking for inline" >&5
if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
cat > conftest.$ac_ext <<EOF
#line 979 "configure"
#line 1083 "configure"
#include "confdefs.h"
int main() {
} $ac_kw foo() {
; return 0; }
EOF
if { (eval echo configure:986: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1090: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_inline=$ac_kw; break
else
@ -1025,7 +1129,7 @@ esac
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:1029: checking for a BSD compatible install" >&5
echo "configure:1133: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1086,7 +1190,7 @@ host_makefile_frag=${frag}
# able to link anything, it had better be able to at least compile
# something.
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:1090: checking how to run the C preprocessor" >&5
echo "configure:1194: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@ -1101,13 +1205,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 1105 "configure"
#line 1209 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1111: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1215: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -1118,13 +1222,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 1122 "configure"
#line 1226 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1128: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1232: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -1135,13 +1239,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
#line 1139 "configure"
#line 1243 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1145: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1249: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -1169,17 +1273,17 @@ for ac_hdr in sys/file.h sys/param.h limits.h stdlib.h string.h unistd.h strings
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1173: checking for $ac_hdr" >&5
echo "configure:1277: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1178 "configure"
#line 1282 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1183: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1287: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1206,12 +1310,12 @@ fi
done
echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
echo "configure:1210: checking for sys/wait.h that is POSIX.1 compatible" >&5
echo "configure:1314: checking for sys/wait.h that is POSIX.1 compatible" >&5
if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1215 "configure"
#line 1319 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/wait.h>
@ -1227,7 +1331,7 @@ wait (&s);
s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
; return 0; }
EOF
if { (eval echo configure:1231: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1335: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_sys_wait_h=yes
else
@ -1248,12 +1352,12 @@ EOF
fi
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
echo "configure:1252: checking whether time.h and sys/time.h may both be included" >&5
echo "configure:1356: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1257 "configure"
#line 1361 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@ -1262,7 +1366,7 @@ int main() {
struct tm *tp;
; return 0; }
EOF
if { (eval echo configure:1266: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1370: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
@ -1284,19 +1388,19 @@ fi
echo $ac_n "checking whether errno must be declared""... $ac_c" 1>&6
echo "configure:1288: checking whether errno must be declared" >&5
echo "configure:1392: checking whether errno must be declared" >&5
if eval "test \"`echo '$''{'libiberty_cv_declare_errno'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1293 "configure"
#line 1397 "configure"
#include "confdefs.h"
#include <errno.h>
int main() {
int x = errno;
; return 0; }
EOF
if { (eval echo configure:1300: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1404: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
libiberty_cv_declare_errno=no
else
@ -1374,12 +1478,12 @@ if test "x" = "y"; then
for ac_func in asprintf atexit basename bcmp bcopy bsearch bzero calloc clock
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1378: checking for $ac_func" >&5
echo "configure:1482: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1383 "configure"
#line 1487 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1402,7 +1506,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1406: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1510: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1429,12 +1533,12 @@ done
for ac_func in getcwd getpagesize index insque mkstemps memchr memcmp memcpy
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1433: checking for $ac_func" >&5
echo "configure:1537: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1438 "configure"
#line 1542 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1457,7 +1561,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1461: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1565: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1484,12 +1588,12 @@ done
for ac_func in memmove memset putenv random rename rindex sigsetmask
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1488: checking for $ac_func" >&5
echo "configure:1592: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1493 "configure"
#line 1597 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1512,7 +1616,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1539,12 +1643,12 @@ done
for ac_func in strcasecmp setenv strchr strdup strncasecmp strrchr strstr
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1543: checking for $ac_func" >&5
echo "configure:1647: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1548 "configure"
#line 1652 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1567,7 +1671,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1571: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1594,12 +1698,12 @@ done
for ac_func in strtod strtol strtoul tmpnam vasprintf vfprintf vprintf
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1598: checking for $ac_func" >&5
echo "configure:1702: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1603 "configure"
#line 1707 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1622,7 +1726,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1626: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1649,12 +1753,12 @@ done
for ac_func in vsprintf waitpid getrusage on_exit psignal strerror strsignal
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1653: checking for $ac_func" >&5
echo "configure:1757: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1658 "configure"
#line 1762 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1677,7 +1781,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1785: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1704,12 +1808,12 @@ done
for ac_func in sysconf times sbrk gettimeofday ffs
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1708: checking for $ac_func" >&5
echo "configure:1812: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1713 "configure"
#line 1817 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1732,7 +1836,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1840: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1929,7 +2033,7 @@ if test -z "${setobjs}"; then
# We haven't set the list of objects yet. Use the standard autoconf
# tests. This will only work if the compiler works.
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
echo "configure:1933: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
echo "configure:2037: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@ -1940,12 +2044,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
#line 1944 "configure"
#line 2048 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
if { (eval echo configure:1949: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@ -1971,19 +2075,19 @@ if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
echo "configure:1975: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "configure:2079: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
for ac_func in $funcs
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1982: checking for $ac_func" >&5
echo "configure:2086: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1987 "configure"
#line 2091 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -2006,7 +2110,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:2010: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2114: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -2033,12 +2137,12 @@ done
echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
echo "configure:2037: checking whether alloca needs Cray hooks" >&5
echo "configure:2141: checking whether alloca needs Cray hooks" >&5
if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2042 "configure"
#line 2146 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@ -2063,12 +2167,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:2067: checking for $ac_func" >&5
echo "configure:2171: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2072 "configure"
#line 2176 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -2091,7 +2195,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:2095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2199: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -2117,7 +2221,7 @@ fi
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
echo "configure:2121: checking stack direction for C alloca" >&5
echo "configure:2225: checking stack direction for C alloca" >&5
if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2125,7 +2229,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
#line 2129 "configure"
#line 2233 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@ -2144,7 +2248,7 @@ main ()
exit (find_stack_direction() < 0);
}
EOF
if { (eval echo configure:2148: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:2252: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_stack_direction=1
else
@ -2165,12 +2269,12 @@ EOF
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
echo "configure:2169: checking for ANSI C header files" >&5
echo "configure:2273: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2174 "configure"
#line 2278 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@ -2178,7 +2282,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2182: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2286: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@ -2195,7 +2299,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
#line 2199 "configure"
#line 2303 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@ -2213,7 +2317,7 @@ 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 <<EOF
#line 2217 "configure"
#line 2321 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@ -2234,7 +2338,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
#line 2238 "configure"
#line 2342 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@ -2245,7 +2349,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
if { (eval echo configure:2249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:2353: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@ -2269,12 +2373,12 @@ EOF
fi
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
echo "configure:2273: checking for pid_t" >&5
echo "configure:2377: checking for pid_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2278 "configure"
#line 2382 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@ -2303,17 +2407,17 @@ fi
ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
echo "configure:2307: checking for vfork.h" >&5
echo "configure:2411: checking for vfork.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2312 "configure"
#line 2416 "configure"
#include "confdefs.h"
#include <vfork.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2317: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2421: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@ -2338,18 +2442,18 @@ else
fi
echo $ac_n "checking for working vfork""... $ac_c" 1>&6
echo "configure:2342: checking for working vfork" >&5
echo "configure:2446: checking for working vfork" >&5
if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$cross_compiling" = yes; then
echo $ac_n "checking for vfork""... $ac_c" 1>&6
echo "configure:2348: checking for vfork" >&5
echo "configure:2452: checking for vfork" >&5
if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2353 "configure"
#line 2457 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vfork(); below. */
@ -2372,7 +2476,7 @@ vfork();
; return 0; }
EOF
if { (eval echo configure:2376: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2480: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_vfork=yes"
else
@ -2394,7 +2498,7 @@ fi
ac_cv_func_vfork_works=$ac_cv_func_vfork
else
cat > conftest.$ac_ext <<EOF
#line 2398 "configure"
#line 2502 "configure"
#include "confdefs.h"
/* Thanks to Paul Eggert for this test. */
#include <stdio.h>
@ -2489,7 +2593,7 @@ main() {
}
}
EOF
if { (eval echo configure:2493: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:2597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_vfork_works=yes
else
@ -2516,19 +2620,19 @@ fi
fi
for v in $vars; do
echo $ac_n "checking for $v""... $ac_c" 1>&6
echo "configure:2520: checking for $v" >&5
echo "configure:2624: checking for $v" >&5
if eval "test \"`echo '$''{'libiberty_cv_var_$v'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2525 "configure"
#line 2629 "configure"
#include "confdefs.h"
int *p;
int main() {
extern int $v; p = &$v;
; return 0; }
EOF
if { (eval echo configure:2532: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "libiberty_cv_var_$v=yes"
else
@ -2554,12 +2658,12 @@ EOF
for ac_func in $checkfuncs
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:2558: checking for $ac_func" >&5
echo "configure:2662: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2563 "configure"
#line 2667 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -2582,7 +2686,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:2586: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -2612,17 +2716,17 @@ for ac_hdr in unistd.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2616: checking for $ac_hdr" >&5
echo "configure:2720: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2621 "configure"
#line 2725 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2626: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2730: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@ -2651,12 +2755,12 @@ done
for ac_func in getpagesize
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:2655: checking for $ac_func" >&5
echo "configure:2759: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2660 "configure"
#line 2764 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -2679,7 +2783,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:2683: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2787: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -2704,7 +2808,7 @@ fi
done
echo $ac_n "checking for working mmap""... $ac_c" 1>&6
echo "configure:2708: checking for working mmap" >&5
echo "configure:2812: checking for working mmap" >&5
if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2712,7 +2816,7 @@ else
ac_cv_func_mmap_fixed_mapped=no
else
cat > conftest.$ac_ext <<EOF
#line 2716 "configure"
#line 2820 "configure"
#include "confdefs.h"
/* Thanks to Mike Haertel and Jim Avera for this test.
@ -2852,7 +2956,7 @@ main()
}
EOF
if { (eval echo configure:2856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:2960: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_mmap_fixed_mapped=yes
else
@ -2876,7 +2980,7 @@ fi
echo $ac_n "checking for working strncmp""... $ac_c" 1>&6
echo "configure:2880: checking for working strncmp" >&5
echo "configure:2984: checking for working strncmp" >&5
if eval "test \"`echo '$''{'ac_cv_func_strncmp_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2884,7 +2988,7 @@ else
ac_cv_func_strncmp_works=no
else
cat > conftest.$ac_ext <<EOF
#line 2888 "configure"
#line 2992 "configure"
#include "confdefs.h"
/* Test by Jim Wilson and Kaveh Ghazi.
@ -2945,7 +3049,7 @@ main ()
}
EOF
if { (eval echo configure:2949: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:3053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_strncmp_works=yes
else
@ -3109,6 +3213,12 @@ s%@includedir@%$includedir%g
s%@oldincludedir@%$oldincludedir%g
s%@infodir@%$infodir%g
s%@mandir@%$mandir%g
s%@MAINT@%$MAINT%g
s%@NOTMAINT@%$NOTMAINT%g
s%@MAKEINFO@%$MAKEINFO%g
s%@BUILD_INFO@%$BUILD_INFO%g
s%@PERL@%$PERL%g
s%@HAVE_PERL@%$HAVE_PERL%g
s%@host@%$host%g
s%@host_alias@%$host_alias%g
s%@host_cpu@%$host_cpu%g

View File

@ -26,6 +26,51 @@ else
fi
AC_CONFIG_AUX_DIR($libiberty_topdir)
dnl Very limited version of automake's enable-maintainer-mode
AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
dnl maintainer-mode is disabled by default
AC_ARG_ENABLE(maintainer-mode,
[ --enable-maintainer-mode
enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer],
maintainer_mode=$enableval,
maintainer_mode=no)
AC_MSG_RESULT($maintainer_mode)
if test "$maintainer_mode" = "yes"; then
MAINT=''
NOTMAINT='#'
else
MAINT='#'
NOTMAINT=''
fi
AC_SUBST(MAINT)dnl
AC_SUBST(NOTMAINT)dnl
# Do we have a single-tree copy of texinfo?
if test -f $srcdir/../texinfo/Makefile.in; then
MAKEINFO='$(objdir)/../texinfo/makeinfo/makeinfo'
AC_MSG_RESULT([Using makeinfo from the unified source tree.])
else
AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
fi
if test x"$MAKEINFO" = x""; then
BUILD_INFO=
else
BUILD_INFO=info
fi
AC_SUBST(BUILD_INFO)
AC_CHECK_PROG(PERL, perl, perl, )
if test x"$PERL" = x""; then
HAVE_PERL='#'
else
HAVE_PERL=''
fi
AC_SUBST(HAVE_PERL)
AC_CANONICAL_HOST
dnl When we start using automake:

565
libiberty/copying-lib.texi Normal file
View File

@ -0,0 +1,565 @@
@node Library Copying,,,Licenses
@appendixsec GNU LESSER GENERAL PUBLIC LICENSE
@cindex LGPL, Lesser General Public License
@center Version 2.1, February 1999
@display
Copyright @copyright{} 1991, 1999 Free Software Foundation, Inc.
59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence the
version number 2.1.]
@end display
@appendixsubsec Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software---to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software---typically libraries---of the Free
Software Foundation and other authors who decide to use it. You can use
it too, but we suggest you first think carefully about whether this
license or the ordinary General Public License is the better strategy to
use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of it
in new free programs; and that you are informed that you can do these
things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the @dfn{Lesser} General Public License because it
does @emph{Less} to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
``work based on the library'' and a ``work that uses the library''. The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
@iftex
@appendixsubsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end iftex
@ifinfo
@center GNU LESSER GENERAL PUBLIC LICENSE
@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@end ifinfo
@enumerate 0
@item
This License Agreement applies to any software library or other program
which contains a notice placed by the copyright holder or other
authorized party saying it may be distributed under the terms of this
Lesser General Public License (also called ``this License''). Each
licensee is addressed as ``you''.
A ``library'' means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The ``Library'', below, refers to any such software library or work
which has been distributed under these terms. A ``work based on the
Library'' means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term ``modification''.)
``Source code'' for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
@item
You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
@item
You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
@enumerate a
@item
The modified work must itself be a software library.
@item
You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
@item
You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
@item
If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
@end enumerate
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
@item
You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
@item
You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
@item
A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a ``work that uses the Library''. Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a ``work that uses the Library'' with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a ``work that uses the
library''. The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a ``work that uses the Library'' uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
@item
As an exception to the Sections above, you may also combine or
link a ``work that uses the Library'' with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
@enumerate a
@item
Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable ``work that
uses the Library'', as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
@item
Use a suitable shared library mechanism for linking with the Library. A
suitable mechanism is one that (1) uses at run time a copy of the
library already present on the user's computer system, rather than
copying library functions into the executable, and (2) will operate
properly with a modified version of the library, if the user installs
one, as long as the modified version is interface-compatible with the
version that the work was made with.
@item
Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
@item
If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
@item
Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
@end enumerate
For an executable, the required form of the ``work that uses the
Library'' must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies the
executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
@item
You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
@enumerate a
@item
Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
@item
Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
@end enumerate
@item
You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
@item
You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
@item
Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
@item
If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
@item
If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
@item
The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
``any later version'', you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
@item
If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
@iftex
@heading NO WARRANTY
@end iftex
@ifinfo
@center NO WARRANTY
@end ifinfo
@item
BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY ``AS IS'' WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
@item
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
@end enumerate
@iftex
@heading END OF TERMS AND CONDITIONS
@end iftex
@ifinfo
@center END OF TERMS AND CONDITIONS
@end ifinfo
@page
@appendixsubsec How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
``copyright'' line and a pointer to where the full notice is found.
@smallexample
@var{one line to give the library's name and an idea of what it does.}
Copyright (C) @var{year} @var{name of author}
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
USA.
@end smallexample
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a ``copyright disclaimer'' for the library, if
necessary. Here is a sample; alter the names:
@smallexample
Yoyodyne, Inc., hereby disclaims all copyright interest in the library
`Frob' (a library for tweaking knobs) written by James Random Hacker.
@var{signature of Ty Coon}, 1 April 1990
Ty Coon, President of Vice
@end smallexample
That's all there is to it!

515
libiberty/functions.texi Normal file
View File

@ -0,0 +1,515 @@
@c Automatically generated from *.c and others (the comments before
@c each entry tell you which file and where in that file). DO NOT EDIT!
@c Edit the *.c files, configure with --enable-maintainer-mode,
@c and let gather-docs build you a new copy.
@c alloca.c:26
@deftypefn Replacement void* alloca (size_t)
This function allocates memory which will be automatically reclaimed
after the procedure exits. The @libib{} implementation does not free
the memory immediately but will do so eventually during subsequent
calls to this function. Memory is allocated using @code{xmalloc} under
normal circumstances.
The header file @file{alloca-conf.h} can be used in conjunction with the
GNU Autoconf test @code{AC_FUNC_ALLOCA} to test for and properly make
available this function. The @code{AC_FUNC_ALLOCA} test requires that
client code use a block of preprocessor code to be safe (see the Autoconf
manual for more); this header incorporates that logic and more, including
the possibility of a GCC builtin function.
@end deftypefn
@c atexit.c:6
@deftypefn Supplemental int atexit (void (*@var{f})())
Causes function @var{f} to be called at exit. Returns 0.
@end deftypefn
@c basename.c:6
@deftypefn Supplemental char* basename (const char *@var{name})
Returns a pointer to the last component of pathname @var{name}.
Behavior is undefined if the pathname ends in a directory separator.
@end deftypefn
@c bcmp.c:6
@deftypefn Supplemental int bcmp (char *@var{x}, char *@var{y}, int @var{count})
Compares the first @var{count} bytes of two areas of memory. Returns
zero if they are the same, non-zero otherwise. Returns zero if
@var{count} is zero. A non-zero result only indicates a difference,
it does not indicate any sorting order (say, by having a positive
result mean @var{x} sorts before @var{y}).
@end deftypefn
@c bcopy.c:3
@deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
Copies @var{length} bytes from memory region @var{in} to region
@var{out}. The use of @code{bcopy} is deprecated in new programs.
@end deftypefn
@c bsearch.c:33
@deftypefn Supplemental void* bsearch (const void *@var{key}, const void *@var{base}, size_t @var{nmemb}, size_t @var{size}, int (*@var{compar})(const void *, const void *))
Performs a search over an array of @var{nmemb} elements pointed to by
@var{base} for a member that matches the object pointed to by @var{key}.
The size of each member is specified by @var{size}. The array contents
should be sorted in ascending order according to the @var{compar}
comparison function. This routine should take two arguments pointing to
the @var{key} and to an array member, in that order, and should return an
integer less than, equal to, or greater than zero if the @var{key} object
is respecitively less than, matching, or greater than the array member.
@end deftypefn
@c bzero.c:6
@deftypefn Supplemental void bzero (char *@var{mem}, int @var{count})
Zeros @var{count} bytes starting at @var{mem}. Use if this function
is deprecated in favor of @code{memset}.
@end deftypefn
@c calloc.c:6
@deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize})
Uses @code{malloc} to allocate storage for @var{nelem} objects of
@var{elsize} bytes each, then zeros the memory.
@end deftypefn
@c clock.c:27
@deftypefn Supplemental long clock ()
Returns an approximation of the CPU time used by the process as a
@code{clock_t}; divide this number by @samp{CLOCKS_PER_SEC} to get the
number of seconds used.
@end deftypefn
@c strerror.c:566
@deftypefn Replacement int errno_max (void)
Returns the maximum @code{errno} value for which a corresponding
symbolic name or message is available. Note that in the case where we
use the @code{sys_errlist} supplied by the system, it is possible for
there to be more symbolic names than messages, or vice versa. In
fact, the manual page for @code{perror(3C)} explicitly warns that one
should check the size of the table (@code{sys_nerr}) before indexing
it, since new error codes may be added to the system before they are
added to the table. Thus @code{sys_nerr} might be smaller than value
implied by the largest @code{errno} value defined in @file{errno.h}.
We return the maximum value that can be used to obtain a meaningful
symbolic name or message.
@end deftypefn
@c getcwd.c:6
@deftypefn Supplemental char* getcwd (char *@var{pathname}, @var{len})
Copy the absolute pathname for the current working directory into
@var{pathname}, which is assumed to point to a buffer of at least
@var{len} bytes, and return a pointer to the buffer. If the current
directory's path doesn't fit in @var{len} characters, the result is
NULL and @var{errno} is set. If @var{pathname} is a null pointer,
@code{getcwd} will obtain @var{len} bytes of space using
@code{malloc}.
@end deftypefn
@c getpagesize.c:5
@deftypefn Supplemental int getpagesize ()
Returns the number of bytes in a page of memory. This is the
granularity of many of the system memory management routines. No
guarantee is made as to whether or not it is the same as the basic
memory management hardware page size.
@end deftypefn
@c getpwd.c:5
@deftypefn Supplemental char* getpwd ()
Returns the current working directory. This implementation caches the
result on the assumption that the process will not call @code{chdir}
between calls to @code{getpwd}.
@end deftypefn
@c index.c:5
@deftypefn Supplemental char* index (char *@var{s}, int @var{c})
Returns a pointer to the first occurance of the character @var{c} in
the string @var{s}, or NULL if not found. The use of @code{index} is
deprecated in new programs in favor of @code{strchr}.
@end deftypefn
@c memchr.c:3
@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n})
This function searches memory starting at @code{*}@var{src} for the
character @var{c}. The search only ends with the first occurrence of
@var{c}, or after @var{length} characters; in particular, a null
character does not terminate the search. If the character @var{c} is
found within @var{length} characters of @code{*}@var{src}, a pointer
to the character is returned. If @var{c} is not found, then NULL is
returned.
@end deftypefn
@c memcmp.c:6
@deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, size_t @var{count})
Compares the first @var{count} bytes of two areas of memory. Returns
zero if they are the same, a value less than zero if @var{x} is
lexically less than @var{y}, or a value greater than zero if @var{x}
is lexically greater than @var{y}. Note that lexical order is determined
as if comparing unsigned char arrays.
@end deftypefn
@c memcpy.c:6
@deftypefn Supplemental void* memcpy (void *@var{out}, const void *@var{in}, size_t @var{length})
Copies @var{length} bytes from memory region @var{in} to region
@var{out}. Returns a pointer to @var{out}.
@end deftypefn
@c memmove.c:6
@deftypefn Supplemental void* memmove (void *@var{from}, const void *@var{to}, size_t @var{count})
Copies @var{count} bytes from memory area @var{from} to memory area
@var{to}, returning a pointer to @var{to}.
@end deftypefn
@c memset.c:6
@deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count})
Sets the first @var{count} bytes of @var{s} to the constant byte
@var{c}, returning a pointer to @var{s}.
@end deftypefn
@c putenv.c:21
@deftypefn Supplemental int putenv (const char *@var{string})
Uses @code{setenv} or @code{unsetenv} to put @var{string} into
the environment or remove it. If @var{string} is of the form
@samp{name=value} the string is added; if no `=' is present the
name is unset/removed.
@end deftypefn
@c rename.c:6
@deftypefn Supplemental int rename (const char *@var{old}, const char *@var{new})
Renames a file from @var{old} to @var{new}. If @var{new} already
exists, it is removed.
@end deftypefn
@c rindex.c:5
@deftypefn Supplemental char* rindex (const char *@var{s}, int @var{c})
Returns a pointer to the last occurance of the character @var{c} in
the string @var{s}, or NULL if not found. The use of @code{rindex} is
deprecated in new programs in favor of @code{strrchr}.
@end deftypefn
@c setenv.c:22
@deftypefn Supplemental int setenv (const char *@var{name}, const char *@var{value}, int @var{overwrite})
@deftypefnx Supplemental void unsetenv (const char *@var{name})
@code{setenv} adds @var{name} to the environment with value
@var{value}. If the name was already present in the environment,
the new value will be stored only if @var{overwrite} is non-zero.
The companion @code{unsetenv} function removes @var{name} from the
environment. This implementation is not safe for multithreaded code.
@end deftypefn
@c sigsetmask.c:8
@deftypefn Supplemental int sigsetmask (int @var{set})
Sets the signal mask to the one provided in @var{set} and returns
the old mask (which, for libiberty's implementation, will always
be the value @code{1}).
@end deftypefn
@c strcasecmp.c:15
@deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2})
A case-insensitive @code{strcmp}.
@end deftypefn
@c strchr.c:6
@deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c})
Returns a pointer to the first occurance of the character @var{c} in
the string @var{s}, or NULL if not found. If @var{c} is itself the
null character, the results are undefined.
@end deftypefn
@c strdup.c:3
@deftypefn Supplemental char* strdup (const char *@var{s})
Returns a pointer to a copy of @var{s} in memory obtained from
@code{malloc}, or NULL if insufficient memory was available.
@end deftypefn
@c strerror.c:670
@deftypefn Replacement const char* strerrno (int @var{errnum})
Given an error number returned from a system call (typically returned
in @code{errno}), returns a pointer to a string containing the
symbolic name of that error number, as found in @file{errno.h}.
If the supplied error number is within the valid range of indices for
symbolic names, but no name is available for the particular error
number, then returns the string @samp{"Error NUM"}, where NUM is the
error number.
If the supplied error number is not within the range of valid
indices, then returns NULL.
The contents of the location pointed to are only guaranteed to be
valid until the next call to strerrno.
@end deftypefn
@c strerror.c:602
@deftypefn Replacement char* strerror (int @var{errnoval})
Maps an @code{errno} number to an error message string, the contents
of which are implementation defined. On systems which have the
external variables @code{sys_nerr} and @code{sys_errlist}, these
strings will be the same as the ones used by @code{perror}.
If the supplied error number is within the valid range of indices for
the @code{sys_errlist}, but no message is available for the particular
error number, then returns the string @samp{"Error NUM"}, where NUM is
the error number.
If the supplied error number is not a valid index into
@code{sys_errlist}, returns NULL.
The returned string is only guaranteed to be valid only until the
next call to @code{strerror}.
@end deftypefn
@c strncasecmp.c:15
@deftypefn Supplemental int strncasecmp (const char *@var{s1}, const char *@var{s2})
A case-insensitive @code{strncmp}.
@end deftypefn
@c strncmp.c:6
@deftypefn Supplemental int strncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n})
Compares the first @var{n} bytes of two strings, returning a value as
@code{strcmp}.
@end deftypefn
@c strrchr.c:6
@deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
Returns a pointer to the last occurance of the character @var{c} in
the string @var{s}, or NULL if not found. If @var{c} is itself the
null character, the results are undefined.
@end deftypefn
@c strstr.c:6
@deftypefn Supplemental char* strstr (const char *@var{string}, const char *@var{sub})
This function searches for the substring @var{sub} in the string
@var{string}, not including the terminating NUL characters. A pointer
to the first occurance of @var{sub} is returned, or NULL if the
substring is absent. If @var{sub} points to a string with zero
length, the function returns @var{string}.
@end deftypefn
@c strtod.c:27
@deftypefn Supplemental double strtod (const char *@var{string}, char **@var{endptr})
This ANSI C function converts the initial portion of @var{string} to a
@code{double}. If @var{endptr} is not NULL, a pointer to the
character after the last character used in the conversion is stored in
the location referenced by @var{endptr}. If no conversion is
performed, zero is returned and the value of @var{string} is stored in
the location referenced by @var{endptr}.
@end deftypefn
@c strerror.c:730
@deftypefn Replacement int strtoerrno (const char *@var{name})
Given the symbolic name of a error number (e.g., @code{EACCESS}), map it
to an errno value. If no translation is found, returns 0.
@end deftypefn
@c strtol.c:33
@deftypefn Supplemental {long int} strtol (const char *@var{string}, char **@var{endptr}, int @var{base})
The @code{strtol} function converts the string in @var{string} to a
long integer value according to the given @var{base}, which must be
between 2 and 36 inclusive, or be the special value 0. If @var{base}
is 0, @code{strtol} will look for the prefixes @code{0} and @code{0x}
to indicate bases 8 and 16, respectively, else default to base 10.
When the base is 16 (either explicitly or implicitly), a prefix of
@code{0x} is allowed. The handling of endptr is as that of
@code{strtod} above.
@end deftypefn
@c tmpnam.c:3
@deftypefn Supplemental char* tmpnam (char *@var{s})
This function attempts to create a name for a temporary file, which
will be a valid file name yet not exist when @code{tmpnam} checks for
it. @var{s} must point to a buffer of at least @code{L_tmpnam} bytes,
or be NULL. Use of this function creates a security risk, and it must
not be used in new projects. Use @code{mkstemp} instead.
@end deftypefn
@c vfork.c:6
@deftypefn Supplemental int vfork ()
Emulates @code{vfork} by calling @code{fork} and returning its value.
@end deftypefn
@c vprintf.c:3
@deftypefn Supplemental int vprintf (const char *@var{format}, va_list @var{ap})
@deftypefnx Supplemental int vfprintf (FILE *@var{stream}, const char *@var{format}, va_list @var{ap})
@deftypefnx Supplemental int vsprintf (char *@var{str}, const char *@var{format}, va_list @var{ap})
These functions are the same as @code{printf}, @code{fprintf}, and
@code{sprintf}, respectively, except that they are called with a
@code{va_list} instead of a variable number of arguments. Note that
they do not call @code{va_end}; this is the application's
responsibility. In @libib{} they are implemented in terms of the
nonstandard but common function @code{_doprnt}.
@end deftypefn
@c waitpid.c:3
@deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
This is a wrapper around the @code{wait} function. Any ``special''
values of @var{pid} depend on your implementation of @code{wait}, as
does the return value. The third argument is unused in @libib{}.
@end deftypefn
@c xatexit.c:11
@deftypefun int xatexit (void (*@var{fn}) (void))
Behaves as the standard @code{atexit} function, but with no limit on
the number of registered funtions. Returns 0 on success, or -1 on
failure. If you use @code{xatexit} to register functions, you must use
@code{xexit} to terminate your program.
@end deftypefun
@c xmalloc.c:37
@deftypefn Replacement void* xcalloc (size_t, size_t)
Allocate memory without fail, and set it to zero. This routine functions
like @code{calloc}, but will behave the same as @code{xmalloc} if memory
cannot be found.
@end deftypefn
@c xexit.c:22
@deftypefn Replacement void xexit (int @var{code})
Terminates the program. If any functions have been registered with
the @code{xatexit} rpelacement function, they will be called first.
Termination is handled via the system's normal @code{exit} call.
@end deftypefn
@c xmalloc.c:22
@deftypefn Replacement void* xmalloc (size_t)
Allocate memory without fail. If @code{malloc} fails, this will print
a message to stderr (using the name set by @code{xmalloc_set_program_name},
if any) and then call @code{xexit}. Note that it is therefore safe for
a program to contain @code{#define malloc xmalloc} in its source.
@end deftypefn
@c xmalloc.c:52
@deftypefn Replacement void xmalloc_failed (size_t)
This function is not meant to be called by client code, and is listed
here for completeness only. If any of the allocation routines fail, this
function will be called to print an error message and terminate execution.
@end deftypefn
@c xmalloc.c:45
@deftypefn Replacement void xmalloc_set_program_name (const char *@var{name})
You can use this to set the name of the program used by
@code{xmalloc_failed} when printing a failure message.
@end deftypefn
@c xmemdup.c:7
@deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size})
Duplicates a region of memory without fail. First, @var{alloc_size} bytes
are allocated, then @var{copy_size} bytes from @var{input} are copied into
it, and the new memory is returned. If fewer bytes are copied than were
allocated, the remaining memory is zeroed.
@end deftypefn
@c xmalloc.c:31
@deftypefn Replacement void* xrealloc (void*, size_t)
Reallocate memory without fail. This routine functions like @code{realloc},
but will behave the same as @code{xmalloc} if memory cannot be found.
@end deftypefn
@c xstrdup.c:7
@deftypefn Replacement char* xstrdup (const char *@var{s})
Duplicates a character string without fail, using @code{xmalloc} to
obtain memory.
@end deftypefn
@c xstrerror.c:7
@deftypefn Replacement char* xstrerror (int @var{errnum})
Behaves exactly like the standard @code{strerror} function, but
will never return a NULL pointer.
@end deftypefn

128
libiberty/gather-docs Normal file
View File

@ -0,0 +1,128 @@
#!/usr/bin/perl
# -*- perl -*-
# Copyright (C) 2001
# Free Software Foundation
#
# This file is part of the libiberty library.
# Libiberty is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# Libiberty is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with libiberty; see the file COPYING.LIB. If not,
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# Originally written by DJ Delorie <dj@redhat.com>
# This program looks for texinfo snippets in source files and other
# files, and builds per-category files with entries sorted in
# alphabetical order.
# The syntax it looks for is lines starting with '@def' in *.c and
# other files (see TEXIFILES in Makefile.in). Entries are terminated
# at the next @def* (which begins a new entry) or, for C files, a line
# that begins with '*/' without leading spaces (this assumes that the
# texinfo snippet is within a C-style /* */ comment).
#
if ($ARGV[0] eq "-v") {
$verbose = 1;
shift;
}
$srcdir = shift;
$outfile = shift;
if ($outfile !~ /\S/ || ! -f "$srcdir/Makefile.in" ) {
print STDERR "Usage: gather-docs [-v] srcdir outfile.txi [files with snippets in them ...]\n";
exit 1;
}
$errors = 0;
for $in (@ARGV) {
if (!open(IN, "$srcdir/$in")) {
print STDERR "Cannot open $srcdir/$in for reading: $!\n";
$errors ++;
} else {
$first = 1;
$pertinent = 0;
$man_mode = 0;
$line = 0;
while (<IN>) {
$line ++;
$pertinent = 1 if /^\@def[a-z]*[a-wyz] /;
$pertinent = 0 if /^\*\//;
next unless $pertinent;
if (/^\@def[a-z]*[a-wyz] /) {
($name) = m/[^\(]* ([^\( \t\r\n]+) *\(/;
$name =~ s/[ ]*$//;
$key = $name;
$key =~ tr/A-Z/a-z/;
$key =~ s/[^a-z0-9]+/ /g;
$name{$key} = $node;
$lines{$key} = '';
$src_file{$key} = $in;
$src_line{$key} = $line;
print "\nReading $in :" if $verbose && $first;
$first = 0;
print " $name" if $verbose;
$node_lines{$key} .= $_;
} else {
$node_lines{$key} .= $_;
}
$pertinent = 0 if /^\@end def/;
}
close (IN);
}
}
print "\n" if $verbose;
exit $errors if $errors;
if (!open (OUT, "> $outfile")) {
print STDERR "Cannot open $outfile for writing: $!\n";
$errors ++;
next;
}
print "Writing $outfile\n" if $verbose;
print OUT "\@c Automatically generated from *.c and others (the comments before\n";
print OUT "\@c each entry tell you which file and where in that file). DO NOT EDIT!\n";
print OUT "\@c Edit the *.c files, configure with --enable-maintainer-mode,\n";
print OUT "\@c and let gather-docs build you a new copy.\n\n";
for $key (sort keys %name) {
print OUT "\@c $src_file{$key}:$src_line{$key}\n";
print OUT $node_lines{$key};
print OUT "\n";
}
if (! print OUT "\n") {
print STDERR "Disk full writing $srcdir/$cat.texi\n";
$errors ++;
}
close (OUT);
exit $errors;

View File

@ -2,24 +2,18 @@
This function is in the public domain. */
/*
NAME
getcwd -- get absolute pathname for current working directory
SYNOPSIS
char *getcwd (char pathname[len], len)
@deftypefn Supplemental char* getcwd (char *@var{pathname}, @var{len})
DESCRIPTION
Copy the absolute pathname for the current working directory into
the supplied buffer and return a pointer to the buffer. If the
current directory's path doesn't fit in LEN characters, the result
is NULL and errno is set.
Copy the absolute pathname for the current working directory into
@var{pathname}, which is assumed to point to a buffer of at least
@var{len} bytes, and return a pointer to the buffer. If the current
directory's path doesn't fit in @var{len} characters, the result is
NULL and @var{errno} is set. If @var{pathname} is a null pointer,
@code{getcwd} will obtain @var{len} bytes of space using
@code{malloc}.
If pathname is a null pointer, getcwd() will obtain size bytes of
space using malloc.
BUGS
Emulated via the getwd() call, which is reasonable for most
systems that do not have getcwd().
@end deftypefn
*/

View File

@ -2,20 +2,14 @@
/*
NAME
@deftypefn Supplemental int getpagesize ()
getpagesize -- return the number of bytes in page of memory
Returns the number of bytes in a page of memory. This is the
granularity of many of the system memory management routines. No
guarantee is made as to whether or not it is the same as the basic
memory management hardware page size.
SYNOPSIS
int getpagesize (void)
DESCRIPTION
Returns the number of bytes in a page of memory. This is the
granularity of many of the system memory management routines.
No guarantee is made as to whether or not it is the same as the
basic memory management hardware page size.
@end deftypefn
BUGS

View File

@ -1,5 +1,17 @@
/* getpwd.c - get the working directory */
/*
@deftypefn Supplemental char* getpwd ()
Returns the current working directory. This implementation caches the
result on the assumption that the process will not call @code{chdir}
between calls to @code{getpwd}.
@end deftypefn
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@ -1,5 +1,17 @@
/* Stub implementation of (obsolete) index(). */
/*
@deftypefn Supplemental char* index (char *@var{s}, int @var{c})
Returns a pointer to the first occurance of the character @var{c} in
the string @var{s}, or NULL if not found. The use of @code{index} is
deprecated in new programs in favor of @code{strchr}.
@end deftypefn
*/
extern char * strchr();
char *

316
libiberty/libiberty.texi Normal file
View File

@ -0,0 +1,316 @@
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename libiberty.info
@settitle @sc{gnu} libiberty
@c %**end of header
@syncodeindex fn cp
@syncodeindex vr cp
@macro libib
@code{libiberty}
@end macro
@c The edition date is written in three locations. Search for 'thedate'.
@ifinfo
This manual describes the GNU @libib library of utility subroutines.
This edition accompanies GCC 3, September 2001.
Copyright @copyright{} 2001 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the
section entitled ``GNU Free Documentation License''.
@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries a copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
@end ignore
@end ifinfo
@c The edition date is written in three locations. Search for 'thedate'.
@titlepage
@title @sc{gnu} libiberty
@subtitle September 2001
@subtitle for GCC 3
@author Phil Edwards et al.
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 2001 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the
section entitled ``GNU Free Documentation License''.
@end titlepage
@ifnottex
@node Top,Using,,
@top Introduction
The @libib{} library is a collection of subroutines used by various
GNU programs. It is available under the Library General Public
License; for more information, see @ref{Library Copying}.
@c The edition date is written in three locations. Search for 'thedate'.
This edition accompanies GCC 3, September 2001.
@end ifnottex
@menu
* Using:: How to use libiberty in your code.
* Overview:: Overview of available function groups.
* Functions:: Available functions, macros, and global variables.
* Obstacks:: Object Stacks.
* Licenses:: The various licenses under which libiberty sources are
distributed.
* Index:: Index of functions and categories.
@end menu
@node Using,Overview,Top,Top
@chapter Using
@cindex using libiberty
@cindex libiberty usage
@cindex how to use
@c THIS SECTION IS CRAP AND NEEDS REWRITING BADLY.
To date, @libib{} is generally not installed on its own. It has evolved
over years but does not have its own version number nor release schedule.
Possibly the easiest way to use @libib{} in your projects is to drop the
@libib{} code into your project's sources, and to build the library along
with your own sources; the library would then be linked in at the end. This
prevents any possible version mismatches with other copies of libiberty
elsewhere on the system.
Passing @option{--enable-install-libiberty} to the @command{configure}
script when building @libib{} causes the header files and archive library
to be installed when @samp{make install} is run. This option also takes
an (optional) argument to specify the installation location, in the same
manner as @option{--prefix}.
For your own projects, an approach which offers stability and flexibility
is to include @libib{} with your code, but allow the end user to optionally
choose to use a previously-installed version instead. In this way the
user may choose (for example) to install @libib{} as part of GCC, and use
that version for all software built with that compiler. (This approach
has proven useful with software using the GNU @code{readline} library.)
Making use of @libib{} code usually requires that you include one or more
header files from the @libib{} distribution. (They will be named as
necessary in the function descriptions.) At link time, you will need to
add @option{-liberty} to your link command invocation.
@node Overview,Functions,Using,Top
@chapter Overview
Functions contained in @libib{} can be divided into three general categories.
@menu
* Supplemental Functions:: Providing functions which don't exist
on older operating systems.
* Replacement Functions:: These functions are sometimes buggy or
unpredictable on some operating systems.
* Extensions:: Functions which provide useful extensions
or safety wrappers around existing code.
@end menu
@node Supplemental Functions,Replacement Functions,,Overview
@section Supplemental Functions
@cindex supplemental functions
@cindex functions, supplemental
@cindex functions, missing
Certain operating systems do not provide functions which have since
become standardized, or at least common. For example, the Single
Unix Specification Version 2 requires that the @code{basename}
function be provided, but an OS which predates that specification
might not have this function. This should not prevent well-written
code from running on such a system.
Similarly, some functions exist only among a particular ``flavor''
or ``family'' of operating systems. As an example, the @code{bzero}
function is often not present on systems outside the BSD-derived
family of systems.
Many such functions are provided in @libib{}. They are quickly
listed here with little description, as systems which lack them
become less and less common. Each function @var{foo} is implemented
in @file{foo.c} but not declared in any @libib{} header file; more
comments and caveats for each function's implementation are often
available in the source file. Generally, the function can simply
be declared as @code{extern}.
@node Replacement Functions,Extensions,Supplemental Functions,Overview
@section Replacement Functions
@cindex replacement functions
@cindex functions, replacement
Some functions have extremely limited implementations on different
platforms. Other functions are tedious to use correctly; for example,
proper use of @code{malloc} calls for the return value to be checked and
appropriate action taken if memory has been exhausted. A group of
``replacement functions'' is available in @libib{} to address these issues
for some of the most commonly used subroutines.
All of these functions are declared in the @file{libiberty.h} header
file. Many of the implementations will use preprocessor macros set by
GNU Autoconf, if you decide to make use of that program. Some of these
functions may call one another.
@menu
* Memory Allocation:: Testing and handling failed memory
requests automatically.
* Exit Handlers:: Calling routines on program exit.
* Error Reporting:: Mapping errno and signal numbers to
more useful string formats.
@end menu
@node Memory Allocation
@subsection Memory Allocation
@cindex memory allocation
The functions beginning with the letter `x' are wrappers around
standard functions; the functions provided by the system environment
are called and their results checked before the results are passed back
to client code. If the standard functions fail, these wrappers will
terminate the program. Thus, these versions can be used with impunity.
@node Exit Handlers
@subsection Exit Handlers
@cindex exit handlers
The existence and implementation of the @code{atexit} routine varies
amongst the flavors of Unix. @libib{} provides an unvarying dependable
implementation via @code{xatexit} and @code{xexit}.
@node Error Reporting
@subsection Error Reporting
@cindex error reporting
These are a set of routines to facilitate programming with the system
@code{errno} interface. The @libib{} source file @file{strerror.c}
contains a good deal of documentation for these functions.
@c signal stuff
@node Extensions,,Replacement Functions,Overview
@section Extensions
@cindex extensions
@cindex functions, extension
@libib{} includes additional functionality above and beyond standard
functions, which has proven generically useful in GNU programs, such as
obstacks and regex. These functions are often copied from other
projects as they gain popularity, and are included here to provide a
central location from which to use, maintain, and distribute them.
@menu
* Obstacks:: Stacks of arbitrary objects.
@end menu
@node Functions,Obstacks,Overview,Top
@chapter Function, Variable, and Macro Listing.
@include functions.texi
@c This is generated from the glibc manual using a make-obstacks-texi.sh
@c script of Phil's. Hope it's accurate.
@include obstacks.texi
@node Licenses,Index,Obstacks,Top
@appendix Licenses
@menu
* Library Copying:: The GNU Libary General Public License
* BSD:: Regents of the University of California
@end menu
@c This takes care of Library Copying. It is the copying-lib.texi from the
@c GNU website, with its @node line altered to make makeinfo shut up.
@include copying-lib.texi
@page
@node BSD,,,Licenses
@appendixsec BSD
Copyright @copyright{} 1990 Regents of the University of California.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
@enumerate
@item
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
@item
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
@item
[rescinded 22 July 1999]
@item
Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
@end enumerate
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
@node Index,,Licenses,Top
@unnumbered Index
@printindex cp
@contents
@bye

75
libiberty/maint-tool Normal file
View File

@ -0,0 +1,75 @@
#!/usr/bin/perl
# -*- perl -*-
# Copyright (C) 2001
# Free Software Foundation
#
# This file is part of the libiberty library.
# Libiberty is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# Libiberty is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with libiberty; see the file COPYING.LIB. If not,
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# Originally written by DJ Delorie <dj@redhat.com>
# This is a trivial script which checks the lists of C and O files in
# the Makefile for consistency.
$mode = shift;
$srcdir = ".";
if ($mode eq "-s") {
$srcdir = shift;
$mode = shift;
}
&missing() if $mode eq "missing";
exit 0;
######################################################################
sub missing {
opendir(S, $srcdir);
while ($f = readdir S) {
$have{$f} = 1;
}
closedir(S);
opendir(S, ".");
while ($f = readdir S) {
$have{$f} = 1;
}
closedir(S);
for $a (@ARGV) {
$listed{$a} = 1;
$have{$a} = 0;
}
for $f (sort keys %have) {
next unless $have{$f};
if ($f =~ /\.c$/) {
print "S $f\n";
}
}
for $f (sort keys %listed) {
if ($f =~ /(.*)\.c$/) {
$base = $1;
if (! $listed{"$base.o"}) {
print "O $f\n";
}
}
}
}

View File

@ -1,37 +1,16 @@
/*
FUNCTION
<<memchr>>---find character in memory
INDEX
memchr
@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n})
ANSI_SYNOPSIS
#include <string.h>
void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>);
This function searches memory starting at @code{*}@var{src} for the
character @var{c}. The search only ends with the first occurrence of
@var{c}, or after @var{length} characters; in particular, a null
character does not terminate the search. If the character @var{c} is
found within @var{length} characters of @code{*}@var{src}, a pointer
to the character is returned. If @var{c} is not found, then NULL is
returned.
TRAD_SYNOPSIS
#include <string.h>
void *memchr(<[src]>, <[c]>, <[length]>)
void *<[src]>;
void *<[c]>;
size_t <[length]>;
DESCRIPTION
This function searches memory starting at <<*<[src]>>> for the
character <[c]>. The search only ends with the first
occurrence of <[c]>, or after <[length]> characters; in
particular, <<NULL>> does not terminate the search.
RETURNS
If the character <[c]> is found within <[length]> characters
of <<*<[src]>>>, a pointer to the character is returned. If
<[c]> is not found, then <<NULL>> is returned.
PORTABILITY
<<memchr>> requires no supporting OS subroutines.
QUICKREF
memchr ansi pure
@end deftypefn
*/

View File

@ -2,16 +2,17 @@
This function is in the public domain. */
/*
NAME
memcmp -- compare two memory regions
SYNOPSIS
int memcmp (const void *from, const void *to, size_t count)
@deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, size_t @var{count})
Compares the first @var{count} bytes of two areas of memory. Returns
zero if they are the same, a value less than zero if @var{x} is
lexically less than @var{y}, or a value greater than zero if @var{x}
is lexically greater than @var{y}. Note that lexical order is determined
as if comparing unsigned char arrays.
@end deftypefn
DESCRIPTION
Compare two memory regions and return less than,
equal to, or greater than zero, according to lexicographical
ordering of the compared regions.
*/
#include <ansidecl.h>

View File

@ -2,15 +2,14 @@
This function is in the public domain. */
/*
NAME
memcpy -- copy memory regions of arbitary length
SYNOPSIS
void* memcpy (void *out, const void *in, size_t n);
@deftypefn Supplemental void* memcpy (void *@var{out}, const void *@var{in}, size_t @var{length})
Copies @var{length} bytes from memory region @var{in} to region
@var{out}. Returns a pointer to @var{out}.
@end deftypefn
DESCRIPTION
Copy LENGTH bytes from memory region pointed to by IN to memory
region pointed to by OUT.
*/
#include <ansidecl.h>

View File

@ -1,5 +1,17 @@
/* Wrapper to implement ANSI C's memmove using BSD's bcopy. */
/* This function is in the public domain. --Per Bothner. */
/*
@deftypefn Supplemental void* memmove (void *@var{from}, const void *@var{to}, size_t @var{count})
Copies @var{count} bytes from memory area @var{from} to memory area
@var{to}, returning a pointer to @var{to}.
@end deftypefn
*/
#include <ansidecl.h>
#ifdef __STDC__
#include <stddef.h>

View File

@ -1,6 +1,17 @@
/* memset
This implementation is in the public domain. */
/*
@deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count})
Sets the first @var{count} bytes of @var{s} to the constant byte
@var{c}, returning a pointer to @var{s}.
@end deftypefn
*/
#include <ansidecl.h>
#ifdef __STDC__
#include <stddef.h>

758
libiberty/obstacks.texi Normal file
View File

@ -0,0 +1,758 @@
@node Obstacks,Licenses,Functions,Top
@chapter Obstacks
@cindex obstacks
An @dfn{obstack} is a pool of memory containing a stack of objects. You
can create any number of separate obstacks, and then allocate objects in
specified obstacks. Within each obstack, the last object allocated must
always be the first one freed, but distinct obstacks are independent of
each other.
Aside from this one constraint of order of freeing, obstacks are totally
general: an obstack can contain any number of objects of any size. They
are implemented with macros, so allocation is usually very fast as long as
the objects are usually small. And the only space overhead per object is
the padding needed to start each object on a suitable boundary.
@menu
* Creating Obstacks:: How to declare an obstack in your program.
* Preparing for Obstacks:: Preparations needed before you can
use obstacks.
* Allocation in an Obstack:: Allocating objects in an obstack.
* Freeing Obstack Objects:: Freeing objects in an obstack.
* Obstack Functions:: The obstack functions are both
functions and macros.
* Growing Objects:: Making an object bigger by stages.
* Extra Fast Growing:: Extra-high-efficiency (though more
complicated) growing objects.
* Status of an Obstack:: Inquiries about the status of an obstack.
* Obstacks Data Alignment:: Controlling alignment of objects in obstacks.
* Obstack Chunks:: How obstacks obtain and release chunks;
efficiency considerations.
* Summary of Obstacks::
@end menu
@node Creating Obstacks
@section Creating Obstacks
The utilities for manipulating obstacks are declared in the header
file @file{obstack.h}.
@pindex obstack.h
@comment obstack.h
@comment GNU
@deftp {Data Type} {struct obstack}
An obstack is represented by a data structure of type @code{struct
obstack}. This structure has a small fixed size; it records the status
of the obstack and how to find the space in which objects are allocated.
It does not contain any of the objects themselves. You should not try
to access the contents of the structure directly; use only the functions
described in this chapter.
@end deftp
You can declare variables of type @code{struct obstack} and use them as
obstacks, or you can allocate obstacks dynamically like any other kind
of object. Dynamic allocation of obstacks allows your program to have a
variable number of different stacks. (You can even allocate an
obstack structure in another obstack, but this is rarely useful.)
All the functions that work with obstacks require you to specify which
obstack to use. You do this with a pointer of type @code{struct obstack
*}. In the following, we often say ``an obstack'' when strictly
speaking the object at hand is such a pointer.
The objects in the obstack are packed into large blocks called
@dfn{chunks}. The @code{struct obstack} structure points to a chain of
the chunks currently in use.
The obstack library obtains a new chunk whenever you allocate an object
that won't fit in the previous chunk. Since the obstack library manages
chunks automatically, you don't need to pay much attention to them, but
you do need to supply a function which the obstack library should use to
get a chunk. Usually you supply a function which uses @code{malloc}
directly or indirectly. You must also supply a function to free a chunk.
These matters are described in the following section.
@node Preparing for Obstacks
@section Preparing for Using Obstacks
Each source file in which you plan to use the obstack functions
must include the header file @file{obstack.h}, like this:
@smallexample
#include <obstack.h>
@end smallexample
@findex obstack_chunk_alloc
@findex obstack_chunk_free
Also, if the source file uses the macro @code{obstack_init}, it must
declare or define two functions or macros that will be called by the
obstack library. One, @code{obstack_chunk_alloc}, is used to allocate
the chunks of memory into which objects are packed. The other,
@code{obstack_chunk_free}, is used to return chunks when the objects in
them are freed. These macros should appear before any use of obstacks
in the source file.
Usually these are defined to use @code{malloc} via the intermediary
@code{xmalloc} (@pxref{Unconstrained Allocation, , , libc, The GNU C Library Reference Manual}). This is done with
the following pair of macro definitions:
@smallexample
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
@end smallexample
@noindent
Though the memory you get using obstacks really comes from @code{malloc},
using obstacks is faster because @code{malloc} is called less often, for
larger blocks of memory. @xref{Obstack Chunks}, for full details.
At run time, before the program can use a @code{struct obstack} object
as an obstack, it must initialize the obstack by calling
@code{obstack_init}.
@comment obstack.h
@comment GNU
@deftypefun int obstack_init (struct obstack *@var{obstack-ptr})
Initialize obstack @var{obstack-ptr} for allocation of objects. This
function calls the obstack's @code{obstack_chunk_alloc} function. If
allocation of memory fails, the function pointed to by
@code{obstack_alloc_failed_handler} is called. The @code{obstack_init}
function always returns 1 (Compatibility notice: Former versions of
obstack returned 0 if allocation failed).
@end deftypefun
Here are two examples of how to allocate the space for an obstack and
initialize it. First, an obstack that is a static variable:
@smallexample
static struct obstack myobstack;
@dots{}
obstack_init (&myobstack);
@end smallexample
@noindent
Second, an obstack that is itself dynamically allocated:
@smallexample
struct obstack *myobstack_ptr
= (struct obstack *) xmalloc (sizeof (struct obstack));
obstack_init (myobstack_ptr);
@end smallexample
@comment obstack.h
@comment GNU
@defvar obstack_alloc_failed_handler
The value of this variable is a pointer to a function that
@code{obstack} uses when @code{obstack_chunk_alloc} fails to allocate
memory. The default action is to print a message and abort.
You should supply a function that either calls @code{exit}
(@pxref{Program Termination, , , libc, The GNU C Library Reference Manual}) or @code{longjmp} (@pxref{Non-Local
Exits, , , libc, The GNU C Library Reference Manual}) and doesn't return.
@smallexample
void my_obstack_alloc_failed (void)
@dots{}
obstack_alloc_failed_handler = &my_obstack_alloc_failed;
@end smallexample
@end defvar
@node Allocation in an Obstack
@section Allocation in an Obstack
@cindex allocation (obstacks)
The most direct way to allocate an object in an obstack is with
@code{obstack_alloc}, which is invoked almost like @code{malloc}.
@comment obstack.h
@comment GNU
@deftypefun {void *} obstack_alloc (struct obstack *@var{obstack-ptr}, int @var{size})
This allocates an uninitialized block of @var{size} bytes in an obstack
and returns its address. Here @var{obstack-ptr} specifies which obstack
to allocate the block in; it is the address of the @code{struct obstack}
object which represents the obstack. Each obstack function or macro
requires you to specify an @var{obstack-ptr} as the first argument.
This function calls the obstack's @code{obstack_chunk_alloc} function if
it needs to allocate a new chunk of memory; it calls
@code{obstack_alloc_failed_handler} if allocation of memory by
@code{obstack_chunk_alloc} failed.
@end deftypefun
For example, here is a function that allocates a copy of a string @var{str}
in a specific obstack, which is in the variable @code{string_obstack}:
@smallexample
struct obstack string_obstack;
char *
copystring (char *string)
@{
size_t len = strlen (string) + 1;
char *s = (char *) obstack_alloc (&string_obstack, len);
memcpy (s, string, len);
return s;
@}
@end smallexample
To allocate a block with specified contents, use the function
@code{obstack_copy}, declared like this:
@comment obstack.h
@comment GNU
@deftypefun {void *} obstack_copy (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
This allocates a block and initializes it by copying @var{size}
bytes of data starting at @var{address}. It calls
@code{obstack_alloc_failed_handler} if allocation of memory by
@code{obstack_chunk_alloc} failed.
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun {void *} obstack_copy0 (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
Like @code{obstack_copy}, but appends an extra byte containing a null
character. This extra byte is not counted in the argument @var{size}.
@end deftypefun
The @code{obstack_copy0} function is convenient for copying a sequence
of characters into an obstack as a null-terminated string. Here is an
example of its use:
@smallexample
char *
obstack_savestring (char *addr, int size)
@{
return obstack_copy0 (&myobstack, addr, size);
@}
@end smallexample
@noindent
Contrast this with the previous example of @code{savestring} using
@code{malloc} (@pxref{Basic Allocation, , , libc, The GNU C Library Reference Manual}).
@node Freeing Obstack Objects
@section Freeing Objects in an Obstack
@cindex freeing (obstacks)
To free an object allocated in an obstack, use the function
@code{obstack_free}. Since the obstack is a stack of objects, freeing
one object automatically frees all other objects allocated more recently
in the same obstack.
@comment obstack.h
@comment GNU
@deftypefun void obstack_free (struct obstack *@var{obstack-ptr}, void *@var{object})
If @var{object} is a null pointer, everything allocated in the obstack
is freed. Otherwise, @var{object} must be the address of an object
allocated in the obstack. Then @var{object} is freed, along with
everything allocated in @var{obstack} since @var{object}.
@end deftypefun
Note that if @var{object} is a null pointer, the result is an
uninitialized obstack. To free all memory in an obstack but leave it
valid for further allocation, call @code{obstack_free} with the address
of the first object allocated on the obstack:
@smallexample
obstack_free (obstack_ptr, first_object_allocated_ptr);
@end smallexample
Recall that the objects in an obstack are grouped into chunks. When all
the objects in a chunk become free, the obstack library automatically
frees the chunk (@pxref{Preparing for Obstacks}). Then other
obstacks, or non-obstack allocation, can reuse the space of the chunk.
@node Obstack Functions
@section Obstack Functions and Macros
@cindex macros
The interfaces for using obstacks may be defined either as functions or
as macros, depending on the compiler. The obstack facility works with
all C compilers, including both @w{ISO C} and traditional C, but there are
precautions you must take if you plan to use compilers other than GNU C.
If you are using an old-fashioned @w{non-ISO C} compiler, all the obstack
``functions'' are actually defined only as macros. You can call these
macros like functions, but you cannot use them in any other way (for
example, you cannot take their address).
Calling the macros requires a special precaution: namely, the first
operand (the obstack pointer) may not contain any side effects, because
it may be computed more than once. For example, if you write this:
@smallexample
obstack_alloc (get_obstack (), 4);
@end smallexample
@noindent
you will find that @code{get_obstack} may be called several times.
If you use @code{*obstack_list_ptr++} as the obstack pointer argument,
you will get very strange results since the incrementation may occur
several times.
In @w{ISO C}, each function has both a macro definition and a function
definition. The function definition is used if you take the address of the
function without calling it. An ordinary call uses the macro definition by
default, but you can request the function definition instead by writing the
function name in parentheses, as shown here:
@smallexample
char *x;
void *(*funcp) ();
/* @r{Use the macro}. */
x = (char *) obstack_alloc (obptr, size);
/* @r{Call the function}. */
x = (char *) (obstack_alloc) (obptr, size);
/* @r{Take the address of the function}. */
funcp = obstack_alloc;
@end smallexample
@noindent
This is the same situation that exists in @w{ISO C} for the standard library
functions. @xref{Macro Definitions, , , libc, The GNU C Library Reference Manual}.
@strong{Warning:} When you do use the macros, you must observe the
precaution of avoiding side effects in the first operand, even in @w{ISO C}.
If you use the GNU C compiler, this precaution is not necessary, because
various language extensions in GNU C permit defining the macros so as to
compute each argument only once.
@node Growing Objects
@section Growing Objects
@cindex growing objects (in obstacks)
@cindex changing the size of a block (obstacks)
Because memory in obstack chunks is used sequentially, it is possible to
build up an object step by step, adding one or more bytes at a time to the
end of the object. With this technique, you do not need to know how much
data you will put in the object until you come to the end of it. We call
this the technique of @dfn{growing objects}. The special functions
for adding data to the growing object are described in this section.
You don't need to do anything special when you start to grow an object.
Using one of the functions to add data to the object automatically
starts it. However, it is necessary to say explicitly when the object is
finished. This is done with the function @code{obstack_finish}.
The actual address of the object thus built up is not known until the
object is finished. Until then, it always remains possible that you will
add so much data that the object must be copied into a new chunk.
While the obstack is in use for a growing object, you cannot use it for
ordinary allocation of another object. If you try to do so, the space
already added to the growing object will become part of the other object.
@comment obstack.h
@comment GNU
@deftypefun void obstack_blank (struct obstack *@var{obstack-ptr}, int @var{size})
The most basic function for adding to a growing object is
@code{obstack_blank}, which adds space without initializing it.
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun void obstack_grow (struct obstack *@var{obstack-ptr}, void *@var{data}, int @var{size})
To add a block of initialized space, use @code{obstack_grow}, which is
the growing-object analogue of @code{obstack_copy}. It adds @var{size}
bytes of data to the growing object, copying the contents from
@var{data}.
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun void obstack_grow0 (struct obstack *@var{obstack-ptr}, void *@var{data}, int @var{size})
This is the growing-object analogue of @code{obstack_copy0}. It adds
@var{size} bytes copied from @var{data}, followed by an additional null
character.
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun void obstack_1grow (struct obstack *@var{obstack-ptr}, char @var{c})
To add one character at a time, use the function @code{obstack_1grow}.
It adds a single byte containing @var{c} to the growing object.
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun void obstack_ptr_grow (struct obstack *@var{obstack-ptr}, void *@var{data})
Adding the value of a pointer one can use the function
@code{obstack_ptr_grow}. It adds @code{sizeof (void *)} bytes
containing the value of @var{data}.
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun void obstack_int_grow (struct obstack *@var{obstack-ptr}, int @var{data})
A single value of type @code{int} can be added by using the
@code{obstack_int_grow} function. It adds @code{sizeof (int)} bytes to
the growing object and initializes them with the value of @var{data}.
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun {void *} obstack_finish (struct obstack *@var{obstack-ptr})
When you are finished growing the object, use the function
@code{obstack_finish} to close it off and return its final address.
Once you have finished the object, the obstack is available for ordinary
allocation or for growing another object.
This function can return a null pointer under the same conditions as
@code{obstack_alloc} (@pxref{Allocation in an Obstack}).
@end deftypefun
When you build an object by growing it, you will probably need to know
afterward how long it became. You need not keep track of this as you grow
the object, because you can find out the length from the obstack just
before finishing the object with the function @code{obstack_object_size},
declared as follows:
@comment obstack.h
@comment GNU
@deftypefun int obstack_object_size (struct obstack *@var{obstack-ptr})
This function returns the current size of the growing object, in bytes.
Remember to call this function @emph{before} finishing the object.
After it is finished, @code{obstack_object_size} will return zero.
@end deftypefun
If you have started growing an object and wish to cancel it, you should
finish it and then free it, like this:
@smallexample
obstack_free (obstack_ptr, obstack_finish (obstack_ptr));
@end smallexample
@noindent
This has no effect if no object was growing.
@cindex shrinking objects
You can use @code{obstack_blank} with a negative size argument to make
the current object smaller. Just don't try to shrink it beyond zero
length---there's no telling what will happen if you do that.
@node Extra Fast Growing
@section Extra Fast Growing Objects
@cindex efficiency and obstacks
The usual functions for growing objects incur overhead for checking
whether there is room for the new growth in the current chunk. If you
are frequently constructing objects in small steps of growth, this
overhead can be significant.
You can reduce the overhead by using special ``fast growth''
functions that grow the object without checking. In order to have a
robust program, you must do the checking yourself. If you do this checking
in the simplest way each time you are about to add data to the object, you
have not saved anything, because that is what the ordinary growth
functions do. But if you can arrange to check less often, or check
more efficiently, then you make the program faster.
The function @code{obstack_room} returns the amount of room available
in the current chunk. It is declared as follows:
@comment obstack.h
@comment GNU
@deftypefun int obstack_room (struct obstack *@var{obstack-ptr})
This returns the number of bytes that can be added safely to the current
growing object (or to an object about to be started) in obstack
@var{obstack} using the fast growth functions.
@end deftypefun
While you know there is room, you can use these fast growth functions
for adding data to a growing object:
@comment obstack.h
@comment GNU
@deftypefun void obstack_1grow_fast (struct obstack *@var{obstack-ptr}, char @var{c})
The function @code{obstack_1grow_fast} adds one byte containing the
character @var{c} to the growing object in obstack @var{obstack-ptr}.
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun void obstack_ptr_grow_fast (struct obstack *@var{obstack-ptr}, void *@var{data})
The function @code{obstack_ptr_grow_fast} adds @code{sizeof (void *)}
bytes containing the value of @var{data} to the growing object in
obstack @var{obstack-ptr}.
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun void obstack_int_grow_fast (struct obstack *@var{obstack-ptr}, int @var{data})
The function @code{obstack_int_grow_fast} adds @code{sizeof (int)} bytes
containing the value of @var{data} to the growing object in obstack
@var{obstack-ptr}.
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun void obstack_blank_fast (struct obstack *@var{obstack-ptr}, int @var{size})
The function @code{obstack_blank_fast} adds @var{size} bytes to the
growing object in obstack @var{obstack-ptr} without initializing them.
@end deftypefun
When you check for space using @code{obstack_room} and there is not
enough room for what you want to add, the fast growth functions
are not safe. In this case, simply use the corresponding ordinary
growth function instead. Very soon this will copy the object to a
new chunk; then there will be lots of room available again.
So, each time you use an ordinary growth function, check afterward for
sufficient space using @code{obstack_room}. Once the object is copied
to a new chunk, there will be plenty of space again, so the program will
start using the fast growth functions again.
Here is an example:
@smallexample
@group
void
add_string (struct obstack *obstack, const char *ptr, int len)
@{
while (len > 0)
@{
int room = obstack_room (obstack);
if (room == 0)
@{
/* @r{Not enough room. Add one character slowly,}
@r{which may copy to a new chunk and make room.} */
obstack_1grow (obstack, *ptr++);
len--;
@}
else
@{
if (room > len)
room = len;
/* @r{Add fast as much as we have room for.} */
len -= room;
while (room-- > 0)
obstack_1grow_fast (obstack, *ptr++);
@}
@}
@}
@end group
@end smallexample
@node Status of an Obstack
@section Status of an Obstack
@cindex obstack status
@cindex status of obstack
Here are functions that provide information on the current status of
allocation in an obstack. You can use them to learn about an object while
still growing it.
@comment obstack.h
@comment GNU
@deftypefun {void *} obstack_base (struct obstack *@var{obstack-ptr})
This function returns the tentative address of the beginning of the
currently growing object in @var{obstack-ptr}. If you finish the object
immediately, it will have that address. If you make it larger first, it
may outgrow the current chunk---then its address will change!
If no object is growing, this value says where the next object you
allocate will start (once again assuming it fits in the current
chunk).
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun {void *} obstack_next_free (struct obstack *@var{obstack-ptr})
This function returns the address of the first free byte in the current
chunk of obstack @var{obstack-ptr}. This is the end of the currently
growing object. If no object is growing, @code{obstack_next_free}
returns the same value as @code{obstack_base}.
@end deftypefun
@comment obstack.h
@comment GNU
@deftypefun int obstack_object_size (struct obstack *@var{obstack-ptr})
This function returns the size in bytes of the currently growing object.
This is equivalent to
@smallexample
obstack_next_free (@var{obstack-ptr}) - obstack_base (@var{obstack-ptr})
@end smallexample
@end deftypefun
@node Obstacks Data Alignment
@section Alignment of Data in Obstacks
@cindex alignment (in obstacks)
Each obstack has an @dfn{alignment boundary}; each object allocated in
the obstack automatically starts on an address that is a multiple of the
specified boundary. By default, this boundary is 4 bytes.
To access an obstack's alignment boundary, use the macro
@code{obstack_alignment_mask}, whose function prototype looks like
this:
@comment obstack.h
@comment GNU
@deftypefn Macro int obstack_alignment_mask (struct obstack *@var{obstack-ptr})
The value is a bit mask; a bit that is 1 indicates that the corresponding
bit in the address of an object should be 0. The mask value should be one
less than a power of 2; the effect is that all object addresses are
multiples of that power of 2. The default value of the mask is 3, so that
addresses are multiples of 4. A mask value of 0 means an object can start
on any multiple of 1 (that is, no alignment is required).
The expansion of the macro @code{obstack_alignment_mask} is an lvalue,
so you can alter the mask by assignment. For example, this statement:
@smallexample
obstack_alignment_mask (obstack_ptr) = 0;
@end smallexample
@noindent
has the effect of turning off alignment processing in the specified obstack.
@end deftypefn
Note that a change in alignment mask does not take effect until
@emph{after} the next time an object is allocated or finished in the
obstack. If you are not growing an object, you can make the new
alignment mask take effect immediately by calling @code{obstack_finish}.
This will finish a zero-length object and then do proper alignment for
the next object.
@node Obstack Chunks
@section Obstack Chunks
@cindex efficiency of chunks
@cindex chunks
Obstacks work by allocating space for themselves in large chunks, and
then parceling out space in the chunks to satisfy your requests. Chunks
are normally 4096 bytes long unless you specify a different chunk size.
The chunk size includes 8 bytes of overhead that are not actually used
for storing objects. Regardless of the specified size, longer chunks
will be allocated when necessary for long objects.
The obstack library allocates chunks by calling the function
@code{obstack_chunk_alloc}, which you must define. When a chunk is no
longer needed because you have freed all the objects in it, the obstack
library frees the chunk by calling @code{obstack_chunk_free}, which you
must also define.
These two must be defined (as macros) or declared (as functions) in each
source file that uses @code{obstack_init} (@pxref{Creating Obstacks}).
Most often they are defined as macros like this:
@smallexample
#define obstack_chunk_alloc malloc
#define obstack_chunk_free free
@end smallexample
Note that these are simple macros (no arguments). Macro definitions with
arguments will not work! It is necessary that @code{obstack_chunk_alloc}
or @code{obstack_chunk_free}, alone, expand into a function name if it is
not itself a function name.
If you allocate chunks with @code{malloc}, the chunk size should be a
power of 2. The default chunk size, 4096, was chosen because it is long
enough to satisfy many typical requests on the obstack yet short enough
not to waste too much memory in the portion of the last chunk not yet used.
@comment obstack.h
@comment GNU
@deftypefn Macro int obstack_chunk_size (struct obstack *@var{obstack-ptr})
This returns the chunk size of the given obstack.
@end deftypefn
Since this macro expands to an lvalue, you can specify a new chunk size by
assigning it a new value. Doing so does not affect the chunks already
allocated, but will change the size of chunks allocated for that particular
obstack in the future. It is unlikely to be useful to make the chunk size
smaller, but making it larger might improve efficiency if you are
allocating many objects whose size is comparable to the chunk size. Here
is how to do so cleanly:
@smallexample
if (obstack_chunk_size (obstack_ptr) < @var{new-chunk-size})
obstack_chunk_size (obstack_ptr) = @var{new-chunk-size};
@end smallexample
@node Summary of Obstacks
@section Summary of Obstack Functions
Here is a summary of all the functions associated with obstacks. Each
takes the address of an obstack (@code{struct obstack *}) as its first
argument.
@table @code
@item void obstack_init (struct obstack *@var{obstack-ptr})
Initialize use of an obstack. @xref{Creating Obstacks}.
@item void *obstack_alloc (struct obstack *@var{obstack-ptr}, int @var{size})
Allocate an object of @var{size} uninitialized bytes.
@xref{Allocation in an Obstack}.
@item void *obstack_copy (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
Allocate an object of @var{size} bytes, with contents copied from
@var{address}. @xref{Allocation in an Obstack}.
@item void *obstack_copy0 (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
Allocate an object of @var{size}+1 bytes, with @var{size} of them copied
from @var{address}, followed by a null character at the end.
@xref{Allocation in an Obstack}.
@item void obstack_free (struct obstack *@var{obstack-ptr}, void *@var{object})
Free @var{object} (and everything allocated in the specified obstack
more recently than @var{object}). @xref{Freeing Obstack Objects}.
@item void obstack_blank (struct obstack *@var{obstack-ptr}, int @var{size})
Add @var{size} uninitialized bytes to a growing object.
@xref{Growing Objects}.
@item void obstack_grow (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
Add @var{size} bytes, copied from @var{address}, to a growing object.
@xref{Growing Objects}.
@item void obstack_grow0 (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
Add @var{size} bytes, copied from @var{address}, to a growing object,
and then add another byte containing a null character. @xref{Growing
Objects}.
@item void obstack_1grow (struct obstack *@var{obstack-ptr}, char @var{data-char})
Add one byte containing @var{data-char} to a growing object.
@xref{Growing Objects}.
@item void *obstack_finish (struct obstack *@var{obstack-ptr})
Finalize the object that is growing and return its permanent address.
@xref{Growing Objects}.
@item int obstack_object_size (struct obstack *@var{obstack-ptr})
Get the current size of the currently growing object. @xref{Growing
Objects}.
@item void obstack_blank_fast (struct obstack *@var{obstack-ptr}, int @var{size})
Add @var{size} uninitialized bytes to a growing object without checking
that there is enough room. @xref{Extra Fast Growing}.
@item void obstack_1grow_fast (struct obstack *@var{obstack-ptr}, char @var{data-char})
Add one byte containing @var{data-char} to a growing object without
checking that there is enough room. @xref{Extra Fast Growing}.
@item int obstack_room (struct obstack *@var{obstack-ptr})
Get the amount of room now available for growing the current object.
@xref{Extra Fast Growing}.
@item int obstack_alignment_mask (struct obstack *@var{obstack-ptr})
The mask used for aligning the beginning of an object. This is an
lvalue. @xref{Obstacks Data Alignment}.
@item int obstack_chunk_size (struct obstack *@var{obstack-ptr})
The size for allocating chunks. This is an lvalue. @xref{Obstack Chunks}.
@item void *obstack_base (struct obstack *@var{obstack-ptr})
Tentative starting address of the currently growing object.
@xref{Status of an Obstack}.
@item void *obstack_next_free (struct obstack *@var{obstack-ptr})
Address just after the end of the currently growing object.
@xref{Status of an Obstack}.
@end table

View File

@ -16,6 +16,19 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/*
@deftypefn Supplemental int putenv (const char *@var{string})
Uses @code{setenv} or @code{unsetenv} to put @var{string} into
the environment or remove it. If @var{string} is of the form
@samp{name=value} the string is added; if no `=' is present the
name is unset/removed.
@end deftypefn
*/
#if defined (_AIX) && !defined (__GNUC__)
#pragma alloca
#endif

View File

@ -1,7 +1,16 @@
/* rename -- rename a file
This function is in the public domain. */
/* Rename a file. */
/*
@deftypefn Supplemental int rename (const char *@var{old}, const char *@var{new})
Renames a file from @var{old} to @var{new}. If @var{new} already
exists, it is removed.
@end deftypefn
*/
#ifdef HAVE_CONFIG_H
#include "config.h"

View File

@ -1,5 +1,17 @@
/* Stub implementation of (obsolete) rindex(). */
/*
@deftypefn Supplemental char* rindex (const char *@var{s}, int @var{c})
Returns a pointer to the last occurance of the character @var{c} in
the string @var{s}, or NULL if not found. The use of @code{rindex} is
deprecated in new programs in favor of @code{strrchr}.
@end deftypefn
*/
extern char *strrchr ();
char *

View File

@ -16,6 +16,22 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/*
@deftypefn Supplemental int setenv (const char *@var{name}, const char *@var{value}, int @var{overwrite})
@deftypefnx Supplemental void unsetenv (const char *@var{name})
@code{setenv} adds @var{name} to the environment with value
@var{value}. If the name was already present in the environment,
the new value will be stored only if @var{overwrite} is non-zero.
The companion @code{unsetenv} function removes @var{name} from the
environment. This implementation is not safe for multithreaded code.
@end deftypefn
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif

View File

@ -3,8 +3,17 @@
Contributed by Cygnus Support.
This file is in the public doamin. */
/* Set the current signal mask to the set provided, and return the
previous value */
/*
@deftypefn Supplemental int sigsetmask (int @var{set})
Sets the signal mask to the one provided in @var{set} and returns
the old mask (which, for libiberty's implementation, will always
be the value @code{1}).
@end deftypefn
*/
#define _POSIX_SOURCE
#include <ansidecl.h>

View File

@ -10,6 +10,16 @@
* is provided ``as is'' without express or implied warranty.
*/
/*
@deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2})
A case-insensitive @code{strcmp}.
@end deftypefn
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
#endif /* LIBC_SCCS and not lint */

View File

@ -2,19 +2,15 @@
This function is in the public domain. */
/*
NAME
strchr -- return pointer to first occurance of a character
SYNOPSIS
char *strchr (const char *s, int c)
@deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c})
Returns a pointer to the first occurance of the character @var{c} in
the string @var{s}, or NULL if not found. If @var{c} is itself the
null character, the results are undefined.
@end deftypefn
DESCRIPTION
Returns a pointer to the first occurance of character C in
string S, or a NULL pointer if no occurance is found.
BUGS
Behavior when character is the null character is implementation
dependent.
*/
#include <ansidecl.h>

View File

@ -1,3 +1,14 @@
/*
@deftypefn Supplemental char* strdup (const char *@var{s})
Returns a pointer to a copy of @var{s} in memory obtained from
@code{malloc}, or NULL if insufficient memory was available.
@end deftypefn
*/
char *
strdup(s)
char *s;

View File

@ -562,28 +562,23 @@ init_error_tables ()
/*
NAME
errno_max -- return the max errno value
@deftypefn Replacement int errno_max (void)
SYNOPSIS
Returns the maximum @code{errno} value for which a corresponding
symbolic name or message is available. Note that in the case where we
use the @code{sys_errlist} supplied by the system, it is possible for
there to be more symbolic names than messages, or vice versa. In
fact, the manual page for @code{perror(3C)} explicitly warns that one
should check the size of the table (@code{sys_nerr}) before indexing
it, since new error codes may be added to the system before they are
added to the table. Thus @code{sys_nerr} might be smaller than value
implied by the largest @code{errno} value defined in @file{errno.h}.
int errno_max ();
We return the maximum value that can be used to obtain a meaningful
symbolic name or message.
DESCRIPTION
Returns the maximum errno value for which a corresponding symbolic
name or message is available. Note that in the case where
we use the sys_errlist supplied by the system, it is possible for
there to be more symbolic names than messages, or vice versa.
In fact, the manual page for perror(3C) explicitly warns that one
should check the size of the table (sys_nerr) before indexing it,
since new error codes may be added to the system before they are
added to the table. Thus sys_nerr might be smaller than value
implied by the largest errno value defined in <errno.h>.
We return the maximum value that can be used to obtain a meaningful
symbolic name or message.
@end deftypefn
*/
@ -604,31 +599,25 @@ errno_max ()
/*
NAME
@deftypefn Replacement char* strerror (int @var{errnoval})
strerror -- map an error number to an error message string
Maps an @code{errno} number to an error message string, the contents
of which are implementation defined. On systems which have the
external variables @code{sys_nerr} and @code{sys_errlist}, these
strings will be the same as the ones used by @code{perror}.
SYNOPSIS
If the supplied error number is within the valid range of indices for
the @code{sys_errlist}, but no message is available for the particular
error number, then returns the string @samp{"Error NUM"}, where NUM is
the error number.
char *strerror (int errnoval)
If the supplied error number is not a valid index into
@code{sys_errlist}, returns NULL.
DESCRIPTION
The returned string is only guaranteed to be valid only until the
next call to @code{strerror}.
Maps an errno number to an error message string, the contents of
which are implementation defined. On systems which have the external
variables sys_nerr and sys_errlist, these strings will be the same
as the ones used by perror().
If the supplied error number is within the valid range of indices
for the sys_errlist, but no message is available for the particular
error number, then returns the string "Error NUM", where NUM is the
error number.
If the supplied error number is not a valid index into sys_errlist,
returns NULL.
The returned string is only guaranteed to be valid only until the
next call to strerror.
@end deftypefn
*/
@ -678,32 +667,24 @@ strerror (errnoval)
/*
NAME
@deftypefn Replacement const char* strerrno (int @var{errnum})
strerrno -- map an error number to a symbolic name string
Given an error number returned from a system call (typically returned
in @code{errno}), returns a pointer to a string containing the
symbolic name of that error number, as found in @file{errno.h}.
SYNOPSIS
If the supplied error number is within the valid range of indices for
symbolic names, but no name is available for the particular error
number, then returns the string @samp{"Error NUM"}, where NUM is the
error number.
const char *strerrno (int errnoval)
If the supplied error number is not within the range of valid
indices, then returns NULL.
DESCRIPTION
The contents of the location pointed to are only guaranteed to be
valid until the next call to strerrno.
Given an error number returned from a system call (typically
returned in errno), returns a pointer to a string containing the
symbolic name of that error number, as found in <errno.h>.
If the supplied error number is within the valid range of indices
for symbolic names, but no name is available for the particular
error number, then returns the string "Error NUM", where NUM is
the error number.
If the supplied error number is not within the range of valid
indices, then returns NULL.
BUGS
The contents of the location pointed to are only guaranteed to be
valid until the next call to strerrno.
@end deftypefn
*/
@ -746,18 +727,12 @@ strerrno (errnoval)
/*
NAME
@deftypefn Replacement int strtoerrno (const char *@var{name})
strtoerrno -- map a symbolic errno name to a numeric value
Given the symbolic name of a error number (e.g., @code{EACCESS}), map it
to an errno value. If no translation is found, returns 0.
SYNOPSIS
int strtoerrno (char *name)
DESCRIPTION
Given the symbolic name of a error number, map it to an errno value.
If no translation is found, returns 0.
@end deftypefn
*/

View File

@ -10,6 +10,16 @@
* is provided ``as is'' without express or implied warranty.
*/
/*
@deftypefn Supplemental int strncasecmp (const char *@var{s1}, const char *@var{s2})
A case-insensitive @code{strncmp}.
@end deftypefn
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
#endif /* LIBC_SCCS and not lint */

View File

@ -1,6 +1,17 @@
/* strncmp -- compare two strings, stop after n bytes.
This function is in the public domain. */
/*
@deftypefn Supplemental int strncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n})
Compares the first @var{n} bytes of two strings, returning a value as
@code{strcmp}.
@end deftypefn
*/
#include <ansidecl.h>
#ifdef __STDC__
#include <stddef.h>

View File

@ -2,19 +2,15 @@
This function is in the public domain. */
/*
NAME
strrchr -- return pointer to last occurance of a character
SYNOPSIS
char *strrchr (const char *s, int c)
@deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
Returns a pointer to the last occurance of the character @var{c} in
the string @var{s}, or NULL if not found. If @var{c} is itself the
null character, the results are undefined.
@end deftypefn
DESCRIPTION
Returns a pointer to the last occurance of character C in
string S, or a NULL pointer if no occurance is found.
BUGS
Behavior when character is the null character is implementation
dependent.
*/
#include <ansidecl.h>

View File

@ -3,24 +3,16 @@
/*
NAME
@deftypefn Supplemental char* strstr (const char *@var{string}, const char *@var{sub})
strstr -- locate first occurance of a substring
This function searches for the substring @var{sub} in the string
@var{string}, not including the terminating NUL characters. A pointer
to the first occurance of @var{sub} is returned, or NULL if the
substring is absent. If @var{sub} points to a string with zero
length, the function returns @var{string}.
SYNOPSIS
@end deftypefn
#include <string.h>
char *strstr (char *s1, char *s2)
DESCRIPTION
Locates the first occurance in the string pointed to by S1 of
the string pointed to by S2. Returns a pointer to the substring
found, or a NULL pointer if not found. If S2 points to a string
with zero length, the function returns S1.
BUGS
*/

View File

@ -22,6 +22,21 @@ the resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
/*
@deftypefn Supplemental double strtod (const char *@var{string}, char **@var{endptr})
This ANSI C function converts the initial portion of @var{string} to a
@code{double}. If @var{endptr} is not NULL, a pointer to the
character after the last character used in the conversion is stored in
the location referenced by @var{endptr}. If no conversion is
performed, zero is returned and the value of @var{string} is stored in
the location referenced by @var{endptr}.
@end deftypefn
*/
#include "ansidecl.h"
#include "safe-ctype.h"

View File

@ -28,6 +28,23 @@
* SUCH DAMAGE.
*/
/*
@deftypefn Supplemental {long int} strtol (const char *@var{string}, char **@var{endptr}, int @var{base})
The @code{strtol} function converts the string in @var{string} to a
long integer value according to the given @var{base}, which must be
between 2 and 36 inclusive, or be the special value 0. If @var{base}
is 0, @code{strtol} will look for the prefixes @code{0} and @code{0x}
to indicate bases 8 and 16, respectively, else default to base 10.
When the base is 16 (either explicitly or implicitly), a prefix of
@code{0x} is allowed. The handling of endptr is as that of
@code{strtod} above.
@end deftypefn
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@ -1,3 +1,17 @@
/*
@deftypefn Supplemental char* tmpnam (char *@var{s})
This function attempts to create a name for a temporary file, which
will be a valid file name yet not exist when @code{tmpnam} checks for
it. @var{s} must point to a buffer of at least @code{L_tmpnam} bytes,
or be NULL. Use of this function creates a security risk, and it must
not be used in new projects. Use @code{mkstemp} instead.
@end deftypefn
*/
#include <stdio.h>
#ifndef L_tmpnam

View File

@ -1,6 +1,16 @@
/* Emulate vfork using just plain fork, for systems without a real vfork.
This function is in the public domain. */
/*
@deftypefn Supplemental int vfork ()
Emulates @code{vfork} by calling @code{fork} and returning its value.
@end deftypefn
*/
#include "ansidecl.h"
extern int fork PARAMS ((void));

View File

@ -1,3 +1,20 @@
/*
@deftypefn Supplemental int vprintf (const char *@var{format}, va_list @var{ap})
@deftypefnx Supplemental int vfprintf (FILE *@var{stream}, const char *@var{format}, va_list @var{ap})
@deftypefnx Supplemental int vsprintf (char *@var{str}, const char *@var{format}, va_list @var{ap})
These functions are the same as @code{printf}, @code{fprintf}, and
@code{sprintf}, respectively, except that they are called with a
@code{va_list} instead of a variable number of arguments. Note that
they do not call @code{va_end}; this is the application's
responsibility. In @libib{} they are implemented in terms of the
nonstandard but common function @code{_doprnt}.
@end deftypefn
*/
#ifdef __STDC__
#include <stdarg.h>
#else

View File

@ -1,3 +1,15 @@
/*
@deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
This is a wrapper around the @code{wait} function. Any ``special''
values of @var{pid} depend on your implementation of @code{wait}, as
does the return value. The third argument is unused in @libib{}.
@end deftypefn
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@ -5,6 +5,20 @@
* %sccs.include.redist.c%
*/
/*
@deftypefun int xatexit (void (*@var{fn}) (void))
Behaves as the standard @code{atexit} function, but with no limit on
the number of registered funtions. Returns 0 on success, or -1 on
failure. If you use @code{xatexit} to register functions, you must use
@code{xexit} to terminate your program.
@end deftypefun
*/
/* Adapted from newlib/libc/stdlib/{,at}exit.[ch].
If you use xatexit, you must call xexit instead of exit. */

View File

@ -17,6 +17,18 @@ License along with libiberty; see the file COPYING.LIB. If not, write
to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/*
@deftypefn Replacement void xexit (int @var{code})
Terminates the program. If any functions have been registered with
the @code{xatexit} rpelacement function, they will be called first.
Termination is handled via the system's normal @code{exit} call.
@end deftypefn
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@ -17,6 +17,48 @@ License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/*
@deftypefn Replacement void* xmalloc (size_t)
Allocate memory without fail. If @code{malloc} fails, this will print
a message to stderr (using the name set by @code{xmalloc_set_program_name},
if any) and then call @code{xexit}. Note that it is therefore safe for
a program to contain @code{#define malloc xmalloc} in its source.
@end deftypefn
@deftypefn Replacement void* xrealloc (void*, size_t)
Reallocate memory without fail. This routine functions like @code{realloc},
but will behave the same as @code{xmalloc} if memory cannot be found.
@end deftypefn
@deftypefn Replacement void* xcalloc (size_t, size_t)
Allocate memory without fail, and set it to zero. This routine functions
like @code{calloc}, but will behave the same as @code{xmalloc} if memory
cannot be found.
@end deftypefn
@deftypefn Replacement void xmalloc_set_program_name (const char *@var{name})
You can use this to set the name of the program used by
@code{xmalloc_failed} when printing a failure message.
@end deftypefn
@deftypefn Replacement void xmalloc_failed (size_t)
This function is not meant to be called by client code, and is listed
here for completeness only. If any of the allocation routines fail, this
function will be called to print an error message and terminate execution.
@end deftypefn
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@ -2,6 +2,19 @@
This trivial function is in the public domain.
Jeff Garzik, September 1999. */
/*
@deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size})
Duplicates a region of memory without fail. First, @var{alloc_size} bytes
are allocated, then @var{copy_size} bytes from @var{input} are copied into
it, and the new memory is returned. If fewer bytes are copied than were
allocated, the remaining memory is zeroed.
@end deftypefn
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@ -2,6 +2,17 @@
This trivial function is in the public domain.
Ian Lance Taylor, Cygnus Support, December 1995. */
/*
@deftypefn Replacement char* xstrdup (const char *@var{s})
Duplicates a character string without fail, using @code{xmalloc} to
obtain memory.
@end deftypefn
*/
#include <sys/types.h>
#ifdef HAVE_CONFIG_H
#include "config.h"

View File

@ -2,6 +2,17 @@
Fri Jun 16 18:30:00 1995 Pat Rankin <rankin@eql.caltech.edu>
This code is in the public domain. */
/*
@deftypefn Replacement char* xstrerror (int @var{errnum})
Behaves exactly like the standard @code{strerror} function, but
will never return a NULL pointer.
@end deftypefn
*/
#include <stdio.h>
#include "libiberty.h"