mirror of
https://github.com/pret/agbcc.git
synced 2026-03-21 17:44:20 -05:00
add some more files
This commit is contained in:
parent
cdc6e2c50f
commit
9821a6af98
5
build.sh
5
build.sh
|
|
@ -2,6 +2,11 @@
|
|||
set -e
|
||||
CCOPT=
|
||||
CXXOPT=
|
||||
|
||||
[ ! -e gcc_arm/Makefile ] || make -C gcc_arm clean
|
||||
CC="gcc -m32" cd gcc_arm && ./configure --target=arm-elf --host=i686-linux-gnu && make cc1 && cd ..
|
||||
exit 0
|
||||
|
||||
if [ ! -z "$CC" ]; then CCOPT=CC=$CC; fi
|
||||
if [ ! -z "$CXX" ]; then CXXOPT=CXX=$CXX; fi
|
||||
make -C gcc clean
|
||||
|
|
|
|||
87
config.if
Executable file
87
config.if
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
#! /dev/null
|
||||
# Don't call it directly. This shell script fragment is called to
|
||||
# determine:
|
||||
#
|
||||
# 1. libstcxx_interface: the interface name for libstdc++.
|
||||
# 2. cxx_interface: the interface name for c++.
|
||||
# 3. libc_interface: the interface name for libc.
|
||||
#
|
||||
|
||||
# Get the top level src dir.
|
||||
if [ -z "${topsrcdir}" -a -z "${top_srcdir}" ]
|
||||
then
|
||||
echo "Undefined top level src dir: topsrcdir and top_srcdir are empty" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "${topsrcdir}" ]
|
||||
then
|
||||
if_topsrcdir=${topsrcdir}
|
||||
else
|
||||
if_topsrcdir=${top_srcdir}
|
||||
fi
|
||||
|
||||
if [ -f ${if_topsrcdir}/libstdc++/Makefile.in ]; then
|
||||
# We check libstdc++ for libstdcxx_interface.
|
||||
libstdcxx_interface=`grep "^INTERFACE" ${if_topsrcdir}/libstdc++/Makefile.in | sed 's/INTERFACE[ ]*=[ ]*\(.*\)/\1/'`
|
||||
else
|
||||
libstdcxx_interface=
|
||||
fi
|
||||
|
||||
if [ -f ${if_topsrcdir}/gcc/cp/Makefile.in ]; then
|
||||
# We check gcc/cp for cxx_interface.
|
||||
cxx_interface=`grep "^INTERFACE" ${if_topsrcdir}/gcc/cp/Makefile.in | sed 's/INTERFACE[ ]*=[ ]*\(.*\)/\1/'`
|
||||
else
|
||||
cxx_interface=
|
||||
fi
|
||||
|
||||
# The trickiest part is libc_interface.
|
||||
if [ -z "${libc_interface}" ]
|
||||
then
|
||||
case ${target_os} in
|
||||
*linux*libc1*|*linux*libc5*)
|
||||
case ${target_alias} in
|
||||
*alpha*|*powerpc*)
|
||||
libc_interface=-libc5.9-
|
||||
;;
|
||||
*)
|
||||
libc_interface=-libc5-
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*linux*gnu*)
|
||||
# We have to work harder to figure it out.
|
||||
if [ ${target_alias} = ${build_alias} ]
|
||||
then
|
||||
dummy=if$$
|
||||
cat >$dummy.c <<EOF
|
||||
#include <features.h>
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
printf("%d\n", __GLIBC_MINOR__);
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
${CC-cc} $dummy.c -o $dummy 2>/dev/null
|
||||
if [ "$?" = 0 ]
|
||||
then
|
||||
libc_interface=-libc6.`./$dummy`-
|
||||
rm -f $dummy.c $dummy
|
||||
else
|
||||
# It should never happen.
|
||||
echo "Cannot find the GNU C library minor version number." >&2
|
||||
rm -f $dummy.c $dummy
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Cross compiling. Assume glibc 2.1.
|
||||
libc_interface=-libc6.1-
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
libc_interface=-
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
1274
config.sub
vendored
Executable file
1274
config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
21
gcc_arm/Make-hooks
Normal file
21
gcc_arm/Make-hooks
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
lang.all.build:
|
||||
lang.all.cross:
|
||||
lang.start.encap:
|
||||
lang.rest.encap:
|
||||
lang.info:
|
||||
lang.dvi:
|
||||
lang.install-normal:
|
||||
lang.install-common:
|
||||
lang.install-info:
|
||||
lang.install-man:
|
||||
lang.uninstall:
|
||||
lang.distdir:
|
||||
lang.mostlyclean:
|
||||
lang.clean:
|
||||
lang.distclean:
|
||||
lang.extraclean:
|
||||
lang.maintainer-clean:
|
||||
lang.stage1:
|
||||
lang.stage2:
|
||||
lang.stage3:
|
||||
lang.stage4:
|
||||
0
gcc_arm/Make-host
Normal file
0
gcc_arm/Make-host
Normal file
0
gcc_arm/Make-lang
Normal file
0
gcc_arm/Make-lang
Normal file
35
gcc_arm/Make-target
Normal file
35
gcc_arm/Make-target
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
CROSS_LIBGCC1 = libgcc1-asm.a
|
||||
LIB1ASMSRC = arm/lib1funcs.asm
|
||||
# CYGNUS LOCAL interworking
|
||||
LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _call_via_rX
|
||||
# END CYGNUS LOCAL interworking
|
||||
|
||||
# These are really part of libgcc1, but this will cause them to be
|
||||
# built correctly, so...
|
||||
|
||||
LIB2FUNCS_EXTRA = fp-bit.c dp-bit.c
|
||||
|
||||
fp-bit.c: $(srcdir)/config/fp-bit.c
|
||||
echo '#define FLOAT' > fp-bit.c
|
||||
echo '#ifndef __ARMEB__' >> fp-bit.c
|
||||
echo '#define FLOAT_BIT_ORDER_MISMATCH' >> fp-bit.c
|
||||
echo '#endif' >> fp-bit.c
|
||||
cat $(srcdir)/config/fp-bit.c >> fp-bit.c
|
||||
|
||||
dp-bit.c: $(srcdir)/config/fp-bit.c
|
||||
echo '#ifndef __ARMEB__' > dp-bit.c
|
||||
echo '#define FLOAT_BIT_ORDER_MISMATCH' >> dp-bit.c
|
||||
echo '#define FLOAT_WORD_ORDER_MISMATCH' >> dp-bit.c
|
||||
echo '#endif' >> dp-bit.c
|
||||
cat $(srcdir)/config/fp-bit.c >> dp-bit.c
|
||||
|
||||
# CYGNUS LOCAL
|
||||
MULTILIB_OPTIONS = mlittle-endian/mbig-endian mhard-float/msoft-float mapcs-32/mapcs-26 mno-thumb-interwork/mthumb-interwork fno-leading-underscore/fleading-underscore mcpu=arm7
|
||||
MULTILIB_DIRNAMES = le be fpu soft 32bit 26bit normal interwork elf under nofmult
|
||||
MULTILIB_EXCEPTIONS = *mapcs-26/*mthumb-interwork* *mthumb-interwork*/*mcpu=arm7*
|
||||
MULTILIB_MATCHES = mbig-endian=mbe mlittle-endian=mle mcpu?arm7=mcpu?arm7d mcpu?arm7=mcpu?arm7di mcpu?arm7=mcpu?arm70 mcpu?arm7=mcpu?arm700 mcpu?arm7=mcpu?arm700i mcpu?arm7=mcpu?arm710 mcpu?arm7=mcpu?arm710c mcpu?arm7=mcpu?arm7100 mcpu?arm7=mcpu?arm7500 mcpu?arm7=mcpu?arm7500fe mcpu?arm7=mcpu?arm6 mcpu?arm7=mcpu?arm60 mcpu?arm7=mcpu?arm600 mcpu?arm7=mcpu?arm610 mcpu?arm7=mcpu?arm620
|
||||
LIBGCC = stmp-multilib
|
||||
INSTALL_LIBGCC = install-multilib
|
||||
# END CYGNUS LOCAL
|
||||
|
||||
TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc
|
||||
2881
gcc_arm/Makefile
Normal file
2881
gcc_arm/Makefile
Normal file
File diff suppressed because it is too large
Load Diff
241
gcc_arm/auto-host.h
Normal file
241
gcc_arm/auto-host.h
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
/* auto-host.h. Generated automatically by configure. */
|
||||
/* config.in. Generated automatically from configure.in by autoheader. */
|
||||
/* Define if you can safely include both <string.h> and <strings.h>. */
|
||||
#define STRING_WITH_STRINGS 1
|
||||
|
||||
/* Define if printf supports "%p". */
|
||||
#define HAVE_PRINTF_PTR 1
|
||||
|
||||
/* Define if you want expensive run-time checks. */
|
||||
/* #undef ENABLE_CHECKING */
|
||||
|
||||
/* Define if your cpp understands the stringify operator. */
|
||||
#define HAVE_CPP_STRINGIFY 1
|
||||
|
||||
/* Define if your compiler understands volatile. */
|
||||
#define HAVE_VOLATILE 1
|
||||
|
||||
/* Define if your assembler supports specifying the maximum number
|
||||
of bytes to skip when using the GAS .p2align command. */
|
||||
/* #undef HAVE_GAS_MAX_SKIP_P2ALIGN */
|
||||
|
||||
/* Define if your assembler supports .balign and .p2align. */
|
||||
/* #undef HAVE_GAS_BALIGN_AND_P2ALIGN */
|
||||
|
||||
/* Define if your assembler supports .subsection and .subsection -1 starts
|
||||
emitting at the beginning of your section */
|
||||
/* #undef HAVE_GAS_SUBSECTION_ORDERING */
|
||||
|
||||
/* Define if you have a working <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Whether malloc must be declared even if <stdlib.h> is included. */
|
||||
/* #undef NEED_DECLARATION_MALLOC */
|
||||
|
||||
/* Whether realloc must be declared even if <stdlib.h> is included. */
|
||||
/* #undef NEED_DECLARATION_REALLOC */
|
||||
|
||||
/* Whether calloc must be declared even if <stdlib.h> is included. */
|
||||
/* #undef NEED_DECLARATION_CALLOC */
|
||||
|
||||
/* Whether free must be declared even if <stdlib.h> is included. */
|
||||
/* #undef NEED_DECLARATION_FREE */
|
||||
|
||||
/* Whether bcopy must be declared even if <string.h> is included. */
|
||||
/* #undef NEED_DECLARATION_BCOPY */
|
||||
|
||||
/* Whether bcmp must be declared even if <string.h> is included. */
|
||||
/* #undef NEED_DECLARATION_BCMP */
|
||||
|
||||
/* Whether bzero must be declared even if <string.h> is included. */
|
||||
/* #undef NEED_DECLARATION_BZERO */
|
||||
|
||||
/* Whether index must be declared even if <string.h> is included. */
|
||||
/* #undef NEED_DECLARATION_INDEX */
|
||||
|
||||
/* Whether rindex must be declared even if <string.h> is included. */
|
||||
/* #undef NEED_DECLARATION_RINDEX */
|
||||
|
||||
/* Whether getenv must be declared even if <stdlib.h> is included. */
|
||||
/* #undef NEED_DECLARATION_GETENV */
|
||||
|
||||
/* Whether atol must be declared even if <stdlib.h> is included. */
|
||||
/* #undef NEED_DECLARATION_ATOL */
|
||||
|
||||
/* Whether sbrk must be declared even if <stdlib.h> is included. */
|
||||
/* #undef NEED_DECLARATION_SBRK */
|
||||
|
||||
/* Whether abort must be declared even if <stdlib.h> is included. */
|
||||
/* #undef NEED_DECLARATION_ABORT */
|
||||
|
||||
/* Whether strerror must be declared even if <string.h> is included. */
|
||||
/* #undef NEED_DECLARATION_STRERROR */
|
||||
|
||||
/* Whether strsignal must be declared even if <string.h> is included. */
|
||||
/* #undef NEED_DECLARATION_STRSIGNAL */
|
||||
|
||||
/* Whether getcwd must be declared even if <unistd.h> is included. */
|
||||
/* #undef NEED_DECLARATION_GETCWD */
|
||||
|
||||
/* Whether getwd must be declared even if <unistd.h> is included. */
|
||||
/* #undef NEED_DECLARATION_GETWD */
|
||||
|
||||
/* Whether getrlimit must be declared even if <sys/resource.h> is included. */
|
||||
/* #undef NEED_DECLARATION_GETRLIMIT */
|
||||
|
||||
/* Whether setrlimit must be declared even if <sys/resource.h> is included. */
|
||||
/* #undef NEED_DECLARATION_SETRLIMIT */
|
||||
|
||||
/* Define if you want expensive run-time checks. */
|
||||
/* #undef ENABLE_CHECKING */
|
||||
|
||||
/* Define to enable the use of a default assembler. */
|
||||
/* #undef DEFAULT_ASSEMBLER */
|
||||
|
||||
/* Define to enable the use of a default linker. */
|
||||
/* #undef DEFAULT_LINKER */
|
||||
|
||||
|
||||
/* Define if you don't have vprintf but do have _doprnt. */
|
||||
/* #undef HAVE_DOPRNT */
|
||||
|
||||
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
|
||||
/* Define if you have <vfork.h>. */
|
||||
/* #undef HAVE_VFORK_H */
|
||||
|
||||
/* Define if you have the vprintf function. */
|
||||
#define HAVE_VPRINTF 1
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef pid_t */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if `sys_siglist' is declared by <signal.h>. */
|
||||
#define SYS_SIGLIST_DECLARED 1
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Define vfork as fork if vfork does not work. */
|
||||
/* #undef vfork */
|
||||
|
||||
/* Define if you have the atoll function. */
|
||||
#define HAVE_ATOLL 1
|
||||
|
||||
/* Define if you have the atoq function. */
|
||||
/* #undef HAVE_ATOQ */
|
||||
|
||||
/* Define if you have the bcmp function. */
|
||||
#define HAVE_BCMP 1
|
||||
|
||||
/* Define if you have the bcopy function. */
|
||||
#define HAVE_BCOPY 1
|
||||
|
||||
/* Define if you have the bsearch function. */
|
||||
#define HAVE_BSEARCH 1
|
||||
|
||||
/* Define if you have the bzero function. */
|
||||
#define HAVE_BZERO 1
|
||||
|
||||
/* Define if you have the fputc_unlocked function. */
|
||||
#define HAVE_FPUTC_UNLOCKED 1
|
||||
|
||||
/* Define if you have the fputs_unlocked function. */
|
||||
#define HAVE_FPUTS_UNLOCKED 1
|
||||
|
||||
/* Define if you have the getrlimit function. */
|
||||
#define HAVE_GETRLIMIT 1
|
||||
|
||||
/* Define if you have the gettimeofday function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define if you have the index function. */
|
||||
#define HAVE_INDEX 1
|
||||
|
||||
/* Define if you have the isascii function. */
|
||||
#define HAVE_ISASCII 1
|
||||
|
||||
/* Define if you have the kill function. */
|
||||
#define HAVE_KILL 1
|
||||
|
||||
/* Define if you have the popen function. */
|
||||
#define HAVE_POPEN 1
|
||||
|
||||
/* Define if you have the putc_unlocked function. */
|
||||
#define HAVE_PUTC_UNLOCKED 1
|
||||
|
||||
/* Define if you have the putenv function. */
|
||||
#define HAVE_PUTENV 1
|
||||
|
||||
/* Define if you have the rindex function. */
|
||||
#define HAVE_RINDEX 1
|
||||
|
||||
/* Define if you have the setrlimit function. */
|
||||
#define HAVE_SETRLIMIT 1
|
||||
|
||||
/* Define if you have the strchr function. */
|
||||
#define HAVE_STRCHR 1
|
||||
|
||||
/* Define if you have the strerror function. */
|
||||
#define HAVE_STRERROR 1
|
||||
|
||||
/* Define if you have the strrchr function. */
|
||||
#define HAVE_STRRCHR 1
|
||||
|
||||
/* Define if you have the strsignal function. */
|
||||
#define HAVE_STRSIGNAL 1
|
||||
|
||||
/* Define if you have the strtoul function. */
|
||||
#define HAVE_STRTOUL 1
|
||||
|
||||
/* Define if you have the sysconf function. */
|
||||
#define HAVE_SYSCONF 1
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define if you have the <stab.h> header file. */
|
||||
#define HAVE_STAB_H 1
|
||||
|
||||
/* Define if you have the <stddef.h> header file. */
|
||||
#define HAVE_STDDEF_H 1
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define if you have the <sys/file.h> header file. */
|
||||
#define HAVE_SYS_FILE_H 1
|
||||
|
||||
/* Define if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define if you have the <sys/resource.h> header file. */
|
||||
#define HAVE_SYS_RESOURCE_H 1
|
||||
|
||||
/* Define if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define if you have the <sys/times.h> header file. */
|
||||
#define HAVE_SYS_TIMES_H 1
|
||||
|
||||
/* Define if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
5078
gcc_arm/c-parse.c
5078
gcc_arm/c-parse.c
File diff suppressed because it is too large
Load Diff
|
|
@ -1,114 +0,0 @@
|
|||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
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, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/* Tokens. */
|
||||
#define IDENTIFIER 258
|
||||
#define TYPENAME 259
|
||||
#define SCSPEC 260
|
||||
#define TYPESPEC 261
|
||||
#define TYPE_QUAL 262
|
||||
#define CONSTANT 263
|
||||
#define STRING 264
|
||||
#define ELLIPSIS 265
|
||||
#define SIZEOF 266
|
||||
#define ENUM 267
|
||||
#define STRUCT 268
|
||||
#define UNION 269
|
||||
#define IF 270
|
||||
#define ELSE 271
|
||||
#define WHILE 272
|
||||
#define DO 273
|
||||
#define FOR 274
|
||||
#define SWITCH 275
|
||||
#define CASE 276
|
||||
#define DEFAULT 277
|
||||
#define BREAK 278
|
||||
#define CONTINUE 279
|
||||
#define RETURN 280
|
||||
#define GOTO 281
|
||||
#define ASM_KEYWORD 282
|
||||
#define TYPEOF 283
|
||||
#define ALIGNOF 284
|
||||
#define ATTRIBUTE 285
|
||||
#define EXTENSION 286
|
||||
#define LABEL 287
|
||||
#define REALPART 288
|
||||
#define IMAGPART 289
|
||||
#define ASSIGN 290
|
||||
#define OROR 291
|
||||
#define ANDAND 292
|
||||
#define EQCOMPARE 293
|
||||
#define ARITHCOMPARE 294
|
||||
#define RSHIFT 295
|
||||
#define LSHIFT 296
|
||||
#define MINUSMINUS 297
|
||||
#define PLUSPLUS 298
|
||||
#define UNARY 299
|
||||
#define HYPERUNARY 300
|
||||
#define POINTSAT 301
|
||||
#define INTERFACE 302
|
||||
#define IMPLEMENTATION 303
|
||||
#define END 304
|
||||
#define SELECTOR 305
|
||||
#define DEFS 306
|
||||
#define ENCODE 307
|
||||
#define CLASSNAME 308
|
||||
#define PUBLIC 309
|
||||
#define PRIVATE 310
|
||||
#define PROTECTED 311
|
||||
#define PROTOCOL 312
|
||||
#define OBJECTNAME 313
|
||||
#define CLASS 314
|
||||
#define ALIAS 315
|
||||
#define OBJC_STRING 316
|
||||
|
||||
|
||||
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
#line 87 "c-parse.y"
|
||||
{long itype; tree ttype; enum tree_code code;
|
||||
char *filename; int lineno; int ends_in_label; }
|
||||
/* Line 1489 of yacc.c. */
|
||||
#line 174 "c-parse.h"
|
||||
YYSTYPE;
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
588
gcc_arm/config.bak
Executable file
588
gcc_arm/config.bak
Executable file
|
|
@ -0,0 +1,588 @@
|
|||
#! /bin/sh
|
||||
# Generated automatically by configure.
|
||||
# Run this file to recreate the current configuration.
|
||||
# This directory was configured as follows,
|
||||
# on host cameron-HP-Pavilion-g7-Notebook-PC:
|
||||
#
|
||||
# ./configure --target=arm-elf --host=i686-linux-gnu
|
||||
#
|
||||
# Compiler output produced by configure, useful for debugging
|
||||
# configure, is in ./config.log if it exists.
|
||||
|
||||
ac_cs_usage="Usage: ./config.status [--recheck] [--version] [--help]"
|
||||
for ac_option
|
||||
do
|
||||
case "$ac_option" in
|
||||
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
|
||||
echo "running ${CONFIG_SHELL-/bin/sh} ./configure --target=arm-elf --host=i686-linux-gnu --no-create --no-recursion"
|
||||
exec ${CONFIG_SHELL-/bin/sh} ./configure --target=arm-elf --host=i686-linux-gnu --no-create --no-recursion ;;
|
||||
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
|
||||
echo "./config.status generated by autoconf version 2.13"
|
||||
exit 0 ;;
|
||||
-help | --help | --hel | --he | --h)
|
||||
echo "$ac_cs_usage"; exit 0 ;;
|
||||
*) echo "$ac_cs_usage"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
ac_given_srcdir=.
|
||||
|
||||
trap 'rm -fr Makefile auto-host.h conftest*; exit 1' 1 2 15
|
||||
|
||||
# Protect against being on the right side of a sed subst in config.status.
|
||||
sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g;
|
||||
s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF
|
||||
/^[ ]*VPATH[ ]*=[^:]*$/d
|
||||
|
||||
s%@SHELL@%/bin/sh%g
|
||||
s%@CFLAGS@%-g -O2%g
|
||||
s%@CPPFLAGS@%%g
|
||||
s%@CXXFLAGS@%%g
|
||||
s%@FFLAGS@%%g
|
||||
s%@DEFS@%-DHAVE_CONFIG_H%g
|
||||
s%@LDFLAGS@%%g
|
||||
s%@LIBS@%%g
|
||||
s%@exec_prefix@%${prefix}%g
|
||||
s%@prefix@%/usr/local%g
|
||||
s%@program_transform_name@%s,x,x,%g
|
||||
s%@bindir@%${exec_prefix}/bin%g
|
||||
s%@sbindir@%${exec_prefix}/sbin%g
|
||||
s%@libexecdir@%${exec_prefix}/libexec%g
|
||||
s%@datadir@%${prefix}/share%g
|
||||
s%@sysconfdir@%${prefix}/etc%g
|
||||
s%@sharedstatedir@%${prefix}/com%g
|
||||
s%@localstatedir@%${prefix}/var%g
|
||||
s%@libdir@%${exec_prefix}/lib%g
|
||||
s%@includedir@%${prefix}/include%g
|
||||
s%@oldincludedir@%/usr/include%g
|
||||
s%@infodir@%${prefix}/info%g
|
||||
s%@mandir@%${prefix}/man%g
|
||||
s%@host@%i686-pc-linux-gnu%g
|
||||
s%@host_alias@%i686-linux-gnu%g
|
||||
s%@host_cpu@%i686%g
|
||||
s%@host_vendor@%pc%g
|
||||
s%@host_os@%linux-gnu%g
|
||||
s%@target@%arm-unknown-elf%g
|
||||
s%@target_alias@%arm-elf%g
|
||||
s%@target_cpu@%arm%g
|
||||
s%@target_vendor@%unknown%g
|
||||
s%@target_os@%elf%g
|
||||
s%@build@%i686-pc-linux-gnu%g
|
||||
s%@build_alias@%i686-linux-gnu%g
|
||||
s%@build_cpu@%i686%g
|
||||
s%@build_vendor@%pc%g
|
||||
s%@build_os@%linux-gnu%g
|
||||
s%@CC@%gcc%g
|
||||
s%@stage1_warn_cflags@%$(WARN_CFLAGS)%g
|
||||
s%@SET_MAKE@%%g
|
||||
s%@AWK@%mawk%g
|
||||
s%@LEX@%flex%g
|
||||
s%@LEXLIB@%%g
|
||||
s%@LN@%ln%g
|
||||
s%@LN_S@%ln -s%g
|
||||
s%@RANLIB@%ranlib%g
|
||||
s%@YACC@%bison -y%g
|
||||
s%@INSTALL@%/usr/bin/install -c%g
|
||||
s%@INSTALL_PROGRAM@%${INSTALL}%g
|
||||
s%@INSTALL_DATA@%${INSTALL} -m 644%g
|
||||
s%@CPP@%gcc -E%g
|
||||
s%@gnat@%no%g
|
||||
s%@vfprintf@%%g
|
||||
s%@doprint@%%g
|
||||
s%@manext@%.1%g
|
||||
s%@objext@%.o%g
|
||||
s%@gthread_flags@%%g
|
||||
s%@build_canonical@%i686-pc-linux-gnu%g
|
||||
s%@host_canonical@%i686-pc-linux-gnu%g
|
||||
s%@target_subdir@%arm-unknown-elf/%g
|
||||
s%@inhibit_libc@%%g
|
||||
s%@sched_prefix@%%g
|
||||
s%@sched_cflags@%%g
|
||||
s%@gcc_tooldir@%$(libsubdir)/$(unlibsubdir)/../$(target_alias)%g
|
||||
s%@dollar@%%g
|
||||
s%@objdir@%/home/cameron/programming/agbcc2/gcc_arm%g
|
||||
s%@subdirs@%%g
|
||||
s%@all_languages@%%g
|
||||
s%@all_boot_languages@%%g
|
||||
s%@all_compilers@%%g
|
||||
s%@all_lang_makefiles@%%g
|
||||
s%@all_stagestuff@%%g
|
||||
s%@all_diff_excludes@%%g
|
||||
s%@all_lib2funcs@%%g
|
||||
s%@all_headers@%%g
|
||||
s%@cpp_main@%cccp%g
|
||||
s%@extra_passes@%%g
|
||||
s%@extra_programs@%%g
|
||||
s%@extra_parts@%%g
|
||||
s%@extra_c_objs@%%g
|
||||
s%@extra_cxx_objs@%%g
|
||||
s%@extra_cpp_objs@%%g
|
||||
s%@extra_c_flags@% -DMULTIBYTE_CHARS=1%g
|
||||
s%@extra_objs@% %g
|
||||
s%@host_extra_gcc_objs@%%g
|
||||
s%@extra_headers_list@%%g
|
||||
s%@dep_host_xmake_file@%%g
|
||||
s%@dep_tmake_file@% ./config/arm/t-arm-elf%g
|
||||
s%@out_file@%arm/arm.c%g
|
||||
s%@out_object_file@%arm.o%g
|
||||
s%@md_file@%arm/arm.md%g
|
||||
s%@tm_file_list@% gansidecl.h $(srcdir)/config/arm/unknown-elf.h%g
|
||||
s%@build_xm_file_list@% auto-host.h gansidecl.h $(srcdir)/config/i386/xm-i386.h%g
|
||||
s%@host_xm_file_list@% auto-host.h gansidecl.h $(srcdir)/config/i386/xm-i386.h%g
|
||||
s%@lang_specs_files@%%g
|
||||
s%@lang_options_files@%%g
|
||||
s%@lang_tree_files@%%g
|
||||
s%@thread_file@%single%g
|
||||
s%@objc_boehm_gc@%%g
|
||||
s%@JAVAGC@%boehm%g
|
||||
s%@gcc_version@%2.9-arm-000512%g
|
||||
s%@gcc_version_trigger@%./version.c%g
|
||||
s%@local_prefix@%$(prefix)%g
|
||||
s%@gcc_gxx_include_dir@%$(libsubdir)/$(unlibsubdir)/..`echo $(exec_prefix) | sed -e 's|^$(prefix)||' -e 's|/[^/]*|/..|g'`/include/g++-%g
|
||||
s%@fixincludes@%fixincludes%g
|
||||
s%@build_install_headers_dir@%install-headers-tar%g
|
||||
s%@build_exeext@%%g
|
||||
s%@host_exeext@%%g
|
||||
s%@float_h_file@%float-i64.h%g
|
||||
s%@cc_set_by_configure@%$(CC)%g
|
||||
s%@stage_prefix_set_by_configure@%$(STAGE_PREFIX)%g
|
||||
s%@install@%%g
|
||||
s%@symbolic_link@%ln -s%g
|
||||
/@target_overrides@/r Make-target
|
||||
s%@target_overrides@%%g
|
||||
/@host_overrides@/r Make-host
|
||||
s%@host_overrides@%%g
|
||||
s%@cross_defines@%CROSS=-DCROSS_COMPILE%g
|
||||
/@cross_overrides@/r /home/cameron/programming/agbcc2/gcc_arm/cross-make
|
||||
s%@cross_overrides@%%g
|
||||
/@build_overrides@/r /dev/null
|
||||
s%@build_overrides@%%g
|
||||
/@language_fragments@/r Make-lang
|
||||
s%@language_fragments@%%g
|
||||
/@language_hooks@/r Make-hooks
|
||||
s%@language_hooks@%%g
|
||||
|
||||
CEOF
|
||||
|
||||
# Split the substitutions into bite-sized pieces for seds with
|
||||
# small command number limits, like on Digital OSF/1 and HP-UX.
|
||||
ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
|
||||
ac_file=1 # Number of current file.
|
||||
ac_beg=1 # First line for current file.
|
||||
ac_end=$ac_max_sed_cmds # Line after last line for current file.
|
||||
ac_more_lines=:
|
||||
ac_sed_cmds=""
|
||||
while $ac_more_lines; do
|
||||
if test $ac_beg -gt 1; then
|
||||
sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
|
||||
else
|
||||
sed "${ac_end}q" conftest.subs > conftest.s$ac_file
|
||||
fi
|
||||
if test ! -s conftest.s$ac_file; then
|
||||
ac_more_lines=false
|
||||
rm -f conftest.s$ac_file
|
||||
else
|
||||
if test -z "$ac_sed_cmds"; then
|
||||
ac_sed_cmds="sed -f conftest.s$ac_file"
|
||||
else
|
||||
ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
|
||||
fi
|
||||
ac_file=`expr $ac_file + 1`
|
||||
ac_beg=$ac_end
|
||||
ac_end=`expr $ac_end + $ac_max_sed_cmds`
|
||||
fi
|
||||
done
|
||||
if test -z "$ac_sed_cmds"; then
|
||||
ac_sed_cmds=cat
|
||||
fi
|
||||
|
||||
CONFIG_FILES=${CONFIG_FILES-"Makefile"}
|
||||
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
|
||||
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
|
||||
case "$ac_file" in
|
||||
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
|
||||
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
|
||||
*) ac_file_in="${ac_file}.in" ;;
|
||||
esac
|
||||
|
||||
# Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
|
||||
|
||||
# Remove last slash and all that follows it. Not all systems have dirname.
|
||||
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
|
||||
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
|
||||
# The file is in a subdirectory.
|
||||
test ! -d "$ac_dir" && mkdir "$ac_dir"
|
||||
ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
|
||||
# A "../" for each directory in $ac_dir_suffix.
|
||||
ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
|
||||
else
|
||||
ac_dir_suffix= ac_dots=
|
||||
fi
|
||||
|
||||
case "$ac_given_srcdir" in
|
||||
.) srcdir=.
|
||||
if test -z "$ac_dots"; then top_srcdir=.
|
||||
else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
|
||||
/*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
|
||||
*) # Relative path.
|
||||
srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
|
||||
top_srcdir="$ac_dots$ac_given_srcdir" ;;
|
||||
esac
|
||||
|
||||
|
||||
echo creating "$ac_file"
|
||||
rm -f "$ac_file"
|
||||
configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
|
||||
case "$ac_file" in
|
||||
*Makefile*) ac_comsub="1i\\
|
||||
# $configure_input" ;;
|
||||
*) ac_comsub= ;;
|
||||
esac
|
||||
|
||||
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
|
||||
sed -e "$ac_comsub
|
||||
s%@configure_input@%$configure_input%g
|
||||
s%@srcdir@%$srcdir%g
|
||||
s%@top_srcdir@%$top_srcdir%g
|
||||
" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
|
||||
fi; done
|
||||
rm -f conftest.s*
|
||||
|
||||
# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
|
||||
# NAME is the cpp macro being defined and VALUE is the value it is being given.
|
||||
#
|
||||
# ac_d sets the value in "#define NAME VALUE" lines.
|
||||
ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
|
||||
ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
|
||||
ac_dC='\3'
|
||||
ac_dD='%g'
|
||||
# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
|
||||
ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
|
||||
ac_uB='\([ ]\)%\1#\2define\3'
|
||||
ac_uC=' '
|
||||
ac_uD='\4%g'
|
||||
# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
|
||||
ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
|
||||
ac_eB='$%\1#\2define\3'
|
||||
ac_eC=' '
|
||||
ac_eD='%g'
|
||||
|
||||
if test "${CONFIG_HEADERS+set}" != set; then
|
||||
CONFIG_HEADERS="auto-host.h:config.in"
|
||||
fi
|
||||
for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
|
||||
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
|
||||
case "$ac_file" in
|
||||
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
|
||||
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
|
||||
*) ac_file_in="${ac_file}.in" ;;
|
||||
esac
|
||||
|
||||
echo creating $ac_file
|
||||
|
||||
rm -f conftest.frag conftest.in conftest.out
|
||||
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
|
||||
cat $ac_file_inputs > conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_VOLATILE${ac_dB}HAVE_VOLATILE${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_VOLATILE${ac_uB}HAVE_VOLATILE${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_VOLATILE${ac_eB}HAVE_VOLATILE${ac_eC}1${ac_eD}
|
||||
${ac_dA}STDC_HEADERS${ac_dB}STDC_HEADERS${ac_dC}1${ac_dD}
|
||||
${ac_uA}STDC_HEADERS${ac_uB}STDC_HEADERS${ac_uC}1${ac_uD}
|
||||
${ac_eA}STDC_HEADERS${ac_eB}STDC_HEADERS${ac_eC}1${ac_eD}
|
||||
${ac_dA}TIME_WITH_SYS_TIME${ac_dB}TIME_WITH_SYS_TIME${ac_dC}1${ac_dD}
|
||||
${ac_uA}TIME_WITH_SYS_TIME${ac_uB}TIME_WITH_SYS_TIME${ac_uC}1${ac_uD}
|
||||
${ac_eA}TIME_WITH_SYS_TIME${ac_eB}TIME_WITH_SYS_TIME${ac_eC}1${ac_eD}
|
||||
${ac_dA}STRING_WITH_STRINGS${ac_dB}STRING_WITH_STRINGS${ac_dC}1${ac_dD}
|
||||
${ac_uA}STRING_WITH_STRINGS${ac_uB}STRING_WITH_STRINGS${ac_uC}1${ac_uD}
|
||||
${ac_eA}STRING_WITH_STRINGS${ac_eB}STRING_WITH_STRINGS${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_SYS_WAIT_H${ac_dB}HAVE_SYS_WAIT_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_WAIT_H${ac_uB}HAVE_SYS_WAIT_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_WAIT_H${ac_eB}HAVE_SYS_WAIT_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_LIMITS_H${ac_dB}HAVE_LIMITS_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_LIMITS_H${ac_uB}HAVE_LIMITS_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_LIMITS_H${ac_eB}HAVE_LIMITS_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STDDEF_H${ac_dB}HAVE_STDDEF_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STDDEF_H${ac_uB}HAVE_STDDEF_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STDDEF_H${ac_eB}HAVE_STDDEF_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STRING_H${ac_dB}HAVE_STRING_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRING_H${ac_uB}HAVE_STRING_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRING_H${ac_eB}HAVE_STRING_H${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_STRINGS_H${ac_dB}HAVE_STRINGS_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRINGS_H${ac_uB}HAVE_STRINGS_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRINGS_H${ac_eB}HAVE_STRINGS_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STDLIB_H${ac_dB}HAVE_STDLIB_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STDLIB_H${ac_uB}HAVE_STDLIB_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STDLIB_H${ac_eB}HAVE_STDLIB_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_TIME_H${ac_dB}HAVE_TIME_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_TIME_H${ac_uB}HAVE_TIME_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_TIME_H${ac_eB}HAVE_TIME_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_FCNTL_H${ac_dB}HAVE_FCNTL_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_FCNTL_H${ac_uB}HAVE_FCNTL_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_FCNTL_H${ac_eB}HAVE_FCNTL_H${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_UNISTD_H${ac_dB}HAVE_UNISTD_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_UNISTD_H${ac_uB}HAVE_UNISTD_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_UNISTD_H${ac_eB}HAVE_UNISTD_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STAB_H${ac_dB}HAVE_STAB_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STAB_H${ac_uB}HAVE_STAB_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STAB_H${ac_eB}HAVE_STAB_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYS_FILE_H${ac_dB}HAVE_SYS_FILE_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_FILE_H${ac_uB}HAVE_SYS_FILE_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_FILE_H${ac_eB}HAVE_SYS_FILE_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYS_TIME_H${ac_dB}HAVE_SYS_TIME_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_TIME_H${ac_uB}HAVE_SYS_TIME_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_TIME_H${ac_eB}HAVE_SYS_TIME_H${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_SYS_RESOURCE_H${ac_dB}HAVE_SYS_RESOURCE_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_RESOURCE_H${ac_uB}HAVE_SYS_RESOURCE_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_RESOURCE_H${ac_eB}HAVE_SYS_RESOURCE_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYS_PARAM_H${ac_dB}HAVE_SYS_PARAM_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_PARAM_H${ac_uB}HAVE_SYS_PARAM_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_PARAM_H${ac_eB}HAVE_SYS_PARAM_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYS_TIMES_H${ac_dB}HAVE_SYS_TIMES_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_TIMES_H${ac_uB}HAVE_SYS_TIMES_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_TIMES_H${ac_eB}HAVE_SYS_TIMES_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYS_STAT_H${ac_dB}HAVE_SYS_STAT_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_STAT_H${ac_uB}HAVE_SYS_STAT_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_STAT_H${ac_eB}HAVE_SYS_STAT_H${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_CPP_STRINGIFY${ac_dB}HAVE_CPP_STRINGIFY${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_CPP_STRINGIFY${ac_uB}HAVE_CPP_STRINGIFY${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_CPP_STRINGIFY${ac_eB}HAVE_CPP_STRINGIFY${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_INTTYPES_H${ac_dB}HAVE_INTTYPES_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_INTTYPES_H${ac_uB}HAVE_INTTYPES_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_INTTYPES_H${ac_eB}HAVE_INTTYPES_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STRTOUL${ac_dB}HAVE_STRTOUL${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRTOUL${ac_uB}HAVE_STRTOUL${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRTOUL${ac_eB}HAVE_STRTOUL${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_BSEARCH${ac_dB}HAVE_BSEARCH${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_BSEARCH${ac_uB}HAVE_BSEARCH${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_BSEARCH${ac_eB}HAVE_BSEARCH${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_STRERROR${ac_dB}HAVE_STRERROR${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRERROR${ac_uB}HAVE_STRERROR${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRERROR${ac_eB}HAVE_STRERROR${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_PUTENV${ac_dB}HAVE_PUTENV${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_PUTENV${ac_uB}HAVE_PUTENV${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_PUTENV${ac_eB}HAVE_PUTENV${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_POPEN${ac_dB}HAVE_POPEN${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_POPEN${ac_uB}HAVE_POPEN${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_POPEN${ac_eB}HAVE_POPEN${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_BCOPY${ac_dB}HAVE_BCOPY${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_BCOPY${ac_uB}HAVE_BCOPY${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_BCOPY${ac_eB}HAVE_BCOPY${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_BZERO${ac_dB}HAVE_BZERO${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_BZERO${ac_uB}HAVE_BZERO${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_BZERO${ac_eB}HAVE_BZERO${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_BCMP${ac_dB}HAVE_BCMP${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_BCMP${ac_uB}HAVE_BCMP${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_BCMP${ac_eB}HAVE_BCMP${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_INDEX${ac_dB}HAVE_INDEX${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_INDEX${ac_uB}HAVE_INDEX${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_INDEX${ac_eB}HAVE_INDEX${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_RINDEX${ac_dB}HAVE_RINDEX${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_RINDEX${ac_uB}HAVE_RINDEX${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_RINDEX${ac_eB}HAVE_RINDEX${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_STRCHR${ac_dB}HAVE_STRCHR${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRCHR${ac_uB}HAVE_STRCHR${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRCHR${ac_eB}HAVE_STRCHR${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STRRCHR${ac_dB}HAVE_STRRCHR${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRRCHR${ac_uB}HAVE_STRRCHR${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRRCHR${ac_eB}HAVE_STRRCHR${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_KILL${ac_dB}HAVE_KILL${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_KILL${ac_uB}HAVE_KILL${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_KILL${ac_eB}HAVE_KILL${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_GETRLIMIT${ac_dB}HAVE_GETRLIMIT${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_GETRLIMIT${ac_uB}HAVE_GETRLIMIT${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_GETRLIMIT${ac_eB}HAVE_GETRLIMIT${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_SETRLIMIT${ac_dB}HAVE_SETRLIMIT${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SETRLIMIT${ac_uB}HAVE_SETRLIMIT${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SETRLIMIT${ac_eB}HAVE_SETRLIMIT${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_ATOLL${ac_dB}HAVE_ATOLL${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_ATOLL${ac_uB}HAVE_ATOLL${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_ATOLL${ac_eB}HAVE_ATOLL${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYSCONF${ac_dB}HAVE_SYSCONF${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYSCONF${ac_uB}HAVE_SYSCONF${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYSCONF${ac_eB}HAVE_SYSCONF${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_ISASCII${ac_dB}HAVE_ISASCII${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_ISASCII${ac_uB}HAVE_ISASCII${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_ISASCII${ac_eB}HAVE_ISASCII${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_GETTIMEOFDAY${ac_dB}HAVE_GETTIMEOFDAY${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_GETTIMEOFDAY${ac_uB}HAVE_GETTIMEOFDAY${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_GETTIMEOFDAY${ac_eB}HAVE_GETTIMEOFDAY${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STRSIGNAL${ac_dB}HAVE_STRSIGNAL${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRSIGNAL${ac_uB}HAVE_STRSIGNAL${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRSIGNAL${ac_eB}HAVE_STRSIGNAL${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_PUTC_UNLOCKED${ac_dB}HAVE_PUTC_UNLOCKED${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_PUTC_UNLOCKED${ac_uB}HAVE_PUTC_UNLOCKED${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_PUTC_UNLOCKED${ac_eB}HAVE_PUTC_UNLOCKED${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_FPUTC_UNLOCKED${ac_dB}HAVE_FPUTC_UNLOCKED${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_FPUTC_UNLOCKED${ac_uB}HAVE_FPUTC_UNLOCKED${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_FPUTC_UNLOCKED${ac_eB}HAVE_FPUTC_UNLOCKED${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_FPUTS_UNLOCKED${ac_dB}HAVE_FPUTS_UNLOCKED${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_FPUTS_UNLOCKED${ac_uB}HAVE_FPUTS_UNLOCKED${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_FPUTS_UNLOCKED${ac_eB}HAVE_FPUTS_UNLOCKED${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_VPRINTF${ac_dB}HAVE_VPRINTF${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_VPRINTF${ac_uB}HAVE_VPRINTF${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_VPRINTF${ac_eB}HAVE_VPRINTF${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_PRINTF_PTR${ac_dB}HAVE_PRINTF_PTR${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_PRINTF_PTR${ac_uB}HAVE_PRINTF_PTR${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_PRINTF_PTR${ac_eB}HAVE_PRINTF_PTR${ac_eC}1${ac_eD}
|
||||
${ac_dA}SYS_SIGLIST_DECLARED${ac_dB}SYS_SIGLIST_DECLARED${ac_dC}1${ac_dD}
|
||||
${ac_uA}SYS_SIGLIST_DECLARED${ac_uB}SYS_SIGLIST_DECLARED${ac_uC}1${ac_uD}
|
||||
${ac_eA}SYS_SIGLIST_DECLARED${ac_eB}SYS_SIGLIST_DECLARED${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
rm -f conftest.frag conftest.h
|
||||
echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
|
||||
cat conftest.in >> conftest.h
|
||||
rm -f conftest.in
|
||||
if cmp -s $ac_file conftest.h 2>/dev/null; then
|
||||
echo "$ac_file is unchanged"
|
||||
rm -f conftest.h
|
||||
else
|
||||
# Remove last slash and all that follows it. Not all systems have dirname.
|
||||
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
|
||||
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
|
||||
# The file is in a subdirectory.
|
||||
test ! -d "$ac_dir" && mkdir "$ac_dir"
|
||||
fi
|
||||
rm -f $ac_file
|
||||
mv conftest.h $ac_file
|
||||
fi
|
||||
fi; done
|
||||
|
||||
|
||||
host='i686-pc-linux-gnu'
|
||||
build='i686-pc-linux-gnu'
|
||||
target='arm-unknown-elf'
|
||||
target_alias='arm-elf'
|
||||
srcdir='.'
|
||||
subdirs=''
|
||||
oldstyle_subdirs=''
|
||||
symbolic_link='ln -s'
|
||||
program_transform_set=''
|
||||
program_transform_name='s,x,x,'
|
||||
dep_host_xmake_file=''
|
||||
host_xmake_file='i386/x-i386'
|
||||
dep_tmake_file=' ./config/arm/t-arm-elf'
|
||||
tmake_file='arm/t-arm-elf'
|
||||
thread_file='single'
|
||||
gcc_version='2.9-arm-000512'
|
||||
gcc_version_trigger='./version.c'
|
||||
local_prefix='$(prefix)'
|
||||
build_install_headers_dir='install-headers-tar'
|
||||
build_exeext=''
|
||||
host_exeext=''
|
||||
out_file='arm/arm.c'
|
||||
gdb_needs_out_file_path=''
|
||||
SET_MAKE=''
|
||||
target_list='all.build all.cross start.encap rest.encap info dvi install-normal install-common install-info install-man uninstall distdir mostlyclean clean distclean extraclean maintainer-clean stage1 stage2 stage3 stage4'
|
||||
target_overrides='Make-target'
|
||||
host_overrides='Make-host'
|
||||
cross_defines='CROSS=-DCROSS_COMPILE'
|
||||
cross_overrides='/home/cameron/programming/agbcc2/gcc_arm/cross-make'
|
||||
build_overrides='/dev/null'
|
||||
|
||||
|
||||
. $srcdir/configure.lang
|
||||
case x$CONFIG_HEADERS in
|
||||
xauto-host.h:config.in)
|
||||
echo > cstamp-h ;;
|
||||
esac
|
||||
# If the host supports symlinks, point stage[1234] at ../stage[1234] so
|
||||
# bootstrapping and the installation procedure can still use
|
||||
# CC="stage1/xgcc -Bstage1/". If the host doesn't support symlinks,
|
||||
# FLAGS_TO_PASS has been modified to solve the problem there.
|
||||
# This is virtually a duplicate of what happens in configure.lang; we do
|
||||
# an extra check to make sure this only happens if ln -s can be used.
|
||||
if test "$symbolic_link" = "ln -s"; then
|
||||
for d in .. ${subdirs} ; do
|
||||
if test $d != ..; then
|
||||
STARTDIR=`pwd`
|
||||
cd $d
|
||||
for t in stage1 stage2 stage3 stage4 include
|
||||
do
|
||||
rm -f $t
|
||||
$symbolic_link ../$t $t 2>/dev/null
|
||||
done
|
||||
cd $STARTDIR
|
||||
fi
|
||||
done
|
||||
else true ; fi
|
||||
|
||||
exit 0
|
||||
108
gcc_arm/config.cache
Normal file
108
gcc_arm/config.cache
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
# This file is a shell script that caches the results of configure
|
||||
# tests run on this system so they can be shared between configure
|
||||
# scripts and configure runs. It is not useful on other systems.
|
||||
# If it contains results you don't want to keep, you may remove or edit it.
|
||||
#
|
||||
# By default, configure uses ./config.cache as the cache file,
|
||||
# creating it if it does not exist already. You can give configure
|
||||
# the --cache-file=FILE option to use a different cache file; that is
|
||||
# what configure does when it calls configure scripts in
|
||||
# subdirectories, so they share the cache.
|
||||
# Giving --cache-file=/dev/null disables caching, for debugging configure.
|
||||
# config.status only pays attention to the cache file if you give it the
|
||||
# --recheck option to rerun configure.
|
||||
#
|
||||
ac_cv_decl_sys_siglist=${ac_cv_decl_sys_siglist='yes'}
|
||||
ac_cv_func_atoll=${ac_cv_func_atoll='yes'}
|
||||
ac_cv_func_atoq=${ac_cv_func_atoq='no'}
|
||||
ac_cv_func_bcmp=${ac_cv_func_bcmp='yes'}
|
||||
ac_cv_func_bcopy=${ac_cv_func_bcopy='yes'}
|
||||
ac_cv_func_bsearch=${ac_cv_func_bsearch='yes'}
|
||||
ac_cv_func_bzero=${ac_cv_func_bzero='yes'}
|
||||
ac_cv_func_fputc_unlocked=${ac_cv_func_fputc_unlocked='yes'}
|
||||
ac_cv_func_fputs_unlocked=${ac_cv_func_fputs_unlocked='yes'}
|
||||
ac_cv_func_getrlimit=${ac_cv_func_getrlimit='yes'}
|
||||
ac_cv_func_gettimeofday=${ac_cv_func_gettimeofday='yes'}
|
||||
ac_cv_func_index=${ac_cv_func_index='yes'}
|
||||
ac_cv_func_isascii=${ac_cv_func_isascii='yes'}
|
||||
ac_cv_func_kill=${ac_cv_func_kill='yes'}
|
||||
ac_cv_func_popen=${ac_cv_func_popen='yes'}
|
||||
ac_cv_func_putc_unlocked=${ac_cv_func_putc_unlocked='yes'}
|
||||
ac_cv_func_putenv=${ac_cv_func_putenv='yes'}
|
||||
ac_cv_func_rindex=${ac_cv_func_rindex='yes'}
|
||||
ac_cv_func_setrlimit=${ac_cv_func_setrlimit='yes'}
|
||||
ac_cv_func_strchr=${ac_cv_func_strchr='yes'}
|
||||
ac_cv_func_strerror=${ac_cv_func_strerror='yes'}
|
||||
ac_cv_func_strrchr=${ac_cv_func_strrchr='yes'}
|
||||
ac_cv_func_strsignal=${ac_cv_func_strsignal='yes'}
|
||||
ac_cv_func_strtoul=${ac_cv_func_strtoul='yes'}
|
||||
ac_cv_func_sysconf=${ac_cv_func_sysconf='yes'}
|
||||
ac_cv_func_vfork_works=${ac_cv_func_vfork_works='yes'}
|
||||
ac_cv_func_vprintf=${ac_cv_func_vprintf='yes'}
|
||||
ac_cv_header_fcntl_h=${ac_cv_header_fcntl_h='yes'}
|
||||
ac_cv_header_limits_h=${ac_cv_header_limits_h='yes'}
|
||||
ac_cv_header_pthread_h=${ac_cv_header_pthread_h='yes'}
|
||||
ac_cv_header_stab_h=${ac_cv_header_stab_h='yes'}
|
||||
ac_cv_header_stdc=${ac_cv_header_stdc='yes'}
|
||||
ac_cv_header_stddef_h=${ac_cv_header_stddef_h='yes'}
|
||||
ac_cv_header_stdlib_h=${ac_cv_header_stdlib_h='yes'}
|
||||
ac_cv_header_string_h=${ac_cv_header_string_h='yes'}
|
||||
ac_cv_header_strings_h=${ac_cv_header_strings_h='yes'}
|
||||
ac_cv_header_sys_file_h=${ac_cv_header_sys_file_h='yes'}
|
||||
ac_cv_header_sys_param_h=${ac_cv_header_sys_param_h='yes'}
|
||||
ac_cv_header_sys_resource_h=${ac_cv_header_sys_resource_h='yes'}
|
||||
ac_cv_header_sys_stat_h=${ac_cv_header_sys_stat_h='yes'}
|
||||
ac_cv_header_sys_time_h=${ac_cv_header_sys_time_h='yes'}
|
||||
ac_cv_header_sys_times_h=${ac_cv_header_sys_times_h='yes'}
|
||||
ac_cv_header_sys_wait_h=${ac_cv_header_sys_wait_h='yes'}
|
||||
ac_cv_header_thread_h=${ac_cv_header_thread_h='no'}
|
||||
ac_cv_header_time=${ac_cv_header_time='yes'}
|
||||
ac_cv_header_time_h=${ac_cv_header_time_h='yes'}
|
||||
ac_cv_header_unistd_h=${ac_cv_header_unistd_h='yes'}
|
||||
ac_cv_header_vfork_h=${ac_cv_header_vfork_h='no'}
|
||||
ac_cv_lib_fl_yywrap=${ac_cv_lib_fl_yywrap='no'}
|
||||
ac_cv_path_install=${ac_cv_path_install='/usr/bin/install -c'}
|
||||
ac_cv_prog_AWK=${ac_cv_prog_AWK='mawk'}
|
||||
ac_cv_prog_CC=${ac_cv_prog_CC='gcc'}
|
||||
ac_cv_prog_CPP=${ac_cv_prog_CPP='gcc -E'}
|
||||
ac_cv_prog_LEX=${ac_cv_prog_LEX='flex'}
|
||||
ac_cv_prog_RANLIB=${ac_cv_prog_RANLIB='ranlib'}
|
||||
ac_cv_prog_YACC=${ac_cv_prog_YACC='bison -y'}
|
||||
ac_cv_prog_cc_cross=${ac_cv_prog_cc_cross='no'}
|
||||
ac_cv_prog_cc_g=${ac_cv_prog_cc_g='yes'}
|
||||
ac_cv_prog_cc_works=${ac_cv_prog_cc_works='yes'}
|
||||
ac_cv_prog_gcc=${ac_cv_prog_gcc='yes'}
|
||||
ac_cv_prog_gnat=${ac_cv_prog_gnat='no'}
|
||||
ac_cv_prog_make_make_set=${ac_cv_prog_make_make_set='yes'}
|
||||
ac_cv_type_pid_t=${ac_cv_type_pid_t='yes'}
|
||||
gcc_cv_as=${gcc_cv_as=''}
|
||||
gcc_cv_as_alignment_features=${gcc_cv_as_alignment_features=''}
|
||||
gcc_cv_as_gas_srcdir=${gcc_cv_as_gas_srcdir='./gas'}
|
||||
gcc_cv_as_subsections=${gcc_cv_as_subsections=''}
|
||||
gcc_cv_c_have_stringify=${gcc_cv_c_have_stringify='yes'}
|
||||
gcc_cv_c_volatile=${gcc_cv_c_volatile='yes'}
|
||||
gcc_cv_decl_needed_abort=${gcc_cv_decl_needed_abort='no'}
|
||||
gcc_cv_decl_needed_atof=${gcc_cv_decl_needed_atof='no'}
|
||||
gcc_cv_decl_needed_atol=${gcc_cv_decl_needed_atol='no'}
|
||||
gcc_cv_decl_needed_bcmp=${gcc_cv_decl_needed_bcmp='no'}
|
||||
gcc_cv_decl_needed_bcopy=${gcc_cv_decl_needed_bcopy='no'}
|
||||
gcc_cv_decl_needed_bzero=${gcc_cv_decl_needed_bzero='no'}
|
||||
gcc_cv_decl_needed_calloc=${gcc_cv_decl_needed_calloc='no'}
|
||||
gcc_cv_decl_needed_free=${gcc_cv_decl_needed_free='no'}
|
||||
gcc_cv_decl_needed_getcwd=${gcc_cv_decl_needed_getcwd='no'}
|
||||
gcc_cv_decl_needed_getenv=${gcc_cv_decl_needed_getenv='no'}
|
||||
gcc_cv_decl_needed_getrlimit=${gcc_cv_decl_needed_getrlimit='no'}
|
||||
gcc_cv_decl_needed_getwd=${gcc_cv_decl_needed_getwd='no'}
|
||||
gcc_cv_decl_needed_index=${gcc_cv_decl_needed_index='no'}
|
||||
gcc_cv_decl_needed_malloc=${gcc_cv_decl_needed_malloc='no'}
|
||||
gcc_cv_decl_needed_realloc=${gcc_cv_decl_needed_realloc='no'}
|
||||
gcc_cv_decl_needed_rindex=${gcc_cv_decl_needed_rindex='no'}
|
||||
gcc_cv_decl_needed_sbrk=${gcc_cv_decl_needed_sbrk='no'}
|
||||
gcc_cv_decl_needed_setrlimit=${gcc_cv_decl_needed_setrlimit='no'}
|
||||
gcc_cv_decl_needed_strerror=${gcc_cv_decl_needed_strerror='no'}
|
||||
gcc_cv_decl_needed_strsignal=${gcc_cv_decl_needed_strsignal='no'}
|
||||
gcc_cv_func_printf_ptr=${gcc_cv_func_printf_ptr='yes'}
|
||||
gcc_cv_header_inttypes_h=${gcc_cv_header_inttypes_h='yes'}
|
||||
gcc_cv_header_string=${gcc_cv_header_string='yes'}
|
||||
gcc_cv_prog_LN=${gcc_cv_prog_LN='ln'}
|
||||
gcc_cv_prog_LN_S=${gcc_cv_prog_LN_S='ln -s'}
|
||||
12
gcc_arm/config.h
Normal file
12
gcc_arm/config.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include "auto-host.h"
|
||||
#include "gansidecl.h"
|
||||
#include "i386/xm-i386.h"
|
||||
#ifndef HAVE_ATEXIT
|
||||
#define HAVE_ATEXIT
|
||||
#endif
|
||||
#ifndef POSIX
|
||||
#define POSIX
|
||||
#endif
|
||||
#ifndef BSTRING
|
||||
#define BSTRING
|
||||
#endif
|
||||
588
gcc_arm/config.status
Executable file
588
gcc_arm/config.status
Executable file
|
|
@ -0,0 +1,588 @@
|
|||
#! /bin/sh
|
||||
# Generated automatically by configure.
|
||||
# Run this file to recreate the current configuration.
|
||||
# This directory was configured as follows,
|
||||
# on host cameron-HP-Pavilion-g7-Notebook-PC:
|
||||
#
|
||||
# ./configure --target=arm-elf --host=i686-linux-gnu
|
||||
#
|
||||
# Compiler output produced by configure, useful for debugging
|
||||
# configure, is in ./config.log if it exists.
|
||||
|
||||
ac_cs_usage="Usage: ./config.status [--recheck] [--version] [--help]"
|
||||
for ac_option
|
||||
do
|
||||
case "$ac_option" in
|
||||
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
|
||||
echo "running ${CONFIG_SHELL-/bin/sh} ./configure --target=arm-elf --host=i686-linux-gnu --no-create --no-recursion"
|
||||
exec ${CONFIG_SHELL-/bin/sh} ./configure --target=arm-elf --host=i686-linux-gnu --no-create --no-recursion ;;
|
||||
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
|
||||
echo "./config.status generated by autoconf version 2.13"
|
||||
exit 0 ;;
|
||||
-help | --help | --hel | --he | --h)
|
||||
echo "$ac_cs_usage"; exit 0 ;;
|
||||
*) echo "$ac_cs_usage"; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
ac_given_srcdir=.
|
||||
|
||||
trap 'rm -fr Makefile auto-host.h conftest*; exit 1' 1 2 15
|
||||
|
||||
# Protect against being on the right side of a sed subst in config.status.
|
||||
sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\&%]/\\&/g;
|
||||
s/@@/%@/; s/@@/@%/; s/@g$/%g/' > conftest.subs <<\CEOF
|
||||
/^[ ]*VPATH[ ]*=[^:]*$/d
|
||||
|
||||
s%@SHELL@%/bin/sh%g
|
||||
s%@CFLAGS@%-g -O2%g
|
||||
s%@CPPFLAGS@%%g
|
||||
s%@CXXFLAGS@%%g
|
||||
s%@FFLAGS@%%g
|
||||
s%@DEFS@%-DHAVE_CONFIG_H%g
|
||||
s%@LDFLAGS@%%g
|
||||
s%@LIBS@%%g
|
||||
s%@exec_prefix@%${prefix}%g
|
||||
s%@prefix@%/usr/local%g
|
||||
s%@program_transform_name@%s,x,x,%g
|
||||
s%@bindir@%${exec_prefix}/bin%g
|
||||
s%@sbindir@%${exec_prefix}/sbin%g
|
||||
s%@libexecdir@%${exec_prefix}/libexec%g
|
||||
s%@datadir@%${prefix}/share%g
|
||||
s%@sysconfdir@%${prefix}/etc%g
|
||||
s%@sharedstatedir@%${prefix}/com%g
|
||||
s%@localstatedir@%${prefix}/var%g
|
||||
s%@libdir@%${exec_prefix}/lib%g
|
||||
s%@includedir@%${prefix}/include%g
|
||||
s%@oldincludedir@%/usr/include%g
|
||||
s%@infodir@%${prefix}/info%g
|
||||
s%@mandir@%${prefix}/man%g
|
||||
s%@host@%i686-pc-linux-gnu%g
|
||||
s%@host_alias@%i686-linux-gnu%g
|
||||
s%@host_cpu@%i686%g
|
||||
s%@host_vendor@%pc%g
|
||||
s%@host_os@%linux-gnu%g
|
||||
s%@target@%arm-unknown-elf%g
|
||||
s%@target_alias@%arm-elf%g
|
||||
s%@target_cpu@%arm%g
|
||||
s%@target_vendor@%unknown%g
|
||||
s%@target_os@%elf%g
|
||||
s%@build@%i686-pc-linux-gnu%g
|
||||
s%@build_alias@%i686-linux-gnu%g
|
||||
s%@build_cpu@%i686%g
|
||||
s%@build_vendor@%pc%g
|
||||
s%@build_os@%linux-gnu%g
|
||||
s%@CC@%gcc%g
|
||||
s%@stage1_warn_cflags@%$(WARN_CFLAGS)%g
|
||||
s%@SET_MAKE@%%g
|
||||
s%@AWK@%mawk%g
|
||||
s%@LEX@%flex%g
|
||||
s%@LEXLIB@%%g
|
||||
s%@LN@%ln%g
|
||||
s%@LN_S@%ln -s%g
|
||||
s%@RANLIB@%ranlib%g
|
||||
s%@YACC@%bison -y%g
|
||||
s%@INSTALL@%/usr/bin/install -c%g
|
||||
s%@INSTALL_PROGRAM@%${INSTALL}%g
|
||||
s%@INSTALL_DATA@%${INSTALL} -m 644%g
|
||||
s%@CPP@%gcc -E%g
|
||||
s%@gnat@%no%g
|
||||
s%@vfprintf@%%g
|
||||
s%@doprint@%%g
|
||||
s%@manext@%.1%g
|
||||
s%@objext@%.o%g
|
||||
s%@gthread_flags@%%g
|
||||
s%@build_canonical@%i686-pc-linux-gnu%g
|
||||
s%@host_canonical@%i686-pc-linux-gnu%g
|
||||
s%@target_subdir@%arm-unknown-elf/%g
|
||||
s%@inhibit_libc@%%g
|
||||
s%@sched_prefix@%%g
|
||||
s%@sched_cflags@%%g
|
||||
s%@gcc_tooldir@%$(libsubdir)/$(unlibsubdir)/../$(target_alias)%g
|
||||
s%@dollar@%%g
|
||||
s%@objdir@%/home/cameron/programming/agbcc2/gcc_arm%g
|
||||
s%@subdirs@%%g
|
||||
s%@all_languages@%%g
|
||||
s%@all_boot_languages@%%g
|
||||
s%@all_compilers@%%g
|
||||
s%@all_lang_makefiles@%%g
|
||||
s%@all_stagestuff@%%g
|
||||
s%@all_diff_excludes@%%g
|
||||
s%@all_lib2funcs@%%g
|
||||
s%@all_headers@%%g
|
||||
s%@cpp_main@%cccp%g
|
||||
s%@extra_passes@%%g
|
||||
s%@extra_programs@%%g
|
||||
s%@extra_parts@%%g
|
||||
s%@extra_c_objs@%%g
|
||||
s%@extra_cxx_objs@%%g
|
||||
s%@extra_cpp_objs@%%g
|
||||
s%@extra_c_flags@% -DMULTIBYTE_CHARS=1%g
|
||||
s%@extra_objs@% %g
|
||||
s%@host_extra_gcc_objs@%%g
|
||||
s%@extra_headers_list@%%g
|
||||
s%@dep_host_xmake_file@%%g
|
||||
s%@dep_tmake_file@% ./config/arm/t-arm-elf%g
|
||||
s%@out_file@%arm/arm.c%g
|
||||
s%@out_object_file@%arm.o%g
|
||||
s%@md_file@%arm/arm.md%g
|
||||
s%@tm_file_list@% gansidecl.h $(srcdir)/config/arm/unknown-elf.h%g
|
||||
s%@build_xm_file_list@% auto-host.h gansidecl.h $(srcdir)/config/i386/xm-i386.h%g
|
||||
s%@host_xm_file_list@% auto-host.h gansidecl.h $(srcdir)/config/i386/xm-i386.h%g
|
||||
s%@lang_specs_files@%%g
|
||||
s%@lang_options_files@%%g
|
||||
s%@lang_tree_files@%%g
|
||||
s%@thread_file@%single%g
|
||||
s%@objc_boehm_gc@%%g
|
||||
s%@JAVAGC@%boehm%g
|
||||
s%@gcc_version@%2.9-arm-000512%g
|
||||
s%@gcc_version_trigger@%./version.c%g
|
||||
s%@local_prefix@%$(prefix)%g
|
||||
s%@gcc_gxx_include_dir@%$(libsubdir)/$(unlibsubdir)/..`echo $(exec_prefix) | sed -e 's|^$(prefix)||' -e 's|/[^/]*|/..|g'`/include/g++-%g
|
||||
s%@fixincludes@%fixincludes%g
|
||||
s%@build_install_headers_dir@%install-headers-tar%g
|
||||
s%@build_exeext@%%g
|
||||
s%@host_exeext@%%g
|
||||
s%@float_h_file@%float-i64.h%g
|
||||
s%@cc_set_by_configure@%$(CC)%g
|
||||
s%@stage_prefix_set_by_configure@%$(STAGE_PREFIX)%g
|
||||
s%@install@%%g
|
||||
s%@symbolic_link@%ln -s%g
|
||||
/@target_overrides@/r Make-target
|
||||
s%@target_overrides@%%g
|
||||
/@host_overrides@/r Make-host
|
||||
s%@host_overrides@%%g
|
||||
s%@cross_defines@%CROSS=-DCROSS_COMPILE%g
|
||||
/@cross_overrides@/r /home/cameron/programming/agbcc2/gcc_arm/cross-make
|
||||
s%@cross_overrides@%%g
|
||||
/@build_overrides@/r /dev/null
|
||||
s%@build_overrides@%%g
|
||||
/@language_fragments@/r Make-lang
|
||||
s%@language_fragments@%%g
|
||||
/@language_hooks@/r Make-hooks
|
||||
s%@language_hooks@%%g
|
||||
|
||||
CEOF
|
||||
|
||||
# Split the substitutions into bite-sized pieces for seds with
|
||||
# small command number limits, like on Digital OSF/1 and HP-UX.
|
||||
ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
|
||||
ac_file=1 # Number of current file.
|
||||
ac_beg=1 # First line for current file.
|
||||
ac_end=$ac_max_sed_cmds # Line after last line for current file.
|
||||
ac_more_lines=:
|
||||
ac_sed_cmds=""
|
||||
while $ac_more_lines; do
|
||||
if test $ac_beg -gt 1; then
|
||||
sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
|
||||
else
|
||||
sed "${ac_end}q" conftest.subs > conftest.s$ac_file
|
||||
fi
|
||||
if test ! -s conftest.s$ac_file; then
|
||||
ac_more_lines=false
|
||||
rm -f conftest.s$ac_file
|
||||
else
|
||||
if test -z "$ac_sed_cmds"; then
|
||||
ac_sed_cmds="sed -f conftest.s$ac_file"
|
||||
else
|
||||
ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
|
||||
fi
|
||||
ac_file=`expr $ac_file + 1`
|
||||
ac_beg=$ac_end
|
||||
ac_end=`expr $ac_end + $ac_max_sed_cmds`
|
||||
fi
|
||||
done
|
||||
if test -z "$ac_sed_cmds"; then
|
||||
ac_sed_cmds=cat
|
||||
fi
|
||||
|
||||
CONFIG_FILES=${CONFIG_FILES-"Makefile"}
|
||||
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
|
||||
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
|
||||
case "$ac_file" in
|
||||
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
|
||||
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
|
||||
*) ac_file_in="${ac_file}.in" ;;
|
||||
esac
|
||||
|
||||
# Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
|
||||
|
||||
# Remove last slash and all that follows it. Not all systems have dirname.
|
||||
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
|
||||
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
|
||||
# The file is in a subdirectory.
|
||||
test ! -d "$ac_dir" && mkdir "$ac_dir"
|
||||
ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
|
||||
# A "../" for each directory in $ac_dir_suffix.
|
||||
ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
|
||||
else
|
||||
ac_dir_suffix= ac_dots=
|
||||
fi
|
||||
|
||||
case "$ac_given_srcdir" in
|
||||
.) srcdir=.
|
||||
if test -z "$ac_dots"; then top_srcdir=.
|
||||
else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
|
||||
/*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
|
||||
*) # Relative path.
|
||||
srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
|
||||
top_srcdir="$ac_dots$ac_given_srcdir" ;;
|
||||
esac
|
||||
|
||||
|
||||
echo creating "$ac_file"
|
||||
rm -f "$ac_file"
|
||||
configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
|
||||
case "$ac_file" in
|
||||
*Makefile*) ac_comsub="1i\\
|
||||
# $configure_input" ;;
|
||||
*) ac_comsub= ;;
|
||||
esac
|
||||
|
||||
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
|
||||
sed -e "$ac_comsub
|
||||
s%@configure_input@%$configure_input%g
|
||||
s%@srcdir@%$srcdir%g
|
||||
s%@top_srcdir@%$top_srcdir%g
|
||||
" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
|
||||
fi; done
|
||||
rm -f conftest.s*
|
||||
|
||||
# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
|
||||
# NAME is the cpp macro being defined and VALUE is the value it is being given.
|
||||
#
|
||||
# ac_d sets the value in "#define NAME VALUE" lines.
|
||||
ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
|
||||
ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
|
||||
ac_dC='\3'
|
||||
ac_dD='%g'
|
||||
# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
|
||||
ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
|
||||
ac_uB='\([ ]\)%\1#\2define\3'
|
||||
ac_uC=' '
|
||||
ac_uD='\4%g'
|
||||
# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
|
||||
ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
|
||||
ac_eB='$%\1#\2define\3'
|
||||
ac_eC=' '
|
||||
ac_eD='%g'
|
||||
|
||||
if test "${CONFIG_HEADERS+set}" != set; then
|
||||
CONFIG_HEADERS="auto-host.h:config.in"
|
||||
fi
|
||||
for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
|
||||
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
|
||||
case "$ac_file" in
|
||||
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
|
||||
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
|
||||
*) ac_file_in="${ac_file}.in" ;;
|
||||
esac
|
||||
|
||||
echo creating $ac_file
|
||||
|
||||
rm -f conftest.frag conftest.in conftest.out
|
||||
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
|
||||
cat $ac_file_inputs > conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_VOLATILE${ac_dB}HAVE_VOLATILE${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_VOLATILE${ac_uB}HAVE_VOLATILE${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_VOLATILE${ac_eB}HAVE_VOLATILE${ac_eC}1${ac_eD}
|
||||
${ac_dA}STDC_HEADERS${ac_dB}STDC_HEADERS${ac_dC}1${ac_dD}
|
||||
${ac_uA}STDC_HEADERS${ac_uB}STDC_HEADERS${ac_uC}1${ac_uD}
|
||||
${ac_eA}STDC_HEADERS${ac_eB}STDC_HEADERS${ac_eC}1${ac_eD}
|
||||
${ac_dA}TIME_WITH_SYS_TIME${ac_dB}TIME_WITH_SYS_TIME${ac_dC}1${ac_dD}
|
||||
${ac_uA}TIME_WITH_SYS_TIME${ac_uB}TIME_WITH_SYS_TIME${ac_uC}1${ac_uD}
|
||||
${ac_eA}TIME_WITH_SYS_TIME${ac_eB}TIME_WITH_SYS_TIME${ac_eC}1${ac_eD}
|
||||
${ac_dA}STRING_WITH_STRINGS${ac_dB}STRING_WITH_STRINGS${ac_dC}1${ac_dD}
|
||||
${ac_uA}STRING_WITH_STRINGS${ac_uB}STRING_WITH_STRINGS${ac_uC}1${ac_uD}
|
||||
${ac_eA}STRING_WITH_STRINGS${ac_eB}STRING_WITH_STRINGS${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_SYS_WAIT_H${ac_dB}HAVE_SYS_WAIT_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_WAIT_H${ac_uB}HAVE_SYS_WAIT_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_WAIT_H${ac_eB}HAVE_SYS_WAIT_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_LIMITS_H${ac_dB}HAVE_LIMITS_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_LIMITS_H${ac_uB}HAVE_LIMITS_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_LIMITS_H${ac_eB}HAVE_LIMITS_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STDDEF_H${ac_dB}HAVE_STDDEF_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STDDEF_H${ac_uB}HAVE_STDDEF_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STDDEF_H${ac_eB}HAVE_STDDEF_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STRING_H${ac_dB}HAVE_STRING_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRING_H${ac_uB}HAVE_STRING_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRING_H${ac_eB}HAVE_STRING_H${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_STRINGS_H${ac_dB}HAVE_STRINGS_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRINGS_H${ac_uB}HAVE_STRINGS_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRINGS_H${ac_eB}HAVE_STRINGS_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STDLIB_H${ac_dB}HAVE_STDLIB_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STDLIB_H${ac_uB}HAVE_STDLIB_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STDLIB_H${ac_eB}HAVE_STDLIB_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_TIME_H${ac_dB}HAVE_TIME_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_TIME_H${ac_uB}HAVE_TIME_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_TIME_H${ac_eB}HAVE_TIME_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_FCNTL_H${ac_dB}HAVE_FCNTL_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_FCNTL_H${ac_uB}HAVE_FCNTL_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_FCNTL_H${ac_eB}HAVE_FCNTL_H${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_UNISTD_H${ac_dB}HAVE_UNISTD_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_UNISTD_H${ac_uB}HAVE_UNISTD_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_UNISTD_H${ac_eB}HAVE_UNISTD_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STAB_H${ac_dB}HAVE_STAB_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STAB_H${ac_uB}HAVE_STAB_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STAB_H${ac_eB}HAVE_STAB_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYS_FILE_H${ac_dB}HAVE_SYS_FILE_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_FILE_H${ac_uB}HAVE_SYS_FILE_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_FILE_H${ac_eB}HAVE_SYS_FILE_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYS_TIME_H${ac_dB}HAVE_SYS_TIME_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_TIME_H${ac_uB}HAVE_SYS_TIME_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_TIME_H${ac_eB}HAVE_SYS_TIME_H${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_SYS_RESOURCE_H${ac_dB}HAVE_SYS_RESOURCE_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_RESOURCE_H${ac_uB}HAVE_SYS_RESOURCE_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_RESOURCE_H${ac_eB}HAVE_SYS_RESOURCE_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYS_PARAM_H${ac_dB}HAVE_SYS_PARAM_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_PARAM_H${ac_uB}HAVE_SYS_PARAM_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_PARAM_H${ac_eB}HAVE_SYS_PARAM_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYS_TIMES_H${ac_dB}HAVE_SYS_TIMES_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_TIMES_H${ac_uB}HAVE_SYS_TIMES_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_TIMES_H${ac_eB}HAVE_SYS_TIMES_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYS_STAT_H${ac_dB}HAVE_SYS_STAT_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYS_STAT_H${ac_uB}HAVE_SYS_STAT_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYS_STAT_H${ac_eB}HAVE_SYS_STAT_H${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_CPP_STRINGIFY${ac_dB}HAVE_CPP_STRINGIFY${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_CPP_STRINGIFY${ac_uB}HAVE_CPP_STRINGIFY${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_CPP_STRINGIFY${ac_eB}HAVE_CPP_STRINGIFY${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_INTTYPES_H${ac_dB}HAVE_INTTYPES_H${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_INTTYPES_H${ac_uB}HAVE_INTTYPES_H${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_INTTYPES_H${ac_eB}HAVE_INTTYPES_H${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STRTOUL${ac_dB}HAVE_STRTOUL${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRTOUL${ac_uB}HAVE_STRTOUL${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRTOUL${ac_eB}HAVE_STRTOUL${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_BSEARCH${ac_dB}HAVE_BSEARCH${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_BSEARCH${ac_uB}HAVE_BSEARCH${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_BSEARCH${ac_eB}HAVE_BSEARCH${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_STRERROR${ac_dB}HAVE_STRERROR${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRERROR${ac_uB}HAVE_STRERROR${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRERROR${ac_eB}HAVE_STRERROR${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_PUTENV${ac_dB}HAVE_PUTENV${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_PUTENV${ac_uB}HAVE_PUTENV${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_PUTENV${ac_eB}HAVE_PUTENV${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_POPEN${ac_dB}HAVE_POPEN${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_POPEN${ac_uB}HAVE_POPEN${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_POPEN${ac_eB}HAVE_POPEN${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_BCOPY${ac_dB}HAVE_BCOPY${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_BCOPY${ac_uB}HAVE_BCOPY${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_BCOPY${ac_eB}HAVE_BCOPY${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_BZERO${ac_dB}HAVE_BZERO${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_BZERO${ac_uB}HAVE_BZERO${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_BZERO${ac_eB}HAVE_BZERO${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_BCMP${ac_dB}HAVE_BCMP${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_BCMP${ac_uB}HAVE_BCMP${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_BCMP${ac_eB}HAVE_BCMP${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_INDEX${ac_dB}HAVE_INDEX${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_INDEX${ac_uB}HAVE_INDEX${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_INDEX${ac_eB}HAVE_INDEX${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_RINDEX${ac_dB}HAVE_RINDEX${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_RINDEX${ac_uB}HAVE_RINDEX${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_RINDEX${ac_eB}HAVE_RINDEX${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_STRCHR${ac_dB}HAVE_STRCHR${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRCHR${ac_uB}HAVE_STRCHR${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRCHR${ac_eB}HAVE_STRCHR${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STRRCHR${ac_dB}HAVE_STRRCHR${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRRCHR${ac_uB}HAVE_STRRCHR${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRRCHR${ac_eB}HAVE_STRRCHR${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_KILL${ac_dB}HAVE_KILL${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_KILL${ac_uB}HAVE_KILL${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_KILL${ac_eB}HAVE_KILL${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_GETRLIMIT${ac_dB}HAVE_GETRLIMIT${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_GETRLIMIT${ac_uB}HAVE_GETRLIMIT${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_GETRLIMIT${ac_eB}HAVE_GETRLIMIT${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_SETRLIMIT${ac_dB}HAVE_SETRLIMIT${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SETRLIMIT${ac_uB}HAVE_SETRLIMIT${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SETRLIMIT${ac_eB}HAVE_SETRLIMIT${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_ATOLL${ac_dB}HAVE_ATOLL${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_ATOLL${ac_uB}HAVE_ATOLL${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_ATOLL${ac_eB}HAVE_ATOLL${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_SYSCONF${ac_dB}HAVE_SYSCONF${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_SYSCONF${ac_uB}HAVE_SYSCONF${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_SYSCONF${ac_eB}HAVE_SYSCONF${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_ISASCII${ac_dB}HAVE_ISASCII${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_ISASCII${ac_uB}HAVE_ISASCII${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_ISASCII${ac_eB}HAVE_ISASCII${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_GETTIMEOFDAY${ac_dB}HAVE_GETTIMEOFDAY${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_GETTIMEOFDAY${ac_uB}HAVE_GETTIMEOFDAY${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_GETTIMEOFDAY${ac_eB}HAVE_GETTIMEOFDAY${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_STRSIGNAL${ac_dB}HAVE_STRSIGNAL${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_STRSIGNAL${ac_uB}HAVE_STRSIGNAL${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_STRSIGNAL${ac_eB}HAVE_STRSIGNAL${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_PUTC_UNLOCKED${ac_dB}HAVE_PUTC_UNLOCKED${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_PUTC_UNLOCKED${ac_uB}HAVE_PUTC_UNLOCKED${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_PUTC_UNLOCKED${ac_eB}HAVE_PUTC_UNLOCKED${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_FPUTC_UNLOCKED${ac_dB}HAVE_FPUTC_UNLOCKED${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_FPUTC_UNLOCKED${ac_uB}HAVE_FPUTC_UNLOCKED${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_FPUTC_UNLOCKED${ac_eB}HAVE_FPUTC_UNLOCKED${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
${ac_dA}HAVE_FPUTS_UNLOCKED${ac_dB}HAVE_FPUTS_UNLOCKED${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_FPUTS_UNLOCKED${ac_uB}HAVE_FPUTS_UNLOCKED${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_FPUTS_UNLOCKED${ac_eB}HAVE_FPUTS_UNLOCKED${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_VPRINTF${ac_dB}HAVE_VPRINTF${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_VPRINTF${ac_uB}HAVE_VPRINTF${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_VPRINTF${ac_eB}HAVE_VPRINTF${ac_eC}1${ac_eD}
|
||||
${ac_dA}HAVE_PRINTF_PTR${ac_dB}HAVE_PRINTF_PTR${ac_dC}1${ac_dD}
|
||||
${ac_uA}HAVE_PRINTF_PTR${ac_uB}HAVE_PRINTF_PTR${ac_uC}1${ac_uD}
|
||||
${ac_eA}HAVE_PRINTF_PTR${ac_eB}HAVE_PRINTF_PTR${ac_eC}1${ac_eD}
|
||||
${ac_dA}SYS_SIGLIST_DECLARED${ac_dB}SYS_SIGLIST_DECLARED${ac_dC}1${ac_dD}
|
||||
${ac_uA}SYS_SIGLIST_DECLARED${ac_uB}SYS_SIGLIST_DECLARED${ac_uC}1${ac_uD}
|
||||
${ac_eA}SYS_SIGLIST_DECLARED${ac_eB}SYS_SIGLIST_DECLARED${ac_eC}1${ac_eD}
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
cat > conftest.frag <<CEOF
|
||||
s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
|
||||
CEOF
|
||||
sed -f conftest.frag conftest.in > conftest.out
|
||||
rm -f conftest.in
|
||||
mv conftest.out conftest.in
|
||||
|
||||
rm -f conftest.frag conftest.h
|
||||
echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
|
||||
cat conftest.in >> conftest.h
|
||||
rm -f conftest.in
|
||||
if cmp -s $ac_file conftest.h 2>/dev/null; then
|
||||
echo "$ac_file is unchanged"
|
||||
rm -f conftest.h
|
||||
else
|
||||
# Remove last slash and all that follows it. Not all systems have dirname.
|
||||
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
|
||||
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
|
||||
# The file is in a subdirectory.
|
||||
test ! -d "$ac_dir" && mkdir "$ac_dir"
|
||||
fi
|
||||
rm -f $ac_file
|
||||
mv conftest.h $ac_file
|
||||
fi
|
||||
fi; done
|
||||
|
||||
|
||||
host='i686-pc-linux-gnu'
|
||||
build='i686-pc-linux-gnu'
|
||||
target='arm-unknown-elf'
|
||||
target_alias='arm-elf'
|
||||
srcdir='.'
|
||||
subdirs=''
|
||||
oldstyle_subdirs=''
|
||||
symbolic_link='ln -s'
|
||||
program_transform_set=''
|
||||
program_transform_name='s,x,x,'
|
||||
dep_host_xmake_file=''
|
||||
host_xmake_file='i386/x-i386'
|
||||
dep_tmake_file=' ./config/arm/t-arm-elf'
|
||||
tmake_file='arm/t-arm-elf'
|
||||
thread_file='single'
|
||||
gcc_version='2.9-arm-000512'
|
||||
gcc_version_trigger='./version.c'
|
||||
local_prefix='$(prefix)'
|
||||
build_install_headers_dir='install-headers-tar'
|
||||
build_exeext=''
|
||||
host_exeext=''
|
||||
out_file='arm/arm.c'
|
||||
gdb_needs_out_file_path=''
|
||||
SET_MAKE=''
|
||||
target_list='all.build all.cross start.encap rest.encap info dvi install-normal install-common install-info install-man uninstall distdir mostlyclean clean distclean extraclean maintainer-clean stage1 stage2 stage3 stage4'
|
||||
target_overrides='Make-target'
|
||||
host_overrides='Make-host'
|
||||
cross_defines='CROSS=-DCROSS_COMPILE'
|
||||
cross_overrides='/home/cameron/programming/agbcc2/gcc_arm/cross-make'
|
||||
build_overrides='/dev/null'
|
||||
|
||||
|
||||
. $srcdir/configure.lang
|
||||
case x$CONFIG_HEADERS in
|
||||
xauto-host.h:config.in)
|
||||
echo > cstamp-h ;;
|
||||
esac
|
||||
# If the host supports symlinks, point stage[1234] at ../stage[1234] so
|
||||
# bootstrapping and the installation procedure can still use
|
||||
# CC="stage1/xgcc -Bstage1/". If the host doesn't support symlinks,
|
||||
# FLAGS_TO_PASS has been modified to solve the problem there.
|
||||
# This is virtually a duplicate of what happens in configure.lang; we do
|
||||
# an extra check to make sure this only happens if ln -s can be used.
|
||||
if test "$symbolic_link" = "ln -s"; then
|
||||
for d in .. ${subdirs} ; do
|
||||
if test $d != ..; then
|
||||
STARTDIR=`pwd`
|
||||
cd $d
|
||||
for t in stage1 stage2 stage3 stage4 include
|
||||
do
|
||||
rm -f $t
|
||||
$symbolic_link ../$t $t 2>/dev/null
|
||||
done
|
||||
cd $STARTDIR
|
||||
fi
|
||||
done
|
||||
else true ; fi
|
||||
|
||||
exit 0
|
||||
1
gcc_arm/cstamp-h
Normal file
1
gcc_arm/cstamp-h
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
0
gcc_arm/gencheck.h
Normal file
0
gcc_arm/gencheck.h
Normal file
12
gcc_arm/hconfig.h
Normal file
12
gcc_arm/hconfig.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include "auto-host.h"
|
||||
#include "gansidecl.h"
|
||||
#include "i386/xm-i386.h"
|
||||
#ifndef HAVE_ATEXIT
|
||||
#define HAVE_ATEXIT
|
||||
#endif
|
||||
#ifndef POSIX
|
||||
#define POSIX
|
||||
#endif
|
||||
#ifndef BSTRING
|
||||
#define BSTRING
|
||||
#endif
|
||||
1
gcc_arm/obstack.c
Symbolic link
1
gcc_arm/obstack.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
./../libiberty/obstack.c
|
||||
0
gcc_arm/options.h
Normal file
0
gcc_arm/options.h
Normal file
0
gcc_arm/specs.h
Normal file
0
gcc_arm/specs.h
Normal file
1
gcc_arm/splay-tree.c
Symbolic link
1
gcc_arm/splay-tree.c
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
./../libiberty/splay-tree.c
|
||||
2
gcc_arm/tconfig.h
Normal file
2
gcc_arm/tconfig.h
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#include "gansidecl.h"
|
||||
#include "arm/xm-arm.h"
|
||||
3
gcc_arm/tm.h
Normal file
3
gcc_arm/tm.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#define TARGET_CPU_DEFAULT (TARGET_CPU_generic)
|
||||
#include "gansidecl.h"
|
||||
#include "arm/unknown-elf.h"
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
#line 59 "config/arc/arc.h"
|
||||
_("may not use both -EB and -EL")
|
||||
#line 176 "config/arm/arm.h"
|
||||
_("-mapcs-26 and -mapcs-32 may not be used together")
|
||||
#line 187 "config/arm/arm.h"
|
||||
_("-msoft-float and -mhard_float may not be used together")
|
||||
#line 198 "config/arm/arm.h"
|
||||
_("-mbig-endian and -mlittle-endian may not be used together")
|
||||
#line 72 "config/arm/riscix.h"
|
||||
_("-mbsd and -pedantic incompatible")
|
||||
#line 73 "config/arm/riscix.h"
|
||||
_("-mbsd and -mxopen incompatible")
|
||||
#line 74 "config/arm/riscix.h"
|
||||
_("-mxopen and -pedantic incompatible")
|
||||
#line 133 "config/arm/riscix.h"
|
||||
_("-mbsd and -pedantic incompatible")
|
||||
#line 134 "config/arm/riscix.h"
|
||||
_("-mbsd and -mxopen incompatible")
|
||||
#line 135 "config/arm/riscix.h"
|
||||
_("-mxopen and -pedantic incompatible")
|
||||
#line 126 "config/dsp16xx/dsp16xx.h"
|
||||
_("A -ifile option requires a -map option")
|
||||
#line 135 "config/dsp16xx/dsp16xx.h"
|
||||
_("A -ifile option requires a -map option")
|
||||
#line 809 "config/i386/sco5.h"
|
||||
_("-static not valid with -mcoff")
|
||||
#line 810 "config/i386/sco5.h"
|
||||
_("-shared not valid with -mcoff")
|
||||
#line 811 "config/i386/sco5.h"
|
||||
_("-symbolic not valid with -mcoff")
|
||||
#line 847 "config/i386/sco5.h"
|
||||
_("-fpic is not valid with -mcoff")
|
||||
#line 848 "config/i386/sco5.h"
|
||||
_("-fPIC is not valid with -mcoff")
|
||||
#line 882 "config/i386/sco5.h"
|
||||
_("-static not valid with -mcoff")
|
||||
#line 883 "config/i386/sco5.h"
|
||||
_("-shared not valid with -mcoff")
|
||||
#line 884 "config/i386/sco5.h"
|
||||
_("-symbolic not valid with -mcoff")
|
||||
#line 885 "config/i386/sco5.h"
|
||||
_("-fpic not valid with -mcoff")
|
||||
#line 886 "config/i386/sco5.h"
|
||||
_("-fPIC not valid with -mcoff")
|
||||
#line 305 "config/i860/fx2800.h"
|
||||
_("-p option not supported: use -pg instead")
|
||||
#line 674 "config/mips/mips.h"
|
||||
_("-pipe is not supported.")
|
||||
#line 811 "config/mips/mips.h"
|
||||
_("may not use both -mfp64 and -msingle-float")
|
||||
#line 812 "config/mips/mips.h"
|
||||
_("may not use both -mfp64 and -m4650")
|
||||
#line 815 "config/mips/mips.h"
|
||||
_("may not use both -EB and -EL")
|
||||
#line 27 "config/mips/r3900.h"
|
||||
_("-mhard-float not supported.")
|
||||
#line 29 "config/mips/r3900.h"
|
||||
_("-msingle-float and -msoft-float can not both be specified.")
|
||||
#line 41 "config/mips/r3900.h"
|
||||
_("-mhard-float not supported.")
|
||||
#line 43 "config/mips/r3900.h"
|
||||
_("-msingle-float and -msoft-float can not both be specified.")
|
||||
#line 166 "config/nextstep.h"
|
||||
_("-p profiling is no longer supported. Use -pg instead.")
|
||||
#line 169 "config/nextstep.h"
|
||||
_("-p profiling is no longer supported. Use -pg instead.")
|
||||
#line 36 "config/vax/vax.h"
|
||||
_("profiling not supported with -mg\n")
|
||||
#line 37 "config/vax/vax.h"
|
||||
_("profiling not supported with -mg\n")
|
||||
#line 32 "cp/lang-specs.h"
|
||||
_("GNU C++ does not support -C without using -E")
|
||||
#line 45 "cp/lang-specs.h"
|
||||
_("-pg and -fomit-frame-pointer are incompatible")
|
||||
#line 56 "cp/lang-specs.h"
|
||||
_("-pg and -fomit-frame-pointer are incompatible")
|
||||
#line 603 "gcc.c"
|
||||
_("GNU C does not support -C without using -E")
|
||||
#line 617 "gcc.c"
|
||||
_("-pg and -fomit-frame-pointer are incompatible")
|
||||
#line 624 "gcc.c"
|
||||
_("GNU C does not support -C without using -E")
|
||||
#line 633 "gcc.c"
|
||||
_("-E required when input is from standard input")
|
||||
#line 637 "gcc.c"
|
||||
_("GNU C does not support -C without using -E")
|
||||
#line 652 "gcc.c"
|
||||
_("-pg and -fomit-frame-pointer are incompatible")
|
||||
#line 659 "gcc.c"
|
||||
_("Compilation of header file requested")
|
||||
#line 661 "gcc.c"
|
||||
_("GNU C does not support -C without using -E")
|
||||
#line 676 "gcc.c"
|
||||
_("-pg and -fomit-frame-pointer are incompatible")
|
||||
#line 689 "gcc.c"
|
||||
_("GNU C does not support -C without using -E")
|
||||
163
include/ansidecl.h
Executable file
163
include/ansidecl.h
Executable file
|
|
@ -0,0 +1,163 @@
|
|||
/* ANSI and traditional C compatability macros
|
||||
Copyright 1991, 1992, 1996 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
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. */
|
||||
|
||||
/* ANSI and traditional C compatibility macros
|
||||
|
||||
ANSI C is assumed if __STDC__ is #defined.
|
||||
|
||||
Macro ANSI C definition Traditional C definition
|
||||
----- ---- - ---------- ----------- - ----------
|
||||
PTR `void *' `char *'
|
||||
LONG_DOUBLE `long double' `double'
|
||||
VOLATILE `volatile' `'
|
||||
SIGNED `signed' `'
|
||||
PTRCONST `void *const' `char *'
|
||||
ANSI_PROTOTYPES 1 not defined
|
||||
|
||||
CONST is also defined, but is obsolete. Just use const.
|
||||
|
||||
obsolete -- DEFUN (name, arglist, args)
|
||||
|
||||
Defines function NAME.
|
||||
|
||||
ARGLIST lists the arguments, separated by commas and enclosed in
|
||||
parentheses. ARGLIST becomes the argument list in traditional C.
|
||||
|
||||
ARGS list the arguments with their types. It becomes a prototype in
|
||||
ANSI C, and the type declarations in traditional C. Arguments should
|
||||
be separated with `AND'. For functions with a variable number of
|
||||
arguments, the last thing listed should be `DOTS'.
|
||||
|
||||
obsolete -- DEFUN_VOID (name)
|
||||
|
||||
Defines a function NAME, which takes no arguments.
|
||||
|
||||
obsolete -- EXFUN (name, (prototype)) -- obsolete.
|
||||
|
||||
Replaced by PARAMS. Do not use; will disappear someday soon.
|
||||
Was used in external function declarations.
|
||||
In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in
|
||||
parentheses). In traditional C it is `NAME()'.
|
||||
For a function that takes no arguments, PROTOTYPE should be `(void)'.
|
||||
|
||||
obsolete -- PROTO (type, name, (prototype) -- obsolete.
|
||||
|
||||
This one has also been replaced by PARAMS. Do not use.
|
||||
|
||||
PARAMS ((args))
|
||||
|
||||
We could use the EXFUN macro to handle prototype declarations, but
|
||||
the name is misleading and the result is ugly. So we just define a
|
||||
simple macro to handle the parameter lists, as in:
|
||||
|
||||
static int foo PARAMS ((int, char));
|
||||
|
||||
This produces: `static int foo();' or `static int foo (int, char);'
|
||||
|
||||
EXFUN would have done it like this:
|
||||
|
||||
static int EXFUN (foo, (int, char));
|
||||
|
||||
but the function is not external...and it's hard to visually parse
|
||||
the function name out of the mess. EXFUN should be considered
|
||||
obsolete; new code should be written to use PARAMS.
|
||||
|
||||
DOTS is also obsolete.
|
||||
|
||||
Examples:
|
||||
|
||||
extern int printf PARAMS ((const char *format, ...));
|
||||
*/
|
||||
|
||||
#ifndef _ANSIDECL_H
|
||||
|
||||
#define _ANSIDECL_H 1
|
||||
|
||||
|
||||
/* Every source file includes this file,
|
||||
so they will all get the switch for lint. */
|
||||
/* LINTLIBRARY */
|
||||
|
||||
|
||||
#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32)
|
||||
/* All known AIX compilers implement these things (but don't always
|
||||
define __STDC__). The RISC/OS MIPS compiler defines these things
|
||||
in SVR4 mode, but does not define __STDC__. */
|
||||
|
||||
#define PTR void *
|
||||
#define PTRCONST void *CONST
|
||||
#define LONG_DOUBLE long double
|
||||
|
||||
#ifndef IN_GCC
|
||||
#define AND ,
|
||||
#define NOARGS void
|
||||
#define VOLATILE volatile
|
||||
#define SIGNED signed
|
||||
#endif /* ! IN_GCC */
|
||||
|
||||
#define PARAMS(paramlist) paramlist
|
||||
#define ANSI_PROTOTYPES 1
|
||||
|
||||
#define VPARAMS(ARGS) ARGS
|
||||
#define VA_START(va_list,var) va_start(va_list,var)
|
||||
|
||||
/* These are obsolete. Do not use. */
|
||||
#ifndef IN_GCC
|
||||
#define CONST const
|
||||
#define DOTS , ...
|
||||
#define PROTO(type, name, arglist) type name arglist
|
||||
#define EXFUN(name, proto) name proto
|
||||
#define DEFUN(name, arglist, args) name(args)
|
||||
#define DEFUN_VOID(name) name(void)
|
||||
#endif /* ! IN_GCC */
|
||||
|
||||
#else /* Not ANSI C. */
|
||||
|
||||
#define PTR char *
|
||||
#define PTRCONST PTR
|
||||
#define LONG_DOUBLE double
|
||||
|
||||
#ifndef IN_GCC
|
||||
#define AND ;
|
||||
#define NOARGS
|
||||
#define VOLATILE
|
||||
#define SIGNED
|
||||
#endif /* !IN_GCC */
|
||||
|
||||
#ifndef const /* some systems define it in header files for non-ansi mode */
|
||||
#define const
|
||||
#endif
|
||||
|
||||
#define PARAMS(paramlist) ()
|
||||
|
||||
#define VPARAMS(ARGS) (va_alist) va_dcl
|
||||
#define VA_START(va_list,var) va_start(va_list)
|
||||
|
||||
/* These are obsolete. Do not use. */
|
||||
#ifndef IN_GCC
|
||||
#define CONST
|
||||
#define DOTS
|
||||
#define PROTO(type, name, arglist) type name ()
|
||||
#define EXFUN(name, proto) name()
|
||||
#define DEFUN(name, arglist, args) name arglist args;
|
||||
#define DEFUN_VOID(name) name()
|
||||
#endif /* ! IN_GCC */
|
||||
|
||||
#endif /* ANSI C. */
|
||||
|
||||
#endif /* ansidecl.h */
|
||||
180
include/libiberty.h
Executable file
180
include/libiberty.h
Executable file
|
|
@ -0,0 +1,180 @@
|
|||
/* Function declarations for libiberty.
|
||||
Written by Cygnus Support, 1994.
|
||||
|
||||
The libiberty library provides a number of functions which are
|
||||
missing on some operating systems. We do not declare those here,
|
||||
to avoid conflicts with the system header files on operating
|
||||
systems that do support those functions. In this file we only
|
||||
declare those functions which are specific to libiberty. */
|
||||
|
||||
#ifndef LIBIBERTY_H
|
||||
#define LIBIBERTY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ansidecl.h"
|
||||
|
||||
/* Build an argument vector from a string. Allocates memory using
|
||||
malloc. Use freeargv to free the vector. */
|
||||
|
||||
extern char **buildargv PARAMS ((char *));
|
||||
|
||||
/* Free a vector returned by buildargv. */
|
||||
|
||||
extern void freeargv PARAMS ((char **));
|
||||
|
||||
/* Duplicate an argument vector. Allocates memory using malloc. Use
|
||||
freeargv to free the vector. */
|
||||
|
||||
extern char **dupargv PARAMS ((char **));
|
||||
|
||||
|
||||
/* Return the last component of a path name. Note that we can't use a
|
||||
prototype here because the parameter is declared inconsistently
|
||||
across different systems, sometimes as "char *" and sometimes as
|
||||
"const char *" */
|
||||
|
||||
#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__)
|
||||
extern char *basename PARAMS ((const char *));
|
||||
#else
|
||||
extern char *basename ();
|
||||
#endif
|
||||
|
||||
/* Concatenate an arbitrary number of strings, up to (char *) NULL.
|
||||
Allocates memory using xmalloc. */
|
||||
|
||||
extern char *concat PARAMS ((const char *, ...));
|
||||
|
||||
/* Check whether two file descriptors refer to the same file. */
|
||||
|
||||
extern int fdmatch PARAMS ((int fd1, int fd2));
|
||||
|
||||
/* Get the amount of time the process has run, in microseconds. */
|
||||
|
||||
extern long get_run_time PARAMS ((void));
|
||||
|
||||
/* Choose a temporary directory to use for scratch files. */
|
||||
|
||||
extern char *choose_temp_base PARAMS ((void));
|
||||
|
||||
/* Allocate memory filled with spaces. Allocates using malloc. */
|
||||
|
||||
extern const char *spaces PARAMS ((int count));
|
||||
|
||||
/* Return the maximum error number for which strerror will return a
|
||||
string. */
|
||||
|
||||
extern int errno_max PARAMS ((void));
|
||||
|
||||
/* Return the name of an errno value (e.g., strerrno (EINVAL) returns
|
||||
"EINVAL"). */
|
||||
|
||||
extern const char *strerrno PARAMS ((int));
|
||||
|
||||
/* Given the name of an errno value, return the value. */
|
||||
|
||||
extern int strtoerrno PARAMS ((const char *));
|
||||
|
||||
/* ANSI's strerror(), but more robust. */
|
||||
|
||||
extern char *xstrerror PARAMS ((int));
|
||||
|
||||
/* Return the maximum signal number for which strsignal will return a
|
||||
string. */
|
||||
|
||||
extern int signo_max PARAMS ((void));
|
||||
|
||||
/* Return a signal message string for a signal number
|
||||
(e.g., strsignal (SIGHUP) returns something like "Hangup"). */
|
||||
/* This is commented out as it can conflict with one in system headers.
|
||||
We still document its existence though. */
|
||||
|
||||
/*extern const char *strsignal PARAMS ((int));*/
|
||||
|
||||
/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
|
||||
"SIGHUP"). */
|
||||
|
||||
extern const char *strsigno PARAMS ((int));
|
||||
|
||||
/* Given the name of a signal, return its number. */
|
||||
|
||||
extern int strtosigno PARAMS ((const char *));
|
||||
|
||||
/* Register a function to be run by xexit. Returns 0 on success. */
|
||||
|
||||
extern int xatexit PARAMS ((void (*fn) (void)));
|
||||
|
||||
/* Exit, calling all the functions registered with xatexit. */
|
||||
|
||||
#ifndef __GNUC__
|
||||
extern void xexit PARAMS ((int status));
|
||||
#else
|
||||
void xexit PARAMS ((int status)) __attribute__ ((noreturn));
|
||||
#endif
|
||||
|
||||
/* Set the program name used by xmalloc. */
|
||||
|
||||
extern void xmalloc_set_program_name PARAMS ((const char *));
|
||||
|
||||
/* Allocate memory without fail. If malloc fails, this will print a
|
||||
message to stderr (using the name set by xmalloc_set_program_name,
|
||||
if any) and then call xexit. */
|
||||
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
/* Get a definition for size_t. */
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
extern PTR xmalloc PARAMS ((size_t));
|
||||
|
||||
/* Reallocate memory without fail. This works like xmalloc.
|
||||
|
||||
FIXME: We do not declare the parameter types for the same reason as
|
||||
xmalloc. */
|
||||
|
||||
extern PTR xrealloc PARAMS ((PTR, size_t));
|
||||
|
||||
/* Allocate memory without fail and set it to zero. This works like
|
||||
xmalloc. */
|
||||
|
||||
extern PTR xcalloc PARAMS ((size_t, size_t));
|
||||
|
||||
/* Copy a string into a memory buffer without fail. */
|
||||
|
||||
extern char *xstrdup PARAMS ((const char *));
|
||||
|
||||
/* hex character manipulation routines */
|
||||
|
||||
#define _hex_array_size 256
|
||||
#define _hex_bad 99
|
||||
extern char _hex_value[_hex_array_size];
|
||||
extern void hex_init PARAMS ((void));
|
||||
#define hex_p(c) (hex_value (c) != _hex_bad)
|
||||
/* If you change this, note well: Some code relies on side effects in
|
||||
the argument being performed exactly once. */
|
||||
#define hex_value(c) (_hex_value[(unsigned char) (c)])
|
||||
|
||||
/* Definitions used by the pexecute routine. */
|
||||
|
||||
#define PEXECUTE_FIRST 1
|
||||
#define PEXECUTE_LAST 2
|
||||
#define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST)
|
||||
#define PEXECUTE_SEARCH 4
|
||||
#define PEXECUTE_VERBOSE 8
|
||||
|
||||
/* Execute a program. */
|
||||
|
||||
extern int pexecute PARAMS ((const char *, char * const *, const char *,
|
||||
const char *, char **, char **, int));
|
||||
|
||||
/* Wait for pexecute to finish. */
|
||||
|
||||
extern int pwait PARAMS ((int, int *, int));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* ! defined (LIBIBERTY_H) */
|
||||
594
include/obstack.h
Executable file
594
include/obstack.h
Executable file
|
|
@ -0,0 +1,594 @@
|
|||
/* obstack.h - object stack macros
|
||||
Copyright (C) 1988,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. */
|
||||
|
||||
/* Summary:
|
||||
|
||||
All the apparent functions defined here are macros. The idea
|
||||
is that you would use these pre-tested macros to solve a
|
||||
very specific set of problems, and they would run fast.
|
||||
Caution: no side-effects in arguments please!! They may be
|
||||
evaluated MANY times!!
|
||||
|
||||
These macros operate a stack of objects. Each object starts life
|
||||
small, and may grow to maturity. (Consider building a word syllable
|
||||
by syllable.) An object can move while it is growing. Once it has
|
||||
been "finished" it never changes address again. So the "top of the
|
||||
stack" is typically an immature growing object, while the rest of the
|
||||
stack is of mature, fixed size and fixed address objects.
|
||||
|
||||
These routines grab large chunks of memory, using a function you
|
||||
supply, called `obstack_chunk_alloc'. On occasion, they free chunks,
|
||||
by calling `obstack_chunk_free'. You must define them and declare
|
||||
them before using any obstack macros.
|
||||
|
||||
Each independent stack is represented by a `struct obstack'.
|
||||
Each of the obstack macros expects a pointer to such a structure
|
||||
as the first argument.
|
||||
|
||||
One motivation for this package is the problem of growing char strings
|
||||
in symbol tables. Unless you are "fascist pig with a read-only mind"
|
||||
--Gosper's immortal quote from HAKMEM item 154, out of context--you
|
||||
would not like to put any arbitrary upper limit on the length of your
|
||||
symbols.
|
||||
|
||||
In practice this often means you will build many short symbols and a
|
||||
few long symbols. At the time you are reading a symbol you don't know
|
||||
how long it is. One traditional method is to read a symbol into a
|
||||
buffer, realloc()ating the buffer every time you try to read a symbol
|
||||
that is longer than the buffer. This is beaut, but you still will
|
||||
want to copy the symbol from the buffer to a more permanent
|
||||
symbol-table entry say about half the time.
|
||||
|
||||
With obstacks, you can work differently. Use one obstack for all symbol
|
||||
names. As you read a symbol, grow the name in the obstack gradually.
|
||||
When the name is complete, finalize it. Then, if the symbol exists already,
|
||||
free the newly read name.
|
||||
|
||||
The way we do this is to take a large chunk, allocating memory from
|
||||
low addresses. When you want to build a symbol in the chunk you just
|
||||
add chars above the current "high water mark" in the chunk. When you
|
||||
have finished adding chars, because you got to the end of the symbol,
|
||||
you know how long the chars are, and you can create a new object.
|
||||
Mostly the chars will not burst over the highest address of the chunk,
|
||||
because you would typically expect a chunk to be (say) 100 times as
|
||||
long as an average object.
|
||||
|
||||
In case that isn't clear, when we have enough chars to make up
|
||||
the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
|
||||
so we just point to it where it lies. No moving of chars is
|
||||
needed and this is the second win: potentially long strings need
|
||||
never be explicitly shuffled. Once an object is formed, it does not
|
||||
change its address during its lifetime.
|
||||
|
||||
When the chars burst over a chunk boundary, we allocate a larger
|
||||
chunk, and then copy the partly formed object from the end of the old
|
||||
chunk to the beginning of the new larger chunk. We then carry on
|
||||
accreting characters to the end of the object as we normally would.
|
||||
|
||||
A special macro is provided to add a single char at a time to a
|
||||
growing object. This allows the use of register variables, which
|
||||
break the ordinary 'growth' macro.
|
||||
|
||||
Summary:
|
||||
We allocate large chunks.
|
||||
We carve out one object at a time from the current chunk.
|
||||
Once carved, an object never moves.
|
||||
We are free to append data of any size to the currently
|
||||
growing object.
|
||||
Exactly one object is growing in an obstack at any one time.
|
||||
You can run one obstack per control block.
|
||||
You may have as many control blocks as you dare.
|
||||
Because of the way we do it, you can `unwind' an obstack
|
||||
back to a previous state. (You may remove objects much
|
||||
as you would with a stack.)
|
||||
*/
|
||||
|
||||
|
||||
/* Don't do the contents of this file more than once. */
|
||||
|
||||
#ifndef _OBSTACK_H
|
||||
#define _OBSTACK_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* We use subtraction of (char *) 0 instead of casting to int
|
||||
because on word-addressable machines a simple cast to int
|
||||
may ignore the byte-within-word field of the pointer. */
|
||||
|
||||
#ifndef __PTR_TO_INT
|
||||
# define __PTR_TO_INT(P) ((P) - (char *) 0)
|
||||
#endif
|
||||
|
||||
#ifndef __INT_TO_PTR
|
||||
# define __INT_TO_PTR(P) ((P) + (char *) 0)
|
||||
#endif
|
||||
|
||||
/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is
|
||||
defined, as with GNU C, use that; that way we don't pollute the
|
||||
namespace with <stddef.h>'s symbols. Otherwise, if <stddef.h> is
|
||||
available, include it and use ptrdiff_t. In traditional C, long is
|
||||
the best that we can do. */
|
||||
|
||||
#ifdef __PTRDIFF_TYPE__
|
||||
# define PTR_INT_TYPE __PTRDIFF_TYPE__
|
||||
#else
|
||||
# ifdef HAVE_STDDEF_H
|
||||
# include <stddef.h>
|
||||
# define PTR_INT_TYPE ptrdiff_t
|
||||
# else
|
||||
# define PTR_INT_TYPE long
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _LIBC || defined HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
|
||||
#else
|
||||
# ifdef memcpy
|
||||
# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
|
||||
# else
|
||||
# define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
struct _obstack_chunk /* Lives at front of each chunk. */
|
||||
{
|
||||
char *limit; /* 1 past end of this chunk */
|
||||
struct _obstack_chunk *prev; /* address of prior chunk or NULL */
|
||||
char contents[4]; /* objects begin here */
|
||||
};
|
||||
|
||||
struct obstack /* control current object in current chunk */
|
||||
{
|
||||
long chunk_size; /* preferred size to allocate chunks in */
|
||||
struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */
|
||||
char *object_base; /* address of object we are building */
|
||||
char *next_free; /* where to add next char to current object */
|
||||
char *chunk_limit; /* address of char after current chunk */
|
||||
PTR_INT_TYPE temp; /* Temporary for some macros. */
|
||||
int alignment_mask; /* Mask of alignment for each object. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
/* These prototypes vary based on `use_extra_arg', and we use
|
||||
casts to the prototypeless function type in all assignments,
|
||||
but having prototypes here quiets -Wstrict-prototypes. */
|
||||
struct _obstack_chunk *(*chunkfun) (void *, long);
|
||||
void (*freefun) (void *, struct _obstack_chunk *);
|
||||
void *extra_arg; /* first arg for chunk alloc/dealloc funcs */
|
||||
#else
|
||||
struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */
|
||||
void (*freefun) (); /* User's function to free a chunk. */
|
||||
char *extra_arg; /* first arg for chunk alloc/dealloc funcs */
|
||||
#endif
|
||||
unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */
|
||||
unsigned maybe_empty_object:1;/* There is a possibility that the current
|
||||
chunk contains a zero-length object. This
|
||||
prevents freeing the chunk if we allocate
|
||||
a bigger chunk to replace it. */
|
||||
unsigned alloc_failed:1; /* No longer used, as we now call the failed
|
||||
handler on error, but retained for binary
|
||||
compatibility. */
|
||||
};
|
||||
|
||||
/* Declare the external functions we use; they are in obstack.c. */
|
||||
|
||||
#if defined __STDC__ && __STDC__
|
||||
extern void _obstack_newchunk (struct obstack *, int);
|
||||
extern void _obstack_free (struct obstack *, void *);
|
||||
extern int _obstack_begin (struct obstack *, int, int,
|
||||
void *(*) (long), void (*) (void *));
|
||||
extern int _obstack_begin_1 (struct obstack *, int, int,
|
||||
void *(*) (void *, long),
|
||||
void (*) (void *, void *), void *);
|
||||
extern int _obstack_memory_used (struct obstack *);
|
||||
#else
|
||||
extern void _obstack_newchunk ();
|
||||
extern void _obstack_free ();
|
||||
extern int _obstack_begin ();
|
||||
extern int _obstack_begin_1 ();
|
||||
extern int _obstack_memory_used ();
|
||||
#endif
|
||||
|
||||
#if defined __STDC__ && __STDC__
|
||||
|
||||
/* Do the function-declarations after the structs
|
||||
but before defining the macros. */
|
||||
|
||||
void obstack_init (struct obstack *obstack);
|
||||
|
||||
void * obstack_alloc (struct obstack *obstack, int size);
|
||||
|
||||
void * obstack_copy (struct obstack *obstack, void *address, int size);
|
||||
void * obstack_copy0 (struct obstack *obstack, void *address, int size);
|
||||
|
||||
void obstack_free (struct obstack *obstack, void *block);
|
||||
|
||||
void obstack_blank (struct obstack *obstack, int size);
|
||||
|
||||
void obstack_grow (struct obstack *obstack, void *data, int size);
|
||||
void obstack_grow0 (struct obstack *obstack, void *data, int size);
|
||||
|
||||
void obstack_1grow (struct obstack *obstack, int data_char);
|
||||
void obstack_ptr_grow (struct obstack *obstack, void *data);
|
||||
void obstack_int_grow (struct obstack *obstack, int data);
|
||||
|
||||
void * obstack_finish (struct obstack *obstack);
|
||||
|
||||
int obstack_object_size (struct obstack *obstack);
|
||||
|
||||
int obstack_room (struct obstack *obstack);
|
||||
void obstack_make_room (struct obstack *obstack, int size);
|
||||
void obstack_1grow_fast (struct obstack *obstack, int data_char);
|
||||
void obstack_ptr_grow_fast (struct obstack *obstack, void *data);
|
||||
void obstack_int_grow_fast (struct obstack *obstack, int data);
|
||||
void obstack_blank_fast (struct obstack *obstack, int size);
|
||||
|
||||
void * obstack_base (struct obstack *obstack);
|
||||
void * obstack_next_free (struct obstack *obstack);
|
||||
int obstack_alignment_mask (struct obstack *obstack);
|
||||
int obstack_chunk_size (struct obstack *obstack);
|
||||
int obstack_memory_used (struct obstack *obstack);
|
||||
|
||||
#endif /* __STDC__ */
|
||||
|
||||
/* Non-ANSI C cannot really support alternative functions for these macros,
|
||||
so we do not declare them. */
|
||||
|
||||
/* Error handler called when `obstack_chunk_alloc' failed to allocate
|
||||
more memory. This can be set to a user defined function. The
|
||||
default action is to print a message and abort. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
extern void (*obstack_alloc_failed_handler) (void);
|
||||
#else
|
||||
extern void (*obstack_alloc_failed_handler) ();
|
||||
#endif
|
||||
|
||||
/* Exit value used when `print_and_abort' is used. */
|
||||
extern int obstack_exit_failure;
|
||||
|
||||
/* Pointer to beginning of object being allocated or to be allocated next.
|
||||
Note that this might not be the final address of the object
|
||||
because a new chunk might be needed to hold the final size. */
|
||||
|
||||
#define obstack_base(h) ((h)->object_base)
|
||||
|
||||
/* Size for allocating ordinary chunks. */
|
||||
|
||||
#define obstack_chunk_size(h) ((h)->chunk_size)
|
||||
|
||||
/* Pointer to next byte not yet allocated in current chunk. */
|
||||
|
||||
#define obstack_next_free(h) ((h)->next_free)
|
||||
|
||||
/* Mask specifying low bits that should be clear in address of an object. */
|
||||
|
||||
#define obstack_alignment_mask(h) ((h)->alignment_mask)
|
||||
|
||||
/* To prevent prototype warnings provide complete argument list in
|
||||
standard C version. */
|
||||
#if defined __STDC__ && __STDC__
|
||||
|
||||
# define obstack_init(h) \
|
||||
_obstack_begin ((h), 0, 0, \
|
||||
(void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
|
||||
|
||||
# define obstack_begin(h, size) \
|
||||
_obstack_begin ((h), (size), 0, \
|
||||
(void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
|
||||
|
||||
# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
|
||||
_obstack_begin ((h), (size), (alignment), \
|
||||
(void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun))
|
||||
|
||||
# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
|
||||
_obstack_begin_1 ((h), (size), (alignment), \
|
||||
(void *(*) (void *, long)) (chunkfun), \
|
||||
(void (*) (void *, void *)) (freefun), (arg))
|
||||
|
||||
# define obstack_chunkfun(h, newchunkfun) \
|
||||
((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
|
||||
|
||||
# define obstack_freefun(h, newfreefun) \
|
||||
((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
|
||||
|
||||
#else
|
||||
|
||||
# define obstack_init(h) \
|
||||
_obstack_begin ((h), 0, 0, \
|
||||
(void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
|
||||
|
||||
# define obstack_begin(h, size) \
|
||||
_obstack_begin ((h), (size), 0, \
|
||||
(void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
|
||||
|
||||
# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
|
||||
_obstack_begin ((h), (size), (alignment), \
|
||||
(void *(*) ()) (chunkfun), (void (*) ()) (freefun))
|
||||
|
||||
# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
|
||||
_obstack_begin_1 ((h), (size), (alignment), \
|
||||
(void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg))
|
||||
|
||||
# define obstack_chunkfun(h, newchunkfun) \
|
||||
((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun))
|
||||
|
||||
# define obstack_freefun(h, newfreefun) \
|
||||
((h) -> freefun = (void (*)()) (newfreefun))
|
||||
|
||||
#endif
|
||||
|
||||
#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
|
||||
|
||||
#define obstack_blank_fast(h,n) ((h)->next_free += (n))
|
||||
|
||||
#define obstack_memory_used(h) _obstack_memory_used (h)
|
||||
|
||||
#if defined __GNUC__ && defined __STDC__ && __STDC__
|
||||
/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
|
||||
does not implement __extension__. But that compiler doesn't define
|
||||
__GNUC_MINOR__. */
|
||||
# if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
|
||||
# define __extension__
|
||||
# endif
|
||||
|
||||
/* For GNU C, if not -traditional,
|
||||
we can define these macros to compute all args only once
|
||||
without using a global variable.
|
||||
Also, we can avoid using the `temp' slot, to make faster code. */
|
||||
|
||||
# define obstack_object_size(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
(unsigned) (__o->next_free - __o->object_base); })
|
||||
|
||||
# define obstack_room(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
(unsigned) (__o->chunk_limit - __o->next_free); })
|
||||
|
||||
# define obstack_make_room(OBSTACK,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
if (__o->chunk_limit - __o->next_free < __len) \
|
||||
_obstack_newchunk (__o, __len); \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_empty_p(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
(__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
|
||||
|
||||
# define obstack_grow(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
if (__o->next_free + __len > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, __len); \
|
||||
_obstack_memcpy (__o->next_free, (char *) (where), __len); \
|
||||
__o->next_free += __len; \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_grow0(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
if (__o->next_free + __len + 1 > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, __len + 1); \
|
||||
_obstack_memcpy (__o->next_free, (char *) (where), __len); \
|
||||
__o->next_free += __len; \
|
||||
*(__o->next_free)++ = 0; \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_1grow(OBSTACK,datum) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + 1 > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, 1); \
|
||||
*(__o->next_free)++ = (datum); \
|
||||
(void) 0; })
|
||||
|
||||
/* These assume that the obstack alignment is good enough for pointers or ints,
|
||||
and that the data added so far to the current object
|
||||
shares that much alignment. */
|
||||
|
||||
# define obstack_ptr_grow(OBSTACK,datum) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, sizeof (void *)); \
|
||||
*((void **)__o->next_free) = ((void *)datum); \
|
||||
__o->next_free += sizeof (void *); \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_int_grow(OBSTACK,datum) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
if (__o->next_free + sizeof (int) > __o->chunk_limit) \
|
||||
_obstack_newchunk (__o, sizeof (int)); \
|
||||
*((int *)__o->next_free)++ = ((int)datum); \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr)
|
||||
# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
|
||||
|
||||
# define obstack_blank(OBSTACK,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
int __len = (length); \
|
||||
if (__o->chunk_limit - __o->next_free < __len) \
|
||||
_obstack_newchunk (__o, __len); \
|
||||
__o->next_free += __len; \
|
||||
(void) 0; })
|
||||
|
||||
# define obstack_alloc(OBSTACK,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__h = (OBSTACK); \
|
||||
obstack_blank (__h, (length)); \
|
||||
obstack_finish (__h); })
|
||||
|
||||
# define obstack_copy(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__h = (OBSTACK); \
|
||||
obstack_grow (__h, (where), (length)); \
|
||||
obstack_finish (__h); })
|
||||
|
||||
# define obstack_copy0(OBSTACK,where,length) \
|
||||
__extension__ \
|
||||
({ struct obstack *__h = (OBSTACK); \
|
||||
obstack_grow0 (__h, (where), (length)); \
|
||||
obstack_finish (__h); })
|
||||
|
||||
/* The local variable is named __o1 to avoid a name conflict
|
||||
when obstack_blank is called. */
|
||||
# define obstack_finish(OBSTACK) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o1 = (OBSTACK); \
|
||||
void *value; \
|
||||
value = (void *) __o1->object_base; \
|
||||
if (__o1->next_free == value) \
|
||||
__o1->maybe_empty_object = 1; \
|
||||
__o1->next_free \
|
||||
= __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
|
||||
& ~ (__o1->alignment_mask)); \
|
||||
if (__o1->next_free - (char *)__o1->chunk \
|
||||
> __o1->chunk_limit - (char *)__o1->chunk) \
|
||||
__o1->next_free = __o1->chunk_limit; \
|
||||
__o1->object_base = __o1->next_free; \
|
||||
value; })
|
||||
|
||||
# define obstack_free(OBSTACK, OBJ) \
|
||||
__extension__ \
|
||||
({ struct obstack *__o = (OBSTACK); \
|
||||
void *__obj = (OBJ); \
|
||||
if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
|
||||
__o->next_free = __o->object_base = __obj; \
|
||||
else (obstack_free) (__o, __obj); })
|
||||
|
||||
#else /* not __GNUC__ or not __STDC__ */
|
||||
|
||||
# define obstack_object_size(h) \
|
||||
(unsigned) ((h)->next_free - (h)->object_base)
|
||||
|
||||
# define obstack_room(h) \
|
||||
(unsigned) ((h)->chunk_limit - (h)->next_free)
|
||||
|
||||
# define obstack_empty_p(h) \
|
||||
((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
|
||||
|
||||
/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
|
||||
so that we can avoid having void expressions
|
||||
in the arms of the conditional expression.
|
||||
Casting the third operand to void was tried before,
|
||||
but some compilers won't accept it. */
|
||||
|
||||
# define obstack_make_room(h,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0))
|
||||
|
||||
# define obstack_grow(h,where,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
|
||||
_obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \
|
||||
(h)->next_free += (h)->temp)
|
||||
|
||||
# define obstack_grow0(h,where,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \
|
||||
_obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \
|
||||
(h)->next_free += (h)->temp, \
|
||||
*((h)->next_free)++ = 0)
|
||||
|
||||
# define obstack_1grow(h,datum) \
|
||||
( (((h)->next_free + 1 > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), 1), 0) : 0), \
|
||||
(*((h)->next_free)++ = (datum)))
|
||||
|
||||
# define obstack_ptr_grow(h,datum) \
|
||||
( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
|
||||
(*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum)))
|
||||
|
||||
# define obstack_int_grow(h,datum) \
|
||||
( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
|
||||
? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
|
||||
(*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum)))
|
||||
|
||||
# define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr)
|
||||
# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
|
||||
|
||||
# define obstack_blank(h,length) \
|
||||
( (h)->temp = (length), \
|
||||
(((h)->chunk_limit - (h)->next_free < (h)->temp) \
|
||||
? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \
|
||||
((h)->next_free += (h)->temp))
|
||||
|
||||
# define obstack_alloc(h,length) \
|
||||
(obstack_blank ((h), (length)), obstack_finish ((h)))
|
||||
|
||||
# define obstack_copy(h,where,length) \
|
||||
(obstack_grow ((h), (where), (length)), obstack_finish ((h)))
|
||||
|
||||
# define obstack_copy0(h,where,length) \
|
||||
(obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
|
||||
|
||||
# define obstack_finish(h) \
|
||||
( ((h)->next_free == (h)->object_base \
|
||||
? (((h)->maybe_empty_object = 1), 0) \
|
||||
: 0), \
|
||||
(h)->temp = __PTR_TO_INT ((h)->object_base), \
|
||||
(h)->next_free \
|
||||
= __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \
|
||||
& ~ ((h)->alignment_mask)), \
|
||||
(((h)->next_free - (char *) (h)->chunk \
|
||||
> (h)->chunk_limit - (char *) (h)->chunk) \
|
||||
? ((h)->next_free = (h)->chunk_limit) : 0), \
|
||||
(h)->object_base = (h)->next_free, \
|
||||
__INT_TO_PTR ((h)->temp))
|
||||
|
||||
# if defined __STDC__ && __STDC__
|
||||
# define obstack_free(h,obj) \
|
||||
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
|
||||
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
|
||||
? (int) ((h)->next_free = (h)->object_base \
|
||||
= (h)->temp + (char *) (h)->chunk) \
|
||||
: (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
|
||||
# else
|
||||
# define obstack_free(h,obj) \
|
||||
( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \
|
||||
(((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
|
||||
? (int) ((h)->next_free = (h)->object_base \
|
||||
= (h)->temp + (char *) (h)->chunk) \
|
||||
: (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
|
||||
# endif
|
||||
|
||||
#endif /* not __GNUC__ or not __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* C++ */
|
||||
#endif
|
||||
|
||||
#endif /* obstack.h */
|
||||
112
include/splay-tree.h
Executable file
112
include/splay-tree.h
Executable file
|
|
@ -0,0 +1,112 @@
|
|||
/* A splay-tree datatype.
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
Contributed by Mark Mitchell (mark@markmitchell.com).
|
||||
|
||||
This file is part of GNU CC.
|
||||
|
||||
GNU CC 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.
|
||||
|
||||
GNU CC 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. */
|
||||
|
||||
/* For an easily readable description of splay-trees, see:
|
||||
|
||||
Lewis, Harry R. and Denenberg, Larry. Data Structures and Their
|
||||
Algorithms. Harper-Collins, Inc. 1991.
|
||||
|
||||
The major feature of splay trees is that all basic tree operations
|
||||
are amortized O(log n) time for a tree with n nodes. */
|
||||
|
||||
#ifndef _SPLAY_TREE_H
|
||||
#define _SPLAY_TREE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <ansidecl.h>
|
||||
|
||||
/* Use typedefs for the key and data types to facilitate changing
|
||||
these types, if necessary. These types should be sufficiently wide
|
||||
that any pointer or scalar can be cast to these types, and then
|
||||
cast back, without loss of precision. */
|
||||
typedef unsigned long int splay_tree_key;
|
||||
typedef unsigned long int splay_tree_value;
|
||||
|
||||
/* Forward declaration for a node in the tree. */
|
||||
typedef struct splay_tree_node *splay_tree_node;
|
||||
|
||||
/* The type of a function which compares two splay-tree keys. The
|
||||
function should return values as for qsort. */
|
||||
typedef int (*splay_tree_compare_fn) PARAMS((splay_tree_key, splay_tree_key));
|
||||
|
||||
/* The type of a function used to deallocate any resources associated
|
||||
with the key. */
|
||||
typedef void (*splay_tree_delete_key_fn) PARAMS((splay_tree_key));
|
||||
|
||||
/* The type of a function used to deallocate any resources associated
|
||||
with the value. */
|
||||
typedef void (*splay_tree_delete_value_fn) PARAMS((splay_tree_value));
|
||||
|
||||
/* The type of a function used to iterate over the tree. */
|
||||
typedef int (*splay_tree_foreach_fn) PARAMS((splay_tree_node, void*));
|
||||
|
||||
/* The nodes in the splay tree. */
|
||||
struct splay_tree_node
|
||||
{
|
||||
/* The key. */
|
||||
splay_tree_key key;
|
||||
|
||||
/* The value. */
|
||||
splay_tree_value value;
|
||||
|
||||
/* The left and right children, respectively. */
|
||||
splay_tree_node left;
|
||||
splay_tree_node right;
|
||||
};
|
||||
|
||||
/* The splay tree itself. */
|
||||
typedef struct splay_tree
|
||||
{
|
||||
/* The root of the tree. */
|
||||
splay_tree_node root;
|
||||
|
||||
/* The comparision function. */
|
||||
splay_tree_compare_fn comp;
|
||||
|
||||
/* The deallocate-key function. NULL if no cleanup is necessary. */
|
||||
splay_tree_delete_key_fn delete_key;
|
||||
|
||||
/* The deallocate-value function. NULL if no cleanup is necessary. */
|
||||
splay_tree_delete_value_fn delete_value;
|
||||
} *splay_tree;
|
||||
|
||||
extern splay_tree splay_tree_new PARAMS((splay_tree_compare_fn,
|
||||
splay_tree_delete_key_fn,
|
||||
splay_tree_delete_value_fn));
|
||||
extern void splay_tree_delete PARAMS((splay_tree));
|
||||
extern void splay_tree_insert PARAMS((splay_tree,
|
||||
splay_tree_key,
|
||||
splay_tree_value));
|
||||
extern splay_tree_node splay_tree_lookup
|
||||
PARAMS((splay_tree,
|
||||
splay_tree_key));
|
||||
extern int splay_tree_foreach PARAMS((splay_tree,
|
||||
splay_tree_foreach_fn,
|
||||
void*));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _SPLAY_TREE_H */
|
||||
482
libiberty/COPYING.LIB
Executable file
482
libiberty/COPYING.LIB
Executable file
|
|
@ -0,0 +1,482 @@
|
|||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
MA 02111-1307, USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
3132
libiberty/ChangeLog
Executable file
3132
libiberty/ChangeLog
Executable file
File diff suppressed because it is too large
Load Diff
246
libiberty/Makefile.in
Executable file
246
libiberty/Makefile.in
Executable file
|
|
@ -0,0 +1,246 @@
|
|||
#
|
||||
# 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
|
||||
65
libiberty/README
Executable file
65
libiberty/README
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
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.
|
||||
11
libiberty/acconfig.h
Executable file
11
libiberty/acconfig.h
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
/* 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
|
||||
24
libiberty/alloca-conf.h
Executable file
24
libiberty/alloca-conf.h
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#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__) */
|
||||
505
libiberty/alloca.c
Executable file
505
libiberty/alloca.c
Executable file
|
|
@ -0,0 +1,505 @@
|
|||
/* 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
Executable file
390
libiberty/argv.c
Executable file
|
|
@ -0,0 +1,390 @@
|
|||
/* 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 */
|
||||
57
libiberty/asprintf.c
Executable file
57
libiberty/asprintf.c
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
/* 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;
|
||||
}
|
||||
18
libiberty/atexit.c
Executable file
18
libiberty/atexit.c
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
/* 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
|
||||
37
libiberty/basename.c
Executable file
37
libiberty/basename.c
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
/* 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;
|
||||
}
|
||||
49
libiberty/bcmp.c
Executable file
49
libiberty/bcmp.c
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
/* 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);
|
||||
}
|
||||
|
||||
35
libiberty/bcopy.c
Executable file
35
libiberty/bcopy.c
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
/* 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--;
|
||||
}
|
||||
}
|
||||
31
libiberty/bzero.c
Executable file
31
libiberty/bzero.c
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
/* 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;
|
||||
}
|
||||
}
|
||||
26
libiberty/calloc.c
Executable file
26
libiberty/calloc.c
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#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;
|
||||
}
|
||||
203
libiberty/choose-temp.c
Executable file
203
libiberty/choose-temp.c
Executable file
|
|
@ -0,0 +1,203 @@
|
|||
/* Utility to pick a temporary filename prefix.
|
||||
Copyright (C) 1996, 1997, 1998 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. */
|
||||
|
||||
/* This file exports two functions: choose_temp_base and make_temp_file. */
|
||||
|
||||
/* This file lives in at least two places: libiberty and gcc.
|
||||
Don't change one without the other. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h> /* May get P_tmpdir. */
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_FILE_H
|
||||
#include <sys/file.h> /* May get R_OK, etc. on some systems. */
|
||||
#endif
|
||||
|
||||
#ifndef R_OK
|
||||
#define R_OK 4
|
||||
#define W_OK 2
|
||||
#define X_OK 1
|
||||
#endif
|
||||
|
||||
#include "libiberty.h"
|
||||
extern int mkstemps ();
|
||||
|
||||
#ifndef IN_GCC
|
||||
#if defined (__MSDOS__) || defined (_WIN32)
|
||||
#define DIR_SEPARATOR '\\'
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DIR_SEPARATOR
|
||||
#define DIR_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
/* On MSDOS, write temp files in current dir
|
||||
because there's no place else we can expect to use. */
|
||||
/* ??? Although the current directory is tried as a last resort,
|
||||
this is left in so that on MSDOS it is preferred to /tmp on the
|
||||
off chance that someone requires this, since that was the previous
|
||||
behaviour. */
|
||||
#ifdef __MSDOS__
|
||||
#ifndef P_tmpdir
|
||||
#define P_tmpdir "."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Name of temporary file.
|
||||
mktemp requires 6 trailing X's. */
|
||||
#define TEMP_FILE "ccXXXXXX"
|
||||
|
||||
/* Subroutine of choose_temp_base.
|
||||
If BASE is non-NULL, return it.
|
||||
Otherwise it checks if DIR is a usable directory.
|
||||
If success, DIR is returned.
|
||||
Otherwise NULL is returned. */
|
||||
|
||||
static char *
|
||||
try (dir, base)
|
||||
char *dir, *base;
|
||||
{
|
||||
if (base != 0)
|
||||
return base;
|
||||
if (dir != 0
|
||||
&& access (dir, R_OK | W_OK | X_OK) == 0)
|
||||
return dir;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return a prefix for temporary file names or NULL if unable to find one.
|
||||
The current directory is chosen if all else fails so the program is
|
||||
exited if a temporary directory can't be found (mktemp fails).
|
||||
The buffer for the result is obtained with xmalloc.
|
||||
|
||||
This function is provided for backwards compatability only. It use
|
||||
is not recommended. */
|
||||
|
||||
char *
|
||||
choose_temp_base ()
|
||||
{
|
||||
char *base = 0;
|
||||
char *temp_filename;
|
||||
int len;
|
||||
static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
|
||||
static char usrtmp[] = { DIR_SEPARATOR, 'u', 's', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 };
|
||||
|
||||
base = try (getenv ("TMPDIR"), base);
|
||||
base = try (getenv ("TMP"), base);
|
||||
base = try (getenv ("TEMP"), base);
|
||||
|
||||
#ifdef P_tmpdir
|
||||
base = try (P_tmpdir, base);
|
||||
#endif
|
||||
|
||||
/* Try /usr/tmp, then /tmp. */
|
||||
base = try (usrtmp, base);
|
||||
base = try (tmp, base);
|
||||
|
||||
/* If all else fails, use the current directory! */
|
||||
if (base == 0)
|
||||
base = ".";
|
||||
|
||||
len = strlen (base);
|
||||
temp_filename = xmalloc (len + 1 /*DIR_SEPARATOR*/
|
||||
+ strlen (TEMP_FILE) + 1);
|
||||
strcpy (temp_filename, base);
|
||||
|
||||
if (len != 0
|
||||
&& temp_filename[len-1] != '/'
|
||||
&& temp_filename[len-1] != DIR_SEPARATOR)
|
||||
temp_filename[len++] = DIR_SEPARATOR;
|
||||
strcpy (temp_filename + len, TEMP_FILE);
|
||||
|
||||
mktemp (temp_filename);
|
||||
if (strlen (temp_filename) == 0)
|
||||
abort ();
|
||||
return temp_filename;
|
||||
}
|
||||
/* Return a temporary file name (as a string) or NULL if unable to create
|
||||
one. */
|
||||
|
||||
char *
|
||||
make_temp_file (suffix)
|
||||
char *suffix;
|
||||
{
|
||||
char *base = 0;
|
||||
char *temp_filename;
|
||||
int base_len, suffix_len;
|
||||
int fd;
|
||||
static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
|
||||
static char usrtmp[] = { DIR_SEPARATOR, 'u', 's', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 };
|
||||
|
||||
base = try (getenv ("TMPDIR"), base);
|
||||
base = try (getenv ("TMP"), base);
|
||||
base = try (getenv ("TEMP"), base);
|
||||
|
||||
#ifdef P_tmpdir
|
||||
base = try (P_tmpdir, base);
|
||||
#endif
|
||||
|
||||
/* Try /usr/tmp, then /tmp. */
|
||||
base = try (usrtmp, base);
|
||||
base = try (tmp, base);
|
||||
|
||||
/* If all else fails, use the current directory! */
|
||||
if (base == 0)
|
||||
base = ".";
|
||||
|
||||
base_len = strlen (base);
|
||||
|
||||
if (suffix)
|
||||
suffix_len = strlen (suffix);
|
||||
else
|
||||
suffix_len = 0;
|
||||
|
||||
temp_filename = xmalloc (base_len + 1 /*DIR_SEPARATOR*/
|
||||
+ strlen (TEMP_FILE)
|
||||
+ suffix_len + 1);
|
||||
strcpy (temp_filename, base);
|
||||
|
||||
if (base_len != 0
|
||||
&& temp_filename[base_len-1] != '/'
|
||||
&& temp_filename[base_len-1] != DIR_SEPARATOR)
|
||||
temp_filename[base_len++] = DIR_SEPARATOR;
|
||||
strcpy (temp_filename + base_len, TEMP_FILE);
|
||||
|
||||
if (suffix)
|
||||
strcat (temp_filename, suffix);
|
||||
|
||||
fd = mkstemps (temp_filename, suffix_len);
|
||||
/* If mkstemps failed, then something bad is happening. Maybe we should
|
||||
issue a message about a possible security attack in progress? */
|
||||
if (fd == -1)
|
||||
abort ();
|
||||
/* Similarly if we can not close the file. */
|
||||
if (close (fd))
|
||||
abort ();
|
||||
return temp_filename;
|
||||
}
|
||||
75
libiberty/clock.c
Executable file
75
libiberty/clock.c
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
/* 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 */
|
||||
}
|
||||
|
||||
167
libiberty/concat.c
Executable file
167
libiberty/concat.c
Executable file
|
|
@ -0,0 +1,167 @@
|
|||
/* Concatenate variable number of strings.
|
||||
Copyright (C) 1991, 1994 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. */
|
||||
|
||||
|
||||
/*
|
||||
|
||||
NAME
|
||||
|
||||
concat -- concatenate a variable number of strings
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
#include <varargs.h>
|
||||
|
||||
char *concat (s1, s2, s3, ..., NULL)
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
Concatenate a variable number of strings and return the result
|
||||
in freshly malloc'd memory.
|
||||
|
||||
Returns NULL if insufficient memory is available. The argument
|
||||
list is terminated by the first NULL pointer encountered. Pointers
|
||||
to empty strings are ignored.
|
||||
|
||||
NOTES
|
||||
|
||||
This function uses xmalloc() which is expected to be a front end
|
||||
function to malloc() that deals with low memory situations. In
|
||||
typical use, if malloc() returns NULL then xmalloc() diverts to an
|
||||
error handler routine which never returns, and thus xmalloc will
|
||||
never return a NULL pointer. If the client application wishes to
|
||||
deal with low memory situations itself, it should supply an xmalloc
|
||||
that just directly invokes malloc and blindly returns whatever
|
||||
malloc returns.
|
||||
*/
|
||||
|
||||
|
||||
#include "ansidecl.h"
|
||||
#include "libiberty.h"
|
||||
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
extern size_t strlen (const char *s);
|
||||
#else
|
||||
extern int strlen ();
|
||||
#endif
|
||||
|
||||
#define NULLP (char *)0
|
||||
|
||||
/* VARARGS */
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
char *
|
||||
concat (const char *first, ...)
|
||||
#else
|
||||
char *
|
||||
concat (va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
register int length;
|
||||
register char *newstr;
|
||||
register char *end;
|
||||
register const char *arg;
|
||||
va_list args;
|
||||
#ifndef ANSI_PROTOTYPES
|
||||
const char *first;
|
||||
#endif
|
||||
|
||||
/* First compute the size of the result and get sufficient memory. */
|
||||
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
va_start (args, first);
|
||||
#else
|
||||
va_start (args);
|
||||
first = va_arg (args, const char *);
|
||||
#endif
|
||||
|
||||
if (first == NULLP)
|
||||
length = 0;
|
||||
else
|
||||
{
|
||||
length = strlen (first);
|
||||
while ((arg = va_arg (args, const char *)) != NULLP)
|
||||
{
|
||||
length += strlen (arg);
|
||||
}
|
||||
}
|
||||
newstr = (char *) xmalloc (length + 1);
|
||||
va_end (args);
|
||||
|
||||
/* Now copy the individual pieces to the result string. */
|
||||
|
||||
if (newstr != NULLP)
|
||||
{
|
||||
#ifdef ANSI_PROTOTYPES
|
||||
va_start (args, first);
|
||||
#else
|
||||
va_start (args);
|
||||
first = va_arg (args, const char *);
|
||||
#endif
|
||||
end = newstr;
|
||||
if (first != NULLP)
|
||||
{
|
||||
arg = first;
|
||||
while (*arg)
|
||||
{
|
||||
*end++ = *arg++;
|
||||
}
|
||||
while ((arg = va_arg (args, const char *)) != NULLP)
|
||||
{
|
||||
while (*arg)
|
||||
{
|
||||
*end++ = *arg++;
|
||||
}
|
||||
}
|
||||
}
|
||||
*end = '\000';
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
return (newstr);
|
||||
}
|
||||
|
||||
#ifdef MAIN
|
||||
|
||||
/* Simple little test driver. */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
printf ("\"\" = \"%s\"\n", concat (NULLP));
|
||||
printf ("\"a\" = \"%s\"\n", concat ("a", NULLP));
|
||||
printf ("\"ab\" = \"%s\"\n", concat ("a", "b", NULLP));
|
||||
printf ("\"abc\" = \"%s\"\n", concat ("a", "b", "c", NULLP));
|
||||
printf ("\"abcd\" = \"%s\"\n", concat ("ab", "cd", NULLP));
|
||||
printf ("\"abcde\" = \"%s\"\n", concat ("ab", "c", "de", NULLP));
|
||||
printf ("\"abcdef\" = \"%s\"\n", concat ("", "a", "", "bcd", "ef", NULLP));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
13
libiberty/config.h-vms
Executable file
13
libiberty/config.h-vms
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#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
|
||||
|
||||
203
libiberty/config.in
Executable file
203
libiberty/config.in
Executable file
|
|
@ -0,0 +1,203 @@
|
|||
/* 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
|
||||
55
libiberty/config.table
Executable file
55
libiberty/config.table
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
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
|
||||
9
libiberty/config/mh-aix
Executable file
9
libiberty/config/mh-aix
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
# 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
libiberty/config/mh-cxux7
Executable file
1
libiberty/config/mh-cxux7
Executable file
|
|
@ -0,0 +1 @@
|
|||
HDEFINES = -DHARRIS_FLOAT_FORMAT
|
||||
1
libiberty/config/mh-fbsd21
Executable file
1
libiberty/config/mh-fbsd21
Executable file
|
|
@ -0,0 +1 @@
|
|||
EXTRA_OFILES=vasprintf.o
|
||||
1
libiberty/config/mh-windows
Executable file
1
libiberty/config/mh-windows
Executable file
|
|
@ -0,0 +1 @@
|
|||
EXTRA_OFILES=asprintf.o strcasecmp.o strncasecmp.o vasprintf.o
|
||||
2799
libiberty/configure
vendored
Executable file
2799
libiberty/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
14
libiberty/configure.bat
Executable file
14
libiberty/configure.bat
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
@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
|
||||
333
libiberty/configure.in
Executable file
333
libiberty/configure.in
Executable file
|
|
@ -0,0 +1,333 @@
|
|||
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}
|
||||
)
|
||||
140
libiberty/copysign.c
Executable file
140
libiberty/copysign.c
Executable file
|
|
@ -0,0 +1,140 @@
|
|||
#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;
|
||||
}
|
||||
73
libiberty/fdmatch.c
Executable file
73
libiberty/fdmatch.c
Executable file
|
|
@ -0,0 +1,73 @@
|
|||
/* 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);
|
||||
}
|
||||
}
|
||||
403
libiberty/floatformat.c
Executable file
403
libiberty/floatformat.c
Executable file
|
|
@ -0,0 +1,403 @@
|
|||
/* 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
|
||||
225
libiberty/fnmatch.c
Executable file
225
libiberty/fnmatch.c
Executable file
|
|
@ -0,0 +1,225 @@
|
|||
/* 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__. */
|
||||
54
libiberty/getcwd.c
Executable file
54
libiberty/getcwd.c
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
/* 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
Executable file
1049
libiberty/getopt.c
Executable file
File diff suppressed because it is too large
Load Diff
190
libiberty/getopt1.c
Executable file
190
libiberty/getopt1.c
Executable file
|
|
@ -0,0 +1,190 @@
|
|||
/* 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 */
|
||||
96
libiberty/getpagesize.c
Executable file
96
libiberty/getpagesize.c
Executable file
|
|
@ -0,0 +1,96 @@
|
|||
/* 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 */
|
||||
74
libiberty/getruntime.c
Executable file
74
libiberty/getruntime.c
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
/* 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 */
|
||||
}
|
||||
33
libiberty/hex.c
Executable file
33
libiberty/hex.c
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
/* 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;
|
||||
}
|
||||
11
libiberty/index.c
Executable file
11
libiberty/index.c
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
/* Stub implementation of (obsolete) index(). */
|
||||
|
||||
extern char * strchr();
|
||||
|
||||
char *
|
||||
index (s, c)
|
||||
char *s;
|
||||
int c;
|
||||
{
|
||||
return strchr (s, c);
|
||||
}
|
||||
50
libiberty/insque.c
Executable file
50
libiberty/insque.c
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
/* 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;
|
||||
}
|
||||
29
libiberty/makefile.dos
Executable file
29
libiberty/makefile.dos
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
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)
|
||||
33
libiberty/makefile.vms
Executable file
33
libiberty/makefile.vms
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#
|
||||
# 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;
|
||||
60
libiberty/memchr.c
Executable file
60
libiberty/memchr.c
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
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;
|
||||
}
|
||||
38
libiberty/memcmp.c
Executable file
38
libiberty/memcmp.c
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
/* 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;
|
||||
}
|
||||
|
||||
28
libiberty/memcpy.c
Executable file
28
libiberty/memcpy.c
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
/* 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;
|
||||
}
|
||||
18
libiberty/memmove.c
Executable file
18
libiberty/memmove.c
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
/* 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;
|
||||
}
|
||||
19
libiberty/memset.c
Executable file
19
libiberty/memset.c
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
/* 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;
|
||||
}
|
||||
128
libiberty/mkstemp.c
Executable file
128
libiberty/mkstemp.c
Executable file
|
|
@ -0,0 +1,128 @@
|
|||
/* Copyright (C) 1991, 1992, 1996, 1998 Free Software Foundation, Inc.
|
||||
This file is derived from mkstemp.c from the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include "ansidecl.h"
|
||||
|
||||
/* We need to provide a type for gcc_uint64_t. */
|
||||
#ifdef __GNUC__
|
||||
typedef unsigned long long gcc_uint64_t;
|
||||
#else
|
||||
typedef unsigned long gcc_uint64_t;
|
||||
#endif
|
||||
|
||||
#ifndef TMP_MAX
|
||||
#define TMP_MAX 16384
|
||||
#endif
|
||||
|
||||
/* Generate a unique temporary file name from TEMPLATE.
|
||||
|
||||
TEMPLATE has the form:
|
||||
|
||||
<path>/ccXXXXXX<suffix>
|
||||
|
||||
SUFFIX_LEN tells us how long <suffix> is (it can be zero length).
|
||||
|
||||
The last six characters of TEMPLATE before <suffix> must be "XXXXXX";
|
||||
they are replaced with a string that makes the filename unique.
|
||||
|
||||
Returns a file descriptor open on the file for reading and writing. */
|
||||
int
|
||||
mkstemps (template, suffix_len)
|
||||
char *template;
|
||||
int suffix_len;
|
||||
{
|
||||
static const char letters[]
|
||||
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
static gcc_uint64_t value;
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
struct timeval tv;
|
||||
#endif
|
||||
char *XXXXXX;
|
||||
size_t len;
|
||||
int count;
|
||||
|
||||
len = strlen (template);
|
||||
|
||||
if ((int) len < 6 + suffix_len
|
||||
|| strncmp (&template[len - 6 - suffix_len], "XXXXXX", 6))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
XXXXXX = &template[len - 6 - suffix_len];
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
/* Get some more or less random data. */
|
||||
gettimeofday (&tv, NULL);
|
||||
value += ((gcc_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
|
||||
#else
|
||||
value += getpid ();
|
||||
#endif
|
||||
|
||||
for (count = 0; count < TMP_MAX; ++count)
|
||||
{
|
||||
gcc_uint64_t v = value;
|
||||
int fd;
|
||||
|
||||
/* Fill in the random bits. */
|
||||
XXXXXX[0] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[1] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[2] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[3] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[4] = letters[v % 62];
|
||||
v /= 62;
|
||||
XXXXXX[5] = letters[v % 62];
|
||||
|
||||
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
|
||||
if (fd >= 0)
|
||||
/* The file does not exist. */
|
||||
return fd;
|
||||
|
||||
/* This is a random value. It is only necessary that the next
|
||||
TMP_MAX values generated by adding 7777 to VALUE are different
|
||||
with (module 2^32). */
|
||||
value += 7777;
|
||||
}
|
||||
|
||||
/* We return the null string if we can't find a unique file name. */
|
||||
template[0] = '\0';
|
||||
return -1;
|
||||
}
|
||||
7
libiberty/mpw-config.in
Executable file
7
libiberty/mpw-config.in
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
# MPW configuration fragment for libiberty.
|
||||
|
||||
Echo '/* config.h. Generated by mpw-configure. */' > "{o}"config.new
|
||||
|
||||
MoveIfChange "{o}"config.new "{o}"config.h
|
||||
|
||||
|
||||
51
libiberty/mpw-make.sed
Executable file
51
libiberty/mpw-make.sed
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
# 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
Executable file
1010
libiberty/mpw.c
Executable file
File diff suppressed because it is too large
Load Diff
15
libiberty/msdos.c
Executable file
15
libiberty/msdos.c
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
char msg[] = "No vfork available - aborting\n";
|
||||
vfork()
|
||||
{
|
||||
write(1, msg, sizeof(msg));
|
||||
}
|
||||
|
||||
sigsetmask()
|
||||
{
|
||||
/* no signals support in go32 (yet) */
|
||||
}
|
||||
|
||||
waitpid()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
291
libiberty/objalloc.c
Executable file
291
libiberty/objalloc.c
Executable file
|
|
@ -0,0 +1,291 @@
|
|||
/* 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;
|
||||
}
|
||||
}
|
||||
586
libiberty/obstack.c
Executable file
586
libiberty/obstack.c
Executable file
|
|
@ -0,0 +1,586 @@
|
|||
/* obstack.c - subroutines used implicitly by object stack macros
|
||||
Copyright (C) 1988,89,90,91,92,93,94,96,97 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 "obstack.h"
|
||||
|
||||
/* NOTE BEFORE MODIFYING THIS FILE: This version number must be
|
||||
incremented whenever callers compiled using an old obstack.h can no
|
||||
longer properly call the functions in this obstack.c. */
|
||||
#define OBSTACK_INTERFACE_VERSION 1
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself, and the installed library
|
||||
supports the same library interface we do. 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. */
|
||||
|
||||
#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */
|
||||
#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
|
||||
#include <gnu-versions.h>
|
||||
#if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
|
||||
#define ELIDE_CODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#define POINTER void *
|
||||
#else
|
||||
#define POINTER char *
|
||||
#endif
|
||||
|
||||
/* Determine default alignment. */
|
||||
struct fooalign {char x; double d;};
|
||||
#define DEFAULT_ALIGNMENT \
|
||||
((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
|
||||
/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
|
||||
But in fact it might be less smart and round addresses to as much as
|
||||
DEFAULT_ROUNDING. So we prepare for it to do that. */
|
||||
union fooround {long x; double d;};
|
||||
#define DEFAULT_ROUNDING (sizeof (union fooround))
|
||||
|
||||
/* When we copy a long block of data, this is the unit to do it with.
|
||||
On some machines, copying successive ints does not work;
|
||||
in such a case, redefine COPYING_UNIT to `long' (if that works)
|
||||
or `char' as a last resort. */
|
||||
#ifndef COPYING_UNIT
|
||||
#define COPYING_UNIT int
|
||||
#endif
|
||||
|
||||
|
||||
/* The functions allocating more room by calling `obstack_chunk_alloc'
|
||||
jump to the handler pointed to by `obstack_alloc_failed_handler'.
|
||||
This variable by default points to the internal function
|
||||
`print_and_abort'. */
|
||||
#if defined (__STDC__) && __STDC__
|
||||
static void print_and_abort (void);
|
||||
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
|
||||
#else
|
||||
static void print_and_abort ();
|
||||
void (*obstack_alloc_failed_handler) () = print_and_abort;
|
||||
#endif
|
||||
|
||||
/* Exit value used when `print_and_abort' is used. */
|
||||
#if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifndef EXIT_FAILURE
|
||||
#define EXIT_FAILURE 1
|
||||
#endif
|
||||
int obstack_exit_failure = EXIT_FAILURE;
|
||||
|
||||
/* The non-GNU-C macros copy the obstack into this global variable
|
||||
to avoid multiple evaluation. */
|
||||
|
||||
struct obstack *_obstack;
|
||||
|
||||
/* Define a macro that either calls functions with the traditional malloc/free
|
||||
calling interface, or calls functions with the mmalloc/mfree interface
|
||||
(that adds an extra first argument), based on the state of use_extra_arg.
|
||||
For free, do not use ?:, since some compilers, like the MIPS compilers,
|
||||
do not allow (expr) ? void : void. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#define CALL_CHUNKFUN(h, size) \
|
||||
(((h) -> use_extra_arg) \
|
||||
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
|
||||
: (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
|
||||
|
||||
#define CALL_FREEFUN(h, old_chunk) \
|
||||
do { \
|
||||
if ((h) -> use_extra_arg) \
|
||||
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
|
||||
else \
|
||||
(*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define CALL_CHUNKFUN(h, size) \
|
||||
(((h) -> use_extra_arg) \
|
||||
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
|
||||
: (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size)))
|
||||
|
||||
#define CALL_FREEFUN(h, old_chunk) \
|
||||
do { \
|
||||
if ((h) -> use_extra_arg) \
|
||||
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
|
||||
else \
|
||||
(*(void (*) ()) (h)->freefun) ((old_chunk)); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
|
||||
Objects start on multiples of ALIGNMENT (0 means use default).
|
||||
CHUNKFUN is the function to use to allocate chunks,
|
||||
and FREEFUN the function to free them.
|
||||
|
||||
Return nonzero if successful, zero if out of memory.
|
||||
To recover from an out of memory error,
|
||||
free up some memory, then call this again. */
|
||||
|
||||
int
|
||||
_obstack_begin (h, size, alignment, chunkfun, freefun)
|
||||
struct obstack *h;
|
||||
int size;
|
||||
int alignment;
|
||||
#if defined (__STDC__) && __STDC__
|
||||
POINTER (*chunkfun) (long);
|
||||
void (*freefun) (void *);
|
||||
#else
|
||||
POINTER (*chunkfun) ();
|
||||
void (*freefun) ();
|
||||
#endif
|
||||
{
|
||||
register struct _obstack_chunk *chunk; /* points to new chunk */
|
||||
|
||||
if (alignment == 0)
|
||||
alignment = (int) DEFAULT_ALIGNMENT;
|
||||
if (size == 0)
|
||||
/* Default size is what GNU malloc can fit in a 4096-byte block. */
|
||||
{
|
||||
/* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
|
||||
Use the values for range checking, because if range checking is off,
|
||||
the extra bytes won't be missed terribly, but if range checking is on
|
||||
and we used a larger request, a whole extra 4096 bytes would be
|
||||
allocated.
|
||||
|
||||
These number are irrelevant to the new GNU malloc. I suspect it is
|
||||
less sensitive to the size of the request. */
|
||||
int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
|
||||
+ 4 + DEFAULT_ROUNDING - 1)
|
||||
& ~(DEFAULT_ROUNDING - 1));
|
||||
size = 4096 - extra;
|
||||
}
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
|
||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||
#else
|
||||
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
|
||||
h->freefun = freefun;
|
||||
#endif
|
||||
h->chunk_size = size;
|
||||
h->alignment_mask = alignment - 1;
|
||||
h->use_extra_arg = 0;
|
||||
|
||||
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
|
||||
if (!chunk)
|
||||
(*obstack_alloc_failed_handler) ();
|
||||
h->next_free = h->object_base = chunk->contents;
|
||||
h->chunk_limit = chunk->limit
|
||||
= (char *) chunk + h->chunk_size;
|
||||
chunk->prev = 0;
|
||||
/* The initial chunk now contains no empty object. */
|
||||
h->maybe_empty_object = 0;
|
||||
h->alloc_failed = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
_obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
|
||||
struct obstack *h;
|
||||
int size;
|
||||
int alignment;
|
||||
#if defined (__STDC__) && __STDC__
|
||||
POINTER (*chunkfun) (POINTER, long);
|
||||
void (*freefun) (POINTER, POINTER);
|
||||
#else
|
||||
POINTER (*chunkfun) ();
|
||||
void (*freefun) ();
|
||||
#endif
|
||||
POINTER arg;
|
||||
{
|
||||
register struct _obstack_chunk *chunk; /* points to new chunk */
|
||||
|
||||
if (alignment == 0)
|
||||
alignment = (int) DEFAULT_ALIGNMENT;
|
||||
if (size == 0)
|
||||
/* Default size is what GNU malloc can fit in a 4096-byte block. */
|
||||
{
|
||||
/* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
|
||||
Use the values for range checking, because if range checking is off,
|
||||
the extra bytes won't be missed terribly, but if range checking is on
|
||||
and we used a larger request, a whole extra 4096 bytes would be
|
||||
allocated.
|
||||
|
||||
These number are irrelevant to the new GNU malloc. I suspect it is
|
||||
less sensitive to the size of the request. */
|
||||
int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
|
||||
+ 4 + DEFAULT_ROUNDING - 1)
|
||||
& ~(DEFAULT_ROUNDING - 1));
|
||||
size = 4096 - extra;
|
||||
}
|
||||
|
||||
#if defined(__STDC__) && __STDC__
|
||||
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
|
||||
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
|
||||
#else
|
||||
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
|
||||
h->freefun = freefun;
|
||||
#endif
|
||||
h->chunk_size = size;
|
||||
h->alignment_mask = alignment - 1;
|
||||
h->extra_arg = arg;
|
||||
h->use_extra_arg = 1;
|
||||
|
||||
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
|
||||
if (!chunk)
|
||||
(*obstack_alloc_failed_handler) ();
|
||||
h->next_free = h->object_base = chunk->contents;
|
||||
h->chunk_limit = chunk->limit
|
||||
= (char *) chunk + h->chunk_size;
|
||||
chunk->prev = 0;
|
||||
/* The initial chunk now contains no empty object. */
|
||||
h->maybe_empty_object = 0;
|
||||
h->alloc_failed = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Allocate a new current chunk for the obstack *H
|
||||
on the assumption that LENGTH bytes need to be added
|
||||
to the current object, or a new object of length LENGTH allocated.
|
||||
Copies any partial object from the end of the old chunk
|
||||
to the beginning of the new one. */
|
||||
|
||||
void
|
||||
_obstack_newchunk (h, length)
|
||||
struct obstack *h;
|
||||
int length;
|
||||
{
|
||||
register struct _obstack_chunk *old_chunk = h->chunk;
|
||||
register struct _obstack_chunk *new_chunk;
|
||||
register long new_size;
|
||||
register long obj_size = h->next_free - h->object_base;
|
||||
register long i;
|
||||
long already;
|
||||
|
||||
/* Compute size for new chunk. */
|
||||
new_size = (obj_size + length) + (obj_size >> 3) + 100;
|
||||
if (new_size < h->chunk_size)
|
||||
new_size = h->chunk_size;
|
||||
|
||||
/* Allocate and initialize the new chunk. */
|
||||
new_chunk = CALL_CHUNKFUN (h, new_size);
|
||||
if (!new_chunk)
|
||||
(*obstack_alloc_failed_handler) ();
|
||||
h->chunk = new_chunk;
|
||||
new_chunk->prev = old_chunk;
|
||||
new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
|
||||
|
||||
/* Move the existing object to the new chunk.
|
||||
Word at a time is fast and is safe if the object
|
||||
is sufficiently aligned. */
|
||||
if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)
|
||||
{
|
||||
for (i = obj_size / sizeof (COPYING_UNIT) - 1;
|
||||
i >= 0; i--)
|
||||
((COPYING_UNIT *)new_chunk->contents)[i]
|
||||
= ((COPYING_UNIT *)h->object_base)[i];
|
||||
/* We used to copy the odd few remaining bytes as one extra COPYING_UNIT,
|
||||
but that can cross a page boundary on a machine
|
||||
which does not do strict alignment for COPYING_UNITS. */
|
||||
already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);
|
||||
}
|
||||
else
|
||||
already = 0;
|
||||
/* Copy remaining bytes one by one. */
|
||||
for (i = already; i < obj_size; i++)
|
||||
new_chunk->contents[i] = h->object_base[i];
|
||||
|
||||
/* If the object just copied was the only data in OLD_CHUNK,
|
||||
free that chunk and remove it from the chain.
|
||||
But not if that chunk might contain an empty object. */
|
||||
if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)
|
||||
{
|
||||
new_chunk->prev = old_chunk->prev;
|
||||
CALL_FREEFUN (h, old_chunk);
|
||||
}
|
||||
|
||||
h->object_base = new_chunk->contents;
|
||||
h->next_free = h->object_base + obj_size;
|
||||
/* The new chunk certainly contains no empty object yet. */
|
||||
h->maybe_empty_object = 0;
|
||||
}
|
||||
|
||||
/* Return nonzero if object OBJ has been allocated from obstack H.
|
||||
This is here for debugging.
|
||||
If you use it in a program, you are probably losing. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
|
||||
obstack.h because it is just for debugging. */
|
||||
int _obstack_allocated_p (struct obstack *h, POINTER obj);
|
||||
#endif
|
||||
|
||||
int
|
||||
_obstack_allocated_p (h, obj)
|
||||
struct obstack *h;
|
||||
POINTER obj;
|
||||
{
|
||||
register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
|
||||
register struct _obstack_chunk *plp; /* point to previous chunk if any */
|
||||
|
||||
lp = (h)->chunk;
|
||||
/* We use >= rather than > since the object cannot be exactly at
|
||||
the beginning of the chunk but might be an empty object exactly
|
||||
at the end of an adjacent chunk. */
|
||||
while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
|
||||
{
|
||||
plp = lp->prev;
|
||||
lp = plp;
|
||||
}
|
||||
return lp != 0;
|
||||
}
|
||||
|
||||
/* Free objects in obstack H, including OBJ and everything allocate
|
||||
more recently than OBJ. If OBJ is zero, free everything in H. */
|
||||
|
||||
#undef obstack_free
|
||||
|
||||
/* This function has two names with identical definitions.
|
||||
This is the first one, called from non-ANSI code. */
|
||||
|
||||
void
|
||||
_obstack_free (h, obj)
|
||||
struct obstack *h;
|
||||
POINTER obj;
|
||||
{
|
||||
register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
|
||||
register struct _obstack_chunk *plp; /* point to previous chunk if any */
|
||||
|
||||
lp = h->chunk;
|
||||
/* We use >= because there cannot be an object at the beginning of a chunk.
|
||||
But there can be an empty object at that address
|
||||
at the end of another chunk. */
|
||||
while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
|
||||
{
|
||||
plp = lp->prev;
|
||||
CALL_FREEFUN (h, lp);
|
||||
lp = plp;
|
||||
/* If we switch chunks, we can't tell whether the new current
|
||||
chunk contains an empty object, so assume that it may. */
|
||||
h->maybe_empty_object = 1;
|
||||
}
|
||||
if (lp)
|
||||
{
|
||||
h->object_base = h->next_free = (char *) (obj);
|
||||
h->chunk_limit = lp->limit;
|
||||
h->chunk = lp;
|
||||
}
|
||||
else if (obj != 0)
|
||||
/* obj is not in any of the chunks! */
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* This function is used from ANSI code. */
|
||||
|
||||
void
|
||||
obstack_free (h, obj)
|
||||
struct obstack *h;
|
||||
POINTER obj;
|
||||
{
|
||||
register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
|
||||
register struct _obstack_chunk *plp; /* point to previous chunk if any */
|
||||
|
||||
lp = h->chunk;
|
||||
/* We use >= because there cannot be an object at the beginning of a chunk.
|
||||
But there can be an empty object at that address
|
||||
at the end of another chunk. */
|
||||
while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
|
||||
{
|
||||
plp = lp->prev;
|
||||
CALL_FREEFUN (h, lp);
|
||||
lp = plp;
|
||||
/* If we switch chunks, we can't tell whether the new current
|
||||
chunk contains an empty object, so assume that it may. */
|
||||
h->maybe_empty_object = 1;
|
||||
}
|
||||
if (lp)
|
||||
{
|
||||
h->object_base = h->next_free = (char *) (obj);
|
||||
h->chunk_limit = lp->limit;
|
||||
h->chunk = lp;
|
||||
}
|
||||
else if (obj != 0)
|
||||
/* obj is not in any of the chunks! */
|
||||
abort ();
|
||||
}
|
||||
|
||||
int
|
||||
_obstack_memory_used (h)
|
||||
struct obstack *h;
|
||||
{
|
||||
register struct _obstack_chunk* lp;
|
||||
register int nbytes = 0;
|
||||
|
||||
for (lp = h->chunk; lp != 0; lp = lp->prev)
|
||||
{
|
||||
nbytes += lp->limit - (char *) lp;
|
||||
}
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
/* Define the error handler. */
|
||||
#ifndef _
|
||||
#define _(Str) (Str)
|
||||
#endif
|
||||
|
||||
static void
|
||||
print_and_abort ()
|
||||
{
|
||||
fputs (_("memory exhausted\n"), stderr);
|
||||
exit (obstack_exit_failure);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* These are now turned off because the applications do not use it
|
||||
and it uses bcopy via obstack_grow, which causes trouble on sysV. */
|
||||
|
||||
/* Now define the functional versions of the obstack macros.
|
||||
Define them to simply use the corresponding macros to do the job. */
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
/* These function definitions do not work with non-ANSI preprocessors;
|
||||
they won't pass through the macro names in parentheses. */
|
||||
|
||||
/* The function names appear in parentheses in order to prevent
|
||||
the macro-definitions of the names from being expanded there. */
|
||||
|
||||
POINTER (obstack_base) (obstack)
|
||||
struct obstack *obstack;
|
||||
{
|
||||
return obstack_base (obstack);
|
||||
}
|
||||
|
||||
POINTER (obstack_next_free) (obstack)
|
||||
struct obstack *obstack;
|
||||
{
|
||||
return obstack_next_free (obstack);
|
||||
}
|
||||
|
||||
int (obstack_object_size) (obstack)
|
||||
struct obstack *obstack;
|
||||
{
|
||||
return obstack_object_size (obstack);
|
||||
}
|
||||
|
||||
int (obstack_room) (obstack)
|
||||
struct obstack *obstack;
|
||||
{
|
||||
return obstack_room (obstack);
|
||||
}
|
||||
|
||||
int (obstack_make_room) (obstack, length)
|
||||
struct obstack *obstack;
|
||||
int length;
|
||||
{
|
||||
return obstack_make_room (obstack, length);
|
||||
}
|
||||
|
||||
void (obstack_grow) (obstack, pointer, length)
|
||||
struct obstack *obstack;
|
||||
POINTER pointer;
|
||||
int length;
|
||||
{
|
||||
obstack_grow (obstack, pointer, length);
|
||||
}
|
||||
|
||||
void (obstack_grow0) (obstack, pointer, length)
|
||||
struct obstack *obstack;
|
||||
POINTER pointer;
|
||||
int length;
|
||||
{
|
||||
obstack_grow0 (obstack, pointer, length);
|
||||
}
|
||||
|
||||
void (obstack_1grow) (obstack, character)
|
||||
struct obstack *obstack;
|
||||
int character;
|
||||
{
|
||||
obstack_1grow (obstack, character);
|
||||
}
|
||||
|
||||
void (obstack_blank) (obstack, length)
|
||||
struct obstack *obstack;
|
||||
int length;
|
||||
{
|
||||
obstack_blank (obstack, length);
|
||||
}
|
||||
|
||||
void (obstack_1grow_fast) (obstack, character)
|
||||
struct obstack *obstack;
|
||||
int character;
|
||||
{
|
||||
obstack_1grow_fast (obstack, character);
|
||||
}
|
||||
|
||||
void (obstack_blank_fast) (obstack, length)
|
||||
struct obstack *obstack;
|
||||
int length;
|
||||
{
|
||||
obstack_blank_fast (obstack, length);
|
||||
}
|
||||
|
||||
POINTER (obstack_finish) (obstack)
|
||||
struct obstack *obstack;
|
||||
{
|
||||
return obstack_finish (obstack);
|
||||
}
|
||||
|
||||
POINTER (obstack_alloc) (obstack, length)
|
||||
struct obstack *obstack;
|
||||
int length;
|
||||
{
|
||||
return obstack_alloc (obstack, length);
|
||||
}
|
||||
|
||||
POINTER (obstack_copy) (obstack, pointer, length)
|
||||
struct obstack *obstack;
|
||||
POINTER pointer;
|
||||
int length;
|
||||
{
|
||||
return obstack_copy (obstack, pointer, length);
|
||||
}
|
||||
|
||||
POINTER (obstack_copy0) (obstack, pointer, length)
|
||||
struct obstack *obstack;
|
||||
POINTER pointer;
|
||||
int length;
|
||||
{
|
||||
return obstack_copy0 (obstack, pointer, length);
|
||||
}
|
||||
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
#endif /* !ELIDE_CODE */
|
||||
734
libiberty/pexecute.c
Executable file
734
libiberty/pexecute.c
Executable file
|
|
@ -0,0 +1,734 @@
|
|||
/* Utilities to execute a program in a subprocess (possibly linked by pipes
|
||||
with other subprocesses), and wait for it.
|
||||
Copyright (C) 1996, 1997, 1998 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. */
|
||||
|
||||
/* This file exports two functions: pexecute and pwait. */
|
||||
|
||||
/* This file lives in at least two places: libiberty and gcc.
|
||||
Don't change one without the other. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#define ISSPACE (x) isspace(x)
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#ifdef vfork /* Autoconf may define this to fork for us. */
|
||||
# define VFORK_STRING "fork"
|
||||
#else
|
||||
# define VFORK_STRING "vfork"
|
||||
#endif
|
||||
#ifdef HAVE_VFORK_H
|
||||
#include <vfork.h>
|
||||
#endif
|
||||
#ifdef VMS
|
||||
#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \
|
||||
lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1)
|
||||
#endif /* VMS */
|
||||
|
||||
#include "libiberty.h"
|
||||
|
||||
/* stdin file number. */
|
||||
#define STDIN_FILE_NO 0
|
||||
|
||||
/* stdout file number. */
|
||||
#define STDOUT_FILE_NO 1
|
||||
|
||||
/* value of `pipe': port index for reading. */
|
||||
#define READ_PORT 0
|
||||
|
||||
/* value of `pipe': port index for writing. */
|
||||
#define WRITE_PORT 1
|
||||
|
||||
static char *install_error_msg = "installation problem, cannot exec `%s'";
|
||||
|
||||
/* pexecute: execute a program.
|
||||
|
||||
PROGRAM and ARGV are the arguments to execv/execvp.
|
||||
|
||||
THIS_PNAME is name of the calling program (i.e. argv[0]).
|
||||
|
||||
TEMP_BASE is the path name, sans suffix, of a temporary file to use
|
||||
if needed. This is currently only needed for MSDOS ports that don't use
|
||||
GO32 (do any still exist?). Ports that don't need it can pass NULL.
|
||||
|
||||
(FLAGS & PEXECUTE_SEARCH) is non-zero if $PATH should be searched
|
||||
(??? It's not clear that GCC passes this flag correctly).
|
||||
(FLAGS & PEXECUTE_FIRST) is nonzero for the first process in chain.
|
||||
(FLAGS & PEXECUTE_FIRST) is nonzero for the last process in chain.
|
||||
FIRST_LAST could be simplified to only mark the last of a chain of processes
|
||||
but that requires the caller to always mark the last one (and not give up
|
||||
early if some error occurs). It's more robust to require the caller to
|
||||
mark both ends of the chain.
|
||||
|
||||
The result is the pid on systems like Unix where we fork/exec and on systems
|
||||
like WIN32 and OS2 where we use spawn. It is up to the caller to wait for
|
||||
the child.
|
||||
|
||||
The result is the WEXITSTATUS on systems like MSDOS where we spawn and wait
|
||||
for the child here.
|
||||
|
||||
Upon failure, ERRMSG_FMT and ERRMSG_ARG are set to the text of the error
|
||||
message with an optional argument (if not needed, ERRMSG_ARG is set to
|
||||
NULL), and -1 is returned. `errno' is available to the caller to use.
|
||||
|
||||
pwait: cover function for wait.
|
||||
|
||||
PID is the process id of the task to wait for.
|
||||
STATUS is the `status' argument to wait.
|
||||
FLAGS is currently unused (allows future enhancement without breaking
|
||||
upward compatibility). Pass 0 for now.
|
||||
|
||||
The result is the pid of the child reaped,
|
||||
or -1 for failure (errno says why).
|
||||
|
||||
On systems that don't support waiting for a particular child, PID is
|
||||
ignored. On systems like MSDOS that don't really multitask pwait
|
||||
is just a mechanism to provide a consistent interface for the caller.
|
||||
|
||||
pfinish: finish generation of script
|
||||
|
||||
pfinish is necessary for systems like MPW where a script is generated that
|
||||
runs the requested programs.
|
||||
*/
|
||||
|
||||
#ifdef __MSDOS__
|
||||
|
||||
/* MSDOS doesn't multitask, but for the sake of a consistent interface
|
||||
the code behaves like it does. pexecute runs the program, tucks the
|
||||
exit code away, and returns a "pid". pwait must be called to fetch the
|
||||
exit code. */
|
||||
|
||||
#include <process.h>
|
||||
|
||||
/* For communicating information from pexecute to pwait. */
|
||||
static int last_pid = 0;
|
||||
static int last_status = 0;
|
||||
static int last_reaped = 0;
|
||||
|
||||
int
|
||||
pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
|
||||
const char *program;
|
||||
char * const *argv;
|
||||
const char *this_pname;
|
||||
const char *temp_base;
|
||||
char **errmsg_fmt, **errmsg_arg;
|
||||
int flags;
|
||||
{
|
||||
int rc;
|
||||
|
||||
last_pid++;
|
||||
if (last_pid < 0)
|
||||
last_pid = 1;
|
||||
|
||||
if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE)
|
||||
abort ();
|
||||
|
||||
#ifdef __GO32__
|
||||
/* ??? What are the possible return values from spawnv? */
|
||||
rc = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (1, program, argv);
|
||||
#else
|
||||
char *scmd, *rf;
|
||||
FILE *argfile;
|
||||
int i, el = flags & PEXECUTE_SEARCH ? 4 : 0;
|
||||
|
||||
scmd = (char *) xmalloc (strlen (program) + strlen (temp_base) + 6 + el);
|
||||
rf = scmd + strlen(program) + 2 + el;
|
||||
sprintf (scmd, "%s%s @%s.gp", program,
|
||||
(flags & PEXECUTE_SEARCH ? ".exe" : ""), temp_base);
|
||||
argfile = fopen (rf, "w");
|
||||
if (argfile == 0)
|
||||
{
|
||||
int errno_save = errno;
|
||||
free (scmd);
|
||||
errno = errno_save;
|
||||
*errmsg_fmt = "cannot open `%s.gp'";
|
||||
*errmsg_arg = temp_base;
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i=1; argv[i]; i++)
|
||||
{
|
||||
char *cp;
|
||||
for (cp = argv[i]; *cp; cp++)
|
||||
{
|
||||
if (*cp == '"' || *cp == '\'' || *cp == '\\' || ISSPACE (*cp))
|
||||
fputc ('\\', argfile);
|
||||
fputc (*cp, argfile);
|
||||
}
|
||||
fputc ('\n', argfile);
|
||||
}
|
||||
fclose (argfile);
|
||||
|
||||
rc = system (scmd);
|
||||
|
||||
{
|
||||
int errno_save = errno;
|
||||
remove (rf);
|
||||
free (scmd);
|
||||
errno = errno_save;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
*errmsg_fmt = install_error_msg;
|
||||
*errmsg_arg = program;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Tuck the status away for pwait, and return a "pid". */
|
||||
last_status = rc << 8;
|
||||
return last_pid;
|
||||
}
|
||||
|
||||
int
|
||||
pwait (pid, status, flags)
|
||||
int pid;
|
||||
int *status;
|
||||
int flags;
|
||||
{
|
||||
/* On MSDOS each pexecute must be followed by it's associated pwait. */
|
||||
if (pid != last_pid
|
||||
/* Called twice for the same child? */
|
||||
|| pid == last_reaped)
|
||||
{
|
||||
/* ??? ECHILD would be a better choice. Can we use it here? */
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
/* ??? Here's an opportunity to canonicalize the values in STATUS.
|
||||
Needed? */
|
||||
*status = last_status;
|
||||
last_reaped = last_pid;
|
||||
return last_pid;
|
||||
}
|
||||
|
||||
#endif /* MSDOS */
|
||||
|
||||
#if defined (_WIN32)
|
||||
|
||||
#include <process.h>
|
||||
|
||||
#ifdef __CYGWIN32__
|
||||
|
||||
#define fix_argv(argvec) (argvec)
|
||||
|
||||
extern int _spawnv ();
|
||||
extern int _spawnvp ();
|
||||
|
||||
#else /* ! __CYGWIN32__ */
|
||||
|
||||
/* This is a kludge to get around the Microsoft C spawn functions' propensity
|
||||
to remove the outermost set of double quotes from all arguments. */
|
||||
|
||||
const char * const *
|
||||
fix_argv (argvec)
|
||||
char **argvec;
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; argvec[i] != 0; i++)
|
||||
{
|
||||
int len, j;
|
||||
char *temp, *newtemp;
|
||||
|
||||
temp = argvec[i];
|
||||
len = strlen (temp);
|
||||
for (j = 0; j < len; j++)
|
||||
{
|
||||
if (temp[j] == '"')
|
||||
{
|
||||
newtemp = xmalloc (len + 2);
|
||||
strncpy (newtemp, temp, j);
|
||||
newtemp [j] = '\\';
|
||||
strncpy (&newtemp [j+1], &temp [j], len-j);
|
||||
newtemp [len+1] = 0;
|
||||
temp = newtemp;
|
||||
len++;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
argvec[i] = temp;
|
||||
}
|
||||
|
||||
return (const char * const *) argvec;
|
||||
}
|
||||
#endif /* __CYGWIN32__ */
|
||||
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
||||
/* mingw32 headers may not define the following. */
|
||||
|
||||
#ifndef _P_WAIT
|
||||
# define _P_WAIT 0
|
||||
# define _P_NOWAIT 1
|
||||
# define _P_OVERLAY 2
|
||||
# define _P_NOWAITO 3
|
||||
# define _P_DETACH 4
|
||||
|
||||
# define WAIT_CHILD 0
|
||||
# define WAIT_GRANDCHILD 1
|
||||
#endif
|
||||
|
||||
/* Win32 supports pipes */
|
||||
int
|
||||
pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
|
||||
const char *program;
|
||||
char * const *argv;
|
||||
const char *this_pname;
|
||||
const char *temp_base;
|
||||
char **errmsg_fmt, **errmsg_arg;
|
||||
int flags;
|
||||
{
|
||||
int pid;
|
||||
int pdes[2], org_stdin, org_stdout;
|
||||
int input_desc, output_desc;
|
||||
int retries, sleep_interval;
|
||||
|
||||
/* Pipe waiting from last process, to be used as input for the next one.
|
||||
Value is STDIN_FILE_NO if no pipe is waiting
|
||||
(i.e. the next command is the first of a group). */
|
||||
static int last_pipe_input;
|
||||
|
||||
/* If this is the first process, initialize. */
|
||||
if (flags & PEXECUTE_FIRST)
|
||||
last_pipe_input = STDIN_FILE_NO;
|
||||
|
||||
input_desc = last_pipe_input;
|
||||
|
||||
/* If this isn't the last process, make a pipe for its output,
|
||||
and record it as waiting to be the input to the next process. */
|
||||
if (! (flags & PEXECUTE_LAST))
|
||||
{
|
||||
if (_pipe (pdes, 256, O_BINARY) < 0)
|
||||
{
|
||||
*errmsg_fmt = "pipe";
|
||||
*errmsg_arg = NULL;
|
||||
return -1;
|
||||
}
|
||||
output_desc = pdes[WRITE_PORT];
|
||||
last_pipe_input = pdes[READ_PORT];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Last process. */
|
||||
output_desc = STDOUT_FILE_NO;
|
||||
last_pipe_input = STDIN_FILE_NO;
|
||||
}
|
||||
|
||||
if (input_desc != STDIN_FILE_NO)
|
||||
{
|
||||
org_stdin = dup (STDIN_FILE_NO);
|
||||
dup2 (input_desc, STDIN_FILE_NO);
|
||||
close (input_desc);
|
||||
}
|
||||
|
||||
if (output_desc != STDOUT_FILE_NO)
|
||||
{
|
||||
org_stdout = dup (STDOUT_FILE_NO);
|
||||
dup2 (output_desc, STDOUT_FILE_NO);
|
||||
close (output_desc);
|
||||
}
|
||||
|
||||
pid = (flags & PEXECUTE_SEARCH ? _spawnvp : _spawnv)
|
||||
(_P_NOWAIT, program, fix_argv(argv));
|
||||
|
||||
if (input_desc != STDIN_FILE_NO)
|
||||
{
|
||||
dup2 (org_stdin, STDIN_FILE_NO);
|
||||
close (org_stdin);
|
||||
}
|
||||
|
||||
if (output_desc != STDOUT_FILE_NO)
|
||||
{
|
||||
dup2 (org_stdout, STDOUT_FILE_NO);
|
||||
close (org_stdout);
|
||||
}
|
||||
|
||||
if (pid == -1)
|
||||
{
|
||||
*errmsg_fmt = install_error_msg;
|
||||
*errmsg_arg = program;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
/* MS CRTDLL doesn't return enough information in status to decide if the
|
||||
child exited due to a signal or not, rather it simply returns an
|
||||
integer with the exit code of the child; eg., if the child exited with
|
||||
an abort() call and didn't have a handler for SIGABRT, it simply returns
|
||||
with status = 3. We fix the status code to conform to the usual WIF*
|
||||
macros. Note that WIFSIGNALED will never be true under CRTDLL. */
|
||||
|
||||
int
|
||||
pwait (pid, status, flags)
|
||||
int pid;
|
||||
int *status;
|
||||
int flags;
|
||||
{
|
||||
#ifdef __CYGWIN32__
|
||||
return wait (status);
|
||||
#else
|
||||
int termstat;
|
||||
|
||||
pid = _cwait (&termstat, pid, WAIT_CHILD);
|
||||
|
||||
/* ??? Here's an opportunity to canonicalize the values in STATUS.
|
||||
Needed? */
|
||||
|
||||
/* cwait returns the child process exit code in termstat.
|
||||
A value of 3 indicates that the child caught a signal, but not
|
||||
which one. Since only SIGABRT, SIGFPE and SIGINT do anything, we
|
||||
report SIGABRT. */
|
||||
if (termstat == 3)
|
||||
*status = SIGABRT;
|
||||
else
|
||||
*status = (((termstat) & 0xff) << 8);
|
||||
|
||||
return pid;
|
||||
#endif /* __CYGWIN32__ */
|
||||
}
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef OS2
|
||||
|
||||
/* ??? Does OS2 have process.h? */
|
||||
extern int spawnv ();
|
||||
extern int spawnvp ();
|
||||
|
||||
int
|
||||
pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
|
||||
const char *program;
|
||||
char * const *argv;
|
||||
const char *this_pname;
|
||||
const char *temp_base;
|
||||
char **errmsg_fmt, **errmsg_arg;
|
||||
int flags;
|
||||
{
|
||||
int pid;
|
||||
|
||||
if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE)
|
||||
abort ();
|
||||
/* ??? Presumably 1 == _P_NOWAIT. */
|
||||
pid = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (1, program, argv);
|
||||
if (pid == -1)
|
||||
{
|
||||
*errmsg_fmt = install_error_msg;
|
||||
*errmsg_arg = program;
|
||||
return -1;
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
|
||||
int
|
||||
pwait (pid, status, flags)
|
||||
int pid;
|
||||
int *status;
|
||||
int flags;
|
||||
{
|
||||
/* ??? Here's an opportunity to canonicalize the values in STATUS.
|
||||
Needed? */
|
||||
int pid = wait (status);
|
||||
return pid;
|
||||
}
|
||||
|
||||
#endif /* OS2 */
|
||||
|
||||
#ifdef MPW
|
||||
|
||||
/* MPW pexecute doesn't actually run anything; instead, it writes out
|
||||
script commands that, when run, will do the actual executing.
|
||||
|
||||
For example, in GCC's case, GCC will write out several script commands:
|
||||
|
||||
cpp ...
|
||||
cc1 ...
|
||||
as ...
|
||||
ld ...
|
||||
|
||||
and then exit. None of the above programs will have run yet. The task
|
||||
that called GCC will then execute the script and cause cpp,etc. to run.
|
||||
The caller must invoke pfinish before calling exit. This adds
|
||||
the finishing touches to the generated script. */
|
||||
|
||||
static int first_time = 1;
|
||||
|
||||
int
|
||||
pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
|
||||
const char *program;
|
||||
char * const *argv;
|
||||
const char *this_pname;
|
||||
const char *temp_base;
|
||||
char **errmsg_fmt, **errmsg_arg;
|
||||
int flags;
|
||||
{
|
||||
char tmpprogram[255];
|
||||
char *cp, *tmpname;
|
||||
int i;
|
||||
|
||||
mpwify_filename (program, tmpprogram);
|
||||
if (first_time)
|
||||
{
|
||||
printf ("Set Failed 0\n");
|
||||
first_time = 0;
|
||||
}
|
||||
|
||||
fputs ("If {Failed} == 0\n", stdout);
|
||||
/* If being verbose, output a copy of the command. It should be
|
||||
accurate enough and escaped enough to be "clickable". */
|
||||
if (flags & PEXECUTE_VERBOSE)
|
||||
{
|
||||
fputs ("\tEcho ", stdout);
|
||||
fputc ('\'', stdout);
|
||||
fputs (tmpprogram, stdout);
|
||||
fputc ('\'', stdout);
|
||||
fputc (' ', stdout);
|
||||
for (i=1; argv[i]; i++)
|
||||
{
|
||||
fputc ('\'', stdout);
|
||||
/* See if we have an argument that needs fixing. */
|
||||
if (strchr(argv[i], '/'))
|
||||
{
|
||||
tmpname = (char *) xmalloc (256);
|
||||
mpwify_filename (argv[i], tmpname);
|
||||
argv[i] = tmpname;
|
||||
}
|
||||
for (cp = argv[i]; *cp; cp++)
|
||||
{
|
||||
/* Write an Option-d escape char in front of special chars. */
|
||||
if (strchr("'+", *cp))
|
||||
fputc ('\266', stdout);
|
||||
fputc (*cp, stdout);
|
||||
}
|
||||
fputc ('\'', stdout);
|
||||
fputc (' ', stdout);
|
||||
}
|
||||
fputs ("\n", stdout);
|
||||
}
|
||||
fputs ("\t", stdout);
|
||||
fputs (tmpprogram, stdout);
|
||||
fputc (' ', stdout);
|
||||
|
||||
for (i=1; argv[i]; i++)
|
||||
{
|
||||
/* See if we have an argument that needs fixing. */
|
||||
if (strchr(argv[i], '/'))
|
||||
{
|
||||
tmpname = (char *) xmalloc (256);
|
||||
mpwify_filename (argv[i], tmpname);
|
||||
argv[i] = tmpname;
|
||||
}
|
||||
if (strchr (argv[i], ' '))
|
||||
fputc ('\'', stdout);
|
||||
for (cp = argv[i]; *cp; cp++)
|
||||
{
|
||||
/* Write an Option-d escape char in front of special chars. */
|
||||
if (strchr("'+", *cp))
|
||||
fputc ('\266', stdout);
|
||||
fputc (*cp, stdout);
|
||||
}
|
||||
if (strchr (argv[i], ' '))
|
||||
fputc ('\'', stdout);
|
||||
fputc (' ', stdout);
|
||||
}
|
||||
|
||||
fputs ("\n", stdout);
|
||||
|
||||
/* Output commands that arrange to clean up and exit if a failure occurs.
|
||||
We have to be careful to collect the status from the program that was
|
||||
run, rather than some other script command. Also, we don't exit
|
||||
immediately, since necessary cleanups are at the end of the script. */
|
||||
fputs ("\tSet TmpStatus {Status}\n", stdout);
|
||||
fputs ("\tIf {TmpStatus} != 0\n", stdout);
|
||||
fputs ("\t\tSet Failed {TmpStatus}\n", stdout);
|
||||
fputs ("\tEnd\n", stdout);
|
||||
fputs ("End\n", stdout);
|
||||
|
||||
/* We're just composing a script, can't fail here. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
pwait (pid, status, flags)
|
||||
int pid;
|
||||
int *status;
|
||||
int flags;
|
||||
{
|
||||
*status = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Write out commands that will exit with the correct error code
|
||||
if something in the script failed. */
|
||||
|
||||
void
|
||||
pfinish ()
|
||||
{
|
||||
printf ("\tExit \"{Failed}\"\n");
|
||||
}
|
||||
|
||||
#endif /* MPW */
|
||||
|
||||
/* include for Unix-like environments but not for Dos-like environments */
|
||||
#if ! defined (__MSDOS__) && ! defined (OS2) && ! defined (MPW) \
|
||||
&& ! defined (_WIN32)
|
||||
|
||||
extern int execv ();
|
||||
extern int execvp ();
|
||||
|
||||
int
|
||||
pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
|
||||
const char *program;
|
||||
char * const *argv;
|
||||
const char *this_pname;
|
||||
const char *temp_base;
|
||||
char **errmsg_fmt, **errmsg_arg;
|
||||
int flags;
|
||||
{
|
||||
int (*func)() = (flags & PEXECUTE_SEARCH ? execvp : execv);
|
||||
int pid;
|
||||
int pdes[2];
|
||||
int input_desc, output_desc;
|
||||
int retries, sleep_interval;
|
||||
/* Pipe waiting from last process, to be used as input for the next one.
|
||||
Value is STDIN_FILE_NO if no pipe is waiting
|
||||
(i.e. the next command is the first of a group). */
|
||||
static int last_pipe_input;
|
||||
|
||||
/* If this is the first process, initialize. */
|
||||
if (flags & PEXECUTE_FIRST)
|
||||
last_pipe_input = STDIN_FILE_NO;
|
||||
|
||||
input_desc = last_pipe_input;
|
||||
|
||||
/* If this isn't the last process, make a pipe for its output,
|
||||
and record it as waiting to be the input to the next process. */
|
||||
if (! (flags & PEXECUTE_LAST))
|
||||
{
|
||||
if (pipe (pdes) < 0)
|
||||
{
|
||||
*errmsg_fmt = "pipe";
|
||||
*errmsg_arg = NULL;
|
||||
return -1;
|
||||
}
|
||||
output_desc = pdes[WRITE_PORT];
|
||||
last_pipe_input = pdes[READ_PORT];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Last process. */
|
||||
output_desc = STDOUT_FILE_NO;
|
||||
last_pipe_input = STDIN_FILE_NO;
|
||||
}
|
||||
|
||||
/* Fork a subprocess; wait and retry if it fails. */
|
||||
sleep_interval = 1;
|
||||
for (retries = 0; retries < 4; retries++)
|
||||
{
|
||||
pid = vfork ();
|
||||
if (pid >= 0)
|
||||
break;
|
||||
sleep (sleep_interval);
|
||||
sleep_interval *= 2;
|
||||
}
|
||||
|
||||
switch (pid)
|
||||
{
|
||||
case -1:
|
||||
{
|
||||
*errmsg_fmt = VFORK_STRING;
|
||||
*errmsg_arg = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
case 0: /* child */
|
||||
/* Move the input and output pipes into place, if necessary. */
|
||||
if (input_desc != STDIN_FILE_NO)
|
||||
{
|
||||
close (STDIN_FILE_NO);
|
||||
dup (input_desc);
|
||||
close (input_desc);
|
||||
}
|
||||
if (output_desc != STDOUT_FILE_NO)
|
||||
{
|
||||
close (STDOUT_FILE_NO);
|
||||
dup (output_desc);
|
||||
close (output_desc);
|
||||
}
|
||||
|
||||
/* Close the parent's descs that aren't wanted here. */
|
||||
if (last_pipe_input != STDIN_FILE_NO)
|
||||
close (last_pipe_input);
|
||||
|
||||
/* Exec the program. */
|
||||
(*func) (program, argv);
|
||||
|
||||
/* Note: Calling fprintf and exit here doesn't seem right for vfork. */
|
||||
fprintf (stderr, "%s: ", this_pname);
|
||||
fprintf (stderr, install_error_msg, program);
|
||||
fprintf (stderr, ": %s\n", xstrerror (errno));
|
||||
exit (-1);
|
||||
/* NOTREACHED */
|
||||
return 0;
|
||||
|
||||
default:
|
||||
/* In the parent, after forking.
|
||||
Close the descriptors that we made for this child. */
|
||||
if (input_desc != STDIN_FILE_NO)
|
||||
close (input_desc);
|
||||
if (output_desc != STDOUT_FILE_NO)
|
||||
close (output_desc);
|
||||
|
||||
/* Return child's process number. */
|
||||
return pid;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
pwait (pid, status, flags)
|
||||
int pid;
|
||||
int *status;
|
||||
int flags;
|
||||
{
|
||||
/* ??? Here's an opportunity to canonicalize the values in STATUS.
|
||||
Needed? */
|
||||
#ifdef VMS
|
||||
pid = waitpid (-1, status, 0);
|
||||
#else
|
||||
pid = wait (status);
|
||||
#endif
|
||||
return pid;
|
||||
}
|
||||
|
||||
#endif /* ! __MSDOS__ && ! OS2 && ! MPW && ! _WIN32 */
|
||||
377
libiberty/random.c
Executable file
377
libiberty/random.c
Executable file
|
|
@ -0,0 +1,377 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
22
libiberty/rename.c
Executable file
22
libiberty/rename.c
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
/* 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);
|
||||
}
|
||||
11
libiberty/rindex.c
Executable file
11
libiberty/rindex.c
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
/* Stub implementation of (obsolete) rindex(). */
|
||||
|
||||
extern char *strrchr ();
|
||||
|
||||
char *
|
||||
rindex (s, c)
|
||||
char *s;
|
||||
int c;
|
||||
{
|
||||
return strrchr (s, c);
|
||||
}
|
||||
30
libiberty/sigsetmask.c
Executable file
30
libiberty/sigsetmask.c
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
/* 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
|
||||
78
libiberty/spaces.c
Executable file
78
libiberty/spaces.c
Executable file
|
|
@ -0,0 +1,78 @@
|
|||
/* 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);
|
||||
}
|
||||
|
||||
337
libiberty/splay-tree.c
Executable file
337
libiberty/splay-tree.c
Executable file
|
|
@ -0,0 +1,337 @@
|
|||
/* A splay-tree datatype.
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
Contributed by Mark Mitchell (mark@markmitchell.com).
|
||||
|
||||
This file is part of GNU CC.
|
||||
|
||||
GNU CC 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.
|
||||
|
||||
GNU CC 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* For an easily readable description of splay-trees, see:
|
||||
|
||||
Lewis, Harry R. and Denenberg, Larry. Data Structures and Their
|
||||
Algorithms. Harper-Collins, Inc. 1991. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "libiberty.h"
|
||||
#include "splay-tree.h"
|
||||
|
||||
static void splay_tree_delete_helper PARAMS((splay_tree,
|
||||
splay_tree_node));
|
||||
static void splay_tree_splay PARAMS((splay_tree,
|
||||
splay_tree_key));
|
||||
static splay_tree_node splay_tree_splay_helper
|
||||
PARAMS((splay_tree,
|
||||
splay_tree_key,
|
||||
splay_tree_node*,
|
||||
splay_tree_node*,
|
||||
splay_tree_node*));
|
||||
static int splay_tree_foreach_helper PARAMS((splay_tree,
|
||||
splay_tree_node,
|
||||
splay_tree_foreach_fn,
|
||||
void*));
|
||||
|
||||
/* Deallocate NODE (a member of SP), and all its sub-trees. */
|
||||
|
||||
static void
|
||||
splay_tree_delete_helper (sp, node)
|
||||
splay_tree sp;
|
||||
splay_tree_node node;
|
||||
{
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
splay_tree_delete_helper (sp, node->left);
|
||||
splay_tree_delete_helper (sp, node->right);
|
||||
|
||||
if (sp->delete_key)
|
||||
(*sp->delete_key)(node->key);
|
||||
if (sp->delete_value)
|
||||
(*sp->delete_value)(node->value);
|
||||
|
||||
free ((char*) node);
|
||||
}
|
||||
|
||||
/* Help splay SP around KEY. PARENT and GRANDPARENT are the parent
|
||||
and grandparent, respectively, of NODE. */
|
||||
|
||||
static splay_tree_node
|
||||
splay_tree_splay_helper (sp, key, node, parent, grandparent)
|
||||
splay_tree sp;
|
||||
splay_tree_key key;
|
||||
splay_tree_node *node;
|
||||
splay_tree_node *parent;
|
||||
splay_tree_node *grandparent;
|
||||
{
|
||||
splay_tree_node *next;
|
||||
splay_tree_node n;
|
||||
int comparison;
|
||||
|
||||
n = *node;
|
||||
|
||||
if (!n)
|
||||
return *parent;
|
||||
|
||||
comparison = (*sp->comp) (key, n->key);
|
||||
|
||||
if (comparison == 0)
|
||||
/* We've found the target. */
|
||||
next = 0;
|
||||
else if (comparison < 0)
|
||||
/* The target is to the left. */
|
||||
next = &n->left;
|
||||
else
|
||||
/* The target is to the right. */
|
||||
next = &n->right;
|
||||
|
||||
if (next)
|
||||
{
|
||||
/* Continue down the tree. */
|
||||
n = splay_tree_splay_helper (sp, key, next, node, parent);
|
||||
|
||||
/* The recursive call will change the place to which NODE
|
||||
points. */
|
||||
if (*node != n)
|
||||
return n;
|
||||
}
|
||||
|
||||
if (!parent)
|
||||
/* NODE is the root. We are done. */
|
||||
return n;
|
||||
|
||||
/* First, handle the case where there is no grandparent (i.e.,
|
||||
*PARENT is the root of the tree.) */
|
||||
if (!grandparent)
|
||||
{
|
||||
if (n == (*parent)->left)
|
||||
{
|
||||
*node = n->right;
|
||||
n->right = *parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
*node = n->left;
|
||||
n->left = *parent;
|
||||
}
|
||||
*parent = n;
|
||||
return n;
|
||||
}
|
||||
|
||||
/* Next handle the cases where both N and *PARENT are left children,
|
||||
or where both are right children. */
|
||||
if (n == (*parent)->left && *parent == (*grandparent)->left)
|
||||
{
|
||||
splay_tree_node p = *parent;
|
||||
|
||||
(*grandparent)->left = p->right;
|
||||
p->right = *grandparent;
|
||||
p->left = n->right;
|
||||
n->right = p;
|
||||
*grandparent = n;
|
||||
return n;
|
||||
}
|
||||
else if (n == (*parent)->right && *parent == (*grandparent)->right)
|
||||
{
|
||||
splay_tree_node p = *parent;
|
||||
|
||||
(*grandparent)->right = p->left;
|
||||
p->left = *grandparent;
|
||||
p->right = n->left;
|
||||
n->left = p;
|
||||
*grandparent = n;
|
||||
return n;
|
||||
}
|
||||
|
||||
/* Finally, deal with the case where N is a left child, but *PARENT
|
||||
is a right child, or vice versa. */
|
||||
if (n == (*parent)->left)
|
||||
{
|
||||
(*parent)->left = n->right;
|
||||
n->right = *parent;
|
||||
(*grandparent)->right = n->left;
|
||||
n->left = *grandparent;
|
||||
*grandparent = n;
|
||||
return n;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*parent)->right = n->left;
|
||||
n->left = *parent;
|
||||
(*grandparent)->left = n->right;
|
||||
n->right = *grandparent;
|
||||
*grandparent = n;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
/* Splay SP around KEY. */
|
||||
|
||||
static void
|
||||
splay_tree_splay (sp, key)
|
||||
splay_tree sp;
|
||||
splay_tree_key key;
|
||||
{
|
||||
if (sp->root == 0)
|
||||
return;
|
||||
|
||||
splay_tree_splay_helper (sp, key, &sp->root,
|
||||
/*grandparent=*/0, /*parent=*/0);
|
||||
}
|
||||
|
||||
/* Call FN, passing it the DATA, for every node below NODE, all of
|
||||
which are from SP, following an in-order traversal. If FN every
|
||||
returns a non-zero value, the iteration ceases immediately, and the
|
||||
value is returned. Otherwise, this function returns 0. */
|
||||
|
||||
static int
|
||||
splay_tree_foreach_helper (sp, node, fn, data)
|
||||
splay_tree sp;
|
||||
splay_tree_node node;
|
||||
splay_tree_foreach_fn fn;
|
||||
void* data;
|
||||
{
|
||||
int val;
|
||||
|
||||
if (!node)
|
||||
return 0;
|
||||
|
||||
val = splay_tree_foreach_helper (sp, node->left, fn, data);
|
||||
if (val)
|
||||
return val;
|
||||
|
||||
val = (*fn)(node, data);
|
||||
if (val)
|
||||
return val;
|
||||
|
||||
return splay_tree_foreach_helper (sp, node->right, fn, data);
|
||||
}
|
||||
|
||||
/* Allocate a new splay tree, using COMPARE_FN to compare nodes,
|
||||
DELETE_KEY_FN to deallocate keys, and DELETE_VALUE_FN to deallocate
|
||||
values. */
|
||||
|
||||
splay_tree
|
||||
splay_tree_new (compare_fn, delete_key_fn, delete_value_fn)
|
||||
splay_tree_compare_fn compare_fn;
|
||||
splay_tree_delete_key_fn delete_key_fn;
|
||||
splay_tree_delete_value_fn delete_value_fn;
|
||||
{
|
||||
splay_tree sp = (splay_tree) xmalloc (sizeof (struct splay_tree));
|
||||
sp->root = 0;
|
||||
sp->comp = compare_fn;
|
||||
sp->delete_key = delete_key_fn;
|
||||
sp->delete_value = delete_value_fn;
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
/* Deallocate SP. */
|
||||
|
||||
void
|
||||
splay_tree_delete (sp)
|
||||
splay_tree sp;
|
||||
{
|
||||
splay_tree_delete_helper (sp, sp->root);
|
||||
free ((char*) sp);
|
||||
}
|
||||
|
||||
/* Insert a new node (associating KEY with DATA) into SP. If a
|
||||
previous node with the indicated KEY exists, its data is replaced
|
||||
with the new value. */
|
||||
|
||||
void
|
||||
splay_tree_insert (sp, key, value)
|
||||
splay_tree sp;
|
||||
splay_tree_key key;
|
||||
splay_tree_value value;
|
||||
{
|
||||
int comparison;
|
||||
|
||||
splay_tree_splay (sp, key);
|
||||
|
||||
if (sp->root)
|
||||
comparison = (*sp->comp)(sp->root->key, key);
|
||||
|
||||
if (sp->root && comparison == 0)
|
||||
{
|
||||
/* If the root of the tree already has the indicated KEY, just
|
||||
replace the value with VALUE. */
|
||||
if (sp->delete_value)
|
||||
(*sp->delete_value)(sp->root->value);
|
||||
sp->root->value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Create a new node, and insert it at the root. */
|
||||
splay_tree_node node;
|
||||
|
||||
node = (splay_tree_node) xmalloc (sizeof (struct splay_tree_node));
|
||||
node->key = key;
|
||||
node->value = value;
|
||||
|
||||
if (!sp->root)
|
||||
node->left = node->right = 0;
|
||||
else if (comparison < 0)
|
||||
{
|
||||
node->left = sp->root;
|
||||
node->right = node->left->right;
|
||||
node->left->right = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
node->right = sp->root;
|
||||
node->left = node->right->left;
|
||||
node->right->left = 0;
|
||||
}
|
||||
|
||||
sp->root = node;
|
||||
}
|
||||
}
|
||||
|
||||
/* Lookup KEY in SP, returning VALUE if present, and NULL
|
||||
otherwise. */
|
||||
|
||||
splay_tree_node
|
||||
splay_tree_lookup (sp, key)
|
||||
splay_tree sp;
|
||||
splay_tree_key key;
|
||||
{
|
||||
splay_tree_splay (sp, key);
|
||||
|
||||
if (sp->root && (*sp->comp)(sp->root->key, key) == 0)
|
||||
return sp->root;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Call FN, passing it the DATA, for every node in SP, following an
|
||||
in-order traversal. If FN every returns a non-zero value, the
|
||||
iteration ceases immediately, and the value is returned.
|
||||
Otherwise, this function returns 0. */
|
||||
|
||||
int
|
||||
splay_tree_foreach (sp, fn, data)
|
||||
splay_tree sp;
|
||||
splay_tree_foreach_fn fn;
|
||||
void *data;
|
||||
{
|
||||
return splay_tree_foreach_helper (sp, sp->root, fn, data);
|
||||
}
|
||||
82
libiberty/strcasecmp.c
Executable file
82
libiberty/strcasecmp.c
Executable file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
34
libiberty/strchr.c
Executable file
34
libiberty/strchr.c
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
/* 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);
|
||||
}
|
||||
10
libiberty/strdup.c
Executable file
10
libiberty/strdup.c
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
char *
|
||||
strdup(s)
|
||||
char *s;
|
||||
{
|
||||
char *result = (char*)malloc(strlen(s) + 1);
|
||||
if (result == (char*)0)
|
||||
return (char*)0;
|
||||
strcpy(result, s);
|
||||
return result;
|
||||
}
|
||||
831
libiberty/strerror.c
Executable file
831
libiberty/strerror.c
Executable file
|
|
@ -0,0 +1,831 @@
|
|||
/* 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
|
||||
82
libiberty/strncasecmp.c
Executable file
82
libiberty/strncasecmp.c
Executable file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* 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;
|
||||
}
|
||||
34
libiberty/strrchr.c
Executable file
34
libiberty/strrchr.c
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
/* 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);
|
||||
}
|
||||
644
libiberty/strsignal.c
Executable file
644
libiberty/strsignal.c
Executable file
|
|
@ -0,0 +1,644 @@
|
|||
/* 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
|
||||
51
libiberty/strstr.c
Executable file
51
libiberty/strstr.c
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
/* 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);
|
||||
}
|
||||
122
libiberty/strtod.c
Executable file
122
libiberty/strtod.c
Executable file
|
|
@ -0,0 +1,122 @@
|
|||
/* 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;
|
||||
}
|
||||
143
libiberty/strtol.c
Executable file
143
libiberty/strtol.c
Executable file
|
|
@ -0,0 +1,143 @@
|
|||
/*-
|
||||
* 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);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user