mirror of
https://github.com/pret/agbcc.git
synced 2026-07-17 16:41:18 -05:00
kill libiberty
This commit is contained in:
parent
526fd830c2
commit
2f209e7d28
156
gcc/Makefile.in
156
gcc/Makefile.in
|
|
@ -290,10 +290,6 @@ CLIB=
|
|||
# system library.
|
||||
OBSTACK=obstack.o
|
||||
|
||||
# Configure will set these if you need vfprintf and possibly _doprnt support.
|
||||
VFPRINTF=@vfprintf@
|
||||
DOPRINT=@doprint@
|
||||
|
||||
# Specify the rule for actually making libgcc.a,
|
||||
LIBGCC = libgcc.a
|
||||
# and the rule for installing it.
|
||||
|
|
@ -403,11 +399,6 @@ HOST_CFLAGS=$(ALL_CFLAGS)
|
|||
HOST_CLIB=$(CLIB)
|
||||
HOST_LDFLAGS=$(LDFLAGS)
|
||||
HOST_CPPFLAGS=$(ALL_CPPFLAGS)
|
||||
HOST_ALLOCA=$(ALLOCA)
|
||||
HOST_MALLOC=$(MALLOC)
|
||||
HOST_OBSTACK=$(OBSTACK)
|
||||
HOST_VFPRINTF=$(VFPRINTF)
|
||||
HOST_DOPRINT=$(DOPRINT)
|
||||
|
||||
# Actual name to use when installing a native compiler.
|
||||
GCC_INSTALL_NAME = `t='$(program_transform_name)'; echo gcc | sed -e $$t`
|
||||
|
|
@ -476,34 +467,6 @@ ALL_CFLAGS = $(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(CFLAGS) $(XCFLAGS) \
|
|||
# Likewise.
|
||||
ALL_CPPFLAGS = $(CPPFLAGS) $(X_CPPFLAGS) $(T_CPPFLAGS)
|
||||
|
||||
# Even if ALLOCA is set, don't use it if compiling with GCC.
|
||||
USE_ALLOCA= ${ALLOCA}
|
||||
USE_HOST_ALLOCA= ` case "${HOST_ALLOCA}" in ?*) echo ${HOST_PREFIX}${HOST_ALLOCA} ;; esac `
|
||||
USE_HOST_MALLOC= ` case "${HOST_MALLOC}" in ?*) echo ${HOST_PREFIX}${HOST_MALLOC} ;; esac `
|
||||
USE_HOST_OBSTACK= ` case "${HOST_OBSTACK}" in ?*) echo ${HOST_PREFIX}${HOST_OBSTACK} ;; esac `
|
||||
USE_HOST_VFPRINTF= ` case "${HOST_VFPRINTF}" in ?*) echo ${HOST_PREFIX}${HOST_VFPRINTF} ;; esac `
|
||||
USE_HOST_DOPRINT= ` case "${HOST_DOPRINT}" in ?*) echo ${HOST_PREFIX}${HOST_DOPRINT} ;; esac `
|
||||
|
||||
# Dependency on obstack, alloca, malloc or whatever library facilities
|
||||
# are not installed in the system libraries.
|
||||
# We don't use USE_ALLOCA because backquote expansion doesn't work in deps.
|
||||
LIBDEPS= $(OBSTACK) $(ALLOCA) $(MALLOC) $(VFPRINTF) $(DOPRINT)
|
||||
|
||||
# Likewise, for use in the tools that must run on this machine
|
||||
# even if we are cross-building GCC.
|
||||
# We don't use USE_ALLOCA because backquote expansion doesn't work in deps.
|
||||
HOST_LIBDEPS= $(HOST_PREFIX)$(HOST_OBSTACK) $(HOST_PREFIX)$(HOST_ALLOCA) $(HOST_PREFIX)$(HOST_MALLOC) $(HOST_PREFIX)$(HOST_VFPRINTF) $(HOST_PREFIX)$(HOST_DOPRINT)
|
||||
|
||||
# How to link with both our special library facilities
|
||||
# and the system's installed libraries.
|
||||
LIBS = $(OBSTACK) $(USE_ALLOCA) $(MALLOC) $(VFPRINTF) $(DOPRINT) $(CLIB) \
|
||||
../libiberty/libiberty.a
|
||||
|
||||
# Likewise, for use in the tools that must run on this machine
|
||||
# even if we are cross-building GCC.
|
||||
HOST_LIBS = $(USE_HOST_OBSTACK) $(USE_HOST_ALLOCA) $(USE_HOST_MALLOC) \
|
||||
$(USE_HOST_VFPRINTF) $(USE_HOST_DOPRINT) $(HOST_CLIB)
|
||||
|
||||
HOST_RTL = $(HOST_PREFIX)rtl.o $(HOST_PREFIX)bitmap.o
|
||||
HOST_RTLANAL = $(HOST_PREFIX)rtlanal.o
|
||||
HOST_PRINT = $(HOST_PREFIX)print-rtl.o
|
||||
|
|
@ -789,9 +752,9 @@ stamp-objlist: $(OBJS)
|
|||
# to avoid confusion if the current directory is in the path
|
||||
# and CC is `gcc'. It is renamed to `gcc' when it is installed.
|
||||
xgcc$(exeext): gcc.o version.o choose-temp.o pexecute.o prefix.o version.o \
|
||||
mkstemp.o $(LIBDEPS) $(EXTRA_GCC_OBJS)
|
||||
mkstemp.o $(EXTRA_GCC_OBJS)
|
||||
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ gcc.o prefix.o version.o \
|
||||
choose-temp.o pexecute.o mkstemp.o $(EXTRA_GCC_OBJS) $(LIBS)
|
||||
choose-temp.o pexecute.o mkstemp.o $(EXTRA_GCC_OBJS)
|
||||
|
||||
# Dump a specs file to make -B./ read these specs over installed ones.
|
||||
specs: xgcc$(exeext)
|
||||
|
|
@ -804,8 +767,8 @@ specs: xgcc$(exeext)
|
|||
gcc-cross: xgcc$(exeext)
|
||||
cp xgcc$(exeext) gcc-cross$(exeext)
|
||||
|
||||
cc1$(exeext): $(P) $(OBJS) $(C_OBJS) $(LIBDEPS)
|
||||
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(C_OBJS) $(LIBS)
|
||||
cc1$(exeext): $(P) $(OBJS) $(C_OBJS)
|
||||
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(C_OBJS)
|
||||
|
||||
# Build libgcc.a.
|
||||
# This is done in two parts because some functions, in libgcc1.c,
|
||||
|
|
@ -1205,11 +1168,6 @@ pexecute.o: $(srcdir)/../libiberty/pexecute.c $(CONFIG_H) system.h
|
|||
$(LN_S) $(srcdir)/../libiberty/pexecute.c pexecute.c
|
||||
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) pexecute.c
|
||||
|
||||
vfprintf.o: $(srcdir)/../libiberty/vfprintf.c $(CONFIG_H) system.h
|
||||
rm -f vfprintf.c
|
||||
$(LN_S) $(srcdir)/../libiberty/vfprintf.c vfprintf.c
|
||||
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) vfprintf.c
|
||||
|
||||
splay-tree.o: $(srcdir)/../libiberty/splay-tree.c \
|
||||
$(srcdir)/../include/splay-tree.h $(srcdir)/../include/libiberty.h
|
||||
rm -f splay-tree.c
|
||||
|
|
@ -1259,9 +1217,9 @@ s-check : gencheck $(srcdir)/move-if-change
|
|||
$(srcdir)/move-if-change tmp-check.h tree-check.h
|
||||
touch s-check
|
||||
|
||||
gencheck : gencheck.o tree.def $(lang_tree_files) $(HOST_LIBDEPS)
|
||||
gencheck : gencheck.o tree.def $(lang_tree_files)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
gencheck.o $(HOST_LIBS)
|
||||
gencheck.o
|
||||
|
||||
gencheck.o : gencheck.c hconfig.h system.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gencheck.c
|
||||
|
|
@ -1414,15 +1372,6 @@ $(out_object_file): $(out_file) $(CONFIG_H) $(TREE_H) \
|
|||
insn-flags.h output.h insn-attr.h insn-codes.h system.h toplev.h
|
||||
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(out_file)
|
||||
|
||||
# Normally this target is not used; but it is used if you
|
||||
# define ALLOCA=alloca.o. In that case, you must get a suitable alloca.c
|
||||
# from the GNU Emacs distribution.
|
||||
alloca.o: $(srcdir)/../libiberty/alloca.c
|
||||
rm -f alloca.c
|
||||
$(LN_S) $(srcdir)/../libiberty/alloca.c alloca.c
|
||||
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(ALLOCA_FLAGS) \
|
||||
-c `echo alloca.c | sed 's,^\./,,'`
|
||||
$(ALLOCA_FINISH)
|
||||
#
|
||||
# Generate header and source files from the machine description,
|
||||
# and compile them.
|
||||
|
|
@ -1578,86 +1527,86 @@ $(MD_FILE): $(MD_DEPS)
|
|||
$(MD_CPP) $(MD_CPPFLAGS) $(md_file) | sed 's/^# /; /g' > tmp-$@
|
||||
mv tmp-$@ $@
|
||||
|
||||
genconfig : genconfig.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBDEPS)
|
||||
genconfig : genconfig.o $(HOST_RTL) $(HOST_PRINT)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
genconfig.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBS)
|
||||
genconfig.o $(HOST_RTL) $(HOST_PRINT)
|
||||
|
||||
genconfig.o : genconfig.c $(RTL_H) $(build_xm_file) system.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genconfig.c
|
||||
|
||||
genflags : genflags.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBDEPS)
|
||||
genflags : genflags.o $(HOST_RTL) $(HOST_PRINT)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
genflags.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBS)
|
||||
genflags.o $(HOST_RTL) $(HOST_PRINT)
|
||||
|
||||
genflags.o : genflags.c $(RTL_H) $(build_xm_file) system.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genflags.c
|
||||
|
||||
gencodes : gencodes.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBDEPS)
|
||||
gencodes : gencodes.o $(HOST_RTL) $(HOST_PRINT)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
gencodes.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBS)
|
||||
gencodes.o $(HOST_RTL) $(HOST_PRINT)
|
||||
|
||||
gencodes.o : gencodes.c $(RTL_H) $(build_xm_file) system.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gencodes.c
|
||||
|
||||
genemit : genemit.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBDEPS)
|
||||
genemit : genemit.o $(HOST_RTL) $(HOST_PRINT)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
genemit.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBS)
|
||||
genemit.o $(HOST_RTL) $(HOST_PRINT)
|
||||
|
||||
genemit.o : genemit.c $(RTL_H) $(build_xm_file) system.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genemit.c
|
||||
|
||||
genopinit : genopinit.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBDEPS)
|
||||
genopinit : genopinit.o $(HOST_RTL) $(HOST_PRINT)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
genopinit.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBS)
|
||||
genopinit.o $(HOST_RTL) $(HOST_PRINT)
|
||||
|
||||
genopinit.o : genopinit.c $(RTL_H) $(build_xm_file) system.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genopinit.c
|
||||
|
||||
genrecog : genrecog.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBDEPS)
|
||||
genrecog : genrecog.o $(HOST_RTL) $(HOST_PRINT)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
genrecog.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBS)
|
||||
genrecog.o $(HOST_RTL) $(HOST_PRINT)
|
||||
|
||||
genrecog.o : genrecog.c $(RTL_H) $(build_xm_file) system.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genrecog.c
|
||||
|
||||
genextract : genextract.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBDEPS)
|
||||
genextract : genextract.o $(HOST_RTL) $(HOST_PRINT)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
genextract.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBS)
|
||||
genextract.o $(HOST_RTL) $(HOST_PRINT)
|
||||
|
||||
genextract.o : genextract.c $(RTL_H) $(build_xm_file) system.h insn-config.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genextract.c
|
||||
|
||||
genpeep : genpeep.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBDEPS)
|
||||
genpeep : genpeep.o $(HOST_RTL) $(HOST_PRINT)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
genpeep.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBS)
|
||||
genpeep.o $(HOST_RTL) $(HOST_PRINT)
|
||||
|
||||
genpeep.o : genpeep.c $(RTL_H) $(build_xm_file) system.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genpeep.c
|
||||
|
||||
genattr : genattr.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBDEPS)
|
||||
genattr : genattr.o $(HOST_RTL) $(HOST_PRINT)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
genattr.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBS)
|
||||
genattr.o $(HOST_RTL) $(HOST_PRINT)
|
||||
|
||||
genattr.o : genattr.c $(RTL_H) $(build_xm_file) system.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genattr.c
|
||||
|
||||
genattrtab : genattrtab.o $(HOST_RTL) $(HOST_PRINT) $(HOST_RTLANAL) $(HOST_LIBDEPS)
|
||||
genattrtab : genattrtab.o $(HOST_RTL) $(HOST_PRINT) $(HOST_RTLANAL)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
genattrtab.o $(HOST_RTL) $(HOST_PRINT) $(HOST_RTLANAL) $(HOST_LIBS)
|
||||
genattrtab.o $(HOST_RTL) $(HOST_PRINT) $(HOST_RTLANAL)
|
||||
|
||||
genattrtab.o : genattrtab.c $(RTL_H) $(build_xm_file) system.h insn-config.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genattrtab.c
|
||||
|
||||
genoutput : genoutput.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBDEPS)
|
||||
genoutput : genoutput.o $(HOST_RTL) $(HOST_PRINT)
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
genoutput.o $(HOST_RTL) $(HOST_PRINT) $(HOST_LIBS)
|
||||
genoutput.o $(HOST_RTL) $(HOST_PRINT)
|
||||
|
||||
genoutput.o : genoutput.c $(RTL_H) $(build_xm_file) system.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genoutput.c
|
||||
|
||||
gengenrtl : gengenrtl.o $(HOST_LIBDEPS)
|
||||
gengenrtl : gengenrtl.o
|
||||
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
|
||||
gengenrtl.o $(HOST_LIBS)
|
||||
gengenrtl.o
|
||||
|
||||
gengenrtl.o : gengenrtl.c $(RTL_BASE_H) system.h
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gengenrtl.c
|
||||
|
|
@ -1688,31 +1637,11 @@ $(HOST_PREFIX_1)rtlanal.o: $(srcdir)/rtlanal.c $(CONFIG_H) $(RTL_H)
|
|||
sed -e 's/config[.]h/hconfig.h/' $(srcdir)/rtlanal.c > $(HOST_PREFIX)rtlanal.c
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)rtlanal.c
|
||||
|
||||
$(HOST_PREFIX_1)alloca.o: $(srcdir)/../libiberty/alloca.c
|
||||
rm -f $(HOST_PREFIX)alloca.c
|
||||
$(LN_S) $(srcdir)/../libiberty/alloca.c $(HOST_PREFIX)alloca.c
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)alloca.c
|
||||
|
||||
$(HOST_PREFIX_1)obstack.o: $(srcdir)/../libiberty/obstack.c
|
||||
rm -f $(HOST_PREFIX)obstack.c
|
||||
sed -e 's/config[.]h/hconfig.h/' $(srcdir)/../libiberty/obstack.c > $(HOST_PREFIX)obstack.c
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)obstack.c
|
||||
|
||||
$(HOST_PREFIX_1)vfprintf.o: $(srcdir)/../libiberty/vfprintf.c
|
||||
rm -f $(HOST_PREFIX)vfprintf.c
|
||||
sed -e 's/config[.]h/hconfig.h/' $(srcdir)/../libiberty/vfprintf.c > $(HOST_PREFIX)vfprintf.c
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)vfprintf.c
|
||||
|
||||
$(HOST_PREFIX_1)doprint.o: doprint.c
|
||||
rm -f $(HOST_PREFIX)doprint.c
|
||||
sed -e 's/config[.]h/hconfig.h/' $(srcdir)/doprint.c > $(HOST_PREFIX)doprint.c
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)doprint.c
|
||||
|
||||
$(HOST_PREFIX_1)malloc.o: malloc.c
|
||||
rm -f $(HOST_PREFIX)malloc.c
|
||||
sed -e 's/config[.]h/hconfig.h/' $(srcdir)/malloc.c > $(HOST_PREFIX)malloc.c
|
||||
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)malloc.c
|
||||
|
||||
# This satisfies the dependency that we get if you cross-compile a compiler
|
||||
# that does not need to compile alloca, malloc or whatever.
|
||||
$(HOST_PREFIX_1):
|
||||
|
|
@ -1754,28 +1683,6 @@ cpphash.o: cpphash.c cpplib.h machmode.h cpphash.h $(CONFIG_H) system.h
|
|||
|
||||
cppalloc.o: cppalloc.c $(CONFIG_H) cpplib.h machmode.h system.h
|
||||
|
||||
# Note for the stamp targets, we run the program `true' instead of
|
||||
# having an empty command (nothing following the semicolon).
|
||||
|
||||
getopt.o: $(srcdir)/../libiberty/getopt.c $(srcdir)/../include/getopt.h
|
||||
rm -f getopt.c
|
||||
$(LN_S) $(srcdir)/../libiberty/getopt.c getopt.c
|
||||
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) getopt.c
|
||||
|
||||
getopt1.o: $(srcdir)/../libiberty/getopt1.c $(srcdir)/../include/getopt.h
|
||||
rm -f getopt1.c
|
||||
$(LN_S) $(srcdir)/../libiberty/getopt1.c getopt1.c
|
||||
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) getopt1.c
|
||||
|
||||
# This info describes the target machine, so compile with GCC just built.
|
||||
SYSCALLS.c.X: $(srcdir)/sys-types.h $(srcdir)/sys-protos.h $(GCC_PASSES) \
|
||||
stmp-int-hdrs
|
||||
-rm -f SYSCALLS.c tmp-SYSCALLS.s
|
||||
cat $(srcdir)/sys-types.h $(srcdir)/sys-protos.h > SYSCALLS.c
|
||||
$(GCC_FOR_TARGET) $(GCC_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
|
||||
-aux-info $@ -S -o tmp-SYSCALLS.s SYSCALLS.c
|
||||
-rm -f SYSCALLS.c tmp-SYSCALLS.s
|
||||
|
||||
# Build the include directory. The stamp files are stmp-* rather than
|
||||
# s-* so that mostlyclean does not force the include directory to
|
||||
# be rebuilt.
|
||||
|
|
@ -1858,7 +1765,6 @@ mostlyclean: lang.mostlyclean
|
|||
-rm -f $(STAGESTUFF)
|
||||
# Delete the temporary source copies for cross compilation.
|
||||
-rm -f $(HOST_PREFIX_1)rtl.c $(HOST_PREFIX_1)rtlanal.c
|
||||
-rm -f $(HOST_PREFIX_1)alloca.c $(HOST_PREFIX_1)malloc.c
|
||||
-rm -f $(HOST_PREFIX_1)obstack.c
|
||||
# Delete the temp files made in the course of building libgcc.a.
|
||||
-rm -f tmplibgcc* tmpcopy libgcc1-test
|
||||
|
|
@ -1876,7 +1782,7 @@ mostlyclean: lang.mostlyclean
|
|||
-rm -f */*.tree */*.loop */*.dbr */*.jump2 */*.cse2
|
||||
-rm -f */*.stack */*.regmove */*.gcse
|
||||
# Delete some files made during installation.
|
||||
-rm -f specs SYSCALLS.c.X SYSCALLS.c
|
||||
-rm -f specs
|
||||
-rm -f collect mips-tfile mips-tdump alloca.s
|
||||
# CYGNUS LOCAL: binary installation
|
||||
# Delete unwanted output files from TeX.
|
||||
|
|
|
|||
216
gcc/gen-protos.c
216
gcc/gen-protos.c
|
|
@ -1,216 +0,0 @@
|
|||
/* gen-protos.c - massages a list of prototypes, for use by fixproto.
|
||||
Copyright (C) 1993, 94-96, 1998 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "hconfig.h"
|
||||
#include "system.h"
|
||||
#include "scan.h"
|
||||
#include "cpplib.h"
|
||||
#include "cpphash.h"
|
||||
|
||||
int verbose = 0;
|
||||
char *progname;
|
||||
|
||||
#define HASH_SIZE 2503 /* a prime */
|
||||
int hash_tab[HASH_SIZE];
|
||||
int next_index;
|
||||
|
||||
int
|
||||
hashf (name, len, hashsize)
|
||||
register const U_CHAR *name;
|
||||
register int len;
|
||||
int hashsize;
|
||||
{
|
||||
register int r = 0;
|
||||
|
||||
while (len--)
|
||||
r = HASHSTEP (r, *name++);
|
||||
|
||||
return MAKE_POS (r) % hashsize;
|
||||
}
|
||||
|
||||
static void
|
||||
add_hash (fname)
|
||||
char *fname;
|
||||
{
|
||||
int i, i0;
|
||||
|
||||
/* NOTE: If you edit this, also edit lookup_std_proto in fix-header.c !! */
|
||||
i = hashf (fname, strlen (fname), HASH_SIZE);
|
||||
i0 = i;
|
||||
if (hash_tab[i] != 0)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
i = (i+1) % HASH_SIZE;
|
||||
if (i == i0)
|
||||
abort ();
|
||||
if (hash_tab[i] == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
hash_tab[i] = next_index;
|
||||
|
||||
next_index++;
|
||||
}
|
||||
|
||||
/* Given a function prototype, fill in the fields of FN.
|
||||
The result is a boolean indicating if a function prototype was found.
|
||||
|
||||
The input string is modified (trailing NULs are inserted).
|
||||
The fields of FN point to the input string. */
|
||||
|
||||
static int
|
||||
parse_fn_proto (start, end, fn)
|
||||
char *start, *end;
|
||||
struct fn_decl *fn;
|
||||
{
|
||||
register char *ptr;
|
||||
int param_nesting = 1;
|
||||
char *param_start, *param_end, *decl_start, *name_start, *name_end;
|
||||
|
||||
ptr = end - 1;
|
||||
while (*ptr == ' ' || *ptr == '\t') ptr--;
|
||||
if (*ptr-- != ';')
|
||||
{
|
||||
fprintf (stderr, "Funny input line: %s\n", start);
|
||||
return 0;
|
||||
}
|
||||
while (*ptr == ' ' || *ptr == '\t') ptr--;
|
||||
if (*ptr != ')')
|
||||
{
|
||||
fprintf (stderr, "Funny input line: %s\n", start);
|
||||
return 0;
|
||||
}
|
||||
param_end = ptr;
|
||||
for (;;)
|
||||
{
|
||||
int c = *--ptr;
|
||||
if (c == '(' && --param_nesting == 0)
|
||||
break;
|
||||
else if (c == ')')
|
||||
param_nesting++;
|
||||
}
|
||||
param_start = ptr+1;
|
||||
|
||||
ptr--;
|
||||
while (*ptr == ' ' || *ptr == '\t') ptr--;
|
||||
|
||||
if (!ISALNUM ((unsigned char)*ptr))
|
||||
{
|
||||
if (verbose)
|
||||
fprintf (stderr, "%s: Can't handle this complex prototype: %s\n",
|
||||
progname, start);
|
||||
return 0;
|
||||
}
|
||||
name_end = ptr+1;
|
||||
|
||||
while (ISALNUM ((unsigned char)*ptr) || *ptr == '_') --ptr;
|
||||
name_start = ptr+1;
|
||||
while (*ptr == ' ' || *ptr == '\t') ptr--;
|
||||
ptr[1] = 0;
|
||||
*param_end = 0;
|
||||
*name_end = 0;
|
||||
|
||||
decl_start = start;
|
||||
if (strncmp (decl_start, "typedef ", 8) == 0)
|
||||
return 0;
|
||||
if (strncmp (decl_start, "extern ", 7) == 0)
|
||||
decl_start += 7;
|
||||
|
||||
fn->fname = name_start;
|
||||
fn->rtype = decl_start;
|
||||
fn->params = param_start;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc ATTRIBUTE_UNUSED;
|
||||
char **argv;
|
||||
{
|
||||
FILE *inf = stdin;
|
||||
FILE *outf = stdout;
|
||||
int i;
|
||||
sstring linebuf;
|
||||
struct fn_decl fn_decl;
|
||||
|
||||
i = strlen (argv[0]);
|
||||
while (i > 0 && argv[0][i-1] != '/') --i;
|
||||
progname = &argv[0][i];
|
||||
|
||||
INIT_SSTRING (&linebuf);
|
||||
|
||||
fprintf (outf, "struct fn_decl std_protos[] = {\n");
|
||||
|
||||
/* A hash table entry of 0 means "unused" so reserve it. */
|
||||
fprintf (outf, " {\"\", \"\", \"\", 0},\n");
|
||||
next_index = 1;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int c = skip_spaces (inf, ' ');
|
||||
|
||||
if (c == EOF)
|
||||
break;
|
||||
linebuf.ptr = linebuf.base;
|
||||
ungetc (c, inf);
|
||||
c = read_upto (inf, &linebuf, '\n');
|
||||
if (linebuf.base[0] == '#') /* skip cpp command */
|
||||
continue;
|
||||
if (linebuf.base[0] == '\0') /* skip empty line */
|
||||
continue;
|
||||
|
||||
if (! parse_fn_proto (linebuf.base, linebuf.ptr, &fn_decl))
|
||||
continue;
|
||||
|
||||
add_hash (fn_decl.fname);
|
||||
|
||||
fprintf (outf, " {\"%s\", \"%s\", \"%s\", 0},\n",
|
||||
fn_decl.fname, fn_decl.rtype, fn_decl.params);
|
||||
|
||||
if (c == EOF)
|
||||
break;
|
||||
}
|
||||
fprintf (outf, " {0, 0, 0, 0}\n};\n");
|
||||
|
||||
|
||||
fprintf (outf, "#define HASH_SIZE %d\n", HASH_SIZE);
|
||||
fprintf (outf, "short hash_tab[HASH_SIZE] = {\n");
|
||||
for (i = 0; i < HASH_SIZE; i++)
|
||||
fprintf (outf, " %d,\n", hash_tab[i]);
|
||||
fprintf (outf, "};\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Avoid error if config defines abort as fancy_abort.
|
||||
It's not worth "really" implementing this because ordinary
|
||||
compiler users never run fix-header. */
|
||||
|
||||
void
|
||||
fancy_abort ()
|
||||
{
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
fatal (s)
|
||||
char *s;
|
||||
{
|
||||
fprintf (stderr, "%s: %s\n", "gen-protos", s);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
/* syslimits.h stands for the system's own limits.h file.
|
||||
If we can use it ok unmodified, then we install this text.
|
||||
If fixincludes fixes it, then the fixed version is installed
|
||||
instead of this text. */
|
||||
|
||||
#define _GCC_NEXT_LIMITS_H /* tell gcc's limits.h to recurse */
|
||||
#include_next <limits.h>
|
||||
#undef _GCC_NEXT_LIMITS_H
|
||||
|
|
@ -354,13 +354,6 @@ mark_referenced_resources (x, res, include_delayed_effects)
|
|||
|
||||
case INSN:
|
||||
case JUMP_INSN:
|
||||
|
||||
#ifdef INSN_REFERENCES_ARE_DELAYED
|
||||
if (! include_delayed_effects
|
||||
&& INSN_REFERENCES_ARE_DELAYED (x))
|
||||
return;
|
||||
#endif
|
||||
|
||||
/* No special processing, just speed up. */
|
||||
mark_referenced_resources (PATTERN (x), res, include_delayed_effects);
|
||||
return;
|
||||
|
|
@ -652,13 +645,6 @@ mark_set_resources (x, res, in_dest, include_delayed_effects)
|
|||
|
||||
/* An insn consisting of just a CLOBBER (or USE) is just for flow
|
||||
and doesn't actually do anything, so we ignore it. */
|
||||
|
||||
#ifdef INSN_SETS_ARE_DELAYED
|
||||
if (! include_delayed_effects
|
||||
&& INSN_SETS_ARE_DELAYED (x))
|
||||
return;
|
||||
#endif
|
||||
|
||||
x = PATTERN (x);
|
||||
if (GET_CODE (x) != USE && GET_CODE (x) != CLOBBER)
|
||||
goto restart;
|
||||
|
|
|
|||
3132
libiberty/ChangeLog
3132
libiberty/ChangeLog
File diff suppressed because it is too large
Load Diff
|
|
@ -1,246 +0,0 @@
|
|||
#
|
||||
# Makefile
|
||||
# Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
|
||||
# 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.
|
||||
#
|
||||
|
||||
# This file was written by K. Richard Pixley <rich@cygnus.com>.
|
||||
|
||||
#
|
||||
# Makefile for libiberty directory
|
||||
#
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
prefix = @prefix@
|
||||
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
libdir = @libdir@
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
# Multilib support variables.
|
||||
MULTISRCTOP =
|
||||
MULTIBUILDTOP =
|
||||
MULTIDIRS =
|
||||
MULTISUBDIR =
|
||||
MULTIDO = true
|
||||
MULTICLEAN = true
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
AR = @AR@
|
||||
AR_FLAGS = rc
|
||||
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
LIBCFLAGS = $(CFLAGS)
|
||||
RANLIB = @RANLIB@
|
||||
|
||||
PICFLAG =
|
||||
|
||||
MAKEOVERRIDES =
|
||||
|
||||
TARGETLIB = libiberty.a
|
||||
|
||||
LIBOBJS = @LIBOBJS@
|
||||
ALLOCA = @ALLOCA@
|
||||
|
||||
# A configuration can specify extra .o files that should be included,
|
||||
# even if they are in libc. (Perhaps the libc version is buggy.)
|
||||
EXTRA_OFILES =
|
||||
|
||||
# Flags to pass to a recursive make.
|
||||
FLAGS_TO_PASS = \
|
||||
"AR=$(AR)" \
|
||||
"AR_FLAGS=$(AR_FLAGS)" \
|
||||
"CC=$(CC)" \
|
||||
"CFLAGS=$(CFLAGS)" \
|
||||
"LIBCFLAGS=$(LIBCFLAGS)" \
|
||||
"EXTRA_OFILES=$(EXTRA_OFILES)" \
|
||||
"HDEFINES=$(HDEFINES)" \
|
||||
"INSTALL=$(INSTALL)" \
|
||||
"INSTALL_DATA=$(INSTALL_DATA)" \
|
||||
"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
|
||||
"LDFLAGS=$(LDFLAGS)" \
|
||||
"LOADLIBES=$(LOADLIBES)" \
|
||||
"RANLIB=$(RANLIB)" \
|
||||
"SHELL=$(SHELL)"
|
||||
|
||||
all: stamp-picdir $(TARGETLIB) needed-list required-list
|
||||
@$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
|
||||
|
||||
.PHONY: check installcheck
|
||||
check installcheck:
|
||||
|
||||
@host_makefile_frag@
|
||||
|
||||
INCDIR=$(srcdir)/$(MULTISRCTOP)../include
|
||||
|
||||
COMPILE.c = $(CC) -c @DEFS@ $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES)
|
||||
.c.o:
|
||||
test x"$(enable_shared)" != xyes || \
|
||||
$(COMPILE.c) $(PICFLAG) $< -o pic/$@
|
||||
$(COMPILE.c) $<
|
||||
|
||||
info install-info clean-info dvi:
|
||||
|
||||
# Include files that are in this directory.
|
||||
HFILES = alloca-conf.h
|
||||
|
||||
# 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 choose-temp.c clock.c concat.c fdmatch.c \
|
||||
fnmatch.c getcwd.c getopt.c getopt1.c getpagesize.c \
|
||||
getruntime.c floatformat.c hex.c index.c insque.c memchr.c \
|
||||
memcmp.c memcpy.c memmove.c memset.c mkstemp.c objalloc.c obstack.c \
|
||||
pexecute.c random.c rename.c rindex.c sigsetmask.c spaces.c \
|
||||
splay-tree.c strcasecmp.c strncasecmp.c strchr.c strdup.c strerror.c \
|
||||
strrchr.c strsignal.c strstr.c strtod.c strtol.c strtoul.c \
|
||||
tmpnam.c vasprintf.c vfork.c vfprintf.c vprintf.c vsprintf.c \
|
||||
waitpid.c xatexit.c xexit.c xmalloc.c xstrdup.c xstrerror.c
|
||||
|
||||
# These are always included in the library.
|
||||
REQUIRED_OFILES = argv.o choose-temp.o concat.o \
|
||||
fdmatch.o fnmatch.o getopt.o getopt1.o getruntime.o hex.o \
|
||||
floatformat.o mkstemp.o objalloc.o obstack.o pexecute.o spaces.o \
|
||||
splay-tree.o strerror.o strsignal.o xatexit.o xexit.o xmalloc.o \
|
||||
xstrdup.o xstrerror.o
|
||||
|
||||
$(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA)
|
||||
rm -f $(TARGETLIB)
|
||||
$(AR) $(AR_FLAGS) $(TARGETLIB) \
|
||||
$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA)
|
||||
$(RANLIB) $(TARGETLIB)
|
||||
|
||||
INSTALL_DEST = @INSTALL_DEST@
|
||||
install: install_to_$(INSTALL_DEST)
|
||||
|
||||
install_to_libdir: all
|
||||
$(INSTALL_DATA) $(TARGETLIB) $(libdir)$(MULTISUBDIR)/$(TARGETLIB).n
|
||||
( cd $(libdir)$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB).n )
|
||||
mv -f $(libdir)$(MULTISUBDIR)/$(TARGETLIB).n $(libdir)$(MULTISUBDIR)/$(TARGETLIB)
|
||||
@$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
|
||||
|
||||
install_to_tooldir: all
|
||||
$(INSTALL_DATA) $(TARGETLIB) $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB).n
|
||||
( cd $(tooldir)/lib$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB).n )
|
||||
mv -f $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB).n $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB)
|
||||
@$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
|
||||
|
||||
# needed-list is used by libstdc++.
|
||||
needed-list: Makefile
|
||||
f="$(LIBOBJS) $(ALLOCA) $(EXTRA_OFILES)"; \
|
||||
case $$f in \
|
||||
*alloca.o*) f="$$f xmalloc.o xexit.o" ;; \
|
||||
esac; \
|
||||
echo $$f > needed-list
|
||||
|
||||
# required-list was used when building a shared bfd/opcodes/libiberty
|
||||
# library. I don't know if it used by anything currently.
|
||||
required-list: Makefile
|
||||
echo $(REQUIRED_OFILES) > required-list
|
||||
|
||||
stamp-picdir:
|
||||
if [ x"$(enable_shared)" = xyes ] && [ ! -d pic ]; then \
|
||||
mkdir pic; \
|
||||
else true; fi
|
||||
touch stamp-picdir
|
||||
|
||||
.PHONY: all etags tags ls clean stage1 stage2
|
||||
|
||||
etags tags: TAGS
|
||||
|
||||
TAGS: $(CFILES) $(HFILES)
|
||||
etags `for i in $(HFILES) $(CFILES); do echo $(srcdir)/$$i ; done`
|
||||
|
||||
# The standalone demangler (c++filt) has been moved to binutils.
|
||||
demangle:
|
||||
@echo "The standalone demangler, now named c++filt, is now"
|
||||
@echo "a part of binutils."
|
||||
@false
|
||||
|
||||
ls:
|
||||
@echo Makefile $(HFILES) $(CFILES)
|
||||
|
||||
# Need to deal with profiled libraries, too.
|
||||
|
||||
mostlyclean:
|
||||
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
|
||||
@$(MULTICLEAN) multi-clean DO=mostlyclean
|
||||
clean: mostlyclean
|
||||
rm -f *.a required-list tmpmulti.out
|
||||
@$(MULTICLEAN) multi-clean DO=clean
|
||||
distclean: clean
|
||||
@$(MULTICLEAN) multi-clean DO=distclean
|
||||
rm -f *~ Makefile config.status xhost-mkfrag TAGS multilib.out
|
||||
rm -f config.log
|
||||
maintainer-clean realclean: distclean
|
||||
|
||||
force:
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in config.status
|
||||
CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
config.h: stamp-h ; @true
|
||||
stamp-h: config.in config.status
|
||||
CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
|
||||
|
||||
config.status: $(srcdir)/configure $(srcdir)/config.table
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA): stamp-picdir
|
||||
|
||||
alloca.o: config.h
|
||||
atexit.o: config.h
|
||||
argv.o: config.h alloca-conf.h $(INCDIR)/libiberty.h
|
||||
basename.o: $(INCDIR)/libiberty.h
|
||||
choose-temp.o: config.h
|
||||
clock.o: config.h
|
||||
concat.o: $(INCDIR)/libiberty.h
|
||||
fdmatch.o: $(INCDIR)/libiberty.h
|
||||
fnmatch.o: config.h $(INCDIR)/fnmatch.h
|
||||
getcwd.o: config.h
|
||||
getopt.o: config.h $(INCDIR)/getopt.h
|
||||
getopt1.o: config.h $(INCDIR)/getopt.h
|
||||
getpagesize.o: config.h
|
||||
getruntime.o: config.h $(INCDIR)/libiberty.h
|
||||
hex.o: $(INCDIR)/libiberty.h
|
||||
floatformat.o: $(INCDIR)/floatformat.h
|
||||
mkstemp.o: config.h
|
||||
objalloc.o: $(INCDIR)/objalloc.h
|
||||
obstack.o: config.h $(INCDIR)/obstack.h
|
||||
pexecute.o: config.h $(INCDIR)/libiberty.h
|
||||
spaces.o: $(INCDIR)/libiberty.h
|
||||
splay-tree.o: config.h $(INCDIR)/libiberty.h $(INCDIR)/splay-tree.h $(INCDIR)/ansidecl.h
|
||||
strerror.o: config.h $(INCDIR)/libiberty.h
|
||||
strsignal.o: config.h $(INCDIR)/libiberty.h
|
||||
xatexit.o: $(INCDIR)/libiberty.h
|
||||
xexit.o: $(INCDIR)/libiberty.h
|
||||
xmalloc.o: $(INCDIR)/libiberty.h
|
||||
xstrdup.o: $(INCDIR)/libiberty.h
|
||||
xstrerror.o: config.h $(INCDIR)/libiberty.h
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
This directory contains the -liberty library of free software.
|
||||
It is a collection of subroutines used by various GNU programs.
|
||||
Current members include:
|
||||
|
||||
getopt -- get options from command line
|
||||
obstack -- stacks of arbitrarily-sized objects
|
||||
strerror -- error message strings corresponding to errno
|
||||
strtol -- string-to-long conversion
|
||||
strtoul -- string-to-unsigned-long conversion
|
||||
|
||||
We expect many of the GNU subroutines that are floating around to
|
||||
eventually arrive here.
|
||||
|
||||
The library must be configured from the top source directory. Don't
|
||||
try to run configure in this directory. Follow the configuration
|
||||
instructions in ../README.
|
||||
|
||||
Please report bugs and fixes to "bug-gnu-utils@prep.ai.mit.edu". Thank you.
|
||||
|
||||
ADDING A NEW FILE
|
||||
=================
|
||||
|
||||
There are two sets of files: Those that are "required" will be
|
||||
included in the library for all configurations, while those
|
||||
that are "optional" will be included in the library only if "needed."
|
||||
|
||||
To add a new required file, edit Makefile to add the source file
|
||||
name to CFILES and the object file to REQUIRED_OFILES.
|
||||
|
||||
To add a new optional file, it must provide a single function, and the
|
||||
name of the function must be the same as the name of the file.
|
||||
|
||||
* Add the source file name to CFILES.
|
||||
|
||||
* Add the function to name to the funcs shell variable in
|
||||
configure.in.
|
||||
|
||||
* Add the function to the AC_CHECK_FUNCS lists just after the
|
||||
setting of the funcs shell variable. These AC_CHECK_FUNCS calls
|
||||
are never executed; they are there to make autoheader work
|
||||
better.
|
||||
|
||||
* Consider the special cases of building libiberty; as of this
|
||||
writing, the special cases are newlib and VxWorks. If a
|
||||
particular special case provides the function, you do not need
|
||||
to do anything. If it does not provide the function, add the
|
||||
object file to LIBOBJS, and add the function name to the case
|
||||
controlling whether to define HAVE_func.
|
||||
|
||||
The optional file you've added (e.g. getcwd.c) should compile and work
|
||||
on all hosts where it is needed. It does not have to work or even
|
||||
compile on hosts where it is not needed.
|
||||
|
||||
ADDING A NEW CONFIGURATION
|
||||
==========================
|
||||
|
||||
On most hosts you should be able to use the scheme for automatically
|
||||
figuring out which files are needed. In that case, you probably
|
||||
don't need a special Makefile stub for that configuration.
|
||||
|
||||
If the fully automatic scheme doesn't work, you may be able to get
|
||||
by with defining EXTRA_OFILES in your Makefile stub. This is
|
||||
a list of object file names that should be treated as required
|
||||
for this configuration - they will be included in libiberty.a,
|
||||
regardless of whatever might be in the C library.
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/* Define if you have the sys_errlist variable. */
|
||||
#undef HAVE_SYS_ERRLIST
|
||||
|
||||
/* Define if you have the sys_nerr variable. */
|
||||
#undef HAVE_SYS_NERR
|
||||
|
||||
/* Define if you have the sys_siglist variable. */
|
||||
#undef HAVE_SYS_SIGLIST
|
||||
|
||||
/* Define if you have the strerror function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
#include "config.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
# ifndef alloca
|
||||
# define alloca __builtin_alloca
|
||||
# endif
|
||||
#else /* ! defined (__GNUC__) */
|
||||
# ifdef _AIX
|
||||
#pragma alloca
|
||||
# else
|
||||
# ifdef HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# else /* ! defined (HAVE_ALLOCA_H) */
|
||||
# ifdef __STDC__
|
||||
extern PTR alloca (size_t);
|
||||
# else /* ! defined (__STDC__) */
|
||||
extern PTR alloca ();
|
||||
# endif /* ! defined (__STDC__) */
|
||||
# endif /* ! defined (HAVE_ALLOCA_H) */
|
||||
# ifdef _WIN32
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
# endif /* ! defined (_AIX) */
|
||||
#endif /* ! defined (__GNUC__) */
|
||||
|
|
@ -1,505 +0,0 @@
|
|||
/* alloca.c -- allocate automatically reclaimed memory
|
||||
(Mostly) portable public-domain implementation -- D A Gwyn
|
||||
|
||||
This implementation of the PWB library alloca function,
|
||||
which is used to allocate space off the run-time stack so
|
||||
that it is automatically reclaimed upon procedure exit,
|
||||
was inspired by discussions with J. Q. Johnson of Cornell.
|
||||
J.Otto Tennant <jot@cray.com> contributed the Cray support.
|
||||
|
||||
There are some preprocessor constants that can
|
||||
be defined when compiling for your specific system, for
|
||||
improved efficiency; however, the defaults should be okay.
|
||||
|
||||
The general concept of this implementation is to keep
|
||||
track of all alloca-allocated blocks, and reclaim any
|
||||
that are found to be deeper in the stack than the current
|
||||
invocation. This heuristic does not reclaim storage as
|
||||
soon as it becomes invalid, but it will do so eventually.
|
||||
|
||||
As a special case, alloca(0) reclaims storage without
|
||||
allocating any. It is a good idea to use alloca(0) in
|
||||
your main control loop, etc. to force garbage collection. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef emacs
|
||||
#include "blockinput.h"
|
||||
#endif
|
||||
|
||||
/* If compiling with GCC 2, this file's not needed. Except of course if
|
||||
the C alloca is explicitly requested. */
|
||||
#if defined (USE_C_ALLOCA) || !defined (__GNUC__) || __GNUC__ < 2
|
||||
|
||||
/* If someone has defined alloca as a macro,
|
||||
there must be some other way alloca is supposed to work. */
|
||||
#ifndef alloca
|
||||
|
||||
#ifdef emacs
|
||||
#ifdef static
|
||||
/* actually, only want this if static is defined as ""
|
||||
-- this is for usg, in which emacs must undefine static
|
||||
in order to make unexec workable
|
||||
*/
|
||||
#ifndef STACK_DIRECTION
|
||||
you
|
||||
lose
|
||||
-- must know STACK_DIRECTION at compile-time
|
||||
#endif /* STACK_DIRECTION undefined */
|
||||
#endif /* static */
|
||||
#endif /* emacs */
|
||||
|
||||
/* If your stack is a linked list of frames, you have to
|
||||
provide an "address metric" ADDRESS_FUNCTION macro. */
|
||||
|
||||
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
long i00afunc ();
|
||||
#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
|
||||
#else
|
||||
#define ADDRESS_FUNCTION(arg) &(arg)
|
||||
#endif
|
||||
|
||||
#if __STDC__
|
||||
typedef void *pointer;
|
||||
#else
|
||||
typedef char *pointer;
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
/* Different portions of Emacs need to call different versions of
|
||||
malloc. The Emacs executable needs alloca to call xmalloc, because
|
||||
ordinary malloc isn't protected from input signals. On the other
|
||||
hand, the utilities in lib-src need alloca to call malloc; some of
|
||||
them are very simple, and don't have an xmalloc routine.
|
||||
|
||||
Non-Emacs programs expect this to call use xmalloc.
|
||||
|
||||
Callers below should use malloc. */
|
||||
|
||||
#ifndef emacs
|
||||
#define malloc xmalloc
|
||||
#endif
|
||||
extern pointer malloc ();
|
||||
|
||||
/* Define STACK_DIRECTION if you know the direction of stack
|
||||
growth for your system; otherwise it will be automatically
|
||||
deduced at run-time.
|
||||
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
|
||||
#ifndef STACK_DIRECTION
|
||||
#define STACK_DIRECTION 0 /* Direction unknown. */
|
||||
#endif
|
||||
|
||||
#if STACK_DIRECTION != 0
|
||||
|
||||
#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
|
||||
|
||||
#else /* STACK_DIRECTION == 0; need run-time code. */
|
||||
|
||||
static int stack_dir; /* 1 or -1 once known. */
|
||||
#define STACK_DIR stack_dir
|
||||
|
||||
static void
|
||||
find_stack_direction ()
|
||||
{
|
||||
static char *addr = NULL; /* Address of first `dummy', once known. */
|
||||
auto char dummy; /* To get stack address. */
|
||||
|
||||
if (addr == NULL)
|
||||
{ /* Initial entry. */
|
||||
addr = ADDRESS_FUNCTION (dummy);
|
||||
|
||||
find_stack_direction (); /* Recurse once. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Second entry. */
|
||||
if (ADDRESS_FUNCTION (dummy) > addr)
|
||||
stack_dir = 1; /* Stack grew upward. */
|
||||
else
|
||||
stack_dir = -1; /* Stack grew downward. */
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* STACK_DIRECTION == 0 */
|
||||
|
||||
/* An "alloca header" is used to:
|
||||
(a) chain together all alloca'ed blocks;
|
||||
(b) keep track of stack depth.
|
||||
|
||||
It is very important that sizeof(header) agree with malloc
|
||||
alignment chunk size. The following default should work okay. */
|
||||
|
||||
#ifndef ALIGN_SIZE
|
||||
#define ALIGN_SIZE sizeof(double)
|
||||
#endif
|
||||
|
||||
typedef union hdr
|
||||
{
|
||||
char align[ALIGN_SIZE]; /* To force sizeof(header). */
|
||||
struct
|
||||
{
|
||||
union hdr *next; /* For chaining headers. */
|
||||
char *deep; /* For stack depth measure. */
|
||||
} h;
|
||||
} header;
|
||||
|
||||
static header *last_alloca_header = NULL; /* -> last alloca header. */
|
||||
|
||||
/* Return a pointer to at least SIZE bytes of storage,
|
||||
which will be automatically reclaimed upon exit from
|
||||
the procedure that called alloca. Originally, this space
|
||||
was supposed to be taken from the current stack frame of the
|
||||
caller, but that method cannot be made to work for some
|
||||
implementations of C, for example under Gould's UTX/32. */
|
||||
|
||||
pointer
|
||||
alloca (size)
|
||||
unsigned size;
|
||||
{
|
||||
auto char probe; /* Probes stack depth: */
|
||||
register char *depth = ADDRESS_FUNCTION (probe);
|
||||
|
||||
#if STACK_DIRECTION == 0
|
||||
if (STACK_DIR == 0) /* Unknown growth direction. */
|
||||
find_stack_direction ();
|
||||
#endif
|
||||
|
||||
/* Reclaim garbage, defined as all alloca'd storage that
|
||||
was allocated from deeper in the stack than currently. */
|
||||
|
||||
{
|
||||
register header *hp; /* Traverses linked list. */
|
||||
|
||||
#ifdef emacs
|
||||
BLOCK_INPUT;
|
||||
#endif
|
||||
|
||||
for (hp = last_alloca_header; hp != NULL;)
|
||||
if ((STACK_DIR > 0 && hp->h.deep > depth)
|
||||
|| (STACK_DIR < 0 && hp->h.deep < depth))
|
||||
{
|
||||
register header *np = hp->h.next;
|
||||
|
||||
free ((pointer) hp); /* Collect garbage. */
|
||||
|
||||
hp = np; /* -> next header. */
|
||||
}
|
||||
else
|
||||
break; /* Rest are not deeper. */
|
||||
|
||||
last_alloca_header = hp; /* -> last valid storage. */
|
||||
|
||||
#ifdef emacs
|
||||
UNBLOCK_INPUT;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
return NULL; /* No allocation required. */
|
||||
|
||||
/* Allocate combined header + user data storage. */
|
||||
|
||||
{
|
||||
register pointer new = malloc (sizeof (header) + size);
|
||||
/* Address of header. */
|
||||
|
||||
if (new == 0)
|
||||
abort();
|
||||
|
||||
((header *) new)->h.next = last_alloca_header;
|
||||
((header *) new)->h.deep = depth;
|
||||
|
||||
last_alloca_header = (header *) new;
|
||||
|
||||
/* User storage begins just after header. */
|
||||
|
||||
return (pointer) ((char *) new + sizeof (header));
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifndef CRAY_STACK
|
||||
#define CRAY_STACK
|
||||
#ifndef CRAY2
|
||||
/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
|
||||
struct stack_control_header
|
||||
{
|
||||
long shgrow:32; /* Number of times stack has grown. */
|
||||
long shaseg:32; /* Size of increments to stack. */
|
||||
long shhwm:32; /* High water mark of stack. */
|
||||
long shsize:32; /* Current size of stack (all segments). */
|
||||
};
|
||||
|
||||
/* The stack segment linkage control information occurs at
|
||||
the high-address end of a stack segment. (The stack
|
||||
grows from low addresses to high addresses.) The initial
|
||||
part of the stack segment linkage control information is
|
||||
0200 (octal) words. This provides for register storage
|
||||
for the routine which overflows the stack. */
|
||||
|
||||
struct stack_segment_linkage
|
||||
{
|
||||
long ss[0200]; /* 0200 overflow words. */
|
||||
long sssize:32; /* Number of words in this segment. */
|
||||
long ssbase:32; /* Offset to stack base. */
|
||||
long:32;
|
||||
long sspseg:32; /* Offset to linkage control of previous
|
||||
segment of stack. */
|
||||
long:32;
|
||||
long sstcpt:32; /* Pointer to task common address block. */
|
||||
long sscsnm; /* Private control structure number for
|
||||
microtasking. */
|
||||
long ssusr1; /* Reserved for user. */
|
||||
long ssusr2; /* Reserved for user. */
|
||||
long sstpid; /* Process ID for pid based multi-tasking. */
|
||||
long ssgvup; /* Pointer to multitasking thread giveup. */
|
||||
long sscray[7]; /* Reserved for Cray Research. */
|
||||
long ssa0;
|
||||
long ssa1;
|
||||
long ssa2;
|
||||
long ssa3;
|
||||
long ssa4;
|
||||
long ssa5;
|
||||
long ssa6;
|
||||
long ssa7;
|
||||
long sss0;
|
||||
long sss1;
|
||||
long sss2;
|
||||
long sss3;
|
||||
long sss4;
|
||||
long sss5;
|
||||
long sss6;
|
||||
long sss7;
|
||||
};
|
||||
|
||||
#else /* CRAY2 */
|
||||
/* The following structure defines the vector of words
|
||||
returned by the STKSTAT library routine. */
|
||||
struct stk_stat
|
||||
{
|
||||
long now; /* Current total stack size. */
|
||||
long maxc; /* Amount of contiguous space which would
|
||||
be required to satisfy the maximum
|
||||
stack demand to date. */
|
||||
long high_water; /* Stack high-water mark. */
|
||||
long overflows; /* Number of stack overflow ($STKOFEN) calls. */
|
||||
long hits; /* Number of internal buffer hits. */
|
||||
long extends; /* Number of block extensions. */
|
||||
long stko_mallocs; /* Block allocations by $STKOFEN. */
|
||||
long underflows; /* Number of stack underflow calls ($STKRETN). */
|
||||
long stko_free; /* Number of deallocations by $STKRETN. */
|
||||
long stkm_free; /* Number of deallocations by $STKMRET. */
|
||||
long segments; /* Current number of stack segments. */
|
||||
long maxs; /* Maximum number of stack segments so far. */
|
||||
long pad_size; /* Stack pad size. */
|
||||
long current_address; /* Current stack segment address. */
|
||||
long current_size; /* Current stack segment size. This
|
||||
number is actually corrupted by STKSTAT to
|
||||
include the fifteen word trailer area. */
|
||||
long initial_address; /* Address of initial segment. */
|
||||
long initial_size; /* Size of initial segment. */
|
||||
};
|
||||
|
||||
/* The following structure describes the data structure which trails
|
||||
any stack segment. I think that the description in 'asdef' is
|
||||
out of date. I only describe the parts that I am sure about. */
|
||||
|
||||
struct stk_trailer
|
||||
{
|
||||
long this_address; /* Address of this block. */
|
||||
long this_size; /* Size of this block (does not include
|
||||
this trailer). */
|
||||
long unknown2;
|
||||
long unknown3;
|
||||
long link; /* Address of trailer block of previous
|
||||
segment. */
|
||||
long unknown5;
|
||||
long unknown6;
|
||||
long unknown7;
|
||||
long unknown8;
|
||||
long unknown9;
|
||||
long unknown10;
|
||||
long unknown11;
|
||||
long unknown12;
|
||||
long unknown13;
|
||||
long unknown14;
|
||||
};
|
||||
|
||||
#endif /* CRAY2 */
|
||||
#endif /* not CRAY_STACK */
|
||||
|
||||
#ifdef CRAY2
|
||||
/* Determine a "stack measure" for an arbitrary ADDRESS.
|
||||
I doubt that "lint" will like this much. */
|
||||
|
||||
static long
|
||||
i00afunc (long *address)
|
||||
{
|
||||
struct stk_stat status;
|
||||
struct stk_trailer *trailer;
|
||||
long *block, size;
|
||||
long result = 0;
|
||||
|
||||
/* We want to iterate through all of the segments. The first
|
||||
step is to get the stack status structure. We could do this
|
||||
more quickly and more directly, perhaps, by referencing the
|
||||
$LM00 common block, but I know that this works. */
|
||||
|
||||
STKSTAT (&status);
|
||||
|
||||
/* Set up the iteration. */
|
||||
|
||||
trailer = (struct stk_trailer *) (status.current_address
|
||||
+ status.current_size
|
||||
- 15);
|
||||
|
||||
/* There must be at least one stack segment. Therefore it is
|
||||
a fatal error if "trailer" is null. */
|
||||
|
||||
if (trailer == 0)
|
||||
abort ();
|
||||
|
||||
/* Discard segments that do not contain our argument address. */
|
||||
|
||||
while (trailer != 0)
|
||||
{
|
||||
block = (long *) trailer->this_address;
|
||||
size = trailer->this_size;
|
||||
if (block == 0 || size == 0)
|
||||
abort ();
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
if ((block <= address) && (address < (block + size)))
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set the result to the offset in this segment and add the sizes
|
||||
of all predecessor segments. */
|
||||
|
||||
result = address - block;
|
||||
|
||||
if (trailer == 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (trailer->this_size <= 0)
|
||||
abort ();
|
||||
result += trailer->this_size;
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
}
|
||||
while (trailer != 0);
|
||||
|
||||
/* We are done. Note that if you present a bogus address (one
|
||||
not in any segment), you will get a different number back, formed
|
||||
from subtracting the address of the first block. This is probably
|
||||
not what you want. */
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
#else /* not CRAY2 */
|
||||
/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
|
||||
Determine the number of the cell within the stack,
|
||||
given the address of the cell. The purpose of this
|
||||
routine is to linearize, in some sense, stack addresses
|
||||
for alloca. */
|
||||
|
||||
static long
|
||||
i00afunc (long address)
|
||||
{
|
||||
long stkl = 0;
|
||||
|
||||
long size, pseg, this_segment, stack;
|
||||
long result = 0;
|
||||
|
||||
struct stack_segment_linkage *ssptr;
|
||||
|
||||
/* Register B67 contains the address of the end of the
|
||||
current stack segment. If you (as a subprogram) store
|
||||
your registers on the stack and find that you are past
|
||||
the contents of B67, you have overflowed the segment.
|
||||
|
||||
B67 also points to the stack segment linkage control
|
||||
area, which is what we are really interested in. */
|
||||
|
||||
stkl = CRAY_STACKSEG_END ();
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
|
||||
/* If one subtracts 'size' from the end of the segment,
|
||||
one has the address of the first word of the segment.
|
||||
|
||||
If this is not the first segment, 'pseg' will be
|
||||
nonzero. */
|
||||
|
||||
pseg = ssptr->sspseg;
|
||||
size = ssptr->sssize;
|
||||
|
||||
this_segment = stkl - size;
|
||||
|
||||
/* It is possible that calling this routine itself caused
|
||||
a stack overflow. Discard stack segments which do not
|
||||
contain the target address. */
|
||||
|
||||
while (!(this_segment <= address && address <= stkl))
|
||||
{
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
|
||||
#endif
|
||||
if (pseg == 0)
|
||||
break;
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
pseg = ssptr->sspseg;
|
||||
this_segment = stkl - size;
|
||||
}
|
||||
|
||||
result = address - this_segment;
|
||||
|
||||
/* If you subtract pseg from the current end of the stack,
|
||||
you get the address of the previous stack segment's end.
|
||||
This seems a little convoluted to me, but I'll bet you save
|
||||
a cycle somewhere. */
|
||||
|
||||
while (pseg != 0)
|
||||
{
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o\n", pseg, size);
|
||||
#endif
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
pseg = ssptr->sspseg;
|
||||
result += size;
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
#endif /* not CRAY2 */
|
||||
#endif /* CRAY */
|
||||
|
||||
#endif /* no alloca */
|
||||
#endif /* not GCC version 2 */
|
||||
390
libiberty/argv.c
390
libiberty/argv.c
|
|
@ -1,390 +0,0 @@
|
|||
/* Create and destroy argument vectors (argv's)
|
||||
Copyright (C) 1992 Free Software Foundation, Inc.
|
||||
Written by Fred Fish @ Cygnus Support
|
||||
|
||||
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. */
|
||||
|
||||
|
||||
/* Create and destroy argument vectors. An argument vector is simply an
|
||||
array of string pointers, terminated by a NULL pointer. */
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#ifdef isspace
|
||||
#undef isspace
|
||||
#endif
|
||||
#define isspace(ch) ((ch) == ' ' || (ch) == '\t')
|
||||
|
||||
/* Routines imported from standard C runtime libraries. */
|
||||
|
||||
#ifdef __STDC__
|
||||
|
||||
#include <stddef.h>
|
||||
extern void *memcpy (void *s1, const void *s2, size_t n); /* 4.11.2.1 */
|
||||
extern size_t strlen (const char *s); /* 4.11.6.3 */
|
||||
extern void *malloc (size_t size); /* 4.10.3.3 */
|
||||
extern void *realloc (void *ptr, size_t size); /* 4.10.3.4 */
|
||||
extern void free (void *ptr); /* 4.10.3.2 */
|
||||
extern char *strdup (const char *s); /* Non-ANSI */
|
||||
|
||||
#else /* !__STDC__ */
|
||||
|
||||
#if !defined _WIN32 || defined __GNUC__
|
||||
extern char *memcpy (); /* Copy memory region */
|
||||
extern int strlen (); /* Count length of string */
|
||||
extern char *malloc (); /* Standard memory allocater */
|
||||
extern char *realloc (); /* Standard memory reallocator */
|
||||
extern void free (); /* Free malloc'd memory */
|
||||
extern char *strdup (); /* Duplicate a string */
|
||||
#endif
|
||||
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#include "alloca-conf.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef EOS
|
||||
#define EOS '\0'
|
||||
#endif
|
||||
|
||||
#define INITIAL_MAXARGC 8 /* Number of args + NULL in initial argv */
|
||||
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
dupargv -- duplicate an argument vector
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
char **dupargv (vector)
|
||||
char **vector;
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Duplicate an argument vector. Simply scans through the
|
||||
vector, duplicating each argument until the
|
||||
terminating NULL is found.
|
||||
|
||||
RETURNS
|
||||
|
||||
Returns a pointer to the argument vector if
|
||||
successful. Returns NULL if there is insufficient memory to
|
||||
complete building the argument vector.
|
||||
|
||||
*/
|
||||
|
||||
char **
|
||||
dupargv (argv)
|
||||
char **argv;
|
||||
{
|
||||
int argc;
|
||||
char **copy;
|
||||
|
||||
if (argv == NULL)
|
||||
return NULL;
|
||||
|
||||
/* the vector */
|
||||
for (argc = 0; argv[argc] != NULL; argc++);
|
||||
copy = (char **) malloc ((argc + 1) * sizeof (char *));
|
||||
if (copy == NULL)
|
||||
return NULL;
|
||||
|
||||
/* the strings */
|
||||
for (argc = 0; argv[argc] != NULL; argc++)
|
||||
{
|
||||
int len = strlen (argv[argc]);
|
||||
copy[argc] = malloc (sizeof (char *) * (len + 1));
|
||||
if (copy[argc] == NULL)
|
||||
{
|
||||
freeargv (copy);
|
||||
return NULL;
|
||||
}
|
||||
strcpy (copy[argc], argv[argc]);
|
||||
}
|
||||
copy[argc] = NULL;
|
||||
return copy;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
freeargv -- free an argument vector
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
void freeargv (vector)
|
||||
char **vector;
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Free an argument vector that was built using buildargv. Simply scans
|
||||
through the vector, freeing the memory for each argument until the
|
||||
terminating NULL is found, and then frees the vector itself.
|
||||
|
||||
RETURNS
|
||||
|
||||
No value.
|
||||
|
||||
*/
|
||||
|
||||
void freeargv (vector)
|
||||
char **vector;
|
||||
{
|
||||
register char **scan;
|
||||
|
||||
if (vector != NULL)
|
||||
{
|
||||
for (scan = vector; *scan != NULL; scan++)
|
||||
{
|
||||
free (*scan);
|
||||
}
|
||||
free (vector);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
buildargv -- build an argument vector from a string
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
char **buildargv (sp)
|
||||
char *sp;
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Given a pointer to a string, parse the string extracting fields
|
||||
separated by whitespace and optionally enclosed within either single
|
||||
or double quotes (which are stripped off), and build a vector of
|
||||
pointers to copies of the string for each field. The input string
|
||||
remains unchanged.
|
||||
|
||||
All of the memory for the pointer array and copies of the string
|
||||
is obtained from malloc. All of the memory can be returned to the
|
||||
system with the single function call freeargv, which takes the
|
||||
returned result of buildargv, as it's argument.
|
||||
|
||||
The memory for the argv array is dynamically expanded as necessary.
|
||||
|
||||
RETURNS
|
||||
|
||||
Returns a pointer to the argument vector if successful. Returns NULL
|
||||
if the input string pointer is NULL or if there is insufficient
|
||||
memory to complete building the argument vector.
|
||||
|
||||
NOTES
|
||||
|
||||
In order to provide a working buffer for extracting arguments into,
|
||||
with appropriate stripping of quotes and translation of backslash
|
||||
sequences, we allocate a working buffer at least as long as the input
|
||||
string. This ensures that we always have enough space in which to
|
||||
work, since the extracted arg is never larger than the input string.
|
||||
|
||||
If the input is a null string (as opposed to a NULL pointer), then
|
||||
buildarg returns an argv that has one arg, a null string.
|
||||
|
||||
Argv is always kept terminated with a NULL arg pointer, so it can
|
||||
be passed to freeargv at any time, or returned, as appropriate.
|
||||
*/
|
||||
|
||||
char **buildargv (input)
|
||||
char *input;
|
||||
{
|
||||
char *arg;
|
||||
char *copybuf;
|
||||
int squote = 0;
|
||||
int dquote = 0;
|
||||
int bsquote = 0;
|
||||
int argc = 0;
|
||||
int maxargc = 0;
|
||||
char **argv = NULL;
|
||||
char **nargv;
|
||||
|
||||
if (input != NULL)
|
||||
{
|
||||
copybuf = (char *) alloca (strlen (input) + 1);
|
||||
/* Is a do{}while to always execute the loop once. Always return an
|
||||
argv, even for null strings. See NOTES above, test case below. */
|
||||
do
|
||||
{
|
||||
/* Pick off argv[argc] */
|
||||
while (isspace (*input))
|
||||
{
|
||||
input++;
|
||||
}
|
||||
if ((maxargc == 0) || (argc >= (maxargc - 1)))
|
||||
{
|
||||
/* argv needs initialization, or expansion */
|
||||
if (argv == NULL)
|
||||
{
|
||||
maxargc = INITIAL_MAXARGC;
|
||||
nargv = (char **) malloc (maxargc * sizeof (char *));
|
||||
}
|
||||
else
|
||||
{
|
||||
maxargc *= 2;
|
||||
nargv = (char **) realloc (argv, maxargc * sizeof (char *));
|
||||
}
|
||||
if (nargv == NULL)
|
||||
{
|
||||
if (argv != NULL)
|
||||
{
|
||||
freeargv (argv);
|
||||
argv = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
argv = nargv;
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
/* Begin scanning arg */
|
||||
arg = copybuf;
|
||||
while (*input != EOS)
|
||||
{
|
||||
if (isspace (*input) && !squote && !dquote && !bsquote)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bsquote)
|
||||
{
|
||||
bsquote = 0;
|
||||
*arg++ = *input;
|
||||
}
|
||||
else if (*input == '\\')
|
||||
{
|
||||
bsquote = 1;
|
||||
}
|
||||
else if (squote)
|
||||
{
|
||||
if (*input == '\'')
|
||||
{
|
||||
squote = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*arg++ = *input;
|
||||
}
|
||||
}
|
||||
else if (dquote)
|
||||
{
|
||||
if (*input == '"')
|
||||
{
|
||||
dquote = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*arg++ = *input;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*input == '\'')
|
||||
{
|
||||
squote = 1;
|
||||
}
|
||||
else if (*input == '"')
|
||||
{
|
||||
dquote = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*arg++ = *input;
|
||||
}
|
||||
}
|
||||
input++;
|
||||
}
|
||||
}
|
||||
*arg = EOS;
|
||||
argv[argc] = strdup (copybuf);
|
||||
if (argv[argc] == NULL)
|
||||
{
|
||||
freeargv (argv);
|
||||
argv = NULL;
|
||||
break;
|
||||
}
|
||||
argc++;
|
||||
argv[argc] = NULL;
|
||||
|
||||
while (isspace (*input))
|
||||
{
|
||||
input++;
|
||||
}
|
||||
}
|
||||
while (*input != EOS);
|
||||
}
|
||||
return (argv);
|
||||
}
|
||||
|
||||
#ifdef MAIN
|
||||
|
||||
/* Simple little test driver. */
|
||||
|
||||
static char *tests[] =
|
||||
{
|
||||
"a simple command line",
|
||||
"arg 'foo' is single quoted",
|
||||
"arg \"bar\" is double quoted",
|
||||
"arg \"foo bar\" has embedded whitespace",
|
||||
"arg 'Jack said \\'hi\\'' has single quotes",
|
||||
"arg 'Jack said \\\"hi\\\"' has double quotes",
|
||||
"a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9",
|
||||
|
||||
/* This should be expanded into only one argument. */
|
||||
"trailing-whitespace ",
|
||||
|
||||
"",
|
||||
NULL
|
||||
};
|
||||
|
||||
main ()
|
||||
{
|
||||
char **argv;
|
||||
char **test;
|
||||
char **targs;
|
||||
|
||||
for (test = tests; *test != NULL; test++)
|
||||
{
|
||||
printf ("buildargv(\"%s\")\n", *test);
|
||||
if ((argv = buildargv (*test)) == NULL)
|
||||
{
|
||||
printf ("failed!\n\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (targs = argv; *targs != NULL; targs++)
|
||||
{
|
||||
printf ("\t\"%s\"\n", *targs);
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
freeargv (argv);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* MAIN */
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/* Like sprintf but provides a pointer to malloc'd storage, which must
|
||||
be freed by the caller.
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
Contributed by Cygnus Solutions.
|
||||
|
||||
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. */
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#if defined (ANSI_PROTOTYPES) || defined (ALMOST_STDC)
|
||||
#define USE_STDARG
|
||||
#endif
|
||||
|
||||
#ifdef USE_STDARG
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
/* VARARGS */
|
||||
#ifdef USE_STDARG
|
||||
int
|
||||
asprintf (char **buf, const char *fmt, ...)
|
||||
#else
|
||||
int
|
||||
asprintf (buf, fmt, va_alist)
|
||||
char **buf;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
int status;
|
||||
va_list ap;
|
||||
#ifdef USE_STDARG
|
||||
va_start (ap, fmt);
|
||||
#else
|
||||
va_start (ap);
|
||||
#endif
|
||||
status = vasprintf (buf, fmt, ap);
|
||||
va_end (ap);
|
||||
return status;
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/* Wrapper to implement ANSI C's atexit using SunOS's on_exit. */
|
||||
/* This function is in the public domain. --Mike Stump. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_ON_EXIT
|
||||
|
||||
int
|
||||
atexit(f)
|
||||
void (*f)();
|
||||
{
|
||||
/* If the system doesn't provide a definition for atexit, use on_exit
|
||||
if the system provides that. */
|
||||
on_exit (f, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/* Return the basename of a pathname.
|
||||
This file is in the public domain. */
|
||||
|
||||
/*
|
||||
NAME
|
||||
basename -- return pointer to last component of a pathname
|
||||
|
||||
SYNOPSIS
|
||||
char *basename (const char *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).
|
||||
|
||||
BUGS
|
||||
Presumes a UNIX style path with UNIX style separators.
|
||||
*/
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
char *
|
||||
basename (name)
|
||||
const char *name;
|
||||
{
|
||||
const char *base = name;
|
||||
|
||||
while (*name)
|
||||
{
|
||||
if (*name++ == '/')
|
||||
{
|
||||
base = name;
|
||||
}
|
||||
}
|
||||
return (char *) base;
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/* bcmp
|
||||
This function is in the public domain. */
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
bcmp -- compare two memory regions
|
||||
|
||||
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
|
||||
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
bcmp (from, to, count)
|
||||
char *from, *to;
|
||||
int count;
|
||||
{
|
||||
int rtnval = 0;
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
if (*from++ != *to++)
|
||||
{
|
||||
rtnval = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (rtnval);
|
||||
}
|
||||
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
/* bcopy -- copy memory regions of arbitary length
|
||||
|
||||
NAME
|
||||
bcopy -- copy memory regions of arbitrary length
|
||||
|
||||
SYNOPSIS
|
||||
void bcopy (char *in, char *out, int length)
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
void
|
||||
bcopy (src, dest, len)
|
||||
register char *src, *dest;
|
||||
int len;
|
||||
{
|
||||
if (dest < src)
|
||||
while (len--)
|
||||
*dest++ = *src++;
|
||||
else
|
||||
{
|
||||
char *lasts = src + (len-1);
|
||||
char *lastd = dest + (len-1);
|
||||
while (len--)
|
||||
*(char *)lastd-- = *(char *)lasts--;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
/* Portable version of bzero for systems without it.
|
||||
This function is in the public domain. */
|
||||
|
||||
/*
|
||||
NAME
|
||||
bzero -- zero the contents of a specified memory region
|
||||
|
||||
SYNOPSIS
|
||||
void bzero (char *to, int count)
|
||||
|
||||
DESCRIPTION
|
||||
Zero COUNT bytes of memory pointed to by TO.
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
void
|
||||
bzero (to, count)
|
||||
char *to;
|
||||
int count;
|
||||
{
|
||||
while (count-- > 0)
|
||||
{
|
||||
*to++ = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#define size_t unsigned long
|
||||
#endif
|
||||
|
||||
/* For systems with larger pointers than ints, this must be declared. */
|
||||
PTR malloc PARAMS ((size_t));
|
||||
|
||||
PTR
|
||||
calloc (nelem, elsize)
|
||||
size_t nelem, elsize;
|
||||
{
|
||||
register PTR ptr;
|
||||
|
||||
if (nelem == 0 || elsize == 0)
|
||||
nelem = elsize = 1;
|
||||
|
||||
ptr = malloc (nelem * elsize);
|
||||
if (ptr) bzero (ptr, nelem * elsize);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/* ANSI-compatible clock function.
|
||||
Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the libiberty library. This library is free
|
||||
software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU CC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
As a special exception, if you link this library with files
|
||||
compiled with a GNU compiler to produce an executable, this does not cause
|
||||
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. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIMES
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#include <sys/times.h>
|
||||
#endif
|
||||
|
||||
/* FIXME: should be able to declare as clock_t. */
|
||||
|
||||
long
|
||||
clock ()
|
||||
{
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
struct rusage rusage;
|
||||
|
||||
getrusage (0, &rusage);
|
||||
return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
|
||||
+ rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
|
||||
#else
|
||||
#ifdef HAVE_TIMES
|
||||
struct tms tms;
|
||||
|
||||
times (&tms);
|
||||
return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
|
||||
#else
|
||||
#ifdef VMS
|
||||
struct
|
||||
{
|
||||
int proc_user_time;
|
||||
int proc_system_time;
|
||||
int child_user_time;
|
||||
int child_system_time;
|
||||
} vms_times;
|
||||
|
||||
times (&vms_times);
|
||||
return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
|
||||
#else
|
||||
/* A fallback, if nothing else available. */
|
||||
return 0;
|
||||
#endif /* VMS */
|
||||
#endif /* HAVE_TIMES */
|
||||
#endif /* HAVE_GETRUSAGE */
|
||||
}
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#ifndef NEED_strerror
|
||||
#define NEED_strerror
|
||||
#endif
|
||||
#ifndef NEED_basename
|
||||
#define NEED_basename
|
||||
#endif
|
||||
#ifndef NEED_psignal
|
||||
#define NEED_psignal
|
||||
#endif
|
||||
#ifndef NEED_on_exit
|
||||
#define NEED_on_exit
|
||||
#endif
|
||||
|
||||
|
|
@ -1,203 +0,0 @@
|
|||
/* config.in. Generated automatically from configure.in by autoheader. */
|
||||
|
||||
/* Define if using alloca.c. */
|
||||
#undef C_ALLOCA
|
||||
|
||||
/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
|
||||
This function is required for alloca.c support on those systems. */
|
||||
#undef CRAY_STACKSEG_END
|
||||
|
||||
/* Define if you have alloca, as a function or macro. */
|
||||
#undef HAVE_ALLOCA
|
||||
|
||||
/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define if you have <vfork.h>. */
|
||||
#undef HAVE_VFORK_H
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef pid_t
|
||||
|
||||
/* Define if you need to in order for stat and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at run-time.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown
|
||||
*/
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define vfork as fork if vfork does not work. */
|
||||
#undef vfork
|
||||
|
||||
/* Define if you have the sys_errlist variable. */
|
||||
#undef HAVE_SYS_ERRLIST
|
||||
|
||||
/* Define if you have the sys_nerr variable. */
|
||||
#undef HAVE_SYS_NERR
|
||||
|
||||
/* Define if you have the sys_siglist variable. */
|
||||
#undef HAVE_SYS_SIGLIST
|
||||
|
||||
/* Define if you have the strerror function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define if you have the asprintf function. */
|
||||
#undef HAVE_ASPRINTF
|
||||
|
||||
/* Define if you have the atexit function. */
|
||||
#undef HAVE_ATEXIT
|
||||
|
||||
/* Define if you have the basename function. */
|
||||
#undef HAVE_BASENAME
|
||||
|
||||
/* Define if you have the bcmp function. */
|
||||
#undef HAVE_BCMP
|
||||
|
||||
/* Define if you have the bcopy function. */
|
||||
#undef HAVE_BCOPY
|
||||
|
||||
/* Define if you have the bzero function. */
|
||||
#undef HAVE_BZERO
|
||||
|
||||
/* Define if you have the calloc function. */
|
||||
#undef HAVE_CALLOC
|
||||
|
||||
/* Define if you have the clock function. */
|
||||
#undef HAVE_CLOCK
|
||||
|
||||
/* Define if you have the getcwd function. */
|
||||
#undef HAVE_GETCWD
|
||||
|
||||
/* Define if you have the getpagesize function. */
|
||||
#undef HAVE_GETPAGESIZE
|
||||
|
||||
/* Define if you have the getrusage function. */
|
||||
#undef HAVE_GETRUSAGE
|
||||
|
||||
/* Define if you have the index function. */
|
||||
#undef HAVE_INDEX
|
||||
|
||||
/* Define if you have the insque function. */
|
||||
#undef HAVE_INSQUE
|
||||
|
||||
/* Define if you have the memchr function. */
|
||||
#undef HAVE_MEMCHR
|
||||
|
||||
/* Define if you have the memcmp function. */
|
||||
#undef HAVE_MEMCMP
|
||||
|
||||
/* Define if you have the memcpy function. */
|
||||
#undef HAVE_MEMCPY
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define if you have the memset function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define if you have the on_exit function. */
|
||||
#undef HAVE_ON_EXIT
|
||||
|
||||
/* Define if you have the psignal function. */
|
||||
#undef HAVE_PSIGNAL
|
||||
|
||||
/* Define if you have the random function. */
|
||||
#undef HAVE_RANDOM
|
||||
|
||||
/* Define if you have the rename function. */
|
||||
#undef HAVE_RENAME
|
||||
|
||||
/* Define if you have the rindex function. */
|
||||
#undef HAVE_RINDEX
|
||||
|
||||
/* Define if you have the sigsetmask function. */
|
||||
#undef HAVE_SIGSETMASK
|
||||
|
||||
/* Define if you have the strcasecmp function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define if you have the strchr function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* Define if you have the strdup function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define if you have the strerror function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define if you have the strncasecmp function. */
|
||||
#undef HAVE_STRNCASECMP
|
||||
|
||||
/* Define if you have the strrchr function. */
|
||||
#undef HAVE_STRRCHR
|
||||
|
||||
/* Define if you have the strsignal function. */
|
||||
#undef HAVE_STRSIGNAL
|
||||
|
||||
/* Define if you have the strstr function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
/* Define if you have the strtod function. */
|
||||
#undef HAVE_STRTOD
|
||||
|
||||
/* Define if you have the strtol function. */
|
||||
#undef HAVE_STRTOL
|
||||
|
||||
/* Define if you have the strtoul function. */
|
||||
#undef HAVE_STRTOUL
|
||||
|
||||
/* Define if you have the sysconf function. */
|
||||
#undef HAVE_SYSCONF
|
||||
|
||||
/* Define if you have the times function. */
|
||||
#undef HAVE_TIMES
|
||||
|
||||
/* Define if you have the tmpnam function. */
|
||||
#undef HAVE_TMPNAM
|
||||
|
||||
/* Define if you have the vasprintf function. */
|
||||
#undef HAVE_VASPRINTF
|
||||
|
||||
/* Define if you have the vfprintf function. */
|
||||
#undef HAVE_VFPRINTF
|
||||
|
||||
/* Define if you have the vprintf function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define if you have the vsprintf function. */
|
||||
#undef HAVE_VSPRINTF
|
||||
|
||||
/* Define if you have the waitpid function. */
|
||||
#undef HAVE_WAITPID
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define if you have the <sys/file.h> header file. */
|
||||
#undef HAVE_SYS_FILE_H
|
||||
|
||||
/* Define if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
case "${host}" in
|
||||
rs6000-ibm-aix3.1 | rs6000-ibm-aix)
|
||||
frag=mh-aix ;;
|
||||
*-*-cxux7*) frag=mh-cxux7 ;;
|
||||
*-*-freebsd2.1.*) frag=mh-fbsd21 ;;
|
||||
*-*-freebsd2.2.[012]) frag=mh-fbsd21 ;;
|
||||
i[345]86-*-windows*) frag=mh-windows ;;
|
||||
esac
|
||||
|
||||
frags=$frag
|
||||
|
||||
# If they didn't specify --enable-shared, don't generate shared libs.
|
||||
case "${enable_shared}" in
|
||||
yes) shared=yes ;;
|
||||
no) shared=no ;;
|
||||
"") shared=no ;;
|
||||
*) shared=yes ;;
|
||||
esac
|
||||
if [ "${shared}" = "yes" ]; then
|
||||
case "${host}" in
|
||||
*-*-cygwin32*) ;;
|
||||
hppa*-*-*) frags="${frags} ../../config/mh-papic" ;;
|
||||
i[3456]86-*-*) frags="${frags} ../../config/mh-x86pic" ;;
|
||||
*-*-*) frags="${frags} ../../config/mh-${host_cpu}pic" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "# Warning: this fragment is automatically generated" > temp-frag
|
||||
|
||||
for frag in ${frags}; do
|
||||
case ${frag} in
|
||||
../* )
|
||||
if [ ${srcdir} = . ]; then
|
||||
[ -n "${with_target_subdir}" ] && frag=../${frag}
|
||||
[ -n "${with_multisrctop}" ] && frag=${with_multisrctop}${frag}
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
frag=${srcdir}/${xsrcdir}config/$frag
|
||||
if [ -f ${frag} ]; then
|
||||
echo "Appending ${frag} to xhost-mkfrag"
|
||||
echo "# Following fragment copied from ${frag}" >> temp-frag
|
||||
cat ${frag} >> temp-frag
|
||||
fi
|
||||
done
|
||||
|
||||
# record if we want to build shared libs.
|
||||
if [ "${shared}" = "yes" ]; then
|
||||
echo enable_shared = yes >> temp-frag
|
||||
else
|
||||
echo enable_shared = no >> temp-frag
|
||||
fi
|
||||
|
||||
frag=xhost-mkfrag
|
||||
${CONFIG_SHELL} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# This file is only needed by AIX 3.1.
|
||||
HDEFINES = -D__IEEE_BIG_ENDIAN
|
||||
|
||||
# Most releases of AIX 3.1 include an incorrect internal version of copysign
|
||||
# in libc.a for use by some libc public functions including modf. The public
|
||||
# version of copysign in libm.a is usable. For the sake of libg++ (which
|
||||
# uses modf), we add copysign here. Supposedly, this problem is fixed in AIX
|
||||
# 3.1.8 and above, including all releases of AIX 3.2.
|
||||
EXTRA_OFILES = copysign.o
|
||||
|
|
@ -1 +0,0 @@
|
|||
HDEFINES = -DHARRIS_FLOAT_FORMAT
|
||||
|
|
@ -1 +0,0 @@
|
|||
EXTRA_OFILES=vasprintf.o
|
||||
|
|
@ -1 +0,0 @@
|
|||
EXTRA_OFILES=asprintf.o strcasecmp.o strncasecmp.o vasprintf.o
|
||||
2799
libiberty/configure
vendored
2799
libiberty/configure
vendored
File diff suppressed because it is too large
Load Diff
|
|
@ -1,14 +0,0 @@
|
|||
@echo off
|
||||
if "%1" == "h8/300" goto h8300
|
||||
|
||||
echo Configuring libiberty for go32
|
||||
copy Makefile.dos Makefile
|
||||
echo #define NEED_sys_siglist 1 >> config.h
|
||||
echo #define NEED_psignal 1 >> config.h
|
||||
goto exit
|
||||
|
||||
:h8300
|
||||
echo Configuring libiberty for H8/300
|
||||
copy Makefile.dos Makefile
|
||||
|
||||
:exit
|
||||
|
|
@ -1,333 +0,0 @@
|
|||
dnl Process this file with autoconf to produce a configure script
|
||||
|
||||
AC_PREREQ(2.12.1)
|
||||
AC_INIT(pexecute.c)
|
||||
|
||||
dnl We use these options to decide which functions to include.
|
||||
AC_ARG_WITH(target-subdir,
|
||||
[ --with-target-subdir=SUBDIR Configuring in a subdirectory])
|
||||
AC_ARG_WITH(cross-host,
|
||||
[ --with-cross-host=HOST Configuring with a cross compiler])
|
||||
AC_ARG_WITH(newlib,
|
||||
[ --with-newlib Configuring with newlib])
|
||||
|
||||
if test "${srcdir}" = "."; then
|
||||
if test -z "${with_target_subdir}"; then
|
||||
libiberty_topdir="${srcdir}/.."
|
||||
else
|
||||
if test "${with_target_subdir}" != "."; then
|
||||
libiberty_topdir="${srcdir}/${with_multisrctop}../.."
|
||||
else
|
||||
libiberty_topdir="${srcdir}/${with_multisrctop}.."
|
||||
fi
|
||||
fi
|
||||
else
|
||||
libiberty_topdir="${srcdir}/.."
|
||||
fi
|
||||
AC_CONFIG_AUX_DIR($libiberty_topdir)
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
dnl When we start using automake:
|
||||
dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
|
||||
|
||||
dnl These must be called before AM_PROG_LIBTOOL, because it may want
|
||||
dnl to call AC_CHECK_PROG.
|
||||
AC_CHECK_TOOL(AR, ar)
|
||||
AC_CHECK_TOOL(RANLIB, ranlib, :)
|
||||
|
||||
# FIXME: We temporarily define our own version of AC_PROG_CC. This is
|
||||
# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
|
||||
# are probably using a cross compiler, which will not be able to fully
|
||||
# link an executable. This should really be fixed in autoconf
|
||||
# itself.
|
||||
|
||||
AC_DEFUN(LIB_AC_PROG_CC,
|
||||
[AC_BEFORE([$0], [AC_PROG_CPP])dnl
|
||||
AC_PROVIDE([AC_PROG_CC])
|
||||
AC_CHECK_PROG(CC, gcc, gcc)
|
||||
if test -z "$CC"; then
|
||||
AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
|
||||
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
|
||||
fi
|
||||
|
||||
AC_PROG_CC_GNU
|
||||
|
||||
if test $ac_cv_prog_gcc = yes; then
|
||||
GCC=yes
|
||||
dnl Check whether -g works, even if CFLAGS is set, in case the package
|
||||
dnl plays around with CFLAGS (such as to build both debugging and
|
||||
dnl normal versions of a library), tasteless as that idea is.
|
||||
ac_test_CFLAGS="${CFLAGS+set}"
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS=
|
||||
AC_PROG_CC_G
|
||||
if test "$ac_test_CFLAGS" = set; then
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
elif test $ac_cv_prog_cc_g = yes; then
|
||||
CFLAGS="-g -O2"
|
||||
else
|
||||
CFLAGS="-O2"
|
||||
fi
|
||||
else
|
||||
GCC=
|
||||
test "${CFLAGS+set}" = set || CFLAGS="-g"
|
||||
fi
|
||||
])
|
||||
|
||||
LIB_AC_PROG_CC
|
||||
|
||||
AC_ISC_POSIX
|
||||
|
||||
dnl When we start using libtool:
|
||||
dnl Default to a non shared library. This may be overridden by the
|
||||
dnl configure option --enable-shared.
|
||||
dnl AM_DISABLE_SHARED
|
||||
|
||||
dnl When we start using libtool:
|
||||
dnl AM_PROG_LIBTOOL
|
||||
|
||||
dnl When we start using automake:
|
||||
dnl AM_CONFIG_HEADER(config.h:config.in)
|
||||
AC_CONFIG_HEADER(config.h:config.in)
|
||||
|
||||
dnl When we start using automake:
|
||||
dnl AM_MAINTAINER_MODE
|
||||
dnl AC_EXEEXT
|
||||
|
||||
dnl When we start using automake:
|
||||
dnl AM_PROG_INSTALL
|
||||
AC_PROG_INSTALL
|
||||
|
||||
. ${srcdir}/config.table
|
||||
host_makefile_frag=${frag}
|
||||
AC_SUBST_FILE(host_makefile_frag)
|
||||
|
||||
# It's OK to check for header files. Although the compiler may not be
|
||||
# able to link anything, it had better be able to at least compile
|
||||
# something.
|
||||
AC_CHECK_HEADERS(sys/file.h sys/param.h stdlib.h string.h unistd.h strings.h sys/time.h)
|
||||
AC_HEADER_SYS_WAIT
|
||||
|
||||
# This is the list of functions which libiberty will provide if they
|
||||
# are not available on the host.
|
||||
|
||||
funcs="asprintf"
|
||||
funcs="$funcs atexit"
|
||||
funcs="$funcs basename"
|
||||
funcs="$funcs bcmp"
|
||||
funcs="$funcs bcopy"
|
||||
funcs="$funcs bzero"
|
||||
funcs="$funcs calloc"
|
||||
funcs="$funcs clock"
|
||||
funcs="$funcs getcwd"
|
||||
funcs="$funcs getpagesize"
|
||||
funcs="$funcs index"
|
||||
funcs="$funcs insque"
|
||||
funcs="$funcs memchr"
|
||||
funcs="$funcs memcmp"
|
||||
funcs="$funcs memcpy"
|
||||
funcs="$funcs memmove"
|
||||
funcs="$funcs memset"
|
||||
funcs="$funcs random"
|
||||
funcs="$funcs rename"
|
||||
funcs="$funcs rindex"
|
||||
funcs="$funcs sigsetmask"
|
||||
funcs="$funcs strcasecmp"
|
||||
funcs="$funcs strchr"
|
||||
funcs="$funcs strdup"
|
||||
funcs="$funcs strncasecmp"
|
||||
funcs="$funcs strrchr"
|
||||
funcs="$funcs strstr"
|
||||
funcs="$funcs strtod"
|
||||
funcs="$funcs strtol"
|
||||
funcs="$funcs strtoul"
|
||||
funcs="$funcs tmpnam"
|
||||
funcs="$funcs vasprintf"
|
||||
funcs="$funcs vfprintf"
|
||||
funcs="$funcs vprintf"
|
||||
funcs="$funcs vsprintf"
|
||||
funcs="$funcs waitpid"
|
||||
|
||||
# Also in the old function.def file: alloca, vfork, getopt.
|
||||
|
||||
vars="sys_errlist sys_nerr sys_siglist"
|
||||
|
||||
checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times"
|
||||
|
||||
# These are neither executed nor required, but they help keep
|
||||
# autoheader happy without adding a bunch of text to acconfig.h.
|
||||
if test "x" = "y"; then
|
||||
AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bzero calloc clock getcwd)
|
||||
AC_CHECK_FUNCS(getpagesize index insque memchr memcmp memcpy memmove)
|
||||
AC_CHECK_FUNCS(memset random rename rindex sigsetmask strcasecmp)
|
||||
AC_CHECK_FUNCS(strchr strdup strncasecmp strrchr strstr strtod strtol)
|
||||
AC_CHECK_FUNCS(strtoul tmpnam vasprintf vfprintf vprintf vsprintf waitpid)
|
||||
AC_DEFINE(HAVE_SYS_ERRLIST)
|
||||
AC_DEFINE(HAVE_SYS_NERR)
|
||||
AC_DEFINE(HAVE_SYS_SIGLIST)
|
||||
AC_CHECK_FUNCS(getrusage on_exit psignal strerror strsignal sysconf times)
|
||||
fi
|
||||
|
||||
# For each of these functions, if the host does not provide the
|
||||
# function we want to put FN.o in LIBOBJS, and if the host does
|
||||
# provide the function, we want to define HAVE_FN in config.h. Also,
|
||||
# if the host does not provide alloca, we set ALLOCA to alloca.o
|
||||
|
||||
setobjs=
|
||||
if test -n "${with_target_subdir}"; then
|
||||
|
||||
# We are being configured as a target library. AC_REPLACE_FUNCS
|
||||
# may not work correctly, because the compiler may not be able to
|
||||
# link executables. Note that we may still be being configured
|
||||
# native.
|
||||
|
||||
# If we are being configured for newlib, we know which functions
|
||||
# newlib provide and which ones we will be expected to provide.
|
||||
|
||||
if test "x${with_newlib}" = "xyes"; then
|
||||
ALLOCA="alloca.o"
|
||||
LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
|
||||
|
||||
for f in $funcs; do
|
||||
case "$f" in
|
||||
asprintf | basename | insque | random | strdup | vasprintf)
|
||||
;;
|
||||
*)
|
||||
n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
|
||||
AC_DEFINE_UNQUOTED($n)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# newlib doesnt provide any of the variables in $vars, so we
|
||||
# dont have to check them here.
|
||||
|
||||
# Of the functions in $checkfuncs, newlib only has strerror.
|
||||
AC_DEFINE(HAVE_STRERROR)
|
||||
|
||||
setobjs=yes
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "${setobjs}"; then
|
||||
case "${host}" in
|
||||
|
||||
*-*-vxworks*)
|
||||
# Handle VxWorks configuration specially, since on VxWorks the
|
||||
# libraries are actually on the target board, not in the file
|
||||
# system.
|
||||
LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
|
||||
LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
|
||||
for f in $funcs; do
|
||||
case "$f" in
|
||||
basename | getpagesize | insque | random | strcasecmp)
|
||||
;;
|
||||
strncasecmp | strdup | vfork | waitpid | vasprintf)
|
||||
;;
|
||||
*)
|
||||
n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
|
||||
AC_DEFINE_UNQUOTED($n)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# VxWorks doesn't provide any of the variables in $vars, so we
|
||||
# don't have to check them here.
|
||||
|
||||
# Of the functions in $checkfuncs, VxWorks only has strerror.
|
||||
AC_DEFINE(HAVE_STRERROR)
|
||||
|
||||
setobjs=yes
|
||||
;;
|
||||
|
||||
esac
|
||||
fi
|
||||
|
||||
if test -z "${setobjs}"; then
|
||||
|
||||
case "${host}" in
|
||||
|
||||
*-*-cygwin*)
|
||||
# The Cygwin library actually uses a couple of files from
|
||||
# libiberty when it is built. If we are building a native
|
||||
# Cygwin, and we run the tests, we will appear to have these
|
||||
# files. However, when we go on to build winsup, we will wind up
|
||||
# with a library which does not have the files, since they should
|
||||
# have come from libiberty.
|
||||
|
||||
# We handle this by removing the functions the winsup library
|
||||
# provides from our shell variables, so that they appear to be
|
||||
# missing.
|
||||
|
||||
funcs="`echo $funcs | sed -e 's/random//'`"
|
||||
LIBOBJS="$LIBOBJS random.o"
|
||||
vars="`echo $vars | sed -e 's/sys_siglist//'`"
|
||||
checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
|
||||
;;
|
||||
|
||||
*-*-mingw32*)
|
||||
# Under mingw32, sys_nerr and sys_errlist exist, but they are
|
||||
# macros, so the test below won't find them.
|
||||
vars="`echo $vars | sed -e 's/sys_nerr//' -e 's/sys_errlist//'`"
|
||||
AC_DEFINE(HAVE_SYS_NERR)
|
||||
AC_DEFINE(HAVE_SYS_ERRLIST)
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# We haven't set the list of objects yet. Use the standard autoconf
|
||||
# tests. This will only work if the compiler works.
|
||||
AC_PROG_CC_WORKS
|
||||
AC_REPLACE_FUNCS($funcs)
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_VFORK
|
||||
if test $ac_cv_func_vfork_works = no; then
|
||||
LIBOBJS="$LIBOBJS vfork.o"
|
||||
fi
|
||||
for v in $vars; do
|
||||
AC_MSG_CHECKING([for $v])
|
||||
AC_CACHE_VAL(libiberty_cv_var_$v,
|
||||
[AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
|
||||
[eval "libiberty_cv_var_$v=yes"],
|
||||
[eval "libiberty_cv_var_$v=no"])])
|
||||
if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
|
||||
AC_DEFINE_UNQUOTED($n)
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
fi
|
||||
done
|
||||
AC_CHECK_FUNCS($checkfuncs)
|
||||
fi
|
||||
|
||||
# Install a library built with a cross compiler in $(tooldir) rather
|
||||
# than $(libdir).
|
||||
if test -z "${with_cross_host}"; then
|
||||
INSTALL_DEST=libdir
|
||||
else
|
||||
INSTALL_DEST=tooldir
|
||||
fi
|
||||
AC_SUBST(INSTALL_DEST)
|
||||
|
||||
# We need multilib support, but only if configuring for the target.
|
||||
AC_OUTPUT(Makefile,
|
||||
[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
|
||||
if test -n "$CONFIG_FILES"; then
|
||||
if test -n "${with_target_subdir}"; then
|
||||
# FIXME: We shouldn't need to set ac_file
|
||||
ac_file=Makefile
|
||||
. ${libiberty_topdir}/config-ml.in
|
||||
fi
|
||||
fi],
|
||||
srcdir=${srcdir}
|
||||
host=${host}
|
||||
target=${target}
|
||||
with_target_subdir=${with_target_subdir}
|
||||
with_multisubdir=${with_multisubdir}
|
||||
ac_configure_args="--enable-multilib ${ac_configure_args}"
|
||||
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
|
||||
libiberty_topdir=${libiberty_topdir}
|
||||
)
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
#include <ansidecl.h>
|
||||
|
||||
#ifdef __IEEE_BIG_ENDIAN
|
||||
|
||||
typedef union
|
||||
{
|
||||
double value;
|
||||
struct
|
||||
{
|
||||
unsigned int sign : 1;
|
||||
unsigned int exponent: 11;
|
||||
unsigned int fraction0:4;
|
||||
unsigned int fraction1:16;
|
||||
unsigned int fraction2:16;
|
||||
unsigned int fraction3:16;
|
||||
|
||||
} number;
|
||||
struct
|
||||
{
|
||||
unsigned int sign : 1;
|
||||
unsigned int exponent: 11;
|
||||
unsigned int quiet:1;
|
||||
unsigned int function0:3;
|
||||
unsigned int function1:16;
|
||||
unsigned int function2:16;
|
||||
unsigned int function3:16;
|
||||
} nan;
|
||||
struct
|
||||
{
|
||||
unsigned long msw;
|
||||
unsigned long lsw;
|
||||
} parts;
|
||||
long aslong[2];
|
||||
} __ieee_double_shape_type;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __IEEE_LITTLE_ENDIAN
|
||||
|
||||
typedef union
|
||||
{
|
||||
double value;
|
||||
struct
|
||||
{
|
||||
#ifdef __SMALL_BITFIELDS
|
||||
unsigned int fraction3:16;
|
||||
unsigned int fraction2:16;
|
||||
unsigned int fraction1:16;
|
||||
unsigned int fraction0: 4;
|
||||
#else
|
||||
unsigned int fraction1:32;
|
||||
unsigned int fraction0:20;
|
||||
#endif
|
||||
unsigned int exponent :11;
|
||||
unsigned int sign : 1;
|
||||
} number;
|
||||
struct
|
||||
{
|
||||
#ifdef __SMALL_BITFIELDS
|
||||
unsigned int function3:16;
|
||||
unsigned int function2:16;
|
||||
unsigned int function1:16;
|
||||
unsigned int function0:3;
|
||||
#else
|
||||
unsigned int function1:32;
|
||||
unsigned int function0:19;
|
||||
#endif
|
||||
unsigned int quiet:1;
|
||||
unsigned int exponent: 11;
|
||||
unsigned int sign : 1;
|
||||
} nan;
|
||||
struct
|
||||
{
|
||||
unsigned long lsw;
|
||||
unsigned long msw;
|
||||
} parts;
|
||||
|
||||
long aslong[2];
|
||||
|
||||
} __ieee_double_shape_type;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __IEEE_BIG_ENDIAN
|
||||
typedef union
|
||||
{
|
||||
float value;
|
||||
struct
|
||||
{
|
||||
unsigned int sign : 1;
|
||||
unsigned int exponent: 8;
|
||||
unsigned int fraction0: 7;
|
||||
unsigned int fraction1: 16;
|
||||
} number;
|
||||
struct
|
||||
{
|
||||
unsigned int sign:1;
|
||||
unsigned int exponent:8;
|
||||
unsigned int quiet:1;
|
||||
unsigned int function0:6;
|
||||
unsigned int function1:16;
|
||||
} nan;
|
||||
long p1;
|
||||
|
||||
} __ieee_float_shape_type;
|
||||
#endif
|
||||
|
||||
#ifdef __IEEE_LITTLE_ENDIAN
|
||||
typedef union
|
||||
{
|
||||
float value;
|
||||
struct
|
||||
{
|
||||
unsigned int fraction0: 7;
|
||||
unsigned int fraction1: 16;
|
||||
unsigned int exponent: 8;
|
||||
unsigned int sign : 1;
|
||||
} number;
|
||||
struct
|
||||
{
|
||||
unsigned int function1:16;
|
||||
unsigned int function0:6;
|
||||
unsigned int quiet:1;
|
||||
unsigned int exponent:8;
|
||||
unsigned int sign:1;
|
||||
} nan;
|
||||
long p1;
|
||||
|
||||
} __ieee_float_shape_type;
|
||||
#endif
|
||||
|
||||
|
||||
double DEFUN(copysign, (x, y), double x AND double y)
|
||||
{
|
||||
__ieee_double_shape_type a,b;
|
||||
b.value = y;
|
||||
a.value = x;
|
||||
a.number.sign =b.number.sign;
|
||||
return a.value;
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
/* Compare two open file descriptors to see if they refer to the same file.
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
fdmatch -- see if two file descriptors refer to same file
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
int fdmatch (int fd1, int fd2)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Check to see if two open file descriptors refer to the same file.
|
||||
This is useful, for example, when we have an open file descriptor
|
||||
for an unnamed file, and the name of a file that we believe to
|
||||
correspond to that fd. This can happen when we are exec'd with
|
||||
an already open file (stdout for example) or from the SVR4 /proc
|
||||
calls that return open file descriptors for mapped address spaces.
|
||||
All we have to do is open the file by name and check the two file
|
||||
descriptors for a match, which is done by comparing major&minor
|
||||
device numbers and inode numbers.
|
||||
|
||||
BUGS
|
||||
|
||||
(FIXME: does this work for networks?)
|
||||
It works for NFS, which assigns a device number to each mount.
|
||||
|
||||
*/
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int fdmatch (fd1, fd2)
|
||||
int fd1;
|
||||
int fd2;
|
||||
{
|
||||
struct stat sbuf1;
|
||||
struct stat sbuf2;
|
||||
|
||||
if ((fstat (fd1, &sbuf1) == 0) &&
|
||||
(fstat (fd2, &sbuf2) == 0) &&
|
||||
(sbuf1.st_dev == sbuf2.st_dev) &&
|
||||
(sbuf1.st_ino == sbuf2.st_ino))
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,403 +0,0 @@
|
|||
/* IEEE floating point support routines, for GDB, the GNU Debugger.
|
||||
Copyright (C) 1991, 1994 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GDB.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "floatformat.h"
|
||||
#include <math.h> /* ldexp */
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
extern void *memcpy (void *s1, const void *s2, size_t n);
|
||||
extern void *memset (void *s, int c, size_t n);
|
||||
#else
|
||||
extern char *memcpy ();
|
||||
extern char *memset ();
|
||||
#endif
|
||||
|
||||
/* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not
|
||||
going to bother with trying to muck around with whether it is defined in
|
||||
a system header, what we do if not, etc. */
|
||||
#define FLOATFORMAT_CHAR_BIT 8
|
||||
|
||||
/* floatformats for IEEE single and double, big and little endian. */
|
||||
const struct floatformat floatformat_ieee_single_big =
|
||||
{
|
||||
floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no
|
||||
};
|
||||
const struct floatformat floatformat_ieee_single_little =
|
||||
{
|
||||
floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no
|
||||
};
|
||||
const struct floatformat floatformat_ieee_double_big =
|
||||
{
|
||||
floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no
|
||||
};
|
||||
const struct floatformat floatformat_ieee_double_little =
|
||||
{
|
||||
floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no
|
||||
};
|
||||
|
||||
/* floatformat for IEEE double, little endian byte order, with big endian word
|
||||
ordering, as on the ARM. */
|
||||
|
||||
const struct floatformat floatformat_ieee_double_littlebyte_bigword =
|
||||
{
|
||||
floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no
|
||||
};
|
||||
|
||||
const struct floatformat floatformat_i387_ext =
|
||||
{
|
||||
floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
|
||||
floatformat_intbit_yes
|
||||
};
|
||||
const struct floatformat floatformat_m68881_ext =
|
||||
{
|
||||
/* Note that the bits from 16 to 31 are unused. */
|
||||
floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64, floatformat_intbit_yes
|
||||
};
|
||||
const struct floatformat floatformat_i960_ext =
|
||||
{
|
||||
/* Note that the bits from 0 to 15 are unused. */
|
||||
floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64,
|
||||
floatformat_intbit_yes
|
||||
};
|
||||
const struct floatformat floatformat_m88110_ext =
|
||||
{
|
||||
#ifdef HARRIS_FLOAT_FORMAT
|
||||
/* Harris uses raw format 128 bytes long, but the number is just an ieee
|
||||
double, and the last 64 bits are wasted. */
|
||||
floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52,
|
||||
floatformat_intbit_no
|
||||
#else
|
||||
floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
|
||||
floatformat_intbit_yes
|
||||
#endif /* HARRIS_FLOAT_FORMAT */
|
||||
};
|
||||
const struct floatformat floatformat_arm_ext =
|
||||
{
|
||||
/* Bits 1 to 16 are unused. */
|
||||
floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
|
||||
floatformat_intbit_yes
|
||||
};
|
||||
|
||||
static unsigned long get_field PARAMS ((unsigned char *,
|
||||
enum floatformat_byteorders,
|
||||
unsigned int,
|
||||
unsigned int,
|
||||
unsigned int));
|
||||
|
||||
/* Extract a field which starts at START and is LEN bytes long. DATA and
|
||||
TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
|
||||
static unsigned long
|
||||
get_field (data, order, total_len, start, len)
|
||||
unsigned char *data;
|
||||
enum floatformat_byteorders order;
|
||||
unsigned int total_len;
|
||||
unsigned int start;
|
||||
unsigned int len;
|
||||
{
|
||||
unsigned long result;
|
||||
unsigned int cur_byte;
|
||||
int cur_bitshift;
|
||||
|
||||
/* Start at the least significant part of the field. */
|
||||
cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT;
|
||||
if (order == floatformat_little)
|
||||
cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1;
|
||||
cur_bitshift =
|
||||
((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT;
|
||||
result = *(data + cur_byte) >> (-cur_bitshift);
|
||||
cur_bitshift += FLOATFORMAT_CHAR_BIT;
|
||||
if (order == floatformat_little)
|
||||
++cur_byte;
|
||||
else
|
||||
--cur_byte;
|
||||
|
||||
/* Move towards the most significant part of the field. */
|
||||
while (cur_bitshift < len)
|
||||
{
|
||||
if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)
|
||||
/* This is the last byte; zero out the bits which are not part of
|
||||
this field. */
|
||||
result |=
|
||||
(*(data + cur_byte) & ((1 << (len - cur_bitshift)) - 1))
|
||||
<< cur_bitshift;
|
||||
else
|
||||
result |= *(data + cur_byte) << cur_bitshift;
|
||||
cur_bitshift += FLOATFORMAT_CHAR_BIT;
|
||||
if (order == floatformat_little)
|
||||
++cur_byte;
|
||||
else
|
||||
--cur_byte;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef min
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/* Convert from FMT to a double.
|
||||
FROM is the address of the extended float.
|
||||
Store the double in *TO. */
|
||||
|
||||
void
|
||||
floatformat_to_double (fmt, from, to)
|
||||
const struct floatformat *fmt;
|
||||
char *from;
|
||||
double *to;
|
||||
{
|
||||
unsigned char *ufrom = (unsigned char *)from;
|
||||
double dto;
|
||||
long exponent;
|
||||
unsigned long mant;
|
||||
unsigned int mant_bits, mant_off;
|
||||
int mant_bits_left;
|
||||
int special_exponent; /* It's a NaN, denorm or zero */
|
||||
|
||||
exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
|
||||
fmt->exp_start, fmt->exp_len);
|
||||
/* Note that if exponent indicates a NaN, we can't really do anything useful
|
||||
(not knowing if the host has NaN's, or how to build one). So it will
|
||||
end up as an infinity or something close; that is OK. */
|
||||
|
||||
mant_bits_left = fmt->man_len;
|
||||
mant_off = fmt->man_start;
|
||||
dto = 0.0;
|
||||
|
||||
special_exponent = exponent == 0 || exponent == fmt->exp_nan;
|
||||
|
||||
/* Don't bias zero's, denorms or NaNs. */
|
||||
if (!special_exponent)
|
||||
exponent -= fmt->exp_bias;
|
||||
|
||||
/* Build the result algebraically. Might go infinite, underflow, etc;
|
||||
who cares. */
|
||||
|
||||
/* If this format uses a hidden bit, explicitly add it in now. Otherwise,
|
||||
increment the exponent by one to account for the integer bit. */
|
||||
|
||||
if (!special_exponent)
|
||||
{
|
||||
if (fmt->intbit == floatformat_intbit_no)
|
||||
dto = ldexp (1.0, exponent);
|
||||
else
|
||||
exponent++;
|
||||
}
|
||||
|
||||
while (mant_bits_left > 0)
|
||||
{
|
||||
mant_bits = min (mant_bits_left, 32);
|
||||
|
||||
mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
|
||||
mant_off, mant_bits);
|
||||
|
||||
dto += ldexp ((double)mant, exponent - mant_bits);
|
||||
exponent -= mant_bits;
|
||||
mant_off += mant_bits;
|
||||
mant_bits_left -= mant_bits;
|
||||
}
|
||||
|
||||
/* Negate it if negative. */
|
||||
if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1))
|
||||
dto = -dto;
|
||||
*to = dto;
|
||||
}
|
||||
|
||||
static void put_field PARAMS ((unsigned char *, enum floatformat_byteorders,
|
||||
unsigned int,
|
||||
unsigned int,
|
||||
unsigned int,
|
||||
unsigned long));
|
||||
|
||||
/* Set a field which starts at START and is LEN bytes long. DATA and
|
||||
TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
|
||||
static void
|
||||
put_field (data, order, total_len, start, len, stuff_to_put)
|
||||
unsigned char *data;
|
||||
enum floatformat_byteorders order;
|
||||
unsigned int total_len;
|
||||
unsigned int start;
|
||||
unsigned int len;
|
||||
unsigned long stuff_to_put;
|
||||
{
|
||||
unsigned int cur_byte;
|
||||
int cur_bitshift;
|
||||
|
||||
/* Start at the least significant part of the field. */
|
||||
cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT;
|
||||
if (order == floatformat_little)
|
||||
cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1;
|
||||
cur_bitshift =
|
||||
((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT;
|
||||
*(data + cur_byte) &=
|
||||
~(((1 << ((start + len) % FLOATFORMAT_CHAR_BIT)) - 1) << (-cur_bitshift));
|
||||
*(data + cur_byte) |=
|
||||
(stuff_to_put & ((1 << FLOATFORMAT_CHAR_BIT) - 1)) << (-cur_bitshift);
|
||||
cur_bitshift += FLOATFORMAT_CHAR_BIT;
|
||||
if (order == floatformat_little)
|
||||
++cur_byte;
|
||||
else
|
||||
--cur_byte;
|
||||
|
||||
/* Move towards the most significant part of the field. */
|
||||
while (cur_bitshift < len)
|
||||
{
|
||||
if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)
|
||||
{
|
||||
/* This is the last byte. */
|
||||
*(data + cur_byte) &=
|
||||
~((1 << (len - cur_bitshift)) - 1);
|
||||
*(data + cur_byte) |= (stuff_to_put >> cur_bitshift);
|
||||
}
|
||||
else
|
||||
*(data + cur_byte) = ((stuff_to_put >> cur_bitshift)
|
||||
& ((1 << FLOATFORMAT_CHAR_BIT) - 1));
|
||||
cur_bitshift += FLOATFORMAT_CHAR_BIT;
|
||||
if (order == floatformat_little)
|
||||
++cur_byte;
|
||||
else
|
||||
--cur_byte;
|
||||
}
|
||||
}
|
||||
|
||||
/* The converse: convert the double *FROM to an extended float
|
||||
and store where TO points. Neither FROM nor TO have any alignment
|
||||
restrictions. */
|
||||
|
||||
void
|
||||
floatformat_from_double (fmt, from, to)
|
||||
const struct floatformat *fmt;
|
||||
double *from;
|
||||
char *to;
|
||||
{
|
||||
double dfrom;
|
||||
int exponent;
|
||||
double mant;
|
||||
unsigned int mant_bits, mant_off;
|
||||
int mant_bits_left;
|
||||
unsigned char *uto = (unsigned char *)to;
|
||||
|
||||
memcpy (&dfrom, from, sizeof (dfrom));
|
||||
memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT);
|
||||
if (dfrom == 0)
|
||||
return; /* Result is zero */
|
||||
if (dfrom != dfrom)
|
||||
{
|
||||
/* From is NaN */
|
||||
put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
|
||||
fmt->exp_len, fmt->exp_nan);
|
||||
/* Be sure it's not infinity, but NaN value is irrel */
|
||||
put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start,
|
||||
32, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If negative, set the sign bit. */
|
||||
if (dfrom < 0)
|
||||
{
|
||||
put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1);
|
||||
dfrom = -dfrom;
|
||||
}
|
||||
|
||||
/* How to tell an infinity from an ordinary number? FIXME-someday */
|
||||
|
||||
mant = frexp (dfrom, &exponent);
|
||||
put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, fmt->exp_len,
|
||||
exponent + fmt->exp_bias - 1);
|
||||
|
||||
mant_bits_left = fmt->man_len;
|
||||
mant_off = fmt->man_start;
|
||||
while (mant_bits_left > 0)
|
||||
{
|
||||
unsigned long mant_long;
|
||||
mant_bits = mant_bits_left < 32 ? mant_bits_left : 32;
|
||||
|
||||
mant *= 4294967296.0;
|
||||
mant_long = (unsigned long)mant;
|
||||
mant -= mant_long;
|
||||
|
||||
/* If the integer bit is implicit, then we need to discard it.
|
||||
If we are discarding a zero, we should be (but are not) creating
|
||||
a denormalized number which means adjusting the exponent
|
||||
(I think). */
|
||||
if (mant_bits_left == fmt->man_len
|
||||
&& fmt->intbit == floatformat_intbit_no)
|
||||
{
|
||||
mant_long &= 0x7fffffff;
|
||||
mant_bits -= 1;
|
||||
}
|
||||
else if (mant_bits < 32)
|
||||
{
|
||||
/* The bits we want are in the most significant MANT_BITS bits of
|
||||
mant_long. Move them to the least significant. */
|
||||
mant_long >>= 32 - mant_bits;
|
||||
}
|
||||
|
||||
put_field (uto, fmt->byteorder, fmt->totalsize,
|
||||
mant_off, mant_bits, mant_long);
|
||||
mant_off += mant_bits;
|
||||
mant_bits_left -= mant_bits;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef IEEE_DEBUG
|
||||
|
||||
/* This is to be run on a host which uses IEEE floating point. */
|
||||
|
||||
void
|
||||
ieee_test (n)
|
||||
double n;
|
||||
{
|
||||
double result;
|
||||
char exten[16];
|
||||
|
||||
floatformat_to_double (&floatformat_ieee_double_big, &n, &result);
|
||||
if (n != result)
|
||||
printf ("Differ(to): %.20g -> %.20g\n", n, result);
|
||||
floatformat_from_double (&floatformat_ieee_double_big, &n, &result);
|
||||
if (n != result)
|
||||
printf ("Differ(from): %.20g -> %.20g\n", n, result);
|
||||
|
||||
floatformat_from_double (&floatformat_m68881_ext, &n, exten);
|
||||
floatformat_to_double (&floatformat_m68881_ext, exten, &result);
|
||||
if (n != result)
|
||||
printf ("Differ(to+from): %.20g -> %.20g\n", n, result);
|
||||
|
||||
#if IEEE_DEBUG > 1
|
||||
/* This is to be run on a host which uses 68881 format. */
|
||||
{
|
||||
long double ex = *(long double *)exten;
|
||||
if (ex != n)
|
||||
printf ("Differ(from vs. extended): %.20g\n", n);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
ieee_test (0.5);
|
||||
ieee_test (256.0);
|
||||
ieee_test (0.12345);
|
||||
ieee_test (234235.78907234);
|
||||
ieee_test (-512.0);
|
||||
ieee_test (-0.004321);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,225 +0,0 @@
|
|||
/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#if defined (CONFIG_BROKETS)
|
||||
/* We use <config.h> instead of "config.h" so that a compilation
|
||||
using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
|
||||
(which it would do because it found this file in $srcdir). */
|
||||
#include <config.h>
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
/* This code to undef const added in libiberty. */
|
||||
#ifndef __STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <fnmatch.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
|
||||
|
||||
|
||||
#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* Match STRING against the filename pattern PATTERN, returning zero if
|
||||
it matches, nonzero if not. */
|
||||
int
|
||||
fnmatch (pattern, string, flags)
|
||||
const char *pattern;
|
||||
const char *string;
|
||||
int flags;
|
||||
{
|
||||
register const char *p = pattern, *n = string;
|
||||
register unsigned char c;
|
||||
|
||||
/* Note that this evalutes C many times. */
|
||||
#define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c))
|
||||
|
||||
while ((c = *p++) != '\0')
|
||||
{
|
||||
c = FOLD (c);
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '?':
|
||||
if (*n == '\0')
|
||||
return FNM_NOMATCH;
|
||||
else if ((flags & FNM_FILE_NAME) && *n == '/')
|
||||
return FNM_NOMATCH;
|
||||
else if ((flags & FNM_PERIOD) && *n == '.' &&
|
||||
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
|
||||
return FNM_NOMATCH;
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
if (!(flags & FNM_NOESCAPE))
|
||||
{
|
||||
c = *p++;
|
||||
c = FOLD (c);
|
||||
}
|
||||
if (FOLD ((unsigned char)*n) != c)
|
||||
return FNM_NOMATCH;
|
||||
break;
|
||||
|
||||
case '*':
|
||||
if ((flags & FNM_PERIOD) && *n == '.' &&
|
||||
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
|
||||
if (((flags & FNM_FILE_NAME) && *n == '/') ||
|
||||
(c == '?' && *n == '\0'))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if (c == '\0')
|
||||
return 0;
|
||||
|
||||
{
|
||||
unsigned char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
|
||||
c1 = FOLD (c1);
|
||||
for (--p; *n != '\0'; ++n)
|
||||
if ((c == '[' || FOLD ((unsigned char)*n) == c1) &&
|
||||
fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
|
||||
return 0;
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
case '[':
|
||||
{
|
||||
/* Nonzero if the sense of the character class is inverted. */
|
||||
register int not;
|
||||
|
||||
if (*n == '\0')
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if ((flags & FNM_PERIOD) && *n == '.' &&
|
||||
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
not = (*p == '!' || *p == '^');
|
||||
if (not)
|
||||
++p;
|
||||
|
||||
c = *p++;
|
||||
for (;;)
|
||||
{
|
||||
register unsigned char cstart = c, cend = c;
|
||||
|
||||
if (!(flags & FNM_NOESCAPE) && c == '\\')
|
||||
cstart = cend = *p++;
|
||||
|
||||
cstart = cend = FOLD (cstart);
|
||||
|
||||
if (c == '\0')
|
||||
/* [ (unterminated) loses. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
c = *p++;
|
||||
c = FOLD (c);
|
||||
|
||||
if ((flags & FNM_FILE_NAME) && c == '/')
|
||||
/* [/] can never match. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
if (c == '-' && *p != ']')
|
||||
{
|
||||
cend = *p++;
|
||||
if (!(flags & FNM_NOESCAPE) && cend == '\\')
|
||||
cend = *p++;
|
||||
if (cend == '\0')
|
||||
return FNM_NOMATCH;
|
||||
cend = FOLD (cend);
|
||||
|
||||
c = *p++;
|
||||
}
|
||||
|
||||
if (FOLD ((unsigned char)*n) >= cstart
|
||||
&& FOLD ((unsigned char)*n) <= cend)
|
||||
goto matched;
|
||||
|
||||
if (c == ']')
|
||||
break;
|
||||
}
|
||||
if (!not)
|
||||
return FNM_NOMATCH;
|
||||
break;
|
||||
|
||||
matched:;
|
||||
/* Skip the rest of the [...] that already matched. */
|
||||
while (c != ']')
|
||||
{
|
||||
if (c == '\0')
|
||||
/* [... (unterminated) loses. */
|
||||
return FNM_NOMATCH;
|
||||
|
||||
c = *p++;
|
||||
if (!(flags & FNM_NOESCAPE) && c == '\\')
|
||||
/* XXX 1003.2d11 is unclear if this is right. */
|
||||
++p;
|
||||
}
|
||||
if (not)
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (c != FOLD ((unsigned char)*n))
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
++n;
|
||||
}
|
||||
|
||||
if (*n == '\0')
|
||||
return 0;
|
||||
|
||||
if ((flags & FNM_LEADING_DIR) && *n == '/')
|
||||
/* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
|
||||
return 0;
|
||||
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
|
||||
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/* Emulate getcwd using getwd.
|
||||
This function is in the public domain. */
|
||||
|
||||
/*
|
||||
NAME
|
||||
getcwd -- get absolute pathname for current working directory
|
||||
|
||||
SYNOPSIS
|
||||
char *getcwd (char pathname[len], 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.
|
||||
|
||||
BUGS
|
||||
Emulated via the getwd() call, which is reasonable for most
|
||||
systems that do not have getcwd().
|
||||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
extern char *getwd ();
|
||||
extern int errno;
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
char *
|
||||
getcwd (buf, len)
|
||||
char *buf;
|
||||
int len;
|
||||
{
|
||||
char ourbuf[MAXPATHLEN];
|
||||
char *result;
|
||||
|
||||
result = getwd (ourbuf);
|
||||
if (result) {
|
||||
if (strlen (ourbuf) >= len) {
|
||||
errno = ERANGE;
|
||||
return 0;
|
||||
}
|
||||
strcpy (buf, ourbuf);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
1049
libiberty/getopt.c
1049
libiberty/getopt.c
File diff suppressed because it is too large
Load Diff
|
|
@ -1,190 +0,0 @@
|
|||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#if !defined __STDC__ || !__STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#define GETOPT_INTERFACE_VERSION 2
|
||||
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
|
||||
#include <gnu-versions.h>
|
||||
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
|
||||
#define ELIDE_CODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
If an option that starts with '-' (not '--') doesn't match a long option,
|
||||
but does match a short option, it is parsed as a short option
|
||||
instead. */
|
||||
|
||||
int
|
||||
getopt_long_only (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
||||
}
|
||||
|
||||
|
||||
#endif /* Not ELIDE_CODE. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/* Emulation of getpagesize() for systems that need it. */
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
getpagesize -- return the number of bytes in page of memory
|
||||
|
||||
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.
|
||||
|
||||
BUGS
|
||||
|
||||
Is intended as a reasonable replacement for systems where this
|
||||
is not provided as a system call. The value of 4096 may or may
|
||||
not be correct for the systems where it is returned as the default
|
||||
value.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef VMS
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#undef GNU_OUR_PAGESIZE
|
||||
#if defined (HAVE_SYSCONF) && defined (HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#ifdef _SC_PAGESIZE
|
||||
#define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GNU_OUR_PAGESIZE
|
||||
# ifdef PAGESIZE
|
||||
# define GNU_OUR_PAGESIZE PAGESIZE
|
||||
# else /* no PAGESIZE */
|
||||
# ifdef EXEC_PAGESIZE
|
||||
# define GNU_OUR_PAGESIZE EXEC_PAGESIZE
|
||||
# else /* no EXEC_PAGESIZE */
|
||||
# ifdef NBPG
|
||||
# define GNU_OUR_PAGESIZE (NBPG * CLSIZE)
|
||||
# ifndef CLSIZE
|
||||
# define CLSIZE 1
|
||||
# endif /* CLSIZE */
|
||||
# else /* no NBPG */
|
||||
# ifdef NBPC
|
||||
# define GNU_OUR_PAGESIZE NBPC
|
||||
# else /* no NBPC */
|
||||
# define GNU_OUR_PAGESIZE 4096 /* Just punt and use reasonable value */
|
||||
# endif /* NBPC */
|
||||
# endif /* NBPG */
|
||||
# endif /* EXEC_PAGESIZE */
|
||||
# endif /* PAGESIZE */
|
||||
#endif /* GNU_OUR_PAGESIZE */
|
||||
|
||||
int
|
||||
getpagesize ()
|
||||
{
|
||||
return (GNU_OUR_PAGESIZE);
|
||||
}
|
||||
|
||||
#else /* VMS */
|
||||
|
||||
#if 0 /* older distributions of gcc-vms are missing <syidef.h> */
|
||||
#include <syidef.h>
|
||||
#endif
|
||||
#ifndef SYI$_PAGE_SIZE /* VMS V5.4 and earlier didn't have this yet */
|
||||
#define SYI$_PAGE_SIZE 4452
|
||||
#endif
|
||||
extern unsigned long lib$getsyi(const unsigned short *,...);
|
||||
|
||||
int getpagesize ()
|
||||
{
|
||||
long pagsiz = 0L;
|
||||
unsigned short itmcod = SYI$_PAGE_SIZE;
|
||||
|
||||
(void) lib$getsyi (&itmcod, (void *) &pagsiz);
|
||||
if (pagsiz == 0L)
|
||||
pagsiz = 512L; /* VAX default */
|
||||
return (int) pagsiz;
|
||||
}
|
||||
|
||||
#endif /* VMS */
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
/* Return time used so far, in microseconds.
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
/* There are several ways to get elapsed execution time; unfortunately no
|
||||
single way is available for all host systems, nor are there reliable
|
||||
ways to find out which way is correct for a given host. */
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIMES
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#include <sys/times.h>
|
||||
#endif
|
||||
|
||||
/* This is a fallback; if wrong, it will likely make obviously wrong
|
||||
results. */
|
||||
|
||||
#ifndef CLOCKS_PER_SEC
|
||||
#define CLOCKS_PER_SEC 1
|
||||
#endif
|
||||
|
||||
long
|
||||
get_run_time ()
|
||||
{
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
struct rusage rusage;
|
||||
|
||||
getrusage (0, &rusage);
|
||||
return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
|
||||
+ rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
|
||||
#else /* ! HAVE_GETRUSAGE */
|
||||
#ifdef HAVE_TIMES
|
||||
struct tms tms;
|
||||
|
||||
times (&tms);
|
||||
return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
|
||||
#else /* ! HAVE_TIMES */
|
||||
/* Fall back on clock and hope it's correctly implemented. */
|
||||
const long clocks_per_sec = CLOCKS_PER_SEC;
|
||||
if (clocks_per_sec <= 1000000)
|
||||
return clock () * (1000000 / clocks_per_sec);
|
||||
else
|
||||
return clock () / clocks_per_sec;
|
||||
#endif /* HAVE_TIMES */
|
||||
#endif /* HAVE_GETRUSAGE */
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/* Hex character manipulation support.
|
||||
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
#include "libiberty.h"
|
||||
|
||||
char _hex_value[_hex_array_size];
|
||||
|
||||
void hex_init ()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < _hex_array_size; i++)
|
||||
_hex_value[i] = _hex_bad;
|
||||
for (i = 0; i < 10; i++)
|
||||
_hex_value['0' + i] = i;
|
||||
for (i = 0; i < 6; i++)
|
||||
_hex_value['a' + i] = _hex_value['A' + i] = 10 + i;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/* Stub implementation of (obsolete) index(). */
|
||||
|
||||
extern char * strchr();
|
||||
|
||||
char *
|
||||
index (s, c)
|
||||
char *s;
|
||||
int c;
|
||||
{
|
||||
return strchr (s, c);
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/* insque(3C) routines
|
||||
This file is in the public domain. */
|
||||
|
||||
/*
|
||||
NAME
|
||||
insque, remque -- insert, remove an element from a queue
|
||||
|
||||
SYNOPSIS
|
||||
struct qelem {
|
||||
struct qelem *q_forw;
|
||||
struct qelem *q_back;
|
||||
char q_data[];
|
||||
};
|
||||
|
||||
void insque (struct qelem *elem, struct qelem *pred)
|
||||
|
||||
void remque (struct qelem *elem)
|
||||
|
||||
DESCRIPTION
|
||||
Routines to manipulate queues built from doubly linked lists.
|
||||
The insque routine inserts ELEM in the queue immediately after
|
||||
PRED. The remque routine removes ELEM from its containing queue.
|
||||
*/
|
||||
|
||||
|
||||
struct qelem {
|
||||
struct qelem *q_forw;
|
||||
struct qelem *q_back;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
insque (elem, pred)
|
||||
struct qelem *elem;
|
||||
struct qelem *pred;
|
||||
{
|
||||
elem -> q_forw = pred -> q_forw;
|
||||
pred -> q_forw -> q_back = elem;
|
||||
elem -> q_back = pred;
|
||||
pred -> q_forw = elem;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
remque (elem)
|
||||
struct qelem *elem;
|
||||
{
|
||||
elem -> q_forw -> q_back = elem -> q_back;
|
||||
elem -> q_back -> q_forw = elem -> q_forw;
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
CFLAGS=-O2
|
||||
|
||||
OBJS = \
|
||||
argv.o \
|
||||
basename.o \
|
||||
concat.o \
|
||||
cplus-dem.o \
|
||||
fdmatch.o \
|
||||
floatformat.o \
|
||||
getopt.o \
|
||||
getopt1.o \
|
||||
getruntime.o \
|
||||
hex.o \
|
||||
msdos.o \
|
||||
obstack.o \
|
||||
spaces.o \
|
||||
strerror.o \
|
||||
strsignal.o \
|
||||
xatexit.o \
|
||||
xexit.o \
|
||||
xmalloc.o \
|
||||
$E
|
||||
|
||||
.c.o:
|
||||
gcc -I../include $(CFLAGS) -c $<
|
||||
|
||||
libiberty.a : $(OBJS)
|
||||
-rm libiberty.a
|
||||
ar rvs libiberty.a $(OBJS)
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#
|
||||
# Makefile for libiberty under openVMS/Alpha
|
||||
#
|
||||
# For use with gnu-make for vms
|
||||
#
|
||||
# Created by Klaus K"ampf, kkaempf@progis.de
|
||||
#
|
||||
#
|
||||
|
||||
OBJS=bcopy.obj,bcmp.obj,getopt.obj,obstack.obj,xexit.obj,xmalloc.obj,hex.obj,\
|
||||
getopt1.obj,cplus-dem.obj,strncasecmp.obj,strcasecmp.obj,strdup.obj,\
|
||||
concat.obj,getruntime.obj,getpagesize.obj,alloca.obj,xstrerror.obj,\
|
||||
xstrdup.obj,xatexit.obj,choose-temp.obj,fnmatch.obj,objalloc.obj
|
||||
|
||||
ifeq ($(CC),gcc)
|
||||
CFLAGS=/include=([],[-.include])
|
||||
else
|
||||
# assume dec c
|
||||
CFLAGS=/noopt/debug/include=([],[-.include])/define=("const=")/warnings=disable=(missingreturn,implicitfunc)
|
||||
endif
|
||||
|
||||
libiberty.olb: config.h alloca-conf.h $(OBJS)
|
||||
purge
|
||||
lib/create libiberty *.obj
|
||||
|
||||
config.h: config.h-vms
|
||||
$(CP) $< $@
|
||||
|
||||
clean:
|
||||
$$ purge
|
||||
$(RM) config.h;
|
||||
$(RM) *.obj;
|
||||
$(RM) libiberty.olb;
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
FUNCTION
|
||||
<<memchr>>---find character in memory
|
||||
|
||||
INDEX
|
||||
memchr
|
||||
|
||||
ANSI_SYNOPSIS
|
||||
#include <string.h>
|
||||
void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>);
|
||||
|
||||
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
|
||||
|
||||
*/
|
||||
|
||||
#include <ansidecl.h>
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#define size_t unsigned long
|
||||
#endif
|
||||
|
||||
PTR
|
||||
memchr (src_void, c, length)
|
||||
register const PTR src_void;
|
||||
int c;
|
||||
size_t length;
|
||||
{
|
||||
const unsigned char *src = (const unsigned char *)src_void;
|
||||
|
||||
while (--length >= 0)
|
||||
{
|
||||
if (*src == c)
|
||||
return (PTR)src;
|
||||
src++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/* memcmp -- compare two memory regions.
|
||||
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)
|
||||
|
||||
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>
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#define size_t unsigned long
|
||||
#endif
|
||||
|
||||
int
|
||||
DEFUN(memcmp, (str1, str2, count),
|
||||
const PTR str1 AND const PTR str2 AND size_t count)
|
||||
{
|
||||
register unsigned char *s1 = (unsigned char*)str1;
|
||||
register unsigned char *s2 = (unsigned char*)str2;
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
if (*s1++ != *s2++)
|
||||
return s1[-1] < s2[-1] ? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/* memcpy (the standard C function)
|
||||
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);
|
||||
|
||||
DESCRIPTION
|
||||
Copy LENGTH bytes from memory region pointed to by IN to memory
|
||||
region pointed to by OUT.
|
||||
*/
|
||||
|
||||
#include <ansidecl.h>
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#define size_t unsigned long
|
||||
#endif
|
||||
|
||||
PTR
|
||||
DEFUN(memcpy, (out, in, length), PTR out AND const PTR in AND size_t length)
|
||||
{
|
||||
bcopy(in, out, length);
|
||||
return out;
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/* Wrapper to implement ANSI C's memmove using BSD's bcopy. */
|
||||
/* This function is in the public domain. --Per Bothner. */
|
||||
#include <ansidecl.h>
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#define size_t unsigned long
|
||||
#endif
|
||||
|
||||
PTR
|
||||
memmove (s1, s2, n)
|
||||
PTR s1;
|
||||
const PTR s2;
|
||||
size_t n;
|
||||
{
|
||||
bcopy (s2, s1, n);
|
||||
return s1;
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/* memset
|
||||
This implementation is in the public domain. */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#define size_t unsigned long
|
||||
#endif
|
||||
|
||||
PTR
|
||||
DEFUN(memset, (dest, val, len),
|
||||
PTR dest AND register int val AND register size_t len)
|
||||
{
|
||||
register unsigned char *ptr = (unsigned char*)dest;
|
||||
while (len-- > 0)
|
||||
*ptr++ = val;
|
||||
return dest;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# MPW configuration fragment for libiberty.
|
||||
|
||||
Echo '/* config.h. Generated by mpw-configure. */' > "{o}"config.new
|
||||
|
||||
MoveIfChange "{o}"config.new "{o}"config.h
|
||||
|
||||
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
# Sed commands to finish translating libiberty's Unix makefile to MPW syntax.
|
||||
|
||||
# Comment out a useless thing.
|
||||
/^\.always\./s/^/#/
|
||||
|
||||
# Replace the auto-generated list with the list of what we know we need.
|
||||
s/`cat needed-list`/"{o}"alloca.c.o "{o}"bcopy.c.o "{o}"getpagesize.c.o "{o}"insque.c.o "{o}"mpw.c.o "{o}"strcasecmp.c.o "{o}"strdup.c.o "{o}"strncasecmp.c.o/
|
||||
|
||||
# Paste in some desirable definitions.
|
||||
# The default rule here completely replaces the tricky stuff in the Unix
|
||||
# Makefile.in.
|
||||
/^###$/a\
|
||||
\
|
||||
HDEFINES = -d NEED_sys_siglist -d NEED_sys_errlist -d NEED_basename -d NEED_strcasecmp -d NEED_strncasecmp\
|
||||
INCLUDES = -i : -i {INCDIR}: -i {INCDIR}:mpw: -i ::extra-include: -i "{s}"\
|
||||
\
|
||||
.c.o \\Option-f .c\
|
||||
{CC} @DASH_C_FLAG@ {DepDir}{Default}.c {LIBCFLAGS} {INCLUDES} {HDEFINES} @SEGMENT_FLAG({Default})@ -o {TargDir}{Default}.c.o\
|
||||
|
||||
# Remove dependency on needed-list, which we don't use.
|
||||
/DO_ALSO =/s/needed-list//
|
||||
|
||||
/INCDIR=/s/"{srcdir}"{MULTISRCTOP}::/"{topsrcdir}"/
|
||||
|
||||
# Whack out the COMPILE.c trickiness.
|
||||
/^COMPILE.c /,/^$/d
|
||||
|
||||
# Remove the multido trickiness from the "all" target.
|
||||
/^all \\Option-f/,/^$/c\
|
||||
all \\Option-f {TARGETLIB}\
|
||||
|
||||
|
||||
# Remove the RULE1/RULE2 crud.
|
||||
/if \[/,/fi/d
|
||||
/^RULE1 =/,/RULE2 =/d
|
||||
/RULE2/s/RULE2/TARGETLIB/
|
||||
|
||||
# Don't want fdmatch ever.
|
||||
s/ "{o}"fdmatch.c.o//
|
||||
|
||||
# Fix paths to generated files.
|
||||
/config.h/s/"{s}"config.h/"{o}"config.h/
|
||||
|
||||
# Whack out config rebuild rules.
|
||||
/^"{o}"config.h \\Option-f/,/^$/d
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1010
libiberty/mpw.c
1010
libiberty/mpw.c
File diff suppressed because it is too large
Load Diff
|
|
@ -1,15 +0,0 @@
|
|||
char msg[] = "No vfork available - aborting\n";
|
||||
vfork()
|
||||
{
|
||||
write(1, msg, sizeof(msg));
|
||||
}
|
||||
|
||||
sigsetmask()
|
||||
{
|
||||
/* no signals support in go32 (yet) */
|
||||
}
|
||||
|
||||
waitpid()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1,291 +0,0 @@
|
|||
/* objalloc.c -- routines to allocate memory for objects
|
||||
Copyright 1997 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Cygnus Solutions.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "objalloc.h"
|
||||
|
||||
/* Get a definition for NULL. */
|
||||
#include <stdio.h>
|
||||
|
||||
#if VMS
|
||||
#include <stdlib.h>
|
||||
#include <unixlib.h>
|
||||
#else
|
||||
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
/* Get a definition for size_t. */
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
/* For systems with larger pointers than ints, this must be declared. */
|
||||
extern PTR malloc PARAMS ((size_t));
|
||||
extern void free PARAMS ((PTR));
|
||||
#endif
|
||||
|
||||
/* These routines allocate space for an object. Freeing allocated
|
||||
space may or may not free all more recently allocated space.
|
||||
|
||||
We handle large and small allocation requests differently. If we
|
||||
don't have enough space in the current block, and the allocation
|
||||
request is for more than 512 bytes, we simply pass it through to
|
||||
malloc. */
|
||||
|
||||
/* The objalloc structure is defined in objalloc.h. */
|
||||
|
||||
/* This structure appears at the start of each chunk. */
|
||||
|
||||
struct objalloc_chunk
|
||||
{
|
||||
/* Next chunk. */
|
||||
struct objalloc_chunk *next;
|
||||
/* If this chunk contains large objects, this is the value of
|
||||
current_ptr when this chunk was allocated. If this chunk
|
||||
contains small objects, this is NULL. */
|
||||
char *current_ptr;
|
||||
};
|
||||
|
||||
/* The aligned size of objalloc_chunk. */
|
||||
|
||||
#define CHUNK_HEADER_SIZE \
|
||||
((sizeof (struct objalloc_chunk) + OBJALLOC_ALIGN - 1) \
|
||||
&~ (OBJALLOC_ALIGN - 1))
|
||||
|
||||
/* We ask for this much memory each time we create a chunk which is to
|
||||
hold small objects. */
|
||||
|
||||
#define CHUNK_SIZE (4096 - 32)
|
||||
|
||||
/* A request for this amount or more is just passed through to malloc. */
|
||||
|
||||
#define BIG_REQUEST (512)
|
||||
|
||||
/* Create an objalloc structure. */
|
||||
|
||||
struct objalloc *
|
||||
objalloc_create ()
|
||||
{
|
||||
struct objalloc *ret;
|
||||
struct objalloc_chunk *chunk;
|
||||
|
||||
ret = (struct objalloc *) malloc (sizeof *ret);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
ret->chunks = (PTR) malloc (CHUNK_SIZE);
|
||||
if (ret->chunks == NULL)
|
||||
{
|
||||
free (ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
chunk = (struct objalloc_chunk *) ret->chunks;
|
||||
chunk->next = NULL;
|
||||
chunk->current_ptr = NULL;
|
||||
|
||||
ret->current_ptr = (char *) chunk + CHUNK_HEADER_SIZE;
|
||||
ret->current_space = CHUNK_SIZE - CHUNK_HEADER_SIZE;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Allocate space from an objalloc structure. */
|
||||
|
||||
PTR
|
||||
_objalloc_alloc (o, len)
|
||||
struct objalloc *o;
|
||||
unsigned long len;
|
||||
{
|
||||
/* We avoid confusion from zero sized objects by always allocating
|
||||
at least 1 byte. */
|
||||
if (len == 0)
|
||||
len = 1;
|
||||
|
||||
len = (len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1);
|
||||
|
||||
if (len <= o->current_space)
|
||||
{
|
||||
o->current_ptr += len;
|
||||
o->current_space -= len;
|
||||
return (PTR) (o->current_ptr - len);
|
||||
}
|
||||
|
||||
if (len >= BIG_REQUEST)
|
||||
{
|
||||
char *ret;
|
||||
struct objalloc_chunk *chunk;
|
||||
|
||||
ret = (char *) malloc (CHUNK_HEADER_SIZE + len);
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
chunk = (struct objalloc_chunk *) ret;
|
||||
chunk->next = (struct objalloc_chunk *) o->chunks;
|
||||
chunk->current_ptr = o->current_ptr;
|
||||
|
||||
o->chunks = (PTR) chunk;
|
||||
|
||||
return (PTR) (ret + CHUNK_HEADER_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct objalloc_chunk *chunk;
|
||||
|
||||
chunk = (struct objalloc_chunk *) malloc (CHUNK_SIZE);
|
||||
if (chunk == NULL)
|
||||
return NULL;
|
||||
chunk->next = (struct objalloc_chunk *) o->chunks;
|
||||
chunk->current_ptr = NULL;
|
||||
|
||||
o->current_ptr = (char *) chunk + CHUNK_HEADER_SIZE;
|
||||
o->current_space = CHUNK_SIZE - CHUNK_HEADER_SIZE;
|
||||
|
||||
o->chunks = (PTR) chunk;
|
||||
|
||||
return objalloc_alloc (o, len);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free an entire objalloc structure. */
|
||||
|
||||
void
|
||||
objalloc_free (o)
|
||||
struct objalloc *o;
|
||||
{
|
||||
struct objalloc_chunk *l;
|
||||
|
||||
l = (struct objalloc_chunk *) o->chunks;
|
||||
while (l != NULL)
|
||||
{
|
||||
struct objalloc_chunk *next;
|
||||
|
||||
next = l->next;
|
||||
free (l);
|
||||
l = next;
|
||||
}
|
||||
|
||||
free (o);
|
||||
}
|
||||
|
||||
/* Free a block from an objalloc structure. This also frees all more
|
||||
recently allocated blocks. */
|
||||
|
||||
void
|
||||
objalloc_free_block (o, block)
|
||||
struct objalloc *o;
|
||||
PTR block;
|
||||
{
|
||||
struct objalloc_chunk *p, *small;
|
||||
char *b = (char *) block;
|
||||
|
||||
/* First set P to the chunk which contains the block we are freeing,
|
||||
and set Q to the last small object chunk we see before P. */
|
||||
small = NULL;
|
||||
for (p = (struct objalloc_chunk *) o->chunks; p != NULL; p = p->next)
|
||||
{
|
||||
if (p->current_ptr == NULL)
|
||||
{
|
||||
if (b > (char *) p && b < (char *) p + CHUNK_SIZE)
|
||||
break;
|
||||
small = p;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (b == (char *) p + CHUNK_HEADER_SIZE)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we can't find the chunk, the caller has made a mistake. */
|
||||
if (p == NULL)
|
||||
abort ();
|
||||
|
||||
if (p->current_ptr == NULL)
|
||||
{
|
||||
struct objalloc_chunk *q;
|
||||
struct objalloc_chunk *first;
|
||||
|
||||
/* The block is in a chunk containing small objects. We can
|
||||
free every chunk through SMALL, because they have certainly
|
||||
been allocated more recently. After SMALL, we will not see
|
||||
any chunks containing small objects; we can free any big
|
||||
chunk if the current_ptr is greater than or equal to B. We
|
||||
can then reset the new current_ptr to B. */
|
||||
|
||||
first = NULL;
|
||||
q = (struct objalloc_chunk *) o->chunks;
|
||||
while (q != p)
|
||||
{
|
||||
struct objalloc_chunk *next;
|
||||
|
||||
next = q->next;
|
||||
if (small != NULL)
|
||||
{
|
||||
if (small == q)
|
||||
small = NULL;
|
||||
free (q);
|
||||
}
|
||||
else if (q->current_ptr > b)
|
||||
free (q);
|
||||
else if (first == NULL)
|
||||
first = q;
|
||||
|
||||
q = next;
|
||||
}
|
||||
|
||||
if (first == NULL)
|
||||
first = p;
|
||||
o->chunks = (PTR) first;
|
||||
|
||||
/* Now start allocating from this small block again. */
|
||||
o->current_ptr = b;
|
||||
o->current_space = ((char *) p + CHUNK_SIZE) - b;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct objalloc_chunk *q;
|
||||
char *current_ptr;
|
||||
|
||||
/* This block is in a large chunk by itself. We can free
|
||||
everything on the list up to and including this block. We
|
||||
then start allocating from the next chunk containing small
|
||||
objects, setting current_ptr from the value stored with the
|
||||
large chunk we are freeing. */
|
||||
|
||||
current_ptr = p->current_ptr;
|
||||
p = p->next;
|
||||
|
||||
q = (struct objalloc_chunk *) o->chunks;
|
||||
while (q != p)
|
||||
{
|
||||
struct objalloc_chunk *next;
|
||||
|
||||
next = q->next;
|
||||
free (q);
|
||||
q = next;
|
||||
}
|
||||
|
||||
o->chunks = (PTR) p;
|
||||
|
||||
while (p->current_ptr != NULL)
|
||||
p = p->next;
|
||||
|
||||
o->current_ptr = current_ptr;
|
||||
o->current_space = ((char *) p + CHUNK_SIZE) - current_ptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,377 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by the University of California, Berkeley. The name of the
|
||||
* University may not be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is derived from the Berkeley source:
|
||||
* @(#)random.c 5.5 (Berkeley) 7/6/88
|
||||
* It was reworked for the GNU C Library by Roland McGrath.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if 0
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#else
|
||||
|
||||
#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF for 32-bits */
|
||||
#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits*/
|
||||
|
||||
#ifdef __STDC__
|
||||
# define PTR void *
|
||||
# ifndef NULL
|
||||
# define NULL (void *) 0
|
||||
# endif
|
||||
#else
|
||||
# define PTR char *
|
||||
# ifndef NULL
|
||||
# define NULL (void *) 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
long int random ();
|
||||
|
||||
/* An improved random number generation package. In addition to the standard
|
||||
rand()/srand() like interface, this package also has a special state info
|
||||
interface. The initstate() routine is called with a seed, an array of
|
||||
bytes, and a count of how many bytes are being passed in; this array is
|
||||
then initialized to contain information for random number generation with
|
||||
that much state information. Good sizes for the amount of state
|
||||
information are 32, 64, 128, and 256 bytes. The state can be switched by
|
||||
calling the setstate() function with the same array as was initiallized
|
||||
with initstate(). By default, the package runs with 128 bytes of state
|
||||
information and generates far better random numbers than a linear
|
||||
congruential generator. If the amount of state information is less than
|
||||
32 bytes, a simple linear congruential R.N.G. is used. Internally, the
|
||||
state information is treated as an array of longs; the zeroeth element of
|
||||
the array is the type of R.N.G. being used (small integer); the remainder
|
||||
of the array is the state information for the R.N.G. Thus, 32 bytes of
|
||||
state information will give 7 longs worth of state information, which will
|
||||
allow a degree seven polynomial. (Note: The zeroeth word of state
|
||||
information also has some other information stored in it; see setstate
|
||||
for details). The random number generation technique is a linear feedback
|
||||
shift register approach, employing trinomials (since there are fewer terms
|
||||
to sum up that way). In this approach, the least significant bit of all
|
||||
the numbers in the state table will act as a linear feedback shift register,
|
||||
and will have period 2^deg - 1 (where deg is the degree of the polynomial
|
||||
being used, assuming that the polynomial is irreducible and primitive).
|
||||
The higher order bits will have longer periods, since their values are
|
||||
also influenced by pseudo-random carries out of the lower bits. The
|
||||
total period of the generator is approximately deg*(2**deg - 1); thus
|
||||
doubling the amount of state information has a vast influence on the
|
||||
period of the generator. Note: The deg*(2**deg - 1) is an approximation
|
||||
only good for large deg, when the period of the shift register is the
|
||||
dominant factor. With deg equal to seven, the period is actually much
|
||||
longer than the 7*(2**7 - 1) predicted by this formula. */
|
||||
|
||||
|
||||
|
||||
/* For each of the currently supported random number generators, we have a
|
||||
break value on the amount of state information (you need at least thi
|
||||
bytes of state info to support this random number generator), a degree for
|
||||
the polynomial (actually a trinomial) that the R.N.G. is based on, and
|
||||
separation between the two lower order coefficients of the trinomial. */
|
||||
|
||||
/* Linear congruential. */
|
||||
#define TYPE_0 0
|
||||
#define BREAK_0 8
|
||||
#define DEG_0 0
|
||||
#define SEP_0 0
|
||||
|
||||
/* x**7 + x**3 + 1. */
|
||||
#define TYPE_1 1
|
||||
#define BREAK_1 32
|
||||
#define DEG_1 7
|
||||
#define SEP_1 3
|
||||
|
||||
/* x**15 + x + 1. */
|
||||
#define TYPE_2 2
|
||||
#define BREAK_2 64
|
||||
#define DEG_2 15
|
||||
#define SEP_2 1
|
||||
|
||||
/* x**31 + x**3 + 1. */
|
||||
#define TYPE_3 3
|
||||
#define BREAK_3 128
|
||||
#define DEG_3 31
|
||||
#define SEP_3 3
|
||||
|
||||
/* x**63 + x + 1. */
|
||||
#define TYPE_4 4
|
||||
#define BREAK_4 256
|
||||
#define DEG_4 63
|
||||
#define SEP_4 1
|
||||
|
||||
|
||||
/* Array versions of the above information to make code run faster.
|
||||
Relies on fact that TYPE_i == i. */
|
||||
|
||||
#define MAX_TYPES 5 /* Max number of types above. */
|
||||
|
||||
static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 };
|
||||
static int seps[MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
|
||||
|
||||
|
||||
|
||||
/* Initially, everything is set up as if from:
|
||||
initstate(1, randtbl, 128);
|
||||
Note that this initialization takes advantage of the fact that srandom
|
||||
advances the front and rear pointers 10*rand_deg times, and hence the
|
||||
rear pointer which starts at 0 will also end up at zero; thus the zeroeth
|
||||
element of the state information, which contains info about the current
|
||||
position of the rear pointer is just
|
||||
(MAX_TYPES * (rptr - state)) + TYPE_3 == TYPE_3. */
|
||||
|
||||
static long int randtbl[DEG_3 + 1] =
|
||||
{ TYPE_3,
|
||||
0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342,
|
||||
0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb,
|
||||
0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd,
|
||||
0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86,
|
||||
0xda672e2a, 0x1588ca88, 0xe369735d, 0x904f35f7,
|
||||
0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc,
|
||||
0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b,
|
||||
0xf5ad9d0e, 0x8999220b, 0x27fb47b9
|
||||
};
|
||||
|
||||
/* FPTR and RPTR are two pointers into the state info, a front and a rear
|
||||
pointer. These two pointers are always rand_sep places aparts, as they
|
||||
cycle through the state information. (Yes, this does mean we could get
|
||||
away with just one pointer, but the code for random is more efficient
|
||||
this way). The pointers are left positioned as they would be from the call:
|
||||
initstate(1, randtbl, 128);
|
||||
(The position of the rear pointer, rptr, is really 0 (as explained above
|
||||
in the initialization of randtbl) because the state table pointer is set
|
||||
to point to randtbl[1] (as explained below).) */
|
||||
|
||||
static long int *fptr = &randtbl[SEP_3 + 1];
|
||||
static long int *rptr = &randtbl[1];
|
||||
|
||||
|
||||
|
||||
/* The following things are the pointer to the state information table,
|
||||
the type of the current generator, the degree of the current polynomial
|
||||
being used, and the separation between the two pointers.
|
||||
Note that for efficiency of random, we remember the first location of
|
||||
the state information, not the zeroeth. Hence it is valid to access
|
||||
state[-1], which is used to store the type of the R.N.G.
|
||||
Also, we remember the last location, since this is more efficient than
|
||||
indexing every time to find the address of the last element to see if
|
||||
the front and rear pointers have wrapped. */
|
||||
|
||||
static long int *state = &randtbl[1];
|
||||
|
||||
static int rand_type = TYPE_3;
|
||||
static int rand_deg = DEG_3;
|
||||
static int rand_sep = SEP_3;
|
||||
|
||||
static long int *end_ptr = &randtbl[sizeof(randtbl) / sizeof(randtbl[0])];
|
||||
|
||||
/* Initialize the random number generator based on the given seed. If the
|
||||
type is the trivial no-state-information type, just remember the seed.
|
||||
Otherwise, initializes state[] based on the given "seed" via a linear
|
||||
congruential generator. Then, the pointers are set to known locations
|
||||
that are exactly rand_sep places apart. Lastly, it cycles the state
|
||||
information a given number of times to get rid of any initial dependencies
|
||||
introduced by the L.C.R.N.G. Note that the initialization of randtbl[]
|
||||
for default usage relies on values produced by this routine. */
|
||||
void
|
||||
srandom (x)
|
||||
unsigned int x;
|
||||
{
|
||||
state[0] = x;
|
||||
if (rand_type != TYPE_0)
|
||||
{
|
||||
register long int i;
|
||||
for (i = 1; i < rand_deg; ++i)
|
||||
state[i] = (1103515145 * state[i - 1]) + 12345;
|
||||
fptr = &state[rand_sep];
|
||||
rptr = &state[0];
|
||||
for (i = 0; i < 10 * rand_deg; ++i)
|
||||
random();
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize the state information in the given array of N bytes for
|
||||
future random number generation. Based on the number of bytes we
|
||||
are given, and the break values for the different R.N.G.'s, we choose
|
||||
the best (largest) one we can and set things up for it. srandom is
|
||||
then called to initialize the state information. Note that on return
|
||||
from srandom, we set state[-1] to be the type multiplexed with the current
|
||||
value of the rear pointer; this is so successive calls to initstate won't
|
||||
lose this information and will be able to restart with setstate.
|
||||
Note: The first thing we do is save the current state, if any, just like
|
||||
setstate so that it doesn't matter when initstate is called.
|
||||
Returns a pointer to the old state. */
|
||||
PTR
|
||||
initstate (seed, arg_state, n)
|
||||
unsigned int seed;
|
||||
PTR arg_state;
|
||||
unsigned long n;
|
||||
{
|
||||
PTR ostate = (PTR) &state[-1];
|
||||
|
||||
if (rand_type == TYPE_0)
|
||||
state[-1] = rand_type;
|
||||
else
|
||||
state[-1] = (MAX_TYPES * (rptr - state)) + rand_type;
|
||||
if (n < BREAK_1)
|
||||
{
|
||||
if (n < BREAK_0)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
rand_type = TYPE_0;
|
||||
rand_deg = DEG_0;
|
||||
rand_sep = SEP_0;
|
||||
}
|
||||
else if (n < BREAK_2)
|
||||
{
|
||||
rand_type = TYPE_1;
|
||||
rand_deg = DEG_1;
|
||||
rand_sep = SEP_1;
|
||||
}
|
||||
else if (n < BREAK_3)
|
||||
{
|
||||
rand_type = TYPE_2;
|
||||
rand_deg = DEG_2;
|
||||
rand_sep = SEP_2;
|
||||
}
|
||||
else if (n < BREAK_4)
|
||||
{
|
||||
rand_type = TYPE_3;
|
||||
rand_deg = DEG_3;
|
||||
rand_sep = SEP_3;
|
||||
}
|
||||
else
|
||||
{
|
||||
rand_type = TYPE_4;
|
||||
rand_deg = DEG_4;
|
||||
rand_sep = SEP_4;
|
||||
}
|
||||
|
||||
state = &((long int *) arg_state)[1]; /* First location. */
|
||||
/* Must set END_PTR before srandom. */
|
||||
end_ptr = &state[rand_deg];
|
||||
srandom(seed);
|
||||
if (rand_type == TYPE_0)
|
||||
state[-1] = rand_type;
|
||||
else
|
||||
state[-1] = (MAX_TYPES * (rptr - state)) + rand_type;
|
||||
|
||||
return ostate;
|
||||
}
|
||||
|
||||
/* Restore the state from the given state array.
|
||||
Note: It is important that we also remember the locations of the pointers
|
||||
in the current state information, and restore the locations of the pointers
|
||||
from the old state information. This is done by multiplexing the pointer
|
||||
location into the zeroeth word of the state information. Note that due
|
||||
to the order in which things are done, it is OK to call setstate with the
|
||||
same state as the current state
|
||||
Returns a pointer to the old state information. */
|
||||
|
||||
PTR
|
||||
setstate (arg_state)
|
||||
PTR arg_state;
|
||||
{
|
||||
register long int *new_state = (long int *) arg_state;
|
||||
register int type = new_state[0] % MAX_TYPES;
|
||||
register int rear = new_state[0] / MAX_TYPES;
|
||||
PTR ostate = (PTR) &state[-1];
|
||||
|
||||
if (rand_type == TYPE_0)
|
||||
state[-1] = rand_type;
|
||||
else
|
||||
state[-1] = (MAX_TYPES * (rptr - state)) + rand_type;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TYPE_0:
|
||||
case TYPE_1:
|
||||
case TYPE_2:
|
||||
case TYPE_3:
|
||||
case TYPE_4:
|
||||
rand_type = type;
|
||||
rand_deg = degrees[type];
|
||||
rand_sep = seps[type];
|
||||
break;
|
||||
default:
|
||||
/* State info munged. */
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
state = &new_state[1];
|
||||
if (rand_type != TYPE_0)
|
||||
{
|
||||
rptr = &state[rear];
|
||||
fptr = &state[(rear + rand_sep) % rand_deg];
|
||||
}
|
||||
/* Set end_ptr too. */
|
||||
end_ptr = &state[rand_deg];
|
||||
|
||||
return ostate;
|
||||
}
|
||||
|
||||
/* If we are using the trivial TYPE_0 R.N.G., just do the old linear
|
||||
congruential bit. Otherwise, we do our fancy trinomial stuff, which is the
|
||||
same in all ther other cases due to all the global variables that have been
|
||||
set up. The basic operation is to add the number at the rear pointer into
|
||||
the one at the front pointer. Then both pointers are advanced to the next
|
||||
location cyclically in the table. The value returned is the sum generated,
|
||||
reduced to 31 bits by throwing away the "least random" low bit.
|
||||
Note: The code takes advantage of the fact that both the front and
|
||||
rear pointers can't wrap on the same call by not testing the rear
|
||||
pointer if the front one has wrapped. Returns a 31-bit random number. */
|
||||
|
||||
long int
|
||||
random ()
|
||||
{
|
||||
if (rand_type == TYPE_0)
|
||||
{
|
||||
state[0] = ((state[0] * 1103515245) + 12345) & LONG_MAX;
|
||||
return state[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
long int i;
|
||||
*fptr += *rptr;
|
||||
/* Chucking least random bit. */
|
||||
i = (*fptr >> 1) & LONG_MAX;
|
||||
++fptr;
|
||||
if (fptr >= end_ptr)
|
||||
{
|
||||
fptr = state;
|
||||
++rptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
++rptr;
|
||||
if (rptr >= end_ptr)
|
||||
rptr = state;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
/* rename -- rename a file
|
||||
This function is in the public domain. */
|
||||
|
||||
/* Rename a file. */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
rename (zfrom, zto)
|
||||
char *zfrom;
|
||||
char *zto;
|
||||
{
|
||||
if (link (zfrom, zto) < 0)
|
||||
{
|
||||
if (errno != EEXIST)
|
||||
return -1;
|
||||
if (unlink (zto) < 0
|
||||
|| link (zfrom, zto) < 0)
|
||||
return -1;
|
||||
}
|
||||
return unlink (zfrom);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/* Stub implementation of (obsolete) rindex(). */
|
||||
|
||||
extern char *strrchr ();
|
||||
|
||||
char *
|
||||
rindex (s, c)
|
||||
char *s;
|
||||
int c;
|
||||
{
|
||||
return strrchr (s, c);
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
/* Version of sigsetmask.c
|
||||
Written by Steve Chamberlain (sac@cygnus.com).
|
||||
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 */
|
||||
|
||||
#define _POSIX_SOURCE
|
||||
#include <ansidecl.h>
|
||||
/* Including <sys/types.h> seems to be needed by ISC. */
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef SIG_SETMASK
|
||||
int
|
||||
DEFUN(sigsetmask,(set),
|
||||
int set)
|
||||
{
|
||||
sigset_t new;
|
||||
sigset_t old;
|
||||
|
||||
sigemptyset (&new);
|
||||
if (set != 0) {
|
||||
abort(); /* FIXME, we don't know how to translate old mask to new */
|
||||
}
|
||||
sigprocmask(SIG_SETMASK, &new, &old);
|
||||
return 1; /* FIXME, we always return 1 as old value. */
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/* Allocate memory region filled with spaces.
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
spaces -- return a pointer to a buffer full of spaces
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
char *spaces (int count)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Returns a pointer to a memory region filled with the specified
|
||||
number of spaces and null terminated. The returned pointer is
|
||||
valid until at least the next call.
|
||||
|
||||
BUGS
|
||||
|
||||
*/
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#if VMS
|
||||
#include <stdlib.h>
|
||||
#include <unixlib.h>
|
||||
#else
|
||||
/* For systems with larger pointers than ints, these must be declared. */
|
||||
extern PTR malloc PARAMS ((size_t));
|
||||
extern void free PARAMS ((PTR));
|
||||
#endif
|
||||
|
||||
const char *
|
||||
spaces (count)
|
||||
int count;
|
||||
{
|
||||
register char *t;
|
||||
static char *buf;
|
||||
static int maxsize;
|
||||
|
||||
if (count > maxsize)
|
||||
{
|
||||
if (buf)
|
||||
{
|
||||
free (buf);
|
||||
}
|
||||
buf = malloc (count + 1);
|
||||
if (buf == (char *) 0)
|
||||
return 0;
|
||||
for (t = buf + count ; t != buf ; )
|
||||
{
|
||||
*--t = ' ';
|
||||
}
|
||||
maxsize = count;
|
||||
buf[count] = '\0';
|
||||
}
|
||||
return (const char *) (buf + maxsize - count);
|
||||
}
|
||||
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1987 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of California at Berkeley. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific written prior permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#define size_t unsigned long
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This array is designed for mapping upper and lower case letter
|
||||
* together for a case independent comparison. The mappings are
|
||||
* based upon ascii character sequences.
|
||||
*/
|
||||
typedef unsigned char uc;
|
||||
static unsigned char charmap[] = {
|
||||
(uc)'\000',(uc)'\001',(uc)'\002',(uc)'\003',(uc)'\004',(uc)'\005',(uc)'\006',(uc)'\007',
|
||||
(uc)'\010',(uc)'\011',(uc)'\012',(uc)'\013',(uc)'\014',(uc)'\015',(uc)'\016',(uc)'\017',
|
||||
(uc)'\020',(uc)'\021',(uc)'\022',(uc)'\023',(uc)'\024',(uc)'\025',(uc)'\026',(uc)'\027',
|
||||
(uc)'\030',(uc)'\031',(uc)'\032',(uc)'\033',(uc)'\034',(uc)'\035',(uc)'\036',(uc)'\037',
|
||||
(uc)'\040',(uc)'\041',(uc)'\042',(uc)'\043',(uc)'\044',(uc)'\045',(uc)'\046',(uc)'\047',
|
||||
(uc)'\050',(uc)'\051',(uc)'\052',(uc)'\053',(uc)'\054',(uc)'\055',(uc)'\056',(uc)'\057',
|
||||
(uc)'\060',(uc)'\061',(uc)'\062',(uc)'\063',(uc)'\064',(uc)'\065',(uc)'\066',(uc)'\067',
|
||||
(uc)'\070',(uc)'\071',(uc)'\072',(uc)'\073',(uc)'\074',(uc)'\075',(uc)'\076',(uc)'\077',
|
||||
(uc)'\100',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147',
|
||||
(uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157',
|
||||
(uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167',
|
||||
(uc)'\170',(uc)'\171',(uc)'\172',(uc)'\133',(uc)'\134',(uc)'\135',(uc)'\136',(uc)'\137',
|
||||
(uc)'\140',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147',
|
||||
(uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157',
|
||||
(uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167',
|
||||
(uc)'\170',(uc)'\171',(uc)'\172',(uc)'\173',(uc)'\174',(uc)'\175',(uc)'\176',(uc)'\177',
|
||||
(uc)'\200',(uc)'\201',(uc)'\202',(uc)'\203',(uc)'\204',(uc)'\205',(uc)'\206',(uc)'\207',
|
||||
(uc)'\210',(uc)'\211',(uc)'\212',(uc)'\213',(uc)'\214',(uc)'\215',(uc)'\216',(uc)'\217',
|
||||
(uc)'\220',(uc)'\221',(uc)'\222',(uc)'\223',(uc)'\224',(uc)'\225',(uc)'\226',(uc)'\227',
|
||||
(uc)'\230',(uc)'\231',(uc)'\232',(uc)'\233',(uc)'\234',(uc)'\235',(uc)'\236',(uc)'\237',
|
||||
(uc)'\240',(uc)'\241',(uc)'\242',(uc)'\243',(uc)'\244',(uc)'\245',(uc)'\246',(uc)'\247',
|
||||
(uc)'\250',(uc)'\251',(uc)'\252',(uc)'\253',(uc)'\254',(uc)'\255',(uc)'\256',(uc)'\257',
|
||||
(uc)'\260',(uc)'\261',(uc)'\262',(uc)'\263',(uc)'\264',(uc)'\265',(uc)'\266',(uc)'\267',
|
||||
(uc)'\270',(uc)'\271',(uc)'\272',(uc)'\273',(uc)'\274',(uc)'\275',(uc)'\276',(uc)'\277',
|
||||
(uc)'\300',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347',
|
||||
(uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357',
|
||||
(uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367',
|
||||
(uc)'\370',(uc)'\371',(uc)'\372',(uc)'\333',(uc)'\334',(uc)'\335',(uc)'\336',(uc)'\337',
|
||||
(uc)'\340',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347',
|
||||
(uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357',
|
||||
(uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367',
|
||||
(uc)'\370',(uc)'\371',(uc)'\372',(uc)'\373',(uc)'\374',(uc)'\375',(uc)'\376',(uc)'\377',
|
||||
};
|
||||
|
||||
int
|
||||
strcasecmp(s1, s2)
|
||||
const char *s1, *s2;
|
||||
{
|
||||
register unsigned char u1, u2;
|
||||
|
||||
for (;;) {
|
||||
u1 = (unsigned char) *s1++;
|
||||
u2 = (unsigned char) *s2++;
|
||||
if (charmap[u1] != charmap[u2]) {
|
||||
return charmap[u1] - charmap[u2];
|
||||
}
|
||||
if (u1 == '\0') {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/* Portable version of strchr()
|
||||
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)
|
||||
|
||||
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>
|
||||
|
||||
char *
|
||||
strchr (s, c)
|
||||
register const char *s;
|
||||
int c;
|
||||
{
|
||||
do {
|
||||
if (*s == c)
|
||||
{
|
||||
return (char*)s;
|
||||
}
|
||||
} while (*s++);
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
char *
|
||||
strdup(s)
|
||||
char *s;
|
||||
{
|
||||
char *result = (char*)malloc(strlen(s) + 1);
|
||||
if (result == (char*)0)
|
||||
return (char*)0;
|
||||
strcpy(result, s);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1,831 +0,0 @@
|
|||
/* Extended support for using errno values.
|
||||
Written by Fred Fish. fnf@cygnus.com
|
||||
This file is in the public domain. --Per Bothner. */
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_SYS_ERRLIST
|
||||
/* Note that errno.h (not sure what OS) or stdio.h (BSD 4.4, at least)
|
||||
might declare sys_errlist in a way that the compiler might consider
|
||||
incompatible with our later declaration, perhaps by using const
|
||||
attributes. So we hide the declaration in errno.h (if any) using a
|
||||
macro. */
|
||||
#define sys_errlist sys_errlist__
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_SYS_ERRLIST
|
||||
#undef sys_errlist
|
||||
#endif
|
||||
|
||||
/* Routines imported from standard C runtime libraries. */
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
extern void *malloc (size_t size); /* 4.10.3.3 */
|
||||
extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */
|
||||
#else /* !__STDC__ */
|
||||
extern char *malloc (); /* Standard memory allocater */
|
||||
extern char *memset ();
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifndef MAX
|
||||
# define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
static void init_error_tables PARAMS ((void));
|
||||
|
||||
/* Translation table for errno values. See intro(2) in most UNIX systems
|
||||
Programmers Reference Manuals.
|
||||
|
||||
Note that this table is generally only accessed when it is used at runtime
|
||||
to initialize errno name and message tables that are indexed by errno
|
||||
value.
|
||||
|
||||
Not all of these errnos will exist on all systems. This table is the only
|
||||
thing that should have to be updated as new error numbers are introduced.
|
||||
It's sort of ugly, but at least its portable. */
|
||||
|
||||
struct error_info
|
||||
{
|
||||
int value; /* The numeric value from <errno.h> */
|
||||
const char *name; /* The equivalent symbolic value */
|
||||
#ifndef HAVE_SYS_ERRLIST
|
||||
const char *msg; /* Short message about this value */
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef HAVE_SYS_ERRLIST
|
||||
# define ENTRY(value, name, msg) {value, name, msg}
|
||||
#else
|
||||
# define ENTRY(value, name, msg) {value, name}
|
||||
#endif
|
||||
|
||||
static const struct error_info error_table[] =
|
||||
{
|
||||
#if defined (EPERM)
|
||||
ENTRY(EPERM, "EPERM", "Not owner"),
|
||||
#endif
|
||||
#if defined (ENOENT)
|
||||
ENTRY(ENOENT, "ENOENT", "No such file or directory"),
|
||||
#endif
|
||||
#if defined (ESRCH)
|
||||
ENTRY(ESRCH, "ESRCH", "No such process"),
|
||||
#endif
|
||||
#if defined (EINTR)
|
||||
ENTRY(EINTR, "EINTR", "Interrupted system call"),
|
||||
#endif
|
||||
#if defined (EIO)
|
||||
ENTRY(EIO, "EIO", "I/O error"),
|
||||
#endif
|
||||
#if defined (ENXIO)
|
||||
ENTRY(ENXIO, "ENXIO", "No such device or address"),
|
||||
#endif
|
||||
#if defined (E2BIG)
|
||||
ENTRY(E2BIG, "E2BIG", "Arg list too long"),
|
||||
#endif
|
||||
#if defined (ENOEXEC)
|
||||
ENTRY(ENOEXEC, "ENOEXEC", "Exec format error"),
|
||||
#endif
|
||||
#if defined (EBADF)
|
||||
ENTRY(EBADF, "EBADF", "Bad file number"),
|
||||
#endif
|
||||
#if defined (ECHILD)
|
||||
ENTRY(ECHILD, "ECHILD", "No child processes"),
|
||||
#endif
|
||||
#if defined (EWOULDBLOCK) /* Put before EAGAIN, sometimes aliased */
|
||||
ENTRY(EWOULDBLOCK, "EWOULDBLOCK", "Operation would block"),
|
||||
#endif
|
||||
#if defined (EAGAIN)
|
||||
ENTRY(EAGAIN, "EAGAIN", "No more processes"),
|
||||
#endif
|
||||
#if defined (ENOMEM)
|
||||
ENTRY(ENOMEM, "ENOMEM", "Not enough space"),
|
||||
#endif
|
||||
#if defined (EACCES)
|
||||
ENTRY(EACCES, "EACCES", "Permission denied"),
|
||||
#endif
|
||||
#if defined (EFAULT)
|
||||
ENTRY(EFAULT, "EFAULT", "Bad address"),
|
||||
#endif
|
||||
#if defined (ENOTBLK)
|
||||
ENTRY(ENOTBLK, "ENOTBLK", "Block device required"),
|
||||
#endif
|
||||
#if defined (EBUSY)
|
||||
ENTRY(EBUSY, "EBUSY", "Device busy"),
|
||||
#endif
|
||||
#if defined (EEXIST)
|
||||
ENTRY(EEXIST, "EEXIST", "File exists"),
|
||||
#endif
|
||||
#if defined (EXDEV)
|
||||
ENTRY(EXDEV, "EXDEV", "Cross-device link"),
|
||||
#endif
|
||||
#if defined (ENODEV)
|
||||
ENTRY(ENODEV, "ENODEV", "No such device"),
|
||||
#endif
|
||||
#if defined (ENOTDIR)
|
||||
ENTRY(ENOTDIR, "ENOTDIR", "Not a directory"),
|
||||
#endif
|
||||
#if defined (EISDIR)
|
||||
ENTRY(EISDIR, "EISDIR", "Is a directory"),
|
||||
#endif
|
||||
#if defined (EINVAL)
|
||||
ENTRY(EINVAL, "EINVAL", "Invalid argument"),
|
||||
#endif
|
||||
#if defined (ENFILE)
|
||||
ENTRY(ENFILE, "ENFILE", "File table overflow"),
|
||||
#endif
|
||||
#if defined (EMFILE)
|
||||
ENTRY(EMFILE, "EMFILE", "Too many open files"),
|
||||
#endif
|
||||
#if defined (ENOTTY)
|
||||
ENTRY(ENOTTY, "ENOTTY", "Not a typewriter"),
|
||||
#endif
|
||||
#if defined (ETXTBSY)
|
||||
ENTRY(ETXTBSY, "ETXTBSY", "Text file busy"),
|
||||
#endif
|
||||
#if defined (EFBIG)
|
||||
ENTRY(EFBIG, "EFBIG", "File too large"),
|
||||
#endif
|
||||
#if defined (ENOSPC)
|
||||
ENTRY(ENOSPC, "ENOSPC", "No space left on device"),
|
||||
#endif
|
||||
#if defined (ESPIPE)
|
||||
ENTRY(ESPIPE, "ESPIPE", "Illegal seek"),
|
||||
#endif
|
||||
#if defined (EROFS)
|
||||
ENTRY(EROFS, "EROFS", "Read-only file system"),
|
||||
#endif
|
||||
#if defined (EMLINK)
|
||||
ENTRY(EMLINK, "EMLINK", "Too many links"),
|
||||
#endif
|
||||
#if defined (EPIPE)
|
||||
ENTRY(EPIPE, "EPIPE", "Broken pipe"),
|
||||
#endif
|
||||
#if defined (EDOM)
|
||||
ENTRY(EDOM, "EDOM", "Math argument out of domain of func"),
|
||||
#endif
|
||||
#if defined (ERANGE)
|
||||
ENTRY(ERANGE, "ERANGE", "Math result not representable"),
|
||||
#endif
|
||||
#if defined (ENOMSG)
|
||||
ENTRY(ENOMSG, "ENOMSG", "No message of desired type"),
|
||||
#endif
|
||||
#if defined (EIDRM)
|
||||
ENTRY(EIDRM, "EIDRM", "Identifier removed"),
|
||||
#endif
|
||||
#if defined (ECHRNG)
|
||||
ENTRY(ECHRNG, "ECHRNG", "Channel number out of range"),
|
||||
#endif
|
||||
#if defined (EL2NSYNC)
|
||||
ENTRY(EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized"),
|
||||
#endif
|
||||
#if defined (EL3HLT)
|
||||
ENTRY(EL3HLT, "EL3HLT", "Level 3 halted"),
|
||||
#endif
|
||||
#if defined (EL3RST)
|
||||
ENTRY(EL3RST, "EL3RST", "Level 3 reset"),
|
||||
#endif
|
||||
#if defined (ELNRNG)
|
||||
ENTRY(ELNRNG, "ELNRNG", "Link number out of range"),
|
||||
#endif
|
||||
#if defined (EUNATCH)
|
||||
ENTRY(EUNATCH, "EUNATCH", "Protocol driver not attached"),
|
||||
#endif
|
||||
#if defined (ENOCSI)
|
||||
ENTRY(ENOCSI, "ENOCSI", "No CSI structure available"),
|
||||
#endif
|
||||
#if defined (EL2HLT)
|
||||
ENTRY(EL2HLT, "EL2HLT", "Level 2 halted"),
|
||||
#endif
|
||||
#if defined (EDEADLK)
|
||||
ENTRY(EDEADLK, "EDEADLK", "Deadlock condition"),
|
||||
#endif
|
||||
#if defined (ENOLCK)
|
||||
ENTRY(ENOLCK, "ENOLCK", "No record locks available"),
|
||||
#endif
|
||||
#if defined (EBADE)
|
||||
ENTRY(EBADE, "EBADE", "Invalid exchange"),
|
||||
#endif
|
||||
#if defined (EBADR)
|
||||
ENTRY(EBADR, "EBADR", "Invalid request descriptor"),
|
||||
#endif
|
||||
#if defined (EXFULL)
|
||||
ENTRY(EXFULL, "EXFULL", "Exchange full"),
|
||||
#endif
|
||||
#if defined (ENOANO)
|
||||
ENTRY(ENOANO, "ENOANO", "No anode"),
|
||||
#endif
|
||||
#if defined (EBADRQC)
|
||||
ENTRY(EBADRQC, "EBADRQC", "Invalid request code"),
|
||||
#endif
|
||||
#if defined (EBADSLT)
|
||||
ENTRY(EBADSLT, "EBADSLT", "Invalid slot"),
|
||||
#endif
|
||||
#if defined (EDEADLOCK)
|
||||
ENTRY(EDEADLOCK, "EDEADLOCK", "File locking deadlock error"),
|
||||
#endif
|
||||
#if defined (EBFONT)
|
||||
ENTRY(EBFONT, "EBFONT", "Bad font file format"),
|
||||
#endif
|
||||
#if defined (ENOSTR)
|
||||
ENTRY(ENOSTR, "ENOSTR", "Device not a stream"),
|
||||
#endif
|
||||
#if defined (ENODATA)
|
||||
ENTRY(ENODATA, "ENODATA", "No data available"),
|
||||
#endif
|
||||
#if defined (ETIME)
|
||||
ENTRY(ETIME, "ETIME", "Timer expired"),
|
||||
#endif
|
||||
#if defined (ENOSR)
|
||||
ENTRY(ENOSR, "ENOSR", "Out of streams resources"),
|
||||
#endif
|
||||
#if defined (ENONET)
|
||||
ENTRY(ENONET, "ENONET", "Machine is not on the network"),
|
||||
#endif
|
||||
#if defined (ENOPKG)
|
||||
ENTRY(ENOPKG, "ENOPKG", "Package not installed"),
|
||||
#endif
|
||||
#if defined (EREMOTE)
|
||||
ENTRY(EREMOTE, "EREMOTE", "Object is remote"),
|
||||
#endif
|
||||
#if defined (ENOLINK)
|
||||
ENTRY(ENOLINK, "ENOLINK", "Link has been severed"),
|
||||
#endif
|
||||
#if defined (EADV)
|
||||
ENTRY(EADV, "EADV", "Advertise error"),
|
||||
#endif
|
||||
#if defined (ESRMNT)
|
||||
ENTRY(ESRMNT, "ESRMNT", "Srmount error"),
|
||||
#endif
|
||||
#if defined (ECOMM)
|
||||
ENTRY(ECOMM, "ECOMM", "Communication error on send"),
|
||||
#endif
|
||||
#if defined (EPROTO)
|
||||
ENTRY(EPROTO, "EPROTO", "Protocol error"),
|
||||
#endif
|
||||
#if defined (EMULTIHOP)
|
||||
ENTRY(EMULTIHOP, "EMULTIHOP", "Multihop attempted"),
|
||||
#endif
|
||||
#if defined (EDOTDOT)
|
||||
ENTRY(EDOTDOT, "EDOTDOT", "RFS specific error"),
|
||||
#endif
|
||||
#if defined (EBADMSG)
|
||||
ENTRY(EBADMSG, "EBADMSG", "Not a data message"),
|
||||
#endif
|
||||
#if defined (ENAMETOOLONG)
|
||||
ENTRY(ENAMETOOLONG, "ENAMETOOLONG", "File name too long"),
|
||||
#endif
|
||||
#if defined (EOVERFLOW)
|
||||
ENTRY(EOVERFLOW, "EOVERFLOW", "Value too large for defined data type"),
|
||||
#endif
|
||||
#if defined (ENOTUNIQ)
|
||||
ENTRY(ENOTUNIQ, "ENOTUNIQ", "Name not unique on network"),
|
||||
#endif
|
||||
#if defined (EBADFD)
|
||||
ENTRY(EBADFD, "EBADFD", "File descriptor in bad state"),
|
||||
#endif
|
||||
#if defined (EREMCHG)
|
||||
ENTRY(EREMCHG, "EREMCHG", "Remote address changed"),
|
||||
#endif
|
||||
#if defined (ELIBACC)
|
||||
ENTRY(ELIBACC, "ELIBACC", "Can not access a needed shared library"),
|
||||
#endif
|
||||
#if defined (ELIBBAD)
|
||||
ENTRY(ELIBBAD, "ELIBBAD", "Accessing a corrupted shared library"),
|
||||
#endif
|
||||
#if defined (ELIBSCN)
|
||||
ENTRY(ELIBSCN, "ELIBSCN", ".lib section in a.out corrupted"),
|
||||
#endif
|
||||
#if defined (ELIBMAX)
|
||||
ENTRY(ELIBMAX, "ELIBMAX", "Attempting to link in too many shared libraries"),
|
||||
#endif
|
||||
#if defined (ELIBEXEC)
|
||||
ENTRY(ELIBEXEC, "ELIBEXEC", "Cannot exec a shared library directly"),
|
||||
#endif
|
||||
#if defined (EILSEQ)
|
||||
ENTRY(EILSEQ, "EILSEQ", "Illegal byte sequence"),
|
||||
#endif
|
||||
#if defined (ENOSYS)
|
||||
ENTRY(ENOSYS, "ENOSYS", "Operation not applicable"),
|
||||
#endif
|
||||
#if defined (ELOOP)
|
||||
ENTRY(ELOOP, "ELOOP", "Too many symbolic links encountered"),
|
||||
#endif
|
||||
#if defined (ERESTART)
|
||||
ENTRY(ERESTART, "ERESTART", "Interrupted system call should be restarted"),
|
||||
#endif
|
||||
#if defined (ESTRPIPE)
|
||||
ENTRY(ESTRPIPE, "ESTRPIPE", "Streams pipe error"),
|
||||
#endif
|
||||
#if defined (ENOTEMPTY)
|
||||
ENTRY(ENOTEMPTY, "ENOTEMPTY", "Directory not empty"),
|
||||
#endif
|
||||
#if defined (EUSERS)
|
||||
ENTRY(EUSERS, "EUSERS", "Too many users"),
|
||||
#endif
|
||||
#if defined (ENOTSOCK)
|
||||
ENTRY(ENOTSOCK, "ENOTSOCK", "Socket operation on non-socket"),
|
||||
#endif
|
||||
#if defined (EDESTADDRREQ)
|
||||
ENTRY(EDESTADDRREQ, "EDESTADDRREQ", "Destination address required"),
|
||||
#endif
|
||||
#if defined (EMSGSIZE)
|
||||
ENTRY(EMSGSIZE, "EMSGSIZE", "Message too long"),
|
||||
#endif
|
||||
#if defined (EPROTOTYPE)
|
||||
ENTRY(EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"),
|
||||
#endif
|
||||
#if defined (ENOPROTOOPT)
|
||||
ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"),
|
||||
#endif
|
||||
#if defined (EPROTONOSUPPORT)
|
||||
ENTRY(EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"),
|
||||
#endif
|
||||
#if defined (ESOCKTNOSUPPORT)
|
||||
ENTRY(ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "Socket type not supported"),
|
||||
#endif
|
||||
#if defined (EOPNOTSUPP)
|
||||
ENTRY(EOPNOTSUPP, "EOPNOTSUPP", "Operation not supported on transport endpoint"),
|
||||
#endif
|
||||
#if defined (EPFNOSUPPORT)
|
||||
ENTRY(EPFNOSUPPORT, "EPFNOSUPPORT", "Protocol family not supported"),
|
||||
#endif
|
||||
#if defined (EAFNOSUPPORT)
|
||||
ENTRY(EAFNOSUPPORT, "EAFNOSUPPORT", "Address family not supported by protocol"),
|
||||
#endif
|
||||
#if defined (EADDRINUSE)
|
||||
ENTRY(EADDRINUSE, "EADDRINUSE", "Address already in use"),
|
||||
#endif
|
||||
#if defined (EADDRNOTAVAIL)
|
||||
ENTRY(EADDRNOTAVAIL, "EADDRNOTAVAIL","Cannot assign requested address"),
|
||||
#endif
|
||||
#if defined (ENETDOWN)
|
||||
ENTRY(ENETDOWN, "ENETDOWN", "Network is down"),
|
||||
#endif
|
||||
#if defined (ENETUNREACH)
|
||||
ENTRY(ENETUNREACH, "ENETUNREACH", "Network is unreachable"),
|
||||
#endif
|
||||
#if defined (ENETRESET)
|
||||
ENTRY(ENETRESET, "ENETRESET", "Network dropped connection because of reset"),
|
||||
#endif
|
||||
#if defined (ECONNABORTED)
|
||||
ENTRY(ECONNABORTED, "ECONNABORTED", "Software caused connection abort"),
|
||||
#endif
|
||||
#if defined (ECONNRESET)
|
||||
ENTRY(ECONNRESET, "ECONNRESET", "Connection reset by peer"),
|
||||
#endif
|
||||
#if defined (ENOBUFS)
|
||||
ENTRY(ENOBUFS, "ENOBUFS", "No buffer space available"),
|
||||
#endif
|
||||
#if defined (EISCONN)
|
||||
ENTRY(EISCONN, "EISCONN", "Transport endpoint is already connected"),
|
||||
#endif
|
||||
#if defined (ENOTCONN)
|
||||
ENTRY(ENOTCONN, "ENOTCONN", "Transport endpoint is not connected"),
|
||||
#endif
|
||||
#if defined (ESHUTDOWN)
|
||||
ENTRY(ESHUTDOWN, "ESHUTDOWN", "Cannot send after transport endpoint shutdown"),
|
||||
#endif
|
||||
#if defined (ETOOMANYREFS)
|
||||
ENTRY(ETOOMANYREFS, "ETOOMANYREFS", "Too many references: cannot splice"),
|
||||
#endif
|
||||
#if defined (ETIMEDOUT)
|
||||
ENTRY(ETIMEDOUT, "ETIMEDOUT", "Connection timed out"),
|
||||
#endif
|
||||
#if defined (ECONNREFUSED)
|
||||
ENTRY(ECONNREFUSED, "ECONNREFUSED", "Connection refused"),
|
||||
#endif
|
||||
#if defined (EHOSTDOWN)
|
||||
ENTRY(EHOSTDOWN, "EHOSTDOWN", "Host is down"),
|
||||
#endif
|
||||
#if defined (EHOSTUNREACH)
|
||||
ENTRY(EHOSTUNREACH, "EHOSTUNREACH", "No route to host"),
|
||||
#endif
|
||||
#if defined (EALREADY)
|
||||
ENTRY(EALREADY, "EALREADY", "Operation already in progress"),
|
||||
#endif
|
||||
#if defined (EINPROGRESS)
|
||||
ENTRY(EINPROGRESS, "EINPROGRESS", "Operation now in progress"),
|
||||
#endif
|
||||
#if defined (ESTALE)
|
||||
ENTRY(ESTALE, "ESTALE", "Stale NFS file handle"),
|
||||
#endif
|
||||
#if defined (EUCLEAN)
|
||||
ENTRY(EUCLEAN, "EUCLEAN", "Structure needs cleaning"),
|
||||
#endif
|
||||
#if defined (ENOTNAM)
|
||||
ENTRY(ENOTNAM, "ENOTNAM", "Not a XENIX named type file"),
|
||||
#endif
|
||||
#if defined (ENAVAIL)
|
||||
ENTRY(ENAVAIL, "ENAVAIL", "No XENIX semaphores available"),
|
||||
#endif
|
||||
#if defined (EISNAM)
|
||||
ENTRY(EISNAM, "EISNAM", "Is a named type file"),
|
||||
#endif
|
||||
#if defined (EREMOTEIO)
|
||||
ENTRY(EREMOTEIO, "EREMOTEIO", "Remote I/O error"),
|
||||
#endif
|
||||
ENTRY(0, NULL, NULL)
|
||||
};
|
||||
|
||||
#ifdef EVMSERR
|
||||
/* This is not in the table, because the numeric value of EVMSERR (32767)
|
||||
lies outside the range of sys_errlist[]. */
|
||||
static struct { int value; const char *name, *msg; }
|
||||
evmserr = { EVMSERR, "EVMSERR", "VMS-specific error" };
|
||||
#endif
|
||||
|
||||
/* Translation table allocated and initialized at runtime. Indexed by the
|
||||
errno value to find the equivalent symbolic value. */
|
||||
|
||||
static const char **error_names;
|
||||
static int num_error_names = 0;
|
||||
|
||||
/* Translation table allocated and initialized at runtime, if it does not
|
||||
already exist in the host environment. Indexed by the errno value to find
|
||||
the descriptive string.
|
||||
|
||||
We don't export it for use in other modules because even though it has the
|
||||
same name, it differs from other implementations in that it is dynamically
|
||||
initialized rather than statically initialized. */
|
||||
|
||||
#ifndef HAVE_SYS_ERRLIST
|
||||
|
||||
static int sys_nerr;
|
||||
static const char **sys_errlist;
|
||||
|
||||
#else
|
||||
|
||||
extern int sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
init_error_tables -- initialize the name and message tables
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
static void init_error_tables ();
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Using the error_table, which is initialized at compile time, generate
|
||||
the error_names and the sys_errlist (if needed) tables, which are
|
||||
indexed at runtime by a specific errno value.
|
||||
|
||||
BUGS
|
||||
|
||||
The initialization of the tables may fail under low memory conditions,
|
||||
in which case we don't do anything particularly useful, but we don't
|
||||
bomb either. Who knows, it might succeed at a later point if we free
|
||||
some memory in the meantime. In any case, the other routines know
|
||||
how to deal with lack of a table after trying to initialize it. This
|
||||
may or may not be considered to be a bug, that we don't specifically
|
||||
warn about this particular failure mode.
|
||||
|
||||
*/
|
||||
|
||||
static void
|
||||
init_error_tables ()
|
||||
{
|
||||
const struct error_info *eip;
|
||||
int nbytes;
|
||||
|
||||
/* If we haven't already scanned the error_table once to find the maximum
|
||||
errno value, then go find it now. */
|
||||
|
||||
if (num_error_names == 0)
|
||||
{
|
||||
for (eip = error_table; eip -> name != NULL; eip++)
|
||||
{
|
||||
if (eip -> value >= num_error_names)
|
||||
{
|
||||
num_error_names = eip -> value + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Now attempt to allocate the error_names table, zero it out, and then
|
||||
initialize it from the statically initialized error_table. */
|
||||
|
||||
if (error_names == NULL)
|
||||
{
|
||||
nbytes = num_error_names * sizeof (char *);
|
||||
if ((error_names = (const char **) malloc (nbytes)) != NULL)
|
||||
{
|
||||
memset (error_names, 0, nbytes);
|
||||
for (eip = error_table; eip -> name != NULL; eip++)
|
||||
{
|
||||
error_names[eip -> value] = eip -> name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HAVE_SYS_ERRLIST
|
||||
|
||||
/* Now attempt to allocate the sys_errlist table, zero it out, and then
|
||||
initialize it from the statically initialized error_table. */
|
||||
|
||||
if (sys_errlist == NULL)
|
||||
{
|
||||
nbytes = num_error_names * sizeof (char *);
|
||||
if ((sys_errlist = (const char **) malloc (nbytes)) != NULL)
|
||||
{
|
||||
memset (sys_errlist, 0, nbytes);
|
||||
sys_nerr = num_error_names;
|
||||
for (eip = error_table; eip -> name != NULL; eip++)
|
||||
{
|
||||
sys_errlist[eip -> value] = eip -> msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
errno_max -- return the max errno value
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
int errno_max ();
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
errno_max ()
|
||||
{
|
||||
int maxsize;
|
||||
|
||||
if (error_names == NULL)
|
||||
{
|
||||
init_error_tables ();
|
||||
}
|
||||
maxsize = MAX (sys_nerr, num_error_names);
|
||||
return (maxsize - 1);
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRERROR
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
strerror -- map an error number to an error message string
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
char *strerror (int errnoval)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
char *
|
||||
strerror (errnoval)
|
||||
int errnoval;
|
||||
{
|
||||
char *msg;
|
||||
static char buf[32];
|
||||
|
||||
#ifndef HAVE_SYS_ERRLIST
|
||||
|
||||
if (error_names == NULL)
|
||||
{
|
||||
init_error_tables ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if ((errnoval < 0) || (errnoval >= sys_nerr))
|
||||
{
|
||||
#ifdef EVMSERR
|
||||
if (errnoval == evmserr.value)
|
||||
msg = evmserr.msg;
|
||||
else
|
||||
#endif
|
||||
/* Out of range, just return NULL */
|
||||
msg = NULL;
|
||||
}
|
||||
else if ((sys_errlist == NULL) || (sys_errlist[errnoval] == NULL))
|
||||
{
|
||||
/* In range, but no sys_errlist or no entry at this index. */
|
||||
sprintf (buf, "Error %d", errnoval);
|
||||
msg = buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* In range, and a valid message. Just return the message. */
|
||||
msg = (char *) sys_errlist[errnoval];
|
||||
}
|
||||
|
||||
return (msg);
|
||||
}
|
||||
|
||||
#endif /* ! HAVE_STRERROR */
|
||||
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
strerrno -- map an error number to a symbolic name string
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
const char *strerrno (int errnoval)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
const char *
|
||||
strerrno (errnoval)
|
||||
int errnoval;
|
||||
{
|
||||
const char *name;
|
||||
static char buf[32];
|
||||
|
||||
if (error_names == NULL)
|
||||
{
|
||||
init_error_tables ();
|
||||
}
|
||||
|
||||
if ((errnoval < 0) || (errnoval >= num_error_names))
|
||||
{
|
||||
#ifdef EVMSERR
|
||||
if (errnoval == evmserr.value)
|
||||
name = evmserr.name;
|
||||
else
|
||||
#endif
|
||||
/* Out of range, just return NULL */
|
||||
name = NULL;
|
||||
}
|
||||
else if ((error_names == NULL) || (error_names[errnoval] == NULL))
|
||||
{
|
||||
/* In range, but no error_names or no entry at this index. */
|
||||
sprintf (buf, "Error %d", errnoval);
|
||||
name = (const char *) buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* In range, and a valid name. Just return the name. */
|
||||
name = error_names[errnoval];
|
||||
}
|
||||
|
||||
return (name);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
strtoerrno -- map a symbolic errno name to a numeric value
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
strtoerrno (name)
|
||||
const char *name;
|
||||
{
|
||||
int errnoval = 0;
|
||||
|
||||
if (name != NULL)
|
||||
{
|
||||
if (error_names == NULL)
|
||||
{
|
||||
init_error_tables ();
|
||||
}
|
||||
for (errnoval = 0; errnoval < num_error_names; errnoval++)
|
||||
{
|
||||
if ((error_names[errnoval] != NULL) &&
|
||||
(strcmp (name, error_names[errnoval]) == 0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (errnoval == num_error_names)
|
||||
{
|
||||
#ifdef EVMSERR
|
||||
if (strcmp (name, evmserr.name) == 0)
|
||||
errnoval = evmserr.value;
|
||||
else
|
||||
#endif
|
||||
errnoval = 0;
|
||||
}
|
||||
}
|
||||
return (errnoval);
|
||||
}
|
||||
|
||||
|
||||
/* A simple little main that does nothing but print all the errno translations
|
||||
if MAIN is defined and this file is compiled and linked. */
|
||||
|
||||
#ifdef MAIN
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int errn;
|
||||
int errnmax;
|
||||
const char *name;
|
||||
char *msg;
|
||||
char *strerror ();
|
||||
|
||||
errnmax = errno_max ();
|
||||
printf ("%d entries in names table.\n", num_error_names);
|
||||
printf ("%d entries in messages table.\n", sys_nerr);
|
||||
printf ("%d is max useful index.\n", errnmax);
|
||||
|
||||
/* Keep printing values until we get to the end of *both* tables, not
|
||||
*either* table. Note that knowing the maximum useful index does *not*
|
||||
relieve us of the responsibility of testing the return pointer for
|
||||
NULL. */
|
||||
|
||||
for (errn = 0; errn <= errnmax; errn++)
|
||||
{
|
||||
name = strerrno (errn);
|
||||
name = (name == NULL) ? "<NULL>" : name;
|
||||
msg = strerror (errn);
|
||||
msg = (msg == NULL) ? "<NULL>" : msg;
|
||||
printf ("%-4d%-18s%s\n", errn, name, msg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1987 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of California at Berkeley. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific written prior permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <ansidecl.h>
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#define size_t unsigned long
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This array is designed for mapping upper and lower case letter
|
||||
* together for a case independent comparison. The mappings are
|
||||
* based upon ascii character sequences.
|
||||
*/
|
||||
static unsigned char charmap[] = {
|
||||
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
|
||||
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
|
||||
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
|
||||
'\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
|
||||
'\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
|
||||
'\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
|
||||
'\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
|
||||
'\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
|
||||
'\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
|
||||
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
|
||||
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
|
||||
'\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
|
||||
'\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
|
||||
'\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
|
||||
'\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
|
||||
'\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
|
||||
'\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
|
||||
'\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
|
||||
'\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
|
||||
'\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
|
||||
'\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
|
||||
'\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
|
||||
'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
|
||||
'\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
|
||||
'\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
|
||||
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
|
||||
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
|
||||
'\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
|
||||
'\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
|
||||
'\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
|
||||
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
|
||||
'\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
|
||||
};
|
||||
|
||||
int
|
||||
strncasecmp(s1, s2, n)
|
||||
const char *s1, *s2;
|
||||
register size_t n;
|
||||
{
|
||||
register unsigned char u1, u2;
|
||||
|
||||
for (; n != 0; --n) {
|
||||
u1 = (unsigned char) *s1++;
|
||||
u2 = (unsigned char) *s2++;
|
||||
if (charmap[u1] != charmap[u2]) {
|
||||
return charmap[u1] - charmap[u2];
|
||||
}
|
||||
if (u1 == '\0') {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/* Portable version of strrchr().
|
||||
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)
|
||||
|
||||
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>
|
||||
|
||||
char *
|
||||
strrchr (s, c)
|
||||
register const char *s;
|
||||
int c;
|
||||
{
|
||||
char *rtnval = 0;
|
||||
|
||||
do {
|
||||
if (*s == c)
|
||||
rtnval = (char*) s;
|
||||
} while (*s++);
|
||||
return (rtnval);
|
||||
}
|
||||
|
|
@ -1,644 +0,0 @@
|
|||
/* Extended support for using signal values.
|
||||
Written by Fred Fish. fnf@cygnus.com
|
||||
This file is in the public domain. */
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/* We need to declare sys_siglist, because even if the system provides
|
||||
it we can't assume that it is declared in <signal.h> (for example,
|
||||
SunOS provides sys_siglist, but it does not declare it in any
|
||||
header file). fHowever, we can't declare sys_siglist portably,
|
||||
because on some systems it is declared with const and on some
|
||||
systems it is declared without const. If we were using autoconf,
|
||||
we could work out the right declaration. Until, then we just
|
||||
ignore any declaration in the system header files, and always
|
||||
declare it ourselves. With luck, this will always work. */
|
||||
#define sys_siglist no_such_symbol
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
/* Routines imported from standard C runtime libraries. */
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
extern void *malloc (size_t size); /* 4.10.3.3 */
|
||||
extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */
|
||||
#else /* !__STDC__ */
|
||||
extern char *malloc (); /* Standard memory allocater */
|
||||
extern char *memset ();
|
||||
#endif /* __STDC__ */
|
||||
|
||||
/* Undefine the macro we used to hide the definition of sys_siglist
|
||||
found in the system header files. */
|
||||
#undef sys_siglist
|
||||
|
||||
#ifndef NULL
|
||||
# ifdef __STDC__
|
||||
# define NULL (void *) 0
|
||||
# else
|
||||
# define NULL 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
# define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
static void init_signal_tables PARAMS ((void));
|
||||
|
||||
/* Translation table for signal values.
|
||||
|
||||
Note that this table is generally only accessed when it is used at runtime
|
||||
to initialize signal name and message tables that are indexed by signal
|
||||
value.
|
||||
|
||||
Not all of these signals will exist on all systems. This table is the only
|
||||
thing that should have to be updated as new signal numbers are introduced.
|
||||
It's sort of ugly, but at least its portable. */
|
||||
|
||||
struct signal_info
|
||||
{
|
||||
int value; /* The numeric value from <signal.h> */
|
||||
const char *name; /* The equivalent symbolic value */
|
||||
#ifndef HAVE_SYS_SIGLIST
|
||||
const char *msg; /* Short message about this value */
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef HAVE_SYS_SIGLIST
|
||||
# define ENTRY(value, name, msg) {value, name, msg}
|
||||
#else
|
||||
# define ENTRY(value, name, msg) {value, name}
|
||||
#endif
|
||||
|
||||
static const struct signal_info signal_table[] =
|
||||
{
|
||||
#if defined (SIGHUP)
|
||||
ENTRY(SIGHUP, "SIGHUP", "Hangup"),
|
||||
#endif
|
||||
#if defined (SIGINT)
|
||||
ENTRY(SIGINT, "SIGINT", "Interrupt"),
|
||||
#endif
|
||||
#if defined (SIGQUIT)
|
||||
ENTRY(SIGQUIT, "SIGQUIT", "Quit"),
|
||||
#endif
|
||||
#if defined (SIGILL)
|
||||
ENTRY(SIGILL, "SIGILL", "Illegal instruction"),
|
||||
#endif
|
||||
#if defined (SIGTRAP)
|
||||
ENTRY(SIGTRAP, "SIGTRAP", "Trace/breakpoint trap"),
|
||||
#endif
|
||||
/* Put SIGIOT before SIGABRT, so that if SIGIOT==SIGABRT then SIGABRT
|
||||
overrides SIGIOT. SIGABRT is in ANSI and POSIX.1, and SIGIOT isn't. */
|
||||
#if defined (SIGIOT)
|
||||
ENTRY(SIGIOT, "SIGIOT", "IOT trap"),
|
||||
#endif
|
||||
#if defined (SIGABRT)
|
||||
ENTRY(SIGABRT, "SIGABRT", "Aborted"),
|
||||
#endif
|
||||
#if defined (SIGEMT)
|
||||
ENTRY(SIGEMT, "SIGEMT", "Emulation trap"),
|
||||
#endif
|
||||
#if defined (SIGFPE)
|
||||
ENTRY(SIGFPE, "SIGFPE", "Arithmetic exception"),
|
||||
#endif
|
||||
#if defined (SIGKILL)
|
||||
ENTRY(SIGKILL, "SIGKILL", "Killed"),
|
||||
#endif
|
||||
#if defined (SIGBUS)
|
||||
ENTRY(SIGBUS, "SIGBUS", "Bus error"),
|
||||
#endif
|
||||
#if defined (SIGSEGV)
|
||||
ENTRY(SIGSEGV, "SIGSEGV", "Segmentation fault"),
|
||||
#endif
|
||||
#if defined (SIGSYS)
|
||||
ENTRY(SIGSYS, "SIGSYS", "Bad system call"),
|
||||
#endif
|
||||
#if defined (SIGPIPE)
|
||||
ENTRY(SIGPIPE, "SIGPIPE", "Broken pipe"),
|
||||
#endif
|
||||
#if defined (SIGALRM)
|
||||
ENTRY(SIGALRM, "SIGALRM", "Alarm clock"),
|
||||
#endif
|
||||
#if defined (SIGTERM)
|
||||
ENTRY(SIGTERM, "SIGTERM", "Terminated"),
|
||||
#endif
|
||||
#if defined (SIGUSR1)
|
||||
ENTRY(SIGUSR1, "SIGUSR1", "User defined signal 1"),
|
||||
#endif
|
||||
#if defined (SIGUSR2)
|
||||
ENTRY(SIGUSR2, "SIGUSR2", "User defined signal 2"),
|
||||
#endif
|
||||
/* Put SIGCLD before SIGCHLD, so that if SIGCLD==SIGCHLD then SIGCHLD
|
||||
overrides SIGCLD. SIGCHLD is in POXIX.1 */
|
||||
#if defined (SIGCLD)
|
||||
ENTRY(SIGCLD, "SIGCLD", "Child status changed"),
|
||||
#endif
|
||||
#if defined (SIGCHLD)
|
||||
ENTRY(SIGCHLD, "SIGCHLD", "Child status changed"),
|
||||
#endif
|
||||
#if defined (SIGPWR)
|
||||
ENTRY(SIGPWR, "SIGPWR", "Power fail/restart"),
|
||||
#endif
|
||||
#if defined (SIGWINCH)
|
||||
ENTRY(SIGWINCH, "SIGWINCH", "Window size changed"),
|
||||
#endif
|
||||
#if defined (SIGURG)
|
||||
ENTRY(SIGURG, "SIGURG", "Urgent I/O condition"),
|
||||
#endif
|
||||
#if defined (SIGIO)
|
||||
/* "I/O pending" has also been suggested, but is misleading since the
|
||||
signal only happens when the process has asked for it, not everytime
|
||||
I/O is pending. */
|
||||
ENTRY(SIGIO, "SIGIO", "I/O possible"),
|
||||
#endif
|
||||
#if defined (SIGPOLL)
|
||||
ENTRY(SIGPOLL, "SIGPOLL", "Pollable event occurred"),
|
||||
#endif
|
||||
#if defined (SIGSTOP)
|
||||
ENTRY(SIGSTOP, "SIGSTOP", "Stopped (signal)"),
|
||||
#endif
|
||||
#if defined (SIGTSTP)
|
||||
ENTRY(SIGTSTP, "SIGTSTP", "Stopped (user)"),
|
||||
#endif
|
||||
#if defined (SIGCONT)
|
||||
ENTRY(SIGCONT, "SIGCONT", "Continued"),
|
||||
#endif
|
||||
#if defined (SIGTTIN)
|
||||
ENTRY(SIGTTIN, "SIGTTIN", "Stopped (tty input)"),
|
||||
#endif
|
||||
#if defined (SIGTTOU)
|
||||
ENTRY(SIGTTOU, "SIGTTOU", "Stopped (tty output)"),
|
||||
#endif
|
||||
#if defined (SIGVTALRM)
|
||||
ENTRY(SIGVTALRM, "SIGVTALRM", "Virtual timer expired"),
|
||||
#endif
|
||||
#if defined (SIGPROF)
|
||||
ENTRY(SIGPROF, "SIGPROF", "Profiling timer expired"),
|
||||
#endif
|
||||
#if defined (SIGXCPU)
|
||||
ENTRY(SIGXCPU, "SIGXCPU", "CPU time limit exceeded"),
|
||||
#endif
|
||||
#if defined (SIGXFSZ)
|
||||
ENTRY(SIGXFSZ, "SIGXFSZ", "File size limit exceeded"),
|
||||
#endif
|
||||
#if defined (SIGWIND)
|
||||
ENTRY(SIGWIND, "SIGWIND", "SIGWIND"),
|
||||
#endif
|
||||
#if defined (SIGPHONE)
|
||||
ENTRY(SIGPHONE, "SIGPHONE", "SIGPHONE"),
|
||||
#endif
|
||||
#if defined (SIGLOST)
|
||||
ENTRY(SIGLOST, "SIGLOST", "Resource lost"),
|
||||
#endif
|
||||
#if defined (SIGWAITING)
|
||||
ENTRY(SIGWAITING, "SIGWAITING", "Process's LWPs are blocked"),
|
||||
#endif
|
||||
#if defined (SIGLWP)
|
||||
ENTRY(SIGLWP, "SIGLWP", "Signal LWP"),
|
||||
#endif
|
||||
#if defined (SIGDANGER)
|
||||
ENTRY(SIGDANGER, "SIGDANGER", "Swap space dangerously low"),
|
||||
#endif
|
||||
#if defined (SIGGRANT)
|
||||
ENTRY(SIGGRANT, "SIGGRANT", "Monitor mode granted"),
|
||||
#endif
|
||||
#if defined (SIGRETRACT)
|
||||
ENTRY(SIGRETRACT, "SIGRETRACT", "Need to relinguish monitor mode"),
|
||||
#endif
|
||||
#if defined (SIGMSG)
|
||||
ENTRY(SIGMSG, "SIGMSG", "Monitor mode data available"),
|
||||
#endif
|
||||
#if defined (SIGSOUND)
|
||||
ENTRY(SIGSOUND, "SIGSOUND", "Sound completed"),
|
||||
#endif
|
||||
#if defined (SIGSAK)
|
||||
ENTRY(SIGSAK, "SIGSAK", "Secure attention"),
|
||||
#endif
|
||||
ENTRY(0, NULL, NULL)
|
||||
};
|
||||
|
||||
/* Translation table allocated and initialized at runtime. Indexed by the
|
||||
signal value to find the equivalent symbolic value. */
|
||||
|
||||
static const char **signal_names;
|
||||
static int num_signal_names = 0;
|
||||
|
||||
/* Translation table allocated and initialized at runtime, if it does not
|
||||
already exist in the host environment. Indexed by the signal value to find
|
||||
the descriptive string.
|
||||
|
||||
We don't export it for use in other modules because even though it has the
|
||||
same name, it differs from other implementations in that it is dynamically
|
||||
initialized rather than statically initialized. */
|
||||
|
||||
#ifndef HAVE_SYS_SIGLIST
|
||||
|
||||
static int sys_nsig;
|
||||
static const char **sys_siglist;
|
||||
|
||||
#else
|
||||
|
||||
#ifdef NSIG
|
||||
static int sys_nsig = NSIG;
|
||||
#else
|
||||
#ifdef _NSIG
|
||||
static int sys_nsig = _NSIG;
|
||||
#endif
|
||||
#endif
|
||||
extern const char * const sys_siglist[];
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
init_signal_tables -- initialize the name and message tables
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
static void init_signal_tables ();
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Using the signal_table, which is initialized at compile time, generate
|
||||
the signal_names and the sys_siglist (if needed) tables, which are
|
||||
indexed at runtime by a specific signal value.
|
||||
|
||||
BUGS
|
||||
|
||||
The initialization of the tables may fail under low memory conditions,
|
||||
in which case we don't do anything particularly useful, but we don't
|
||||
bomb either. Who knows, it might succeed at a later point if we free
|
||||
some memory in the meantime. In any case, the other routines know
|
||||
how to deal with lack of a table after trying to initialize it. This
|
||||
may or may not be considered to be a bug, that we don't specifically
|
||||
warn about this particular failure mode.
|
||||
|
||||
*/
|
||||
|
||||
static void
|
||||
init_signal_tables ()
|
||||
{
|
||||
const struct signal_info *eip;
|
||||
int nbytes;
|
||||
|
||||
/* If we haven't already scanned the signal_table once to find the maximum
|
||||
signal value, then go find it now. */
|
||||
|
||||
if (num_signal_names == 0)
|
||||
{
|
||||
for (eip = signal_table; eip -> name != NULL; eip++)
|
||||
{
|
||||
if (eip -> value >= num_signal_names)
|
||||
{
|
||||
num_signal_names = eip -> value + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Now attempt to allocate the signal_names table, zero it out, and then
|
||||
initialize it from the statically initialized signal_table. */
|
||||
|
||||
if (signal_names == NULL)
|
||||
{
|
||||
nbytes = num_signal_names * sizeof (char *);
|
||||
if ((signal_names = (const char **) malloc (nbytes)) != NULL)
|
||||
{
|
||||
memset (signal_names, 0, nbytes);
|
||||
for (eip = signal_table; eip -> name != NULL; eip++)
|
||||
{
|
||||
signal_names[eip -> value] = eip -> name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HAVE_SYS_SIGLIST
|
||||
|
||||
/* Now attempt to allocate the sys_siglist table, zero it out, and then
|
||||
initialize it from the statically initialized signal_table. */
|
||||
|
||||
if (sys_siglist == NULL)
|
||||
{
|
||||
nbytes = num_signal_names * sizeof (char *);
|
||||
if ((sys_siglist = (const char **) malloc (nbytes)) != NULL)
|
||||
{
|
||||
memset (sys_siglist, 0, nbytes);
|
||||
sys_nsig = num_signal_names;
|
||||
for (eip = signal_table; eip -> name != NULL; eip++)
|
||||
{
|
||||
sys_siglist[eip -> value] = eip -> msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
signo_max -- return the max signo value
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
int signo_max ();
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Returns the maximum signo value for which a corresponding symbolic
|
||||
name or message is available. Note that in the case where
|
||||
we use the sys_siglist 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 psignal(3b) explicitly warns that one
|
||||
should check the size of the table (NSIG) before indexing it,
|
||||
since new signal codes may be added to the system before they are
|
||||
added to the table. Thus NSIG might be smaller than value
|
||||
implied by the largest signo value defined in <signal.h>.
|
||||
|
||||
We return the maximum value that can be used to obtain a meaningful
|
||||
symbolic name or message.
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
signo_max ()
|
||||
{
|
||||
int maxsize;
|
||||
|
||||
if (signal_names == NULL)
|
||||
{
|
||||
init_signal_tables ();
|
||||
}
|
||||
maxsize = MAX (sys_nsig, num_signal_names);
|
||||
return (maxsize - 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
strsignal -- map a signal number to a signal message string
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
const char *strsignal (int signo)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Maps an signal number to an signal message string, the contents of
|
||||
which are implementation defined. On systems which have the external
|
||||
variable sys_siglist, these strings will be the same as the ones used
|
||||
by psignal().
|
||||
|
||||
If the supplied signal number is within the valid range of indices
|
||||
for the sys_siglist, but no message is available for the particular
|
||||
signal number, then returns the string "Signal NUM", where NUM is the
|
||||
signal number.
|
||||
|
||||
If the supplied signal number is not a valid index into sys_siglist,
|
||||
returns NULL.
|
||||
|
||||
The returned string is only guaranteed to be valid only until the
|
||||
next call to strsignal.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef HAVE_STRSIGNAL
|
||||
|
||||
const char *
|
||||
strsignal (signo)
|
||||
int signo;
|
||||
{
|
||||
const char *msg;
|
||||
static char buf[32];
|
||||
|
||||
#ifndef HAVE_SYS_SIGLIST
|
||||
|
||||
if (signal_names == NULL)
|
||||
{
|
||||
init_signal_tables ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if ((signo < 0) || (signo >= sys_nsig))
|
||||
{
|
||||
/* Out of range, just return NULL */
|
||||
msg = NULL;
|
||||
}
|
||||
else if ((sys_siglist == NULL) || (sys_siglist[signo] == NULL))
|
||||
{
|
||||
/* In range, but no sys_siglist or no entry at this index. */
|
||||
sprintf (buf, "Signal %d", signo);
|
||||
msg = (const char *) buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* In range, and a valid message. Just return the message. */
|
||||
msg = (const char *) sys_siglist[signo];
|
||||
}
|
||||
|
||||
return (msg);
|
||||
}
|
||||
|
||||
#endif /* ! HAVE_STRSIGNAL */
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
strsigno -- map an signal number to a symbolic name string
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
const char *strsigno (int signo)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Given an signal number, returns a pointer to a string containing
|
||||
the symbolic name of that signal number, as found in <signal.h>.
|
||||
|
||||
If the supplied signal number is within the valid range of indices
|
||||
for symbolic names, but no name is available for the particular
|
||||
signal number, then returns the string "Signal NUM", where NUM is
|
||||
the signal number.
|
||||
|
||||
If the supplied signal 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 strsigno.
|
||||
|
||||
*/
|
||||
|
||||
const char *
|
||||
strsigno (signo)
|
||||
int signo;
|
||||
{
|
||||
const char *name;
|
||||
static char buf[32];
|
||||
|
||||
if (signal_names == NULL)
|
||||
{
|
||||
init_signal_tables ();
|
||||
}
|
||||
|
||||
if ((signo < 0) || (signo >= num_signal_names))
|
||||
{
|
||||
/* Out of range, just return NULL */
|
||||
name = NULL;
|
||||
}
|
||||
else if ((signal_names == NULL) || (signal_names[signo] == NULL))
|
||||
{
|
||||
/* In range, but no signal_names or no entry at this index. */
|
||||
sprintf (buf, "Signal %d", signo);
|
||||
name = (const char *) buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* In range, and a valid name. Just return the name. */
|
||||
name = signal_names[signo];
|
||||
}
|
||||
|
||||
return (name);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
strtosigno -- map a symbolic signal name to a numeric value
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
int strtosigno (char *name)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Given the symbolic name of a signal, map it to a signal number.
|
||||
If no translation is found, returns 0.
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
strtosigno (name)
|
||||
const char *name;
|
||||
{
|
||||
int signo = 0;
|
||||
|
||||
if (name != NULL)
|
||||
{
|
||||
if (signal_names == NULL)
|
||||
{
|
||||
init_signal_tables ();
|
||||
}
|
||||
for (signo = 0; signo < num_signal_names; signo++)
|
||||
{
|
||||
if ((signal_names[signo] != NULL) &&
|
||||
(strcmp (name, signal_names[signo]) == 0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (signo == num_signal_names)
|
||||
{
|
||||
signo = 0;
|
||||
}
|
||||
}
|
||||
return (signo);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
psignal -- print message about signal to stderr
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
void psignal (unsigned signo, char *message);
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Print to the standard error the message, followed by a colon,
|
||||
followed by the description of the signal specified by signo,
|
||||
followed by a newline.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_PSIGNAL
|
||||
|
||||
void
|
||||
psignal (signo, message)
|
||||
unsigned signo;
|
||||
char *message;
|
||||
{
|
||||
if (signal_names == NULL)
|
||||
{
|
||||
init_signal_tables ();
|
||||
}
|
||||
if ((signo <= 0) || (signo >= sys_nsig))
|
||||
{
|
||||
fprintf (stderr, "%s: unknown signal\n", message);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s: %s\n", message, sys_siglist[signo]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ! HAVE_PSIGNAL */
|
||||
|
||||
|
||||
/* A simple little main that does nothing but print all the signal translations
|
||||
if MAIN is defined and this file is compiled and linked. */
|
||||
|
||||
#ifdef MAIN
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int signo;
|
||||
int maxsigno;
|
||||
const char *name;
|
||||
const char *msg;
|
||||
|
||||
maxsigno = signo_max ();
|
||||
printf ("%d entries in names table.\n", num_signal_names);
|
||||
printf ("%d entries in messages table.\n", sys_nsig);
|
||||
printf ("%d is max useful index.\n", maxsigno);
|
||||
|
||||
/* Keep printing values until we get to the end of *both* tables, not
|
||||
*either* table. Note that knowing the maximum useful index does *not*
|
||||
relieve us of the responsibility of testing the return pointer for
|
||||
NULL. */
|
||||
|
||||
for (signo = 0; signo <= maxsigno; signo++)
|
||||
{
|
||||
name = strsigno (signo);
|
||||
name = (name == NULL) ? "<NULL>" : name;
|
||||
msg = strsignal (signo);
|
||||
msg = (msg == NULL) ? "<NULL>" : msg;
|
||||
printf ("%-4d%-18s%s\n", signo, name, msg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/* Simple implementation of strstr for systems without it.
|
||||
This function is in the public domain. */
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
strstr -- locate first occurance of a substring
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
#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
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* FIXME: The above description is ANSI compiliant. This routine has not
|
||||
been validated to comply with it. -fnf */
|
||||
|
||||
char *
|
||||
strstr (s1, s2)
|
||||
char *s1, *s2;
|
||||
{
|
||||
register char *p = s1;
|
||||
extern char *strchr ();
|
||||
extern int strncmp ();
|
||||
#if __GNUC__==2
|
||||
extern __SIZE_TYPE__ strlen ();
|
||||
#endif
|
||||
register int len = strlen (s2);
|
||||
|
||||
for (; (p = strchr (p, *s2)) != 0; p++)
|
||||
{
|
||||
if (strncmp (p, s2, len) == 0)
|
||||
{
|
||||
return (p);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
/* Implementation of strtod for systems with atof.
|
||||
Copyright (C) 1991, 1995 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the libiberty library. This library is free
|
||||
software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU CC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
As a special exception, if you link this library with files
|
||||
compiled with a GNU compiler to produce an executable, this does not cause
|
||||
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. */
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
extern double atof ();
|
||||
|
||||
/* Disclaimer: this is currently just used by CHILL in GDB and therefore
|
||||
has not been tested well. It may have been tested for nothing except
|
||||
that it compiles. */
|
||||
|
||||
double
|
||||
strtod (str, ptr)
|
||||
char *str;
|
||||
char **ptr;
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (ptr == (char **)0)
|
||||
return atof (str);
|
||||
|
||||
p = str;
|
||||
|
||||
while (isspace (*p))
|
||||
++p;
|
||||
|
||||
if (*p == '+' || *p == '-')
|
||||
++p;
|
||||
|
||||
/* INF or INFINITY. */
|
||||
if ((p[0] == 'i' || p[0] == 'I')
|
||||
&& (p[1] == 'n' || p[1] == 'N')
|
||||
&& (p[2] == 'f' || p[2] == 'F'))
|
||||
{
|
||||
if ((p[3] == 'i' || p[3] == 'I')
|
||||
&& (p[4] == 'n' || p[4] == 'N')
|
||||
&& (p[5] == 'i' || p[5] == 'I')
|
||||
&& (p[6] == 't' || p[6] == 'T')
|
||||
&& (p[7] == 'y' || p[7] == 'Y'))
|
||||
{
|
||||
*ptr = p + 7;
|
||||
return atof (str);
|
||||
}
|
||||
else
|
||||
{
|
||||
*ptr = p + 3;
|
||||
return atof (str);
|
||||
}
|
||||
}
|
||||
|
||||
/* NAN or NAN(foo). */
|
||||
if ((p[0] == 'n' || p[0] == 'N')
|
||||
&& (p[1] == 'a' || p[1] == 'A')
|
||||
&& (p[2] == 'n' || p[2] == 'N'))
|
||||
{
|
||||
p += 3;
|
||||
if (*p == '(')
|
||||
{
|
||||
++p;
|
||||
while (*p != '\0' && *p != ')')
|
||||
++p;
|
||||
if (*p == ')')
|
||||
++p;
|
||||
}
|
||||
*ptr = p;
|
||||
return atof (str);
|
||||
}
|
||||
|
||||
/* digits, with 0 or 1 periods in it. */
|
||||
if (isdigit (*p) || *p == '.')
|
||||
{
|
||||
int got_dot = 0;
|
||||
while (isdigit (*p) || (!got_dot && *p == '.'))
|
||||
{
|
||||
if (*p == '.')
|
||||
got_dot = 1;
|
||||
++p;
|
||||
}
|
||||
|
||||
/* Exponent. */
|
||||
if (*p == 'e' || *p == 'E')
|
||||
{
|
||||
int i;
|
||||
i = 1;
|
||||
if (p[i] == '+' || p[i] == '-')
|
||||
++i;
|
||||
if (isdigit (p[i]))
|
||||
{
|
||||
while (isdigit (p[i]))
|
||||
++i;
|
||||
*ptr = p + i;
|
||||
return atof (str);
|
||||
}
|
||||
}
|
||||
*ptr = p;
|
||||
return atof (str);
|
||||
}
|
||||
/* Didn't find any digits. Doesn't look like a number. */
|
||||
*ptr = str;
|
||||
return 0.0;
|
||||
}
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
/*-
|
||||
* Copyright (c) 1990 The 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:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#if 0
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include "ansidecl.h"
|
||||
|
||||
/* FIXME: It'd be nice to configure around these, but the include files are too
|
||||
painful. These macros should at least be more portable than hardwired hex
|
||||
constants. */
|
||||
|
||||
#ifndef ULONG_MAX
|
||||
#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */
|
||||
#endif
|
||||
|
||||
#ifndef LONG_MAX
|
||||
#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF */
|
||||
#endif
|
||||
|
||||
#ifndef LONG_MIN
|
||||
#define LONG_MIN ((long)(~LONG_MAX)) /* 0x80000000 */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convert a string to a long integer.
|
||||
*
|
||||
* Ignores `locale' stuff. Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*/
|
||||
long
|
||||
strtol(nptr, endptr, base)
|
||||
const char *nptr;
|
||||
char **endptr;
|
||||
register int base;
|
||||
{
|
||||
register const char *s = nptr;
|
||||
register unsigned long acc;
|
||||
register int c;
|
||||
register unsigned long cutoff;
|
||||
register int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
* If base is 0, allow 0x for hex and 0 for octal, else
|
||||
* assume decimal; if base is already 16, allow 0x.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (isspace(c));
|
||||
if (c == '-') {
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
} else if (c == '+')
|
||||
c = *s++;
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X')) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
|
||||
/*
|
||||
* Compute the cutoff value between legal numbers and illegal
|
||||
* numbers. That is the largest legal value, divided by the
|
||||
* base. An input number that is greater than this value, if
|
||||
* followed by a legal input character, is too big. One that
|
||||
* is equal to this value may be valid or not; the limit
|
||||
* between valid and invalid numbers is then based on the last
|
||||
* digit. For instance, if the range for longs is
|
||||
* [-2147483648..2147483647] and the input base is 10,
|
||||
* cutoff will be set to 214748364 and cutlim to either
|
||||
* 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
|
||||
* a value > 214748364, or equal but the next digit is > 7 (or 8),
|
||||
* the number is too big, and we will return a range error.
|
||||
*
|
||||
* Set any if any `digits' consumed; make it negative to indicate
|
||||
* overflow.
|
||||
*/
|
||||
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
|
||||
cutlim = cutoff % (unsigned long)base;
|
||||
cutoff /= (unsigned long)base;
|
||||
for (acc = 0, any = 0;; c = *s++) {
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
|
||||
any = -1;
|
||||
else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0) {
|
||||
acc = neg ? LONG_MIN : LONG_MAX;
|
||||
errno = ERANGE;
|
||||
} else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != 0)
|
||||
*endptr = (char *) (any ? s - 1 : nptr);
|
||||
return (acc);
|
||||
}
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 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:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#if 0
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include "ansidecl.h"
|
||||
|
||||
#ifndef ULONG_MAX
|
||||
#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convert a string to an unsigned long integer.
|
||||
*
|
||||
* Ignores `locale' stuff. Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*/
|
||||
unsigned long
|
||||
strtoul(nptr, endptr, base)
|
||||
const char *nptr;
|
||||
char **endptr;
|
||||
register int base;
|
||||
{
|
||||
register const char *s = nptr;
|
||||
register unsigned long acc;
|
||||
register int c;
|
||||
register unsigned long cutoff;
|
||||
register int neg = 0, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
*/
|
||||
do {
|
||||
c = *s++;
|
||||
} while (isspace(c));
|
||||
if (c == '-') {
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
} else if (c == '+')
|
||||
c = *s++;
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X')) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
|
||||
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
|
||||
for (acc = 0, any = 0;; c = *s++) {
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
|
||||
any = -1;
|
||||
else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0) {
|
||||
acc = ULONG_MAX;
|
||||
errno = ERANGE;
|
||||
} else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != 0)
|
||||
*endptr = (char *) (any ? s - 1 : nptr);
|
||||
return (acc);
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#ifndef L_tmpnam
|
||||
#define L_tmpname 100
|
||||
#endif
|
||||
#ifndef P_tmpdir
|
||||
#define P_tmpdir "/usr/tmp"
|
||||
#endif
|
||||
|
||||
static char tmpnam_buffer[L_tmpnam];
|
||||
static int tmpnam_counter;
|
||||
|
||||
extern int getpid ();
|
||||
|
||||
char *
|
||||
tmpnam (s)
|
||||
char *s;
|
||||
{
|
||||
int pid = getpid ();
|
||||
|
||||
if (s == NULL)
|
||||
s = tmpnam_buffer;
|
||||
|
||||
/* Generate the filename and make sure that there isn't one called
|
||||
it already. */
|
||||
|
||||
while (1)
|
||||
{
|
||||
FILE *f;
|
||||
sprintf (s, "%s/%s%x.%x", P_tmpdir, "t", pid, tmpnam_counter);
|
||||
f = fopen (s, "r");
|
||||
if (f == NULL)
|
||||
break;
|
||||
tmpnam_counter++;
|
||||
fclose (f);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
/* Like vsprintf but provides a pointer to malloc'd storage, which must
|
||||
be freed by the caller.
|
||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ansidecl.h>
|
||||
|
||||
#ifdef TEST
|
||||
int global_total_width;
|
||||
#endif
|
||||
|
||||
unsigned long strtoul ();
|
||||
char *malloc ();
|
||||
|
||||
static int
|
||||
int_vasprintf (result, format, args)
|
||||
char **result;
|
||||
const char *format;
|
||||
va_list *args;
|
||||
{
|
||||
const char *p = format;
|
||||
/* Add one to make sure that it is never zero, which might cause malloc
|
||||
to return NULL. */
|
||||
int total_width = strlen (format) + 1;
|
||||
va_list ap;
|
||||
|
||||
memcpy ((PTR) &ap, (PTR) args, sizeof (va_list));
|
||||
|
||||
while (*p != '\0')
|
||||
{
|
||||
if (*p++ == '%')
|
||||
{
|
||||
while (strchr ("-+ #0", *p))
|
||||
++p;
|
||||
if (*p == '*')
|
||||
{
|
||||
++p;
|
||||
total_width += abs (va_arg (ap, int));
|
||||
}
|
||||
else
|
||||
total_width += strtoul (p, &p, 10);
|
||||
if (*p == '.')
|
||||
{
|
||||
++p;
|
||||
if (*p == '*')
|
||||
{
|
||||
++p;
|
||||
total_width += abs (va_arg (ap, int));
|
||||
}
|
||||
else
|
||||
total_width += strtoul (p, &p, 10);
|
||||
}
|
||||
while (strchr ("hlL", *p))
|
||||
++p;
|
||||
/* Should be big enough for any format specifier except %s and floats. */
|
||||
total_width += 30;
|
||||
switch (*p)
|
||||
{
|
||||
case 'd':
|
||||
case 'i':
|
||||
case 'o':
|
||||
case 'u':
|
||||
case 'x':
|
||||
case 'X':
|
||||
case 'c':
|
||||
(void) va_arg (ap, int);
|
||||
break;
|
||||
case 'f':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'g':
|
||||
case 'G':
|
||||
(void) va_arg (ap, double);
|
||||
/* Since an ieee double can have an exponent of 307, we'll
|
||||
make the buffer wide enough to cover the gross case. */
|
||||
total_width += 307;
|
||||
break;
|
||||
case 's':
|
||||
total_width += strlen (va_arg (ap, char *));
|
||||
break;
|
||||
case 'p':
|
||||
case 'n':
|
||||
(void) va_arg (ap, char *);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef TEST
|
||||
global_total_width = total_width;
|
||||
#endif
|
||||
*result = malloc (total_width);
|
||||
if (*result != NULL)
|
||||
return vsprintf (*result, format, *args);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
vasprintf (result, format, args)
|
||||
char **result;
|
||||
const char *format;
|
||||
#if defined (_BSD_VA_LIST_) && defined (__FreeBSD__)
|
||||
_BSD_VA_LIST_ args;
|
||||
#else
|
||||
va_list args;
|
||||
#endif
|
||||
{
|
||||
return int_vasprintf (result, format, &args);
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
void
|
||||
checkit
|
||||
#ifdef __STDC__
|
||||
(const char* format, ...)
|
||||
#else
|
||||
(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list args;
|
||||
char *result;
|
||||
|
||||
#ifdef __STDC__
|
||||
va_start (args, format);
|
||||
#else
|
||||
char *format;
|
||||
va_start (args);
|
||||
format = va_arg (args, char *);
|
||||
#endif
|
||||
vasprintf (&result, format, args);
|
||||
if (strlen (result) < global_total_width)
|
||||
printf ("PASS: ");
|
||||
else
|
||||
printf ("FAIL: ");
|
||||
printf ("%d %s\n", global_total_width, result);
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
checkit ("%d", 0x12345678);
|
||||
checkit ("%200d", 5);
|
||||
checkit ("%.300d", 6);
|
||||
checkit ("%100.150d", 7);
|
||||
checkit ("%s", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
|
||||
777777777777777777333333333333366666666666622222222222777777777777733333");
|
||||
checkit ("%f%s%d%s", 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx");
|
||||
}
|
||||
#endif /* TEST */
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
/* Emulate vfork using just plain fork, for systems without a real vfork.
|
||||
This function is in the public domain. */
|
||||
|
||||
int
|
||||
vfork ()
|
||||
{
|
||||
return (fork ());
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
/* Provide a version vfprintf in terms of _doprnt.
|
||||
By Kaveh Ghazi (ghazi@caip.rutgers.edu) 3/29/98
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
*/
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#undef vfprintf
|
||||
|
||||
int
|
||||
vfprintf (stream, format, ap)
|
||||
FILE * stream;
|
||||
const char * format;
|
||||
va_list ap;
|
||||
{
|
||||
return _doprnt (format, ap, stream);
|
||||
}
|
||||
|
|
@ -1,165 +0,0 @@
|
|||
$! libiberty/vmsbuild.com -- build liberty.olb for VMS host, VMS target
|
||||
$!
|
||||
$ CC = "gcc /noVerbose/Debug/Incl=([],[-.include])"
|
||||
$ LIBR = "library /Obj"
|
||||
$ LINK = "link"
|
||||
$ DELETE= "delete /noConfirm"
|
||||
$ SEARCH= "search /Exact"
|
||||
$ ECHO = "write sys$output"
|
||||
$ ABORT = "exit %x002C"
|
||||
$!
|
||||
$ LIB_NAME = "liberty.olb" !this is what we're going to construct
|
||||
$ WORK_LIB = "new-lib.olb" !used to guard against an incomplete build
|
||||
$
|
||||
$! manually copied from Makefile.in
|
||||
$ REQUIRED_OFILES = "argv.o basename.o choose-temp.o concat.o cplus-dem.o "-
|
||||
+ "fdmatch.o fnmatch.o getopt.o getopt1.o getruntime.o hex.o "-
|
||||
+ "floatformat.o objalloc.o obstack.o spaces.o strerror.o strsignal.o "-
|
||||
+ "xatexit.o xexit.o xmalloc.o xstrdup.o xstrerror.o"
|
||||
$! anything not caught by link+search of dummy.* should be added here
|
||||
$ EXTRA_OFILES = ""
|
||||
$!
|
||||
$! move to the directory which contains this command procedure
|
||||
$ old_dir = f$environ("DEFAULT")
|
||||
$ new_dir = f$parse("_._;",f$environ("PROCEDURE")) - "_._;"
|
||||
$ set default 'new_dir'
|
||||
$
|
||||
$ ECHO "Starting libiberty build..."
|
||||
$ create config.h
|
||||
/* libiberty config.h for VMS */
|
||||
#define NEED_sys_siglist
|
||||
#define NEED_strsignal
|
||||
#define NEED_psignal
|
||||
#define NEED_basename
|
||||
$ LIBR 'WORK_LIB' /Create
|
||||
$
|
||||
$! first pass: compile "required" modules
|
||||
$ ofiles = REQUIRED_OFILES + " " + EXTRA_OFILES
|
||||
$ pass = 1
|
||||
$ gosub do_ofiles
|
||||
$
|
||||
$! second pass: process dummy.c, using the first pass' results
|
||||
$ ECHO " now checking run-time library for missing functionality"
|
||||
$ if f$search("dummy.obj").nes."" then DELETE dummy.obj;*
|
||||
$ define/noLog sys$error _NL: !can't use /User_Mode here due to gcc
|
||||
$ define/noLog sys$output _NL: ! driver's use of multiple image activation
|
||||
$ on error then continue
|
||||
$ 'CC' dummy.c
|
||||
$ deassign sys$error !restore, more or less
|
||||
$ deassign sys$output
|
||||
$ if f$search("dummy.obj").eqs."" then goto pass2_failure1
|
||||
$! link dummy.obj, capturing full linker feedback in dummy.map
|
||||
$ oldmsg = f$environ("MESSAGE")
|
||||
$ set message /Facility/Severity/Identification/Text
|
||||
$ define/User sys$output _NL:
|
||||
$ define/User sys$error _NL:
|
||||
$ LINK/Map=dummy.map/noExe dummy.obj,'WORK_LIB'/Libr,-
|
||||
gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr
|
||||
$ set message 'oldmsg'
|
||||
$ if f$search("dummy.map").eqs."" then goto pass2_failure2
|
||||
$ DELETE dummy.obj;*
|
||||
$ SEARCH dummy.map "%LINK-I-UDFSYM" /Output=dummy.list
|
||||
$ DELETE dummy.map;*
|
||||
$ ECHO " check completed"
|
||||
$! we now have a file with one entry per line of unresolvable symbols
|
||||
$ ofiles = ""
|
||||
$ if f$trnlnm("IFILE$").nes."" then close/noLog ifile$
|
||||
$ open/Read ifile$ dummy.list
|
||||
$iloop: read/End=idone ifile$ iline
|
||||
$ iline = f$edit(iline,"COMPRESS,TRIM,LOWERCASE")
|
||||
$ ofiles = ofiles + " " + f$element(1," ",iline) + ".o"
|
||||
$ goto iloop
|
||||
$idone: close ifile$
|
||||
$ DELETE dummy.list;*
|
||||
$ on error then ABORT
|
||||
$
|
||||
$! third pass: compile "missing" modules collected in pass 2
|
||||
$ pass = 3
|
||||
$ gosub do_ofiles
|
||||
$
|
||||
$! finish up
|
||||
$ LIBR 'WORK_LIB' /Compress /Output='LIB_NAME' !new-lib.olb -> liberty.olb
|
||||
$ DELETE 'WORK_LIB';*
|
||||
$
|
||||
$! all done
|
||||
$ ECHO "Completed libiberty build."
|
||||
$ type sys$input:
|
||||
|
||||
You many wish to do
|
||||
$ COPY LIBERTY.OLB GNU_CC:[000000]
|
||||
so that this run-time library resides in the same location as gcc's
|
||||
support library. When building gas, be sure to leave the original
|
||||
copy of liberty.olb here so that gas's build procedure can find it.
|
||||
|
||||
$ set default 'old_dir'
|
||||
$ exit
|
||||
$
|
||||
$!
|
||||
$! compile each element of the space-delimited list 'ofiles'
|
||||
$!
|
||||
$do_ofiles:
|
||||
$ ofiles = f$edit(ofiles,"COMPRESS,TRIM")
|
||||
$ i = 0
|
||||
$oloop:
|
||||
$ f = f$element(i," ",ofiles)
|
||||
$ if f.eqs." " then goto odone
|
||||
$ f = f - ".o" !strip dummy suffix
|
||||
$ ECHO " ''f'"
|
||||
$ skip_f = 0
|
||||
$ if pass.eq.3 .and. f$search("''f'.c").eqs."" then gosub chk_deffunc
|
||||
$ if .not.skip_f
|
||||
$ then
|
||||
$ 'CC' 'f'.c
|
||||
$ LIBR 'WORK_LIB' 'f'.obj /Insert
|
||||
$ DELETE 'f'.obj;*
|
||||
$ endif
|
||||
$ i = i + 1
|
||||
$ goto oloop
|
||||
$odone:
|
||||
$ return
|
||||
$
|
||||
$!
|
||||
$! check functions.def for a DEFFUNC() entry corresponding to missing file 'f'.c
|
||||
$!
|
||||
$chk_deffunc:
|
||||
$ define/User sys$output _NL:
|
||||
$ define/User sys$error _NL:
|
||||
$ SEARCH functions.def "DEFFUNC","''f'" /Match=AND
|
||||
$ if (($status.and.%x7FFFFFFF) .eq. 1)
|
||||
$ then
|
||||
$ skip_f = 1
|
||||
$ open/Append config_h config.h
|
||||
$ write config_h "#define NEED_''f'"
|
||||
$ close config_h
|
||||
$ endif
|
||||
$ return
|
||||
$
|
||||
$!
|
||||
$pass2_failure1:
|
||||
$! if we reach here, dummy.c failed to compile and we're really stuck
|
||||
$ type sys$input:
|
||||
|
||||
Cannot compile the library contents checker (dummy.c + functions.def),
|
||||
so cannot continue!
|
||||
|
||||
$! attempt the compile again, without suppressing diagnostic messages this time
|
||||
$ on error then ABORT +0*f$verify(v)
|
||||
$ v = f$verify(1)
|
||||
$ 'CC' dummy.c
|
||||
$ ABORT +0*f$verify(v) !'f$verify(0)'
|
||||
$!
|
||||
$pass2_failure2:
|
||||
$! should never reach here..
|
||||
$ type sys$input:
|
||||
|
||||
Cannot link the library contents checker (dummy.obj), so cannot continue!
|
||||
|
||||
$! attempt the link again, without suppressing diagnostic messages this time
|
||||
$ on error then ABORT +0*f$verify(v)
|
||||
$ v = f$verify(1)
|
||||
$ LINK/Map=dummy.map/noExe dummy.obj,'WORK_LIB'/Libr,-
|
||||
gnu_cc:[000000]gcclib.olb/Libr,sys$library:vaxcrtl.olb/Libr
|
||||
$ ABORT +0*f$verify(v) !'f$verify(0)'
|
||||
$
|
||||
$! not reached
|
||||
$ exit
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#ifdef __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <ansidecl.h>
|
||||
#undef vprintf
|
||||
int
|
||||
vprintf (format, ap)
|
||||
const char *format;
|
||||
va_list ap;
|
||||
{
|
||||
return vfprintf (stdout, format, ap);
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/* Simple implementation of vsprintf for systems without it.
|
||||
Highly system-dependent, but should work on most "traditional"
|
||||
implementations of stdio; newer ones should already have vsprintf.
|
||||
Written by Per Bothner of Cygnus Support.
|
||||
Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
|
||||
Copyright (C) 1991, 1995 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the libiberty library. This library is free
|
||||
software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2, 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU CC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
As a special exception, if you link this library with files
|
||||
compiled with a GNU compiler to produce an executable, this does not cause
|
||||
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. */
|
||||
|
||||
#include <varargs.h>
|
||||
#include <stdio.h>
|
||||
#include <ansidecl.h>
|
||||
#undef vsprintf
|
||||
|
||||
int
|
||||
vsprintf (buf, format, ap)
|
||||
char *buf;
|
||||
const char *format;
|
||||
va_list ap;
|
||||
{
|
||||
FILE b;
|
||||
int ret;
|
||||
#ifdef VMS
|
||||
b->_flag = _IOWRT|_IOSTRG;
|
||||
b->_ptr = buf;
|
||||
b->_cnt = 12000;
|
||||
#else
|
||||
b._flag = _IOWRT|_IOSTRG;
|
||||
b._ptr = buf;
|
||||
b._cnt = 12000;
|
||||
#endif
|
||||
ret = _doprnt(format, ap, &b);
|
||||
putc('\0', &b);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
int
|
||||
waitpid (pid, stat_loc, options)
|
||||
int pid, *stat_loc, options;
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
int wpid = wait(stat_loc);
|
||||
if (wpid == pid || wpid == -1)
|
||||
return wpid;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1990 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* %sccs.include.redist.c%
|
||||
*/
|
||||
|
||||
/* Adapted from newlib/libc/stdlib/{,at}exit.[ch].
|
||||
If you use xatexit, you must call xexit instead of exit. */
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#define size_t unsigned long
|
||||
#endif
|
||||
|
||||
/* For systems with larger pointers than ints, this must be declared. */
|
||||
PTR malloc PARAMS ((size_t));
|
||||
|
||||
static void xatexit_cleanup PARAMS ((void));
|
||||
|
||||
/* Pointer to function run by xexit. */
|
||||
extern void (*_xexit_cleanup) PARAMS ((void));
|
||||
|
||||
#define XATEXIT_SIZE 32
|
||||
|
||||
struct xatexit {
|
||||
struct xatexit *next; /* next in list */
|
||||
int ind; /* next index in this table */
|
||||
void (*fns[XATEXIT_SIZE]) PARAMS ((void)); /* the table itself */
|
||||
};
|
||||
|
||||
/* Allocate one struct statically to guarantee that we can register
|
||||
at least a few handlers. */
|
||||
static struct xatexit xatexit_first;
|
||||
|
||||
/* Points to head of LIFO stack. */
|
||||
static struct xatexit *xatexit_head = &xatexit_first;
|
||||
|
||||
/* Register function FN to be run by xexit.
|
||||
Return 0 if successful, -1 if not. */
|
||||
|
||||
int
|
||||
xatexit (fn)
|
||||
void (*fn) PARAMS ((void));
|
||||
{
|
||||
register struct xatexit *p;
|
||||
|
||||
/* Tell xexit to call xatexit_cleanup. */
|
||||
if (!_xexit_cleanup)
|
||||
_xexit_cleanup = xatexit_cleanup;
|
||||
|
||||
p = xatexit_head;
|
||||
if (p->ind >= XATEXIT_SIZE)
|
||||
{
|
||||
if ((p = (struct xatexit *) malloc (sizeof *p)) == NULL)
|
||||
return -1;
|
||||
p->ind = 0;
|
||||
p->next = xatexit_head;
|
||||
xatexit_head = p;
|
||||
}
|
||||
p->fns[p->ind++] = fn;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Call any cleanup functions. */
|
||||
|
||||
static void
|
||||
xatexit_cleanup ()
|
||||
{
|
||||
register struct xatexit *p;
|
||||
register int n;
|
||||
|
||||
for (p = xatexit_head; p; p = p->next)
|
||||
for (n = p->ind; --n >= 0;)
|
||||
(*p->fns[n]) ();
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/* xexit.c -- Run any exit handlers, then exit.
|
||||
Copyright (C) 1994, 95, 1997 Free Software Foundation, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* This variable is set by xatexit if it is called. This way, xmalloc
|
||||
doesn't drag xatexit into the link. */
|
||||
void (*_xexit_cleanup) PARAMS ((void));
|
||||
|
||||
void
|
||||
xexit (code)
|
||||
int code;
|
||||
{
|
||||
if (_xexit_cleanup != NULL)
|
||||
(*_xexit_cleanup) ();
|
||||
exit (code);
|
||||
}
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
/* memory allocation routines with error checking.
|
||||
Copyright 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
|
||||
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. */
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#define size_t unsigned long
|
||||
#define ptrdiff_t long
|
||||
#endif
|
||||
|
||||
#if VMS
|
||||
#include <stdlib.h>
|
||||
#include <unixlib.h>
|
||||
#else
|
||||
/* For systems with larger pointers than ints, these must be declared. */
|
||||
PTR malloc PARAMS ((size_t));
|
||||
PTR realloc PARAMS ((PTR, size_t));
|
||||
PTR calloc PARAMS ((size_t, size_t));
|
||||
PTR sbrk PARAMS ((ptrdiff_t));
|
||||
#endif
|
||||
|
||||
/* The program name if set. */
|
||||
static const char *name = "";
|
||||
|
||||
#if ! defined (_WIN32) || defined (__CYGWIN32__)
|
||||
/* The initial sbrk, set when the program name is set. Not used for win32
|
||||
ports other than cygwin32. */
|
||||
static char *first_break = NULL;
|
||||
#endif
|
||||
|
||||
void
|
||||
xmalloc_set_program_name (s)
|
||||
const char *s;
|
||||
{
|
||||
name = s;
|
||||
#if ! defined (_WIN32) || defined (__CYGWIN32__)
|
||||
/* Win32 ports other than cygwin32 don't have brk() */
|
||||
if (first_break == NULL)
|
||||
first_break = (char *) sbrk (0);
|
||||
#endif /* ! _WIN32 || __CYGWIN32 __ */
|
||||
}
|
||||
|
||||
PTR
|
||||
xmalloc (size)
|
||||
size_t size;
|
||||
{
|
||||
PTR newmem;
|
||||
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
newmem = malloc (size);
|
||||
if (!newmem)
|
||||
{
|
||||
#if ! defined (_WIN32) || defined (__CYGWIN32__)
|
||||
extern char **environ;
|
||||
size_t allocated;
|
||||
|
||||
if (first_break != NULL)
|
||||
allocated = (char *) sbrk (0) - first_break;
|
||||
else
|
||||
allocated = (char *) sbrk (0) - (char *) &environ;
|
||||
fprintf (stderr,
|
||||
"\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n",
|
||||
name, *name ? ": " : "",
|
||||
(unsigned long) size, (unsigned long) allocated);
|
||||
#else
|
||||
fprintf (stderr,
|
||||
"\n%s%sCan not allocate %lu bytes\n",
|
||||
name, *name ? ": " : "",
|
||||
(unsigned long) size);
|
||||
#endif /* ! _WIN32 || __CYGWIN32 __ */
|
||||
xexit (1);
|
||||
}
|
||||
return (newmem);
|
||||
}
|
||||
|
||||
PTR
|
||||
xcalloc (nelem, elsize)
|
||||
size_t nelem, elsize;
|
||||
{
|
||||
PTR newmem;
|
||||
|
||||
if (nelem == 0 || elsize == 0)
|
||||
nelem = elsize = 1;
|
||||
|
||||
newmem = calloc (nelem, elsize);
|
||||
if (!newmem)
|
||||
{
|
||||
#if ! defined (_WIN32) || defined (__CYGWIN32__)
|
||||
extern char **environ;
|
||||
size_t allocated;
|
||||
|
||||
if (first_break != NULL)
|
||||
allocated = (char *) sbrk (0) - first_break;
|
||||
else
|
||||
allocated = (char *) sbrk (0) - (char *) &environ;
|
||||
fprintf (stderr,
|
||||
"\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n",
|
||||
name, *name ? ": " : "",
|
||||
(unsigned long) (nelem * elsize), (unsigned long) allocated);
|
||||
#else
|
||||
fprintf (stderr,
|
||||
"\n%s%sCan not allocate %lu bytes\n",
|
||||
name, *name ? ": " : "",
|
||||
(unsigned long) (nelem * elsize));
|
||||
#endif /* ! _WIN32 || __CYGWIN32 __ */
|
||||
xexit (1);
|
||||
}
|
||||
return (newmem);
|
||||
}
|
||||
|
||||
PTR
|
||||
xrealloc (oldmem, size)
|
||||
PTR oldmem;
|
||||
size_t size;
|
||||
{
|
||||
PTR newmem;
|
||||
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
if (!oldmem)
|
||||
newmem = malloc (size);
|
||||
else
|
||||
newmem = realloc (oldmem, size);
|
||||
if (!newmem)
|
||||
{
|
||||
#ifndef __MINGW32__
|
||||
extern char **environ;
|
||||
size_t allocated;
|
||||
|
||||
if (first_break != NULL)
|
||||
allocated = (char *) sbrk (0) - first_break;
|
||||
else
|
||||
allocated = (char *) sbrk (0) - (char *) &environ;
|
||||
fprintf (stderr,
|
||||
"\n%s%sCan not reallocate %lu bytes after allocating %lu bytes\n",
|
||||
name, *name ? ": " : "",
|
||||
(unsigned long) size, (unsigned long) allocated);
|
||||
#else
|
||||
fprintf (stderr,
|
||||
"\n%s%sCan not reallocate %lu bytes\n",
|
||||
name, *name ? ": " : "",
|
||||
(unsigned long) size);
|
||||
#endif /* __MINGW32__ */
|
||||
xexit (1);
|
||||
}
|
||||
return (newmem);
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
/* xstrdup.c -- Duplicate a string in memory, using xmalloc.
|
||||
This trivial function is in the public domain.
|
||||
Ian Lance Taylor, Cygnus Support, December 1995. */
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
char *
|
||||
xstrdup (s)
|
||||
const char *s;
|
||||
{
|
||||
char *ret;
|
||||
|
||||
ret = xmalloc (strlen (s) + 1);
|
||||
strcpy (ret, s);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
/* xstrerror.c -- jacket routine for more robust strerror() usage.
|
||||
Fri Jun 16 18:30:00 1995 Pat Rankin <rankin@eql.caltech.edu>
|
||||
This code is in the public domain. */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "libiberty.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef VMS
|
||||
#include <errno.h>
|
||||
#if !defined (__STRICT_ANSI__) && !defined (__HIDE_FORBIDDEN_NAMES)
|
||||
extern char *strerror PARAMS ((int,...));
|
||||
#define DONT_DECLARE_STRERROR
|
||||
#endif
|
||||
#endif /* VMS */
|
||||
|
||||
#ifndef DONT_DECLARE_STRERROR
|
||||
extern char *strerror PARAMS ((int));
|
||||
#endif
|
||||
|
||||
/* If strerror returns NULL, we'll format the number into a static buffer. */
|
||||
|
||||
#define ERRSTR_FMT "undocumented error #%d"
|
||||
static char xstrerror_buf[sizeof ERRSTR_FMT + 20];
|
||||
|
||||
/* Like strerror, but result is never a null pointer. */
|
||||
|
||||
char *
|
||||
xstrerror (errnum)
|
||||
int errnum;
|
||||
{
|
||||
char *errstr;
|
||||
#ifdef VMS
|
||||
char *(*vmslib_strerror) PARAMS ((int,...));
|
||||
|
||||
/* Override any possibly-conflicting declaration from system header. */
|
||||
vmslib_strerror = (char *(*) PARAMS ((int,...))) strerror;
|
||||
/* Second argument matters iff first is EVMSERR, but it's simpler to
|
||||
pass it unconditionally. `vaxc$errno' is declared in <errno.h>
|
||||
and maintained by the run-time library in parallel to `errno'.
|
||||
We assume that `errnum' corresponds to the last value assigned to
|
||||
errno by the run-time library, hence vaxc$errno will be relevant. */
|
||||
errstr = (*vmslib_strerror) (errnum, vaxc$errno);
|
||||
#else
|
||||
errstr = strerror (errnum);
|
||||
#endif
|
||||
|
||||
/* If `errnum' is out of range, result might be NULL. We'll fix that. */
|
||||
if (!errstr)
|
||||
{
|
||||
sprintf (xstrerror_buf, ERRSTR_FMT, errnum);
|
||||
errstr = xstrerror_buf;
|
||||
}
|
||||
return errstr;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user