diff options
author | kan <kan@FreeBSD.org> | 2004-01-05 20:27:51 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2004-01-05 20:27:51 +0000 |
commit | 79bbe23c4a73528d6812beec7f637fb1de1d1dfd (patch) | |
tree | 41c6fc164bbfd62896736b277be9ebbeaa6ccaa5 /contrib/gcc | |
parent | 2b59a681a581ff30bd628e5a49771a6b8c53862f (diff) | |
download | FreeBSD-src-79bbe23c4a73528d6812beec7f637fb1de1d1dfd.zip FreeBSD-src-79bbe23c4a73528d6812beec7f637fb1de1d1dfd.tar.gz |
Remove files not part of GCC 3.3.x.
Diffstat (limited to 'contrib/gcc')
75 files changed, 0 insertions, 17068 deletions
diff --git a/contrib/gcc/c-lex.h b/contrib/gcc/c-lex.h deleted file mode 100644 index ac917b5..0000000 --- a/contrib/gcc/c-lex.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Define constants for communication with c-parse.y. - Copyright (C) 1987, 1992, 1998, 1999, 2000 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC 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. - -GCC 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 GCC; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ - -#ifndef GCC_C_LEX_H -#define GCC_C_LEX_H - -extern tree make_pointer_declarator PARAMS ((tree, tree)); -extern void position_after_white_space PARAMS ((void)); - -extern int c_lex PARAMS ((tree *)); -extern const char *init_c_lex PARAMS ((const char *)); - -extern int indent_level; - -struct cpp_reader; -extern struct cpp_reader* parse_in; - -#endif /* ! GCC_C_LEX_H */ diff --git a/contrib/gcc/config/alpha/linux-ecoff.h b/contrib/gcc/config/alpha/linux-ecoff.h deleted file mode 100644 index 824d028..0000000 --- a/contrib/gcc/config/alpha/linux-ecoff.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Definitions of target machine for GNU compiler - for Alpha Linux-based GNU systems using ECOFF. - Copyright (C) 1996, 1997 Free Software Foundation, Inc. - Contributed by Bob Manson. - -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. */ - -#undef TARGET_VERSION -#define TARGET_VERSION fprintf (stderr, " (Alpha GNU/Linux for ECOFF)"); - -#undef CPP_SUBTARGET_SPEC -#define CPP_SUBTARGET_SPEC "-D__ECOFF__" - -#undef LINK_SPEC -#define LINK_SPEC "-G 8 %{O*:-O3} %{!O*:-O1}" - -/* stabs get slurped by the assembler into a queer ecoff format. */ -#undef PREFERRED_DEBUGGING_TYPE -#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG - -/* We support #pragma. */ -#define HANDLE_SYSV_PRAGMA diff --git a/contrib/gcc/config/alpha/osf12.h b/contrib/gcc/config/alpha/osf12.h deleted file mode 100644 index 87e2111..0000000 --- a/contrib/gcc/config/alpha/osf12.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Definitions of target machine for GNU compiler, for DEC Alpha. - Copyright (C) 1992, 1993, 1995, 1996 Free Software Foundation, Inc. - Contributed by Richard Kenner (kenner@nyu.edu) - -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. */ - -/* In OSF 1.2, there is a linker bug that prevents use of -O3 to - the linker. */ - -#undef LINK_SPEC -#define LINK_SPEC \ - "-G 8 -O1 %{static:-non_shared} %{rpath*} \ - %{!static:%{shared:-shared} %{!shared:-call_shared}} %{taso}" - -#undef WCHAR_TYPE -#define WCHAR_TYPE "short unsigned int" -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE 16 diff --git a/contrib/gcc/config/alpha/osf2or3.h b/contrib/gcc/config/alpha/osf2or3.h deleted file mode 100644 index 9d8c8f5..0000000 --- a/contrib/gcc/config/alpha/osf2or3.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Definitions of target machine for GNU compiler, for DEC Alpha, osf[23]. - Copyright (C) 1997 Free Software Foundation, Inc. - -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. */ - -/* In OSF 2 or 3, linking with -lprof1 doesn't require -lpdf. */ - -#undef LIB_SPEC -#define LIB_SPEC "%{p:-lprof1} %{pg:-lprof1} %{a:-lprof2} -lc" - -/* As of OSF 3.2, as still can't subtract adjacent labels. */ -#undef TARGET_AS_CAN_SUBTRACT_LABELS -#define TARGET_AS_CAN_SUBTRACT_LABELS 0 - -/* The frame unwind data requires the ability to subtract labels. */ -#undef DWARF2_UNWIND_INFO -#define DWARF2_UNWIND_INFO 0 diff --git a/contrib/gcc/config/arm/arm-wince-pe.h b/contrib/gcc/config/arm/arm-wince-pe.h deleted file mode 100644 index e43ea99..0000000 --- a/contrib/gcc/config/arm/arm-wince-pe.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Definitions of target machine for GNU compiler, - for ARM with PE obj format running under the WinCE operating system. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. - -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. */ - -#define ARM_WINCE 1 - -#include "pe.h" - -#undef USER_LABEL_PREFIX -#define USER_LABEL_PREFIX "" - -#undef TARGET_VERSION -#define TARGET_VERSION fputs (" (ARM/WinCE/PE)", stderr); - -/* The next three definitions are defined in pe.h, - undefined in arm/arm-pe.h and then redefined back here! */ -#undef LIB_SPEC -#define LIB_SPEC "-lcoredll -lcorelibc" - -#define MATH_LIBRARY "" - -#define LIBSTDCXX "-lc" - -#undef STARTFILE_SPEC -#define STARTFILE_SPEC "" -#define ENDFILE_SPEC "" - -#undef CPP_APCS_PC_DEFAULT_SPEC -#define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__" - -#undef CC1_SPEC -#define CC1_SPEC "%{!mapcs-32:%{!mapcs-26:-mapcs-32}}" - -#undef ASM_SPEC -#define ASM_SPEC " \ -%{mbig-endian:-EB} \ -%{mcpu=*:-m%*} \ -%{march=*:-m%*} \ -%{mapcs-*:-mapcs-%*} \ -%{mthumb-interwork:-mthumb-interwork} \ -%{!mapcs-32:%{!mapcs-26:-mapcs-32}} \ -" - -/* WinCE headers require -DARM */ -#undef PE_SUBTARGET_CPP_SPEC -#define PE_SUBTARGET_CPP_SPEC "-D__pe__ -DARM -D__unaligned=__attribute__((aligned(1))) " - -#undef SIZE_TYPE -#define SIZE_TYPE "long unsigned int" diff --git a/contrib/gcc/config/arm/riscix.h b/contrib/gcc/config/arm/riscix.h deleted file mode 100644 index 35fc232..0000000 --- a/contrib/gcc/config/arm/riscix.h +++ /dev/null @@ -1,144 +0,0 @@ -/* Definitions of target machine for GNU compiler. ARM RISCiX version. - Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000 - Free Software Foundation, Inc. - Contributed by Richard Earnshaw (rwe11@cl.cam.ac.uk), based on original - work by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl) - and Martin Simmons (@harleqn.co.uk). - -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. */ - -/* Translation to find startup files. On RISC iX boxes, - crt0, mcrt0 and gcrt0.o are in /usr/lib. */ -#define STARTFILE_SPEC "\ - %{pg:/usr/lib/gcrt0.o%s}\ - %{!pg:%{p:/usr/lib/mcrt0.o%s}\ - %{!p:/usr/lib/crt0.o%s}}" - -/* RISC iX has no concept of -lg */ -/* If -static is specified then link with -lc_n */ - -#ifndef LIB_SPEC -#define LIB_SPEC "\ - %{g*:-lg}\ - %{!p:%{!pg:%{!static:-lc}%{static:-lc_n}}}\ - %{p:-lc_p}\ - %{pg:-lc_p}" -#endif - -/* The RISC iX assembler never deletes any symbols from the object module; - and, by default, ld doesn't either. -X causes local symbols starting - with 'L' to be deleted, which is what we want. */ -#ifndef LINK_SPEC -#define LINK_SPEC "-X" -#endif - -#ifndef CPP_PREDEFINES -#define CPP_PREDEFINES \ - "-Darm -Driscix -Dunix -Asystem=unix" -#endif - - -/* RISCiX has some weird symbol name munging, that is done to the object module - after assembly, which enables multiple libraries to be supported within - one (possibly shared) library. It basically changes the symbol name of - certain symbols (for example _bcopy is converted to _$bcopy if using BSD) - Symrename's parameters are determined as follows: - -mno-symrename Don't run symrename - -mbsd symrename -BSD <file> - -mxopen symrename -XOPEN <file> - -ansi symrename - <file> - <none> symrename -BSD <file> - */ - -#ifndef ASM_FINAL_SPEC -#if !defined (CROSS_COMPILE) -#define ASM_FINAL_SPEC "\ -%{!mno-symrename: \ - \n /usr/bin/symrename \ - -%{mbsd:%{pedantic:%e-mbsd and -pedantic incompatible}BSD}\ -%{mxopen:%{mbsd:%e-mbsd and -mxopen incompatible}\ -%{pedantic:%e-mxopen and -pedantic incompatible}XOPEN}\ -%{!mbsd:%{!mxopen:%{!ansi:BSD}}} %{c:%{o*:%*}%{!o*:%b.o}}%{!c:%U.o}}" -#endif -#endif - -/* None of these is actually used in cc1. If we don't define them in target - switches cc1 complains about them. For the sake of argument lets allocate - bit 31 of target flags for such options. */ -#define SUBTARGET_SWITCHES \ - {"bsd", 0x80000000, N_("Do symbol renaming for BSD")}, \ - {"xopen", 0x80000000, N_("Do symbol renaming for X/OPEN")}, \ - {"no-symrename", 0x80000000, N_("Don't do symbol renaming")}, - - -/* Run-time Target Specification. */ -#define TARGET_VERSION \ - fputs (" (ARM/RISCiX)", stderr); - -/* This is used in ASM_FILE_START */ -#define ARM_OS_NAME "RISCiX" - -/* Unsigned chars produces much better code than signed. */ -#define DEFAULT_SIGNED_CHAR 0 - -/* Some systems use __main in a way incompatible with its use in gcc, in these - cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to - give the same symbol without quotes for an alternative entry point. You - must define both, or neither. */ -#ifndef NAME__MAIN -#define NAME__MAIN "__gccmain" -#define SYMBOL__MAIN __gccmain -#endif - -/* size_t is "unsigned int" in RISCiX */ -#define SIZE_TYPE "unsigned int" - -/* ptrdiff_t is "int" in RISCiX */ -#define PTRDIFF_TYPE "int" - -/* Maths operation domain error number, EDOM */ -#define TARGET_EDOM 33 - -/* Override the normal default CPU */ -#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm2 - -/* r10 is reserved by RISCiX */ -#define SUBTARGET_CONDITIONAL_REGISTER_USAGE \ - fixed_regs[10] = 1; \ - call_used_regs[10] = 1; - -#include "arm/aout.h" - -/* The RISCiX assembler does not understand .set */ -#undef SET_ASM_OP - -/* Add to CPP_SPEC, we want to add the right #defines when using the include - files. */ -#define SUBTARGET_CPP_SPEC "\ - %{mbsd:%{pedantic:%e-mbsd and -pedantic incompatible} -D_BSD_C} \ - %{mxopen:%{mbsd:%e-mbsd and -mxopen incompatible} \ - %{pedantic:%e-mxopen and -pedantic incompatible} -D_XOPEN_C} \ - %{!mbsd:%{!mxopen:%{!ansi: -D_BSD_C}}}" - -/* The native RISCiX assembler does not support stabs of any kind; because - the native assembler is not used by the compiler, Acorn didn't feel it was - necessary to put them in! */ - -#ifdef DBX_DEBUGGING_INFO -#undef DBX_DEBUGGING_INFO -#endif diff --git a/contrib/gcc/config/arm/riscix1-1.h b/contrib/gcc/config/arm/riscix1-1.h deleted file mode 100644 index fd93d40..0000000 --- a/contrib/gcc/config/arm/riscix1-1.h +++ /dev/null @@ -1,103 +0,0 @@ -/* Definitions of target machine for GNU compiler. ARM RISCiX 1.1x version. - Copyright (C) 1993, 1995, 1997, 1999 Free Software Foundation, Inc. - Contributed by Richard Earnshaw (rwe11@cl.cam.ac.uk), based on original - work by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl) - and Martin Simmons (@harleqn.co.uk). - -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. */ - -/* RISCiX 1.1x is basically the same as 1.2x except that it doesn't have - symrename or atexit. */ - -/* Translation to find startup files. On RISCiX boxes, gcrt0.o is in - /usr/lib. */ -#define STARTFILE_SPEC \ - "%{pg:/usr/lib/gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}" - -#ifndef CPP_PREDEFINES -#define CPP_PREDEFINES "-Darm -Driscix -Dunix -Asystem=unix" -#endif - -/* Riscix 1.1 doesn't have X/OPEN support, so only accept -mbsd (but ignore - it). - By not having -mxopen and -mno-symrename, we get warning messages, - but everything still compiles. */ -/* None of these is actually used in cc1, so they modify bit 31 */ -#define SUBTARGET_SWITCHES \ -{"bsd", 0x80000000, ""}, - - -/* Run-time Target Specification. */ -#define TARGET_VERSION \ - fputs (" (ARM/RISCiX)", stderr); - -/* This is used in ASM_FILE_START */ -#define ARM_OS_NAME "RISCiX" - -#ifdef riscos -#define TARGET_WHEN_DEBUGGING 3 -#else -#define TARGET_WHEN_DEBUGGING 1 -#endif - -/* 'char' is signed by default on RISCiX, unsigned on RISCOS. */ -#ifdef riscos -#define DEFAULT_SIGNED_CHAR 0 -#else -#define DEFAULT_SIGNED_CHAR 1 -#endif - -/* Define this if the target system lacks the function atexit from the - ANSI C standard. If this is defined, and ON_EXIT is not - defined, a default exit function will be provided to support C++. - The man page only describes on_exit, but atexit is also there. - This seems to be missing in early versions. - - FIXME Should we define ON_EXIT here? */ -#define NEED_ATEXIT - -/* Some systems use __main in a way incompatible with its use in gcc, in these - cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to - give the same symbol without quotes for an alternative entry point. You - must define both, or neither. */ -#ifndef NAME__MAIN -#define NAME__MAIN "__gccmain" -#define SYMBOL__MAIN __gccmain -#endif - -/* Override the normal default CPU */ -#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm2 - -/* r10 is reserved by RISCiX */ -#define SUBTARGET_CONDITIONAL_REGISTER_USAGE \ - fixed_regs[10] = 1; \ - call_used_regs[10] = 1; - - -#include "arm/aout.h" - -#define SUBTARGET_CPP_SPEC "%{!ansi: -D_BSD_C}" - - -/* The native RISCiX assembler does not support stabs of any kind; because - the native assembler is not used by the compiler, Acorn didn't feel it was - necessary to put them in! */ - -#ifdef DBX_DEBUGGING_INFO -#undef DBX_DEBUGGING_INFO -#endif diff --git a/contrib/gcc/config/arm/rix-gas.h b/contrib/gcc/config/arm/rix-gas.h deleted file mode 100644 index cfb5312..0000000 --- a/contrib/gcc/config/arm/rix-gas.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Definitions of target machine for GNU compiler. ARM RISCiX(stabs) version. - Copyright (C) 1993 Free Software Foundation, Inc. - Contributed by Richard Earnshaw (rwe11@cl.cam.ac.uk), based on original - work by Pieter `Tiggr' Schoenmakers (rcpieter@win.tue.nl) - and Martin Simmons (@harleqn.co.uk). - -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. */ - -/* Limit the length of a stabs entry (for the broken Acorn assembler) */ -#undef DBX_CONTIN_LENGTH -#define DBX_CONTIN_LENGTH 80 - -/* The native RISCiX assembler does not support stabs of any kind; because - the native assembler is not used by the compiler, Acorn didn't feel it was - necessary to put them in! - However, this file assumes that we have an assembler that does have stabs, - so we put them back in. */ - -#define DBX_DEBUGGING_INFO - -/* Unfortunately dbx doesn't understand these */ -/* Dbx on RISCiX is so broken that I've given up trying to support it. - lets just support gdb. */ -/* #define DEFAULT_GDB_EXTENSIONS 0 */ -/* RISCiX dbx doesn't accept xrefs */ -/* #define DBX_NO_XREFS 1 */ - diff --git a/contrib/gcc/config/arm/t-riscix b/contrib/gcc/config/arm/t-riscix deleted file mode 100644 index 0d38cb0..0000000 --- a/contrib/gcc/config/arm/t-riscix +++ /dev/null @@ -1,6 +0,0 @@ -# Just for these, we omit the frame pointer since it makes such a big -# difference. It is then pointless adding debugging. -TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -LIBGCC2_DEBUG_CFLAGS = -g0 - -FIXPROTO_DEFINES= -D_POSIX_SOURCE -D_XOPEN_C -D_BSD_C -D_XOPEN_SOURCE diff --git a/contrib/gcc/config/float-c4x.h b/contrib/gcc/config/float-c4x.h deleted file mode 100644 index ba62176..0000000 --- a/contrib/gcc/config/float-c4x.h +++ /dev/null @@ -1,96 +0,0 @@ -/* float.h for target with TMS320C3x/C4x floating point format */ -#ifndef _FLOAT_H_ -#define _FLOAT_H_ -/* Produced by enquire version 4.3, CWI, Amsterdam */ - - /* Radix of exponent representation */ -#undef FLT_RADIX -#define FLT_RADIX 2 - /* Number of base-FLT_RADIX digits in the significand of a float */ -#undef FLT_MANT_DIG -#define FLT_MANT_DIG 24 - /* Number of decimal digits of precision in a float */ -#undef FLT_DIG -#define FLT_DIG 6 - /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */ -#undef FLT_ROUNDS -#define FLT_ROUNDS 1 - /* Difference between 1.0 and the minimum float greater than 1.0 */ -#undef FLT_EPSILON -#define FLT_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */ -#undef FLT_MIN_EXP -#define FLT_MIN_EXP (-126) - /* Minimum normalised float */ -#undef FLT_MIN -#define FLT_MIN 5.8774718E-39F - /* Minimum int x such that 10**x is a normalised float */ -#undef FLT_MIN_10_EXP -#define FLT_MIN_10_EXP (-39) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */ -#undef FLT_MAX_EXP -#define FLT_MAX_EXP 128 - /* Maximum float */ -#undef FLT_MAX -#define FLT_MAX 3.4028235e+38F - /* Maximum int x such that 10**x is a representable float */ -#undef FLT_MAX_10_EXP -#define FLT_MAX_10_EXP 38 - - /* Number of base-FLT_RADIX digits in the significand of a double */ -#undef DBL_MANT_DIG -#define DBL_MANT_DIG 24 - /* Number of decimal digits of precision in a double */ -#undef DBL_DIG -#define DBL_DIG 6 - /* Difference between 1.0 and the minimum double greater than 1.0 */ -#undef DBL_EPSILON -#define DBL_EPSILON 1.1920929e-07 - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ -#undef DBL_MIN_EXP -#define DBL_MIN_EXP (-126) - /* Minimum normalised double */ -#undef DBL_MIN -#define DBL_MIN 5.8774718E-39 - /* Minimum int x such that 10**x is a normalised double */ -#undef DBL_MIN_10_EXP -#define DBL_MIN_10_EXP -39 - /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ -#undef DBL_MAX_EXP -#define DBL_MAX_EXP 128 - /* Maximum double */ -#undef DBL_MAX -#define DBL_MAX 3.4028235E+38 - /* Maximum int x such that 10**x is a representable double */ -#undef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 38 - - /* Number of base-FLT_RADIX digits in the significand of a long double */ -#undef LDBL_MANT_DIG -#define LDBL_MANT_DIG 32 - /* Number of decimal digits of precision in a long double */ -#undef LDBL_DIG -#define LDBL_DIG 8 - /* Difference between 1.0 and the minimum long double greater than 1.0 */ -#undef LDBL_EPSILON -#define LDBL_EPSILON 1.19209287e-07L - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */ -#undef LDBL_MIN_EXP -#define LDBL_MIN_EXP (-126) - /* Minimum normalised long double */ -#undef LDBL_MIN -#define LDBL_MIN 5.8774717535e-39L - /* Minimum int x such that 10**x is a normalised long double */ -#undef LDBL_MIN_10_EXP -#define LDBL_MIN_10_EXP (-39) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */ -#undef LDBL_MAX_EXP -#define LDBL_MAX_EXP 128 - /* Maximum long double */ -#undef LDBL_MAX -#define LDBL_MAX .4028236688e+38L - /* Maximum int x such that 10**x is a representable long double */ -#undef LDBL_MAX_10_EXP -#define LDBL_MAX_10_EXP 38 - -#endif /* _FLOAT_H_ */ diff --git a/contrib/gcc/config/float-i128.h b/contrib/gcc/config/float-i128.h deleted file mode 100644 index c61c82f..0000000 --- a/contrib/gcc/config/float-i128.h +++ /dev/null @@ -1,123 +0,0 @@ -/* float.h for target with IEEE 32, 64 and 128 bit floating point formats */ -#ifndef _FLOAT_H_ -#define _FLOAT_H_ -/* Produced by enquire version 4.3, CWI, Amsterdam */ - - /* Radix of exponent representation */ -#undef FLT_RADIX -#define FLT_RADIX 2 - /* Number of base-FLT_RADIX digits in the significand of a float */ -#undef FLT_MANT_DIG -#define FLT_MANT_DIG 24 - /* Number of decimal digits of precision in a float */ -#undef FLT_DIG -#define FLT_DIG 6 - /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */ -#undef FLT_ROUNDS -#define FLT_ROUNDS 1 - /* Difference between 1.0 and the minimum float greater than 1.0 */ -#undef FLT_EPSILON -#define FLT_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */ -#undef FLT_MIN_EXP -#define FLT_MIN_EXP (-125) - /* Minimum normalised float */ -#undef FLT_MIN -#define FLT_MIN 1.17549435e-38F - /* Minimum int x such that 10**x is a normalised float */ -#undef FLT_MIN_10_EXP -#define FLT_MIN_10_EXP (-37) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */ -#undef FLT_MAX_EXP -#define FLT_MAX_EXP 128 - /* Maximum float */ -#undef FLT_MAX -#define FLT_MAX 3.40282347e+38F - /* Maximum int x such that 10**x is a representable float */ -#undef FLT_MAX_10_EXP -#define FLT_MAX_10_EXP 38 - - /* Number of base-FLT_RADIX digits in the significand of a double */ -#undef DBL_MANT_DIG -#define DBL_MANT_DIG 53 - /* Number of decimal digits of precision in a double */ -#undef DBL_DIG -#define DBL_DIG 15 - /* Difference between 1.0 and the minimum double greater than 1.0 */ -#undef DBL_EPSILON -#define DBL_EPSILON 2.2204460492503131e-16 - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ -#undef DBL_MIN_EXP -#define DBL_MIN_EXP (-1021) - /* Minimum normalised double */ -#undef DBL_MIN -#define DBL_MIN 2.2250738585072014e-308 - /* Minimum int x such that 10**x is a normalised double */ -#undef DBL_MIN_10_EXP -#define DBL_MIN_10_EXP (-307) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ -#undef DBL_MAX_EXP -#define DBL_MAX_EXP 1024 - /* Maximum double */ -#undef DBL_MAX -#define DBL_MAX 1.7976931348623157e+308 - /* Maximum int x such that 10**x is a representable double */ -#undef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 308 - - /* Number of base-FLT_RADIX digits in the significand of a long double */ -#undef LDBL_MANT_DIG -#define LDBL_MANT_DIG 113 - /* Number of decimal digits of precision in a long double */ -#undef LDBL_DIG -#define LDBL_DIG 33 - /* Difference between 1.0 and the minimum long double greater than 1.0 */ -#undef LDBL_EPSILON -#define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */ -#undef LDBL_MIN_EXP -#define LDBL_MIN_EXP (-16381) - /* Minimum normalised long double */ -#undef LDBL_MIN -#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L - /* Minimum int x such that 10**x is a normalised long double */ -#undef LDBL_MIN_10_EXP -#define LDBL_MIN_10_EXP (-4931) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */ -#undef LDBL_MAX_EXP -#define LDBL_MAX_EXP 16384 - /* Maximum long double */ -#undef LDBL_MAX -#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L - /* Maximum int x such that 10**x is a representable long double */ -#undef LDBL_MAX_10_EXP -#define LDBL_MAX_10_EXP 4932 - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - /* The floating-point expression evaluation method. - -1 indeterminate - 0 evaluate all operations and constants just to the range and - precision of the type - 1 evaluate operations and constants of type float and double - to the range and precision of the double type, evaluate - long double operations and constants to the range and - precision of the long double type - 2 evaluate all operations and constants to the range and - precision of the long double type - */ -# undef FLT_EVAL_METHOD -# define FLT_EVAL_METHOD 0 - - /* Number of decimal digits to enable rounding to the given number of - decimal digits without loss of precision. - if FLT_RADIX == 10^n: #mantissa * log10 (FLT_RADIX) - else : ceil (1 + #mantissa * log10 (FLT_RADIX)) - where #mantissa is the number of bits in the mantissa of the widest - supported floating-point type. - */ -# undef DECIMAL_DIG -# define DECIMAL_DIG 36 - -#endif /* C99 */ - -#endif /* _FLOAT_H_ */ diff --git a/contrib/gcc/config/float-i32.h b/contrib/gcc/config/float-i32.h deleted file mode 100644 index 3e633d8..0000000 --- a/contrib/gcc/config/float-i32.h +++ /dev/null @@ -1,123 +0,0 @@ -/* float.h for target with only IEEE 32 bit floating point format */ -#ifndef _FLOAT_H_ -#define _FLOAT_H_ -/* Produced by enquire version 4.3, CWI, Amsterdam */ - - /* Radix of exponent representation */ -#undef FLT_RADIX -#define FLT_RADIX 2 - /* Number of base-FLT_RADIX digits in the significand of a float */ -#undef FLT_MANT_DIG -#define FLT_MANT_DIG 24 - /* Number of decimal digits of precision in a float */ -#undef FLT_DIG -#define FLT_DIG 6 - /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */ -#undef FLT_ROUNDS -#define FLT_ROUNDS 1 - /* Difference between 1.0 and the minimum float greater than 1.0 */ -#undef FLT_EPSILON -#define FLT_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */ -#undef FLT_MIN_EXP -#define FLT_MIN_EXP (-125) - /* Minimum normalised float */ -#undef FLT_MIN -#define FLT_MIN 1.17549435e-38F - /* Minimum int x such that 10**x is a normalised float */ -#undef FLT_MIN_10_EXP -#define FLT_MIN_10_EXP (-37) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */ -#undef FLT_MAX_EXP -#define FLT_MAX_EXP 128 - /* Maximum float */ -#undef FLT_MAX -#define FLT_MAX 3.40282347e+38F - /* Maximum int x such that 10**x is a representable float */ -#undef FLT_MAX_10_EXP -#define FLT_MAX_10_EXP 38 - - /* Number of base-FLT_RADIX digits in the significand of a double */ -#undef DBL_MANT_DIG -#define DBL_MANT_DIG 24 - /* Number of decimal digits of precision in a double */ -#undef DBL_DIG -#define DBL_DIG 6 - /* Difference between 1.0 and the minimum double greater than 1.0 */ -#undef DBL_EPSILON -#define DBL_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ -#undef DBL_MIN_EXP -#define DBL_MIN_EXP (-125) - /* Minimum normalised double */ -#undef DBL_MIN -#define DBL_MIN 1.17549435e-38F - /* Minimum int x such that 10**x is a normalised double */ -#undef DBL_MIN_10_EXP -#define DBL_MIN_10_EXP (-37) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ -#undef DBL_MAX_EXP -#define DBL_MAX_EXP 128 - /* Maximum double */ -#undef DBL_MAX -#define DBL_MAX 3.40282347e+38F - /* Maximum int x such that 10**x is a representable double */ -#undef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 38 - - /* Number of base-FLT_RADIX digits in the significand of a long double */ -#undef LDBL_MANT_DIG -#define LDBL_MANT_DIG 24 - /* Number of decimal digits of precision in a long double */ -#undef LDBL_DIG -#define LDBL_DIG 6 - /* Difference between 1.0 and the minimum long double greater than 1.0 */ -#undef LDBL_EPSILON -#define LDBL_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */ -#undef LDBL_MIN_EXP -#define LDBL_MIN_EXP (-125) - /* Minimum normalised long double */ -#undef LDBL_MIN -#define LDBL_MIN 1.17549435e-38F - /* Minimum int x such that 10**x is a normalised long double */ -#undef LDBL_MIN_10_EXP -#define LDBL_MIN_10_EXP (-37) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */ -#undef LDBL_MAX_EXP -#define LDBL_MAX_EXP 128 - /* Maximum long double */ -#undef LDBL_MAX -#define LDBL_MAX 3.40282347e+38F - /* Maximum int x such that 10**x is a representable long double */ -#undef LDBL_MAX_10_EXP -#define LDBL_MAX_10_EXP 38 - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - /* The floating-point expression evaluation method. - -1 indeterminate - 0 evaluate all operations and constants just to the range and - precision of the type - 1 evaluate operations and constants of type float and double - to the range and precision of the double type, evaluate - long double operations and constants to the range and - precision of the long double type - 2 evaluate all operations and constants to the range and - precision of the long double type - */ -# undef FLT_EVAL_METHOD -# define FLT_EVAL_METHOD 0 - - /* Number of decimal digits to enable rounding to the given number of - decimal digits without loss of precision. - if FLT_RADIX == 10^n: #mantissa * log10 (FLT_RADIX) - else : ceil (1 + #mantissa * log10 (FLT_RADIX)) - where #mantissa is the number of bits in the mantissa of the widest - supported floating-point type. - */ -# undef DECIMAL_DIG -# define DECIMAL_DIG 9 - -#endif /* C99 */ - -#endif /* _FLOAT_H_ */ diff --git a/contrib/gcc/config/float-i386.h b/contrib/gcc/config/float-i386.h deleted file mode 100644 index 6abb4f2..0000000 --- a/contrib/gcc/config/float-i386.h +++ /dev/null @@ -1,124 +0,0 @@ -/* float.h for target with IEEE 32/64 bit and Intel 386 style 80 bit - floating point formats */ -#ifndef _FLOAT_H_ -#define _FLOAT_H_ -/* Produced by enquire version 4.3, CWI, Amsterdam */ - - /* Radix of exponent representation */ -#undef FLT_RADIX -#define FLT_RADIX 2 - /* Number of base-FLT_RADIX digits in the significand of a float */ -#undef FLT_MANT_DIG -#define FLT_MANT_DIG 24 - /* Number of decimal digits of precision in a float */ -#undef FLT_DIG -#define FLT_DIG 6 - /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */ -#undef FLT_ROUNDS -#define FLT_ROUNDS 1 - /* Difference between 1.0 and the minimum float greater than 1.0 */ -#undef FLT_EPSILON -#define FLT_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */ -#undef FLT_MIN_EXP -#define FLT_MIN_EXP (-125) - /* Minimum normalised float */ -#undef FLT_MIN -#define FLT_MIN 1.17549435e-38F - /* Minimum int x such that 10**x is a normalised float */ -#undef FLT_MIN_10_EXP -#define FLT_MIN_10_EXP (-37) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */ -#undef FLT_MAX_EXP -#define FLT_MAX_EXP 128 - /* Maximum float */ -#undef FLT_MAX -#define FLT_MAX 3.40282347e+38F - /* Maximum int x such that 10**x is a representable float */ -#undef FLT_MAX_10_EXP -#define FLT_MAX_10_EXP 38 - - /* Number of base-FLT_RADIX digits in the significand of a double */ -#undef DBL_MANT_DIG -#define DBL_MANT_DIG 53 - /* Number of decimal digits of precision in a double */ -#undef DBL_DIG -#define DBL_DIG 15 - /* Difference between 1.0 and the minimum double greater than 1.0 */ -#undef DBL_EPSILON -#define DBL_EPSILON 2.2204460492503131e-16 - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ -#undef DBL_MIN_EXP -#define DBL_MIN_EXP (-1021) - /* Minimum normalised double */ -#undef DBL_MIN -#define DBL_MIN 2.2250738585072014e-308 - /* Minimum int x such that 10**x is a normalised double */ -#undef DBL_MIN_10_EXP -#define DBL_MIN_10_EXP (-307) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ -#undef DBL_MAX_EXP -#define DBL_MAX_EXP 1024 - /* Maximum double */ -#undef DBL_MAX -#define DBL_MAX 1.7976931348623157e+308 - /* Maximum int x such that 10**x is a representable double */ -#undef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 308 - - /* Number of base-FLT_RADIX digits in the significand of a long double */ -#undef LDBL_MANT_DIG -#define LDBL_MANT_DIG 64 - /* Number of decimal digits of precision in a long double */ -#undef LDBL_DIG -#define LDBL_DIG 18 - /* Difference between 1.0 and the minimum long double greater than 1.0 */ -#undef LDBL_EPSILON -#define LDBL_EPSILON 1.08420217248550443401e-19L - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */ -#undef LDBL_MIN_EXP -#define LDBL_MIN_EXP (-16381) - /* Minimum normalised long double */ -#undef LDBL_MIN -#define LDBL_MIN 3.36210314311209350626e-4932L - /* Minimum int x such that 10**x is a normalised long double */ -#undef LDBL_MIN_10_EXP -#define LDBL_MIN_10_EXP (-4931) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */ -#undef LDBL_MAX_EXP -#define LDBL_MAX_EXP 16384 - /* Maximum long double */ -#undef LDBL_MAX -#define LDBL_MAX 1.18973149535723176502e+4932L - /* Maximum int x such that 10**x is a representable long double */ -#undef LDBL_MAX_10_EXP -#define LDBL_MAX_10_EXP 4932 - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - /* The floating-point expression evaluation method. - -1 indeterminate - 0 evaluate all operations and constants just to the range and - precision of the type - 1 evaluate operations and constants of type float and double - to the range and precision of the double type, evaluate - long double operations and constants to the range and - precision of the long double type - 2 evaluate all operations and constants to the range and - precision of the long double type - */ -# undef FLT_EVAL_METHOD -# define FLT_EVAL_METHOD 2 - - /* Number of decimal digits to enable rounding to the given number of - decimal digits without loss of precision. - if FLT_RADIX == 10^n: #mantissa * log10 (FLT_RADIX) - else : ceil (1 + #mantissa * log10 (FLT_RADIX)) - where #mantissa is the number of bits in the mantissa of the widest - supported floating-point type. - */ -# undef DECIMAL_DIG -# define DECIMAL_DIG 21 - -#endif /* C99 */ - -#endif /* _FLOAT_H___ */ diff --git a/contrib/gcc/config/float-i64.h b/contrib/gcc/config/float-i64.h deleted file mode 100644 index 735f742..0000000 --- a/contrib/gcc/config/float-i64.h +++ /dev/null @@ -1,123 +0,0 @@ -/* float.h for target with IEEE 32 bit and 64 bit floating point formats */ -#ifndef _FLOAT_H_ -#define _FLOAT_H_ -/* Produced by enquire version 4.3, CWI, Amsterdam */ - - /* Radix of exponent representation */ -#undef FLT_RADIX -#define FLT_RADIX 2 - /* Number of base-FLT_RADIX digits in the significand of a float */ -#undef FLT_MANT_DIG -#define FLT_MANT_DIG 24 - /* Number of decimal digits of precision in a float */ -#undef FLT_DIG -#define FLT_DIG 6 - /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */ -#undef FLT_ROUNDS -#define FLT_ROUNDS 1 - /* Difference between 1.0 and the minimum float greater than 1.0 */ -#undef FLT_EPSILON -#define FLT_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */ -#undef FLT_MIN_EXP -#define FLT_MIN_EXP (-125) - /* Minimum normalised float */ -#undef FLT_MIN -#define FLT_MIN 1.17549435e-38F - /* Minimum int x such that 10**x is a normalised float */ -#undef FLT_MIN_10_EXP -#define FLT_MIN_10_EXP (-37) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */ -#undef FLT_MAX_EXP -#define FLT_MAX_EXP 128 - /* Maximum float */ -#undef FLT_MAX -#define FLT_MAX 3.40282347e+38F - /* Maximum int x such that 10**x is a representable float */ -#undef FLT_MAX_10_EXP -#define FLT_MAX_10_EXP 38 - - /* Number of base-FLT_RADIX digits in the significand of a double */ -#undef DBL_MANT_DIG -#define DBL_MANT_DIG 53 - /* Number of decimal digits of precision in a double */ -#undef DBL_DIG -#define DBL_DIG 15 - /* Difference between 1.0 and the minimum double greater than 1.0 */ -#undef DBL_EPSILON -#define DBL_EPSILON 2.2204460492503131e-16 - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ -#undef DBL_MIN_EXP -#define DBL_MIN_EXP (-1021) - /* Minimum normalised double */ -#undef DBL_MIN -#define DBL_MIN 2.2250738585072014e-308 - /* Minimum int x such that 10**x is a normalised double */ -#undef DBL_MIN_10_EXP -#define DBL_MIN_10_EXP (-307) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ -#undef DBL_MAX_EXP -#define DBL_MAX_EXP 1024 - /* Maximum double */ -#undef DBL_MAX -#define DBL_MAX 1.7976931348623157e+308 - /* Maximum int x such that 10**x is a representable double */ -#undef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 308 - - /* Number of base-FLT_RADIX digits in the significand of a long double */ -#undef LDBL_MANT_DIG -#define LDBL_MANT_DIG 53 - /* Number of decimal digits of precision in a long double */ -#undef LDBL_DIG -#define LDBL_DIG 15 - /* Difference between 1.0 and the minimum long double greater than 1.0 */ -#undef LDBL_EPSILON -#define LDBL_EPSILON 2.2204460492503131e-16L - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */ -#undef LDBL_MIN_EXP -#define LDBL_MIN_EXP (-1021) - /* Minimum normalised long double */ -#undef LDBL_MIN -#define LDBL_MIN 2.2250738585072014e-308L - /* Minimum int x such that 10**x is a normalised long double */ -#undef LDBL_MIN_10_EXP -#define LDBL_MIN_10_EXP (-307) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */ -#undef LDBL_MAX_EXP -#define LDBL_MAX_EXP 1024 - /* Maximum long double */ -#undef LDBL_MAX -#define LDBL_MAX 1.7976931348623157e+308L - /* Maximum int x such that 10**x is a representable long double */ -#undef LDBL_MAX_10_EXP -#define LDBL_MAX_10_EXP 308 - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - /* The floating-point expression evaluation method. - -1 indeterminate - 0 evaluate all operations and constants just to the range and - precision of the type - 1 evaluate operations and constants of type float and double - to the range and precision of the double type, evaluate - long double operations and constants to the range and - precision of the long double type - 2 evaluate all operations and constants to the range and - precision of the long double type - */ -# undef FLT_EVAL_METHOD -# define FLT_EVAL_METHOD 0 - - /* Number of decimal digits to enable rounding to the given number of - decimal digits without loss of precision. - if FLT_RADIX == 10^n: #mantissa * log10 (FLT_RADIX) - else : ceil (1 + #mantissa * log10 (FLT_RADIX)) - where #mantissa is the number of bits in the mantissa of the widest - supported floating-point type. - */ -# undef DECIMAL_DIG -# define DECIMAL_DIG 17 - -#endif /* C99 */ - -#endif /* _FLOAT_H_ */ diff --git a/contrib/gcc/config/float-m68k.h b/contrib/gcc/config/float-m68k.h deleted file mode 100644 index 837126b..0000000 --- a/contrib/gcc/config/float-m68k.h +++ /dev/null @@ -1,127 +0,0 @@ -/* float.h for target with IEEE 32 bit and 64 bit and Motorola style 96 bit - floating point formats */ -#ifndef _FLOAT_H_ -#define _FLOAT_H_ -/* Produced by enquire version 4.3, CWI, Amsterdam */ - - /* Radix of exponent representation */ -#undef FLT_RADIX -#define FLT_RADIX 2 - /* Number of base-FLT_RADIX digits in the significand of a float */ -#undef FLT_MANT_DIG -#define FLT_MANT_DIG 24 - /* Number of decimal digits of precision in a float */ -#undef FLT_DIG -#define FLT_DIG 6 - /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */ -#undef FLT_ROUNDS -#define FLT_ROUNDS 1 - /* Difference between 1.0 and the minimum float greater than 1.0 */ -#undef FLT_EPSILON -#define FLT_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */ -#undef FLT_MIN_EXP -#define FLT_MIN_EXP (-125) - /* Minimum normalised float */ -#undef FLT_MIN -#define FLT_MIN 1.17549435e-38F - /* Minimum int x such that 10**x is a normalised float */ -#undef FLT_MIN_10_EXP -#define FLT_MIN_10_EXP (-37) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */ -#undef FLT_MAX_EXP -#define FLT_MAX_EXP 128 - /* Maximum float */ -#undef FLT_MAX -#define FLT_MAX 3.40282347e+38F - /* Maximum int x such that 10**x is a representable float */ -#undef FLT_MAX_10_EXP -#define FLT_MAX_10_EXP 38 - - /* Number of base-FLT_RADIX digits in the significand of a double */ -#undef DBL_MANT_DIG -#define DBL_MANT_DIG 53 - /* Number of decimal digits of precision in a double */ -#undef DBL_DIG -#define DBL_DIG 15 - /* Difference between 1.0 and the minimum double greater than 1.0 */ -#undef DBL_EPSILON -#define DBL_EPSILON 2.2204460492503131e-16 - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ -#undef DBL_MIN_EXP -#define DBL_MIN_EXP (-1021) - /* Minimum normalised double */ -#undef DBL_MIN -#define DBL_MIN 2.2250738585072014e-308 - /* Minimum int x such that 10**x is a normalised double */ -#undef DBL_MIN_10_EXP -#define DBL_MIN_10_EXP (-307) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ -#undef DBL_MAX_EXP -#define DBL_MAX_EXP 1024 - /* Maximum double */ -#undef DBL_MAX -#define DBL_MAX 1.7976931348623157e+308 - /* Maximum int x such that 10**x is a representable double */ -#undef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 308 - - /* Number of base-FLT_RADIX digits in the significand of a long double */ -#undef LDBL_MANT_DIG -#define LDBL_MANT_DIG 64 - /* Number of decimal digits of precision in a long double */ -#undef LDBL_DIG -#define LDBL_DIG 18 - /* Difference between 1.0 and the minimum long double greater than 1.0 */ -#undef LDBL_EPSILON -#define LDBL_EPSILON 1.08420217248550443401e-19L - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */ -#undef LDBL_MIN_EXP -#define LDBL_MIN_EXP (-16382) - /* Minimum normalised long double */ -#undef LDBL_MIN -#define LDBL_MIN 1.68105157155604675313e-4932L - /* Minimum int x such that 10**x is a normalised long double */ -#undef LDBL_MIN_10_EXP -#define LDBL_MIN_10_EXP (-4931) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */ -#undef LDBL_MAX_EXP -#define LDBL_MAX_EXP 16384 - /* Maximum long double */ -#undef LDBL_MAX -#define LDBL_MAX 1.18973149535723176502e+4932L - /* Maximum int x such that 10**x is a representable long double */ -#undef LDBL_MAX_10_EXP -#define LDBL_MAX_10_EXP 4932 - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - /* The floating-point expression evaluation method. - -1 indeterminate - 0 evaluate all operations and constants just to the range and - precision of the type - 1 evaluate operations and constants of type float and double - to the range and precision of the double type, evaluate - long double operations and constants to the range and - precision of the long double type - 2 evaluate all operations and constants to the range and - precision of the long double type - */ - -/* ??? FLT_EVAL_METHOD depends on TARGET_68040_ONLY. We do not currently - have a preprocessor token that we can use to tell that this is on. */ -# undef FLT_EVAL_METHOD -# define FLT_EVAL_METHOD -1 - - /* Number of decimal digits to enable rounding to the given number of - decimal digits without loss of precision. - if FLT_RADIX == 10^n: #mantissa * log10 (FLT_RADIX) - else : ceil (1 + #mantissa * log10 (FLT_RADIX)) - where #mantissa is the number of bits in the mantissa of the widest - supported floating-point type. - */ -# undef DECIMAL_DIG -# define DECIMAL_DIG 21 - -#endif /* C99 */ - -#endif /* _FLOAT_H_ */ diff --git a/contrib/gcc/config/float-sh.h b/contrib/gcc/config/float-sh.h deleted file mode 100644 index 598994b..0000000 --- a/contrib/gcc/config/float-sh.h +++ /dev/null @@ -1,160 +0,0 @@ -/* float.h for target sh3e with optional IEEE 32 bit double format */ -#ifndef _FLOAT_H_ -#define _FLOAT_H_ -/* Produced by enquire version 4.3, CWI, Amsterdam */ - - /* Radix of exponent representation */ -#undef FLT_RADIX -#define FLT_RADIX 2 - /* Number of base-FLT_RADIX digits in the significand of a float */ -#undef FLT_MANT_DIG -#define FLT_MANT_DIG 24 - /* Number of decimal digits of precision in a float */ -#undef FLT_DIG -#define FLT_DIG 6 - /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */ -#undef FLT_ROUNDS -#define FLT_ROUNDS 1 - /* Difference between 1.0 and the minimum float greater than 1.0 */ -#undef FLT_EPSILON -#define FLT_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */ -#undef FLT_MIN_EXP -#define FLT_MIN_EXP (-125) - /* Minimum normalised float */ -#undef FLT_MIN -#define FLT_MIN 1.17549435e-38F - /* Minimum int x such that 10**x is a normalised float */ -#undef FLT_MIN_10_EXP -#define FLT_MIN_10_EXP (-37) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */ -#undef FLT_MAX_EXP -#define FLT_MAX_EXP 128 - /* Maximum float */ -#undef FLT_MAX -#define FLT_MAX 3.40282347e+38F - /* Maximum int x such that 10**x is a representable float */ -#undef FLT_MAX_10_EXP -#define FLT_MAX_10_EXP 38 - -#if defined (__SH3E__) || defined (__SH4_SINGLE_ONLY__) - - /* Number of base-FLT_RADIX digits in the significand of a double */ -#undef DBL_MANT_DIG -#define DBL_MANT_DIG 24 - /* Number of decimal digits of precision in a double */ -#undef DBL_DIG -#define DBL_DIG 6 - /* Difference between 1.0 and the minimum double greater than 1.0 */ -#undef DBL_EPSILON -#define DBL_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ -#undef DBL_MIN_EXP -#define DBL_MIN_EXP (-125) - /* Minimum normalised double */ -#undef DBL_MIN -#define DBL_MIN 1.17549435e-38F - /* Minimum int x such that 10**x is a normalised double */ -#undef DBL_MIN_10_EXP -#define DBL_MIN_10_EXP (-37) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ -#undef DBL_MAX_EXP -#define DBL_MAX_EXP 128 - /* Maximum double */ -#undef DBL_MAX -#define DBL_MAX 3.40282347e+38F - /* Maximum int x such that 10**x is a representable double */ -#undef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 38 - -#else - - /* Number of base-FLT_RADIX digits in the significand of a double */ -#undef DBL_MANT_DIG -#define DBL_MANT_DIG 53 - /* Number of decimal digits of precision in a double */ -#undef DBL_DIG -#define DBL_DIG 15 - /* Difference between 1.0 and the minimum double greater than 1.0 */ -#undef DBL_EPSILON -#define DBL_EPSILON 2.2204460492503131e-16 - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ -#undef DBL_MIN_EXP -#define DBL_MIN_EXP (-1021) - /* Minimum normalised double */ -#undef DBL_MIN -#define DBL_MIN 2.2250738585072014e-308 - /* Minimum int x such that 10**x is a normalised double */ -#undef DBL_MIN_10_EXP -#define DBL_MIN_10_EXP (-307) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ -#undef DBL_MAX_EXP -#define DBL_MAX_EXP 1024 - /* Maximum double */ -#undef DBL_MAX -#define DBL_MAX 1.7976931348623157e+308 - /* Maximum int x such that 10**x is a representable double */ -#undef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 308 - -#endif - -/* Because -m3e and -m4-single-only have 32-bit doubles, we append L - to the doubles below, so that they're not truncated. */ - - /* Number of base-FLT_RADIX digits in the significand of a long double */ -#undef LDBL_MANT_DIG -#define LDBL_MANT_DIG 53 - /* Number of decimal digits of precision in a long double */ -#undef LDBL_DIG -#define LDBL_DIG 15 - /* Difference between 1.0 and the minimum long double greater than 1.0 */ -#undef LDBL_EPSILON -#define LDBL_EPSILON 2.2204460492503131e-16L - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */ -#undef LDBL_MIN_EXP -#define LDBL_MIN_EXP (-1021) - /* Minimum normalised long double */ -#undef LDBL_MIN -#define LDBL_MIN 2.2250738585072014e-308L - /* Minimum int x such that 10**x is a normalised long double */ -#undef LDBL_MIN_10_EXP -#define LDBL_MIN_10_EXP (-307) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */ -#undef LDBL_MAX_EXP -#define LDBL_MAX_EXP 1024 - /* Maximum long double */ -#undef LDBL_MAX -#define LDBL_MAX 1.7976931348623157e+308L - /* Maximum int x such that 10**x is a representable long double */ -#undef LDBL_MAX_10_EXP -#define LDBL_MAX_10_EXP 308 - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - /* The floating-point expression evaluation method. - -1 indeterminate - 0 evaluate all operations and constants just to the range and - precision of the type - 1 evaluate operations and constants of type float and double - to the range and precision of the double type, evaluate - long double operations and constants to the range and - precision of the long double type - 2 evaluate all operations and constants to the range and - precision of the long double type - */ -# undef FLT_EVAL_METHOD -# define FLT_EVAL_METHOD 0 - - /* Number of decimal digits to enable rounding to the given number of - decimal digits without loss of precision. - if FLT_RADIX == 10^n: #mantissa * log10 (FLT_RADIX) - else : ceil (1 + #mantissa * log10 (FLT_RADIX)) - where #mantissa is the number of bits in the mantissa of the widest - supported floating-point type. - */ -# undef DECIMAL_DIG -# define DECIMAL_DIG 17 - -#endif /* C99 */ - -#endif /* _FLOAT_H_ */ diff --git a/contrib/gcc/config/float-sparc.h b/contrib/gcc/config/float-sparc.h deleted file mode 100644 index 84250e5..0000000 --- a/contrib/gcc/config/float-sparc.h +++ /dev/null @@ -1,153 +0,0 @@ -/* float.h for target with IEEE 32, 64 and 128 bit SPARC floating point formats - (on sparc-linux long double is 64 bit, while on sparc64-linux 128 bit) */ -#ifndef _FLOAT_H_ -#define _FLOAT_H_ -/* Produced by enquire version 4.3, CWI, Amsterdam */ - - /* Radix of exponent representation */ -#undef FLT_RADIX -#define FLT_RADIX 2 - /* Number of base-FLT_RADIX digits in the significand of a float */ -#undef FLT_MANT_DIG -#define FLT_MANT_DIG 24 - /* Number of decimal digits of precision in a float */ -#undef FLT_DIG -#define FLT_DIG 6 - /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */ -#undef FLT_ROUNDS -#define FLT_ROUNDS 1 - /* Difference between 1.0 and the minimum float greater than 1.0 */ -#undef FLT_EPSILON -#define FLT_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */ -#undef FLT_MIN_EXP -#define FLT_MIN_EXP (-125) - /* Minimum normalised float */ -#undef FLT_MIN -#define FLT_MIN 1.17549435e-38F - /* Minimum int x such that 10**x is a normalised float */ -#undef FLT_MIN_10_EXP -#define FLT_MIN_10_EXP (-37) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */ -#undef FLT_MAX_EXP -#define FLT_MAX_EXP 128 - /* Maximum float */ -#undef FLT_MAX -#define FLT_MAX 3.40282347e+38F - /* Maximum int x such that 10**x is a representable float */ -#undef FLT_MAX_10_EXP -#define FLT_MAX_10_EXP 38 - - /* Number of base-FLT_RADIX digits in the significand of a double */ -#undef DBL_MANT_DIG -#define DBL_MANT_DIG 53 - /* Number of decimal digits of precision in a double */ -#undef DBL_DIG -#define DBL_DIG 15 - /* Difference between 1.0 and the minimum double greater than 1.0 */ -#undef DBL_EPSILON -#define DBL_EPSILON 2.2204460492503131e-16 - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ -#undef DBL_MIN_EXP -#define DBL_MIN_EXP (-1021) - /* Minimum normalised double */ -#undef DBL_MIN -#define DBL_MIN 2.2250738585072014e-308 - /* Minimum int x such that 10**x is a normalised double */ -#undef DBL_MIN_10_EXP -#define DBL_MIN_10_EXP (-307) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ -#undef DBL_MAX_EXP -#define DBL_MAX_EXP 1024 - /* Maximum double */ -#undef DBL_MAX -#define DBL_MAX 1.7976931348623157e+308 - /* Maximum int x such that 10**x is a representable double */ -#undef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 308 - -#if defined(__sparcv9) || defined(__arch64__) || defined(__LONG_DOUBLE_128__) - - /* Number of base-FLT_RADIX digits in the significand of a long double */ -#undef LDBL_MANT_DIG -#define LDBL_MANT_DIG 113 - /* Number of decimal digits of precision in a long double */ -#undef LDBL_DIG -#define LDBL_DIG 33 - /* Difference between 1.0 and the minimum long double greater than 1.0 */ -#undef LDBL_EPSILON -#define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */ -#undef LDBL_MIN_EXP -#define LDBL_MIN_EXP (-16381) - /* Minimum normalised long double */ -#undef LDBL_MIN -#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L - /* Minimum int x such that 10**x is a normalised long double */ -#undef LDBL_MIN_10_EXP -#define LDBL_MIN_10_EXP (-4931) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */ -#undef LDBL_MAX_EXP -#define LDBL_MAX_EXP 16384 - /* Maximum long double */ -#undef LDBL_MAX -#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L - /* Maximum int x such that 10**x is a representable long double */ -#undef LDBL_MAX_10_EXP -#define LDBL_MAX_10_EXP 4932 - -#else /* sparc32 */ - -#undef LDBL_MANT_DIG -#define LDBL_MANT_DIG DBL_MANT_DIG -#undef LDBL_DIG -#define LDBL_DIG DBL_DIG -#undef LDBL_EPSILON -#define LDBL_EPSILON DBL_EPSILON -#undef LDBL_MIN_EXP -#define LDBL_MIN_EXP DBL_MIN_EXP -#undef LDBL_MIN -#define LDBL_MIN DBL_MIN -#undef LDBL_MIN_10_EXP -#define LDBL_MIN_10_EXP DBL_MIN_10_EXP -#undef LDBL_MAX_EXP -#define LDBL_MAX_EXP DBL_MAX_EXP -#undef LDBL_MAX -#define LDBL_MAX DBL_MAX -#undef LDBL_MAX_10_EXP -#define LDBL_MAX_10_EXP DBL_MAX_10_EXP - -#endif /* sparc32 */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - /* The floating-point expression evaluation method. - -1 indeterminate - 0 evaluate all operations and constants just to the range and - precision of the type - 1 evaluate operations and constants of type float and double - to the range and precision of the double type, evaluate - long double operations and constants to the range and - precision of the long double type - 2 evaluate all operations and constants to the range and - precision of the long double type - */ -# undef FLT_EVAL_METHOD -# define FLT_EVAL_METHOD 0 - - /* Number of decimal digits to enable rounding to the given number of - decimal digits without loss of precision. - if FLT_RADIX == 10^n: #mantissa * log10 (FLT_RADIX) - else : ceil (1 + #mantissa * log10 (FLT_RADIX)) - where #mantissa is the number of bits in the mantissa of the widest - supported floating-point type. - */ -# undef DECIMAL_DIG -# if LDBL_MANT_DIG == 53 -# define DECIMAL_DIG 17 -# else -# define DECIMAL_DIG 36 -# endif - -#endif /* C99 */ - -#endif /* _FLOAT_H_ */ diff --git a/contrib/gcc/config/float-vax.h b/contrib/gcc/config/float-vax.h deleted file mode 100644 index fff577f..0000000 --- a/contrib/gcc/config/float-vax.h +++ /dev/null @@ -1,159 +0,0 @@ -/* float.h for target with VAX floating point formats */ -#ifndef _FLOAT_H_ -#define _FLOAT_H_ -/* Produced by enquire version 4.3, CWI, Amsterdam */ - - /* Radix of exponent representation */ -#undef FLT_RADIX -#define FLT_RADIX 2 - /* Number of base-FLT_RADIX digits in the significand of a float */ -#undef FLT_MANT_DIG -#define FLT_MANT_DIG 24 - /* Number of decimal digits of precision in a float */ -#undef FLT_DIG -#define FLT_DIG 6 - /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown */ -#undef FLT_ROUNDS -#define FLT_ROUNDS 1 - /* Difference between 1.0 and the minimum float greater than 1.0 */ -#undef FLT_EPSILON -#define FLT_EPSILON 1.19209290e-07F - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised float */ -#undef FLT_MIN_EXP -#define FLT_MIN_EXP (-127) - /* Minimum normalised float */ -#undef FLT_MIN -#define FLT_MIN 2.93873588e-39F - /* Minimum int x such that 10**x is a normalised float */ -#undef FLT_MIN_10_EXP -#define FLT_MIN_10_EXP (-38) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable float */ -#undef FLT_MAX_EXP -#define FLT_MAX_EXP 127 - /* Maximum float */ -#undef FLT_MAX -#define FLT_MAX 1.70141173e+38F - /* Maximum int x such that 10**x is a representable float */ -#undef FLT_MAX_10_EXP -#define FLT_MAX_10_EXP 38 - -#ifdef __GFLOAT - - /* The GFLOAT numbers may be problematic since gcc uses DFLOAT */ - - /* Number of base-FLT_RADIX digits in the significand of a double */ -#undef DBL_MANT_DIG -#define DBL_MANT_DIG 53 - /* Number of decimal digits of precision in a double */ -#undef DBL_DIG -#define DBL_DIG 15 - /* Difference between 1.0 and the minimum double greater than 1.0 */ -#undef DBL_EPSILON -#define DBL_EPSILON 2.2204460492503131e-016 - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ -#undef DBL_MIN_EXP -#define DBL_MIN_EXP (-1023) - /* Minimum normalised double */ -#undef DBL_MIN -#define DBL_MIN 5.5626846462680035e-309 - /* Minimum int x such that 10**x is a normalised double */ -#undef DBL_MIN_10_EXP -#define DBL_MIN_10_EXP (-308) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ -#undef DBL_MAX_EXP -#define DBL_MAX_EXP 1023 - /* Maximum double */ -#undef DBL_MAX -#define DBL_MAX 8.9884656743115775e+307 - /* Maximum int x such that 10**x is a representable double */ -#undef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 307 - - /* Number of base-FLT_RADIX digits in the significand of a long double */ -#undef LDBL_MANT_DIG -#define LDBL_MANT_DIG 53 - /* Number of decimal digits of precision in a long double */ -#undef LDBL_DIG -#define LDBL_DIG 15 - /* Difference between 1.0 and the minimum long double greater than 1.0 */ -#undef LDBL_EPSILON -#define LDBL_EPSILON 2.2204460492503131e-016L - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */ -#undef LDBL_MIN_EXP -#define LDBL_MIN_EXP (-1023) - /* Minimum normalised long double */ -#undef LDBL_MIN -#define LDBL_MIN 5.5626846462680035e-309L - /* Minimum int x such that 10**x is a normalised long double */ -#undef LDBL_MIN_10_EXP -#define LDBL_MIN_10_EXP (-308) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */ -#undef LDBL_MAX_EXP -#define LDBL_MAX_EXP 1023 - /* Maximum long double */ -#undef LDBL_MAX -#define LDBL_MAX 8.9884656743115775e+307L - /* Maximum int x such that 10**x is a representable long double */ -#undef LDBL_MAX_10_EXP -#define LDBL_MAX_10_EXP 307 - -#else /* !__GFLOAT */ - - /* Number of base-FLT_RADIX digits in the significand of a double */ -#undef DBL_MANT_DIG -#define DBL_MANT_DIG 56 - /* Number of decimal digits of precision in a double */ -#undef DBL_DIG -#define DBL_DIG 16 - /* Difference between 1.0 and the minimum double greater than 1.0 */ -#undef DBL_EPSILON -#define DBL_EPSILON 2.77555756156289135e-17 - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised double */ -#undef DBL_MIN_EXP -#define DBL_MIN_EXP (-127) - /* Minimum normalised double */ -#undef DBL_MIN -#define DBL_MIN 2.93873587705571877e-39 - /* Minimum int x such that 10**x is a normalised double */ -#undef DBL_MIN_10_EXP -#define DBL_MIN_10_EXP (-38) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable double */ -#undef DBL_MAX_EXP -#define DBL_MAX_EXP 127 - /* Maximum double */ -#undef DBL_MAX -#define DBL_MAX 1.70141183460469227e+38 - /* Maximum int x such that 10**x is a representable double */ -#undef DBL_MAX_10_EXP -#define DBL_MAX_10_EXP 38 - - /* Number of base-FLT_RADIX digits in the significand of a long double */ -#undef LDBL_MANT_DIG -#define LDBL_MANT_DIG 56 - /* Number of decimal digits of precision in a long double */ -#undef LDBL_DIG -#define LDBL_DIG 16 - /* Difference between 1.0 and the minimum long double greater than 1.0 */ -#undef LDBL_EPSILON -#define LDBL_EPSILON 2.77555756156289135e-17L - /* Minimum int x such that FLT_RADIX**(x-1) is a normalised long double */ -#undef LDBL_MIN_EXP -#define LDBL_MIN_EXP (-127) - /* Minimum normalised long double */ -#undef LDBL_MIN -#define LDBL_MIN 2.93873587705571877e-39L - /* Minimum int x such that 10**x is a normalised long double */ -#undef LDBL_MIN_10_EXP -#define LDBL_MIN_10_EXP (-38) - /* Maximum int x such that FLT_RADIX**(x-1) is a representable long double */ -#undef LDBL_MAX_EXP -#define LDBL_MAX_EXP 127 - /* Maximum long double */ -#undef LDBL_MAX -#define LDBL_MAX 1.70141183460469227e+38L - /* Maximum int x such that 10**x is a representable long double */ -#undef LDBL_MAX_10_EXP -#define LDBL_MAX_10_EXP 38 - -#endif /* __GFLOAT */ -#endif /* _FLOAT_H_ */ diff --git a/contrib/gcc/config/i386/386bsd.h b/contrib/gcc/config/i386/386bsd.h deleted file mode 100644 index a34e6e5..0000000 --- a/contrib/gcc/config/i386/386bsd.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Configuration for an i386 running 386BSD as the target machine. */ - -/* This is tested by i386gas.h. */ -#define YES_UNDERSCORES - -#include "i386/gstabs.h" - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-Dunix -D____386BSD____ -D__386BSD__ -DBSD_NET2 -Asystem=unix -Asystem=bsd" - -/* Like the default, except no -lg. */ -#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}" - -#undef SIZE_TYPE -#define SIZE_TYPE "unsigned int" - -#undef PTRDIFF_TYPE -#define PTRDIFF_TYPE "int" - -#undef WCHAR_TYPE -#define WCHAR_TYPE "short unsigned int" - -#define WCHAR_UNSIGNED 1 - -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE 16 - -/* Redefine this to use %eax instead of %edx. */ -#undef FUNCTION_PROFILER -#define FUNCTION_PROFILER(FILE, LABELNO) \ -{ \ - if (flag_pic) \ - { \ - fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n", \ - LPREFIX, (LABELNO)); \ - fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ - } \ - else \ - { \ - fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO)); \ - fprintf (FILE, "\tcall mcount\n"); \ - } \ -} - -#undef ASM_APP_ON -#define ASM_APP_ON "#APP\n" - -#undef ASM_APP_OFF -#define ASM_APP_OFF "#NO_APP\n" - -/* Don't default to pcc-struct-return, because gcc is the only compiler, and - we want to retain compatibility with older gcc versions. */ -#define DEFAULT_PCC_STRUCT_RETURN 0 diff --git a/contrib/gcc/config/i386/aix386.h b/contrib/gcc/config/i386/aix386.h deleted file mode 100644 index f085c42..0000000 --- a/contrib/gcc/config/i386/aix386.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Definitions for IBM PS2 running AIX/386 with gas. - From: Minh Tran-Le <TRANLE@intellicorp.com> - Copyright (C) 1988, 2000 Free Software Foundation, Inc. - -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. */ - -/* - * This configuration file is for gcc with gas-2.x and gnu ld 2.x - * with aix ps/2 1.3.x. - */ - -/* Define USE_GAS if you have the new version of gas that can handle - * multiple segments and .section pseudo op. This will allow gcc to - * use the .init section for g++ ctor/dtor. - * - * If you don't have gas then undefined USE_GAS. You will also have - * to use collect if you want to use g++ - */ -#define USE_GAS - -#include "i386/aix386ng.h" - -/* Use crt1.o as a startup file and crtn.o as a closing file. - And add crtbegin.o and crtend.o for ctors and dtors */ - -#undef STARTFILE_SPEC -#define STARTFILE_SPEC \ - "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}} crtbegin.o%s" -#undef ENDFILE_SPEC -#define ENDFILE_SPEC \ - "crtend.o%s crtn.o%s" - -/* Removed the -K flags because the gnu ld does not handle it */ -#undef LINK_SPEC -#define LINK_SPEC "%{T*} %{z:-lm}" - -/* Define a few machine-specific details of the implementation of - constructors. */ - -#undef INIT_SECTION_ASM_OP -#define INIT_SECTION_ASM_OP "\t.section .init,\"x\"" - -#define CTOR_LIST_BEGIN \ - asm (INIT_SECTION_ASM_OP); \ - asm ("pushl $0") -#define CTOR_LIST_END CTOR_LIST_BEGIN - -#undef TARGET_ASM_CONSTRUCTOR -#define TARGET_ASM_CONSTRUCTOR ix86_svr3_asm_out_constructor diff --git a/contrib/gcc/config/i386/aix386ng.h b/contrib/gcc/config/i386/aix386ng.h deleted file mode 100644 index 445d333..0000000 --- a/contrib/gcc/config/i386/aix386ng.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Definitions for IBM PS2 running AIX/386. - Copyright (C) 1988, 1996, 1998 Free Software Foundation, Inc. - Contributed by Minh Tran-Le <TRANLE@intellicorp.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. */ - - -#include "i386/i386.h" - -/* Get the generic definitions for system V.3. */ - -#include "svr3.h" - -/* Use the ATT assembler syntax. - This overrides at least one macro (USER_LABEL_PREFIX) from svr3.h. */ - -#include "i386/att.h" - -/* Use crt1.o as a startup file and crtn.o as a closing file. */ - -#define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}" -#define ENDFILE_SPEC "crtn.o%s" - -#define LIB_SPEC "%{shlib:-lc_s} -lc" - -/* Special flags for the linker. I don't know what they do. */ - -#define LINK_SPEC "%{K} %{!K:-K} %{T*} %{z:-lm}" - -/* Specify predefined symbols in preprocessor. */ - -#define CPP_PREDEFINES "-Dps2 -Dunix -Asystem=aix" - -#define CPP_SPEC "%(cpp_cpu) \ - %{posix:-D_POSIX_SOURCE}%{!posix:-DAIX} -D_I386 -D_AIX -D_MBCS" - -/* special flags for the aix assembler to generate the short form for all - qualifying forward reference */ -/* The buggy /bin/as of aix ps/2 1.2.x cannot always handle it. */ -#if 0 -#define ASM_SPEC "-s2" -#endif /* 0 */ - -#undef ASM_FILE_START -#define ASM_FILE_START(FILE) \ - do { output_file_directive (FILE, main_input_filename); \ - if (optimize) \ - ASM_FILE_START_1 (FILE); \ - else \ - fprintf (FILE, "\t.noopt\n"); \ - } while (0) - -/* This was suggested, but it shouldn't be right for DBX output. -- RMS - #define ASM_OUTPUT_SOURCE_FILENAME(FILE, NAME) */ - -/* Writing `int' for a bitfield forces int alignment for the structure. */ - -#define PCC_BITFIELD_TYPE_MATTERS 1 - -#ifndef USE_GAS -/* Don't write a `.optim' pseudo; this assembler - is said to have a bug when .optim is used. */ - -#undef ASM_FILE_START_1 -#define ASM_FILE_START_1(FILE) fprintf (FILE, "\t.noopt\n") -#endif - -/* Output assembler code to FILE to increment profiler label # LABELNO - for profiling a function entry. */ - -#undef FUNCTION_PROFILER -#define FUNCTION_PROFILER(FILE, LABELNO) \ - fprintf (FILE, "\tleal %sP%d,%%eax\n\tcall mcount\n", LPREFIX, (LABELNO)); - -/* Note that using bss_section here caused errors - in building shared libraries on system V.3. - but AIX 1.2 does not have yet shareable libraries on PS2 */ -#undef ASM_OUTPUT_LOCAL -#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ - (bss_section (), \ - ASM_OUTPUT_LABEL ((FILE), (NAME)), \ - fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED))) - - -/* Undef all the .init and .fini section stuff if we are not using gas and - * gnu ld so that we can use collect because the standard /bin/as and /bin/ld - * cannot handle those. - */ -#ifndef USE_GAS -# undef INIT_SECTION_ASM_OP -# undef FINI_SECTION_ASM_OP -# undef CTORS_SECTION_ASM_OP -# undef DTORS_SECTION_ASM_OP -# undef TARGET_ASM_CONSTRUCTOR -# undef TARGET_ASM_DESTRUCTOR -# undef DO_GLOBAL_CTORS_BODY - -# undef CTOR_LIST_BEGIN -# define CTOR_LIST_BEGIN -# undef CTOR_LIST_END -# define CTOR_LIST_END -# undef DTOR_LIST_BEGIN -# define DTOR_LIST_BEGIN -# undef DTOR_LIST_END -# define DTOR_LIST_END - -# undef CONST_SECTION_FUNCTION -# define CONST_SECTION_FUNCTION \ -void \ -const_section () \ -{ \ - text_section(); \ -} - -# undef EXTRA_SECTION_FUNCTIONS -# define EXTRA_SECTION_FUNCTIONS \ - CONST_SECTION_FUNCTION - -/* for collect2 */ -# define OBJECT_FORMAT_COFF -# define MY_ISCOFF(magic) \ - ((magic) == I386MAGIC || (magic) == I386SVMAGIC) - -#endif /* !USE_GAS */ diff --git a/contrib/gcc/config/i386/bsd386.h b/contrib/gcc/config/i386/bsd386.h deleted file mode 100644 index fb24327..0000000 --- a/contrib/gcc/config/i386/bsd386.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Configuration for an i386 running BSDI's BSD/OS (formerly known as BSD/386) - as the target machine. */ - -/* We exist mostly to add -Dbsdi and such to the predefines. */ - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-Dunix -Dbsdi -D____386BSD____ -D__386BSD__\ - -DBSD_NET2 -Asystem=unix -Asystem=bsd" - -#undef WCHAR_TYPE -#define WCHAR_TYPE "int" - -#undef WCHAR_UNSIGNED -#define WCHAR_UNSIGNED 0 - -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE 32 - -/* This is suitable for BSD/OS 3.0; we don't know about earlier releases. */ -#undef ASM_COMMENT_START -#define ASM_COMMENT_START " #" - -/* Until they use ELF or something that handles dwarf2 unwinds - and initialization stuff better. */ -#define DWARF2_UNWIND_INFO 0 - -/* BSD/OS still uses old binutils that don't insert nops by default - when the .align directive demands to insert extra space in the text - segment. */ -#undef ASM_OUTPUT_ALIGN -#define ASM_OUTPUT_ALIGN(FILE,LOG) \ - if ((LOG)!=0) fprintf ((FILE), "\t.align %d,0x90\n", (LOG)) diff --git a/contrib/gcc/config/i386/dgux.h b/contrib/gcc/config/i386/dgux.h deleted file mode 100644 index 2d4c98c..0000000 --- a/contrib/gcc/config/i386/dgux.h +++ /dev/null @@ -1,257 +0,0 @@ -/* Target definitions for GNU compiler for Intel 80x86 running DG/ux - Copyright (C) 1993, 1995, 1996, 1997, 1998, 2000, 2001 - Free Software Foundation, Inc. - Currently maintained by gcc@dg-rtp.dg.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 now, we are just like the sysv4 version with a - few hacks -*/ - -#ifndef VERSION_INFO2 -#define VERSION_INFO2 "$Revision: 1.16 $" -#endif - -#ifndef VERSION_STRING -#define VERSION_STRING version_string -#endif - -/* Identify the compiler. */ -/* TARGET_VERSION used by toplev.c VERSION_STRING used by -midentify-revision */ - -#undef TARGET_VERSION -#define TARGET_VERSION fprintf (stderr, " (%s%s, %s)", \ - VERSION_INFO1, VERSION_INFO2, __DATE__) -#undef VERSION_INFO1 -#define VERSION_INFO1 "ix86 DG/ux, " - -/* Augment TARGET_SWITCHES with the MXDB options. */ -#define MASK_STANDARD 0x40000000 /* Retain standard information */ -#define MASK_NOLEGEND 0x20000000 /* Discard legend information */ -#define MASK_EXTERNAL_LEGEND 0x10000000 /* Make external legends */ -#define MASK_IDENTIFY_REVISION 0x08000000 /* Emit 'ident' to .s */ -#define MASK_WARN_PASS_STRUCT 0x04000000 /* Warn when structures are passed */ - -#define TARGET_STANDARD (target_flags & MASK_STANDARD) -#define TARGET_NOLEGEND (target_flags & MASK_NOLEGEND) -#define TARGET_EXTERNAL_LEGEND (target_flags & MASK_EXTERNAL_LEGEND) -#define TARGET_IDENTIFY_REVISION (target_flags & MASK_IDENTIFY_REVISION) -#define TARGET_WARN_PASS_STRUCT (target_flags & MASK_WARN_PASS_STRUCT) - -#undef SUBTARGET_SWITCHES -#define SUBTARGET_SWITCHES \ - { "standard", MASK_STANDARD, \ - N_("Retain standard MXDB information") }, \ - { "legend", -MASK_NOLEGEND, \ - N_("Retain legend information") }, \ - { "no-legend", MASK_NOLEGEND, "" }, \ - { "external-legend", MASK_EXTERNAL_LEGEND, \ - N_("Generate external legend information") }, \ - { "identify-revision", MASK_IDENTIFY_REVISION, \ - N_("Emit identifying info in .s file") }, \ - { "warn-passed-structs", MASK_WARN_PASS_STRUCT, \ - N_("Warn when a function arg is a structure") }, - -#undef DWARF_DEBUGGING_INFO -#define DWARF_DEBUGGING_INFO - -/* - allow -gstabs so that those who have gnu-as installed - can debug c++ programs. -*/ -#undef DBX_DEBUGGING_INFO -#define DBX_DEBUGGING_INFO - -#undef PREFERRED_DEBUGGING_TYPE -#define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG - -/* Override svr[34].h. Switch to the data section so that the coffsem - symbol isn't in the text section. */ -#undef ASM_FILE_START -#define ASM_FILE_START(FILE) \ - do { \ - output_file_directive (FILE, main_input_filename); \ - fprintf (FILE, "\t.version\t\"01.01\"\n"); \ - data_section (); \ - } while (0) - -/* ix86 abi specified type for wchar_t */ - -#undef WCHAR_TYPE -#define WCHAR_TYPE "long int" - -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE BITS_PER_WORD - - -/* Some machines may desire to change what optimizations are performed for - various optimization levels. This macro, if defined, is executed once - just after the optimization level is determined and before the remainder - of the command options have been parsed. Values set in this macro are - used as the default values for the other command line options. - - LEVEL is the optimization level specified; 2 if -O2 is specified, - 1 if -O is specified, and 0 if neither is specified. */ - -/* This macro used to store 0 in flag_signed_bitfields. - Not only is that misuse of this macro; the whole idea is wrong. - - The GNU C dialect makes bitfields signed by default, - regardless of machine type. Making any machine inconsistent in this - regard is bad for portability. - - I chose to make bitfields signed by default because this is consistent - with the way ordinary variables are handled: `int' equals `signed int'. - If there is a good reason to prefer making bitfields unsigned by default, - it cannot have anything to do with the choice of machine. - If the reason is good enough, we should change the convention for all machines. - - -- rms, 20 July 1991. */ - -/* - this really should go into dgux-local.h -*/ - -#undef OPTIMIZATION_OPTIONS -#define OPTIMIZATION_OPTIONS(LEVEL,SIZE) \ - do { \ - extern int flag_signed_bitfields; \ - flag_signed_bitfields = 0; \ - optimization_options (LEVEL,SIZE); \ - } while (0) - - -/* The normal location of the `ld' and `as' programs */ - -#undef MD_EXEC_PREFIX -#define MD_EXEC_PREFIX "/usr/bin/" - -/* The normal location of the various *crt*.o files is the */ - -#undef MD_STARTFILE_PREFIX -#define MD_STARTFILE_PREFIX "/usr/lib/" - -/* Macros to be automatically defined. - __CLASSIFY_TYPE__ is used in the <varargs.h> and <stdarg.h> header - files with DG/UX revision 5.40 and later. This allows GNU CC to - operate without installing the header files. */ - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-D__ix86 -Dunix -DDGUX -D__CLASSIFY_TYPE__=2\ - -Asystem=unix -Asystem=svr4" - - /* - If not -ansi, -traditional, or restricting include files to one - specific source target, specify full DG/UX features. - */ -#undef CPP_SPEC -#define CPP_SPEC "%(cpp_cpu) %{!ansi:%{!traditional:-D__OPEN_NAMESPACE__}}" - -/* Assembler support (legends for mxdb). */ -#undef ASM_SPEC -#define ASM_SPEC "\ -%{mno-legend:%{mstandard:-Wc,off}}\ -%{g:%{!mno-legend:-Wc,-fix-bb,-s\"%i\"\ -%{traditional:,-lc}%{!traditional:,-lansi-c}\ -%{mstandard:,-keep-std}\ -%{mexternal-legend:,-external}}}" - -/* Override svr4.h. */ - -/* hassey 3/12/94 keep svr4 ASM_FINAL_SPEC allows -pipe to work */ - -/* Linker and library spec's. - -static, -shared, -symbolic, -h* and -z* access AT&T V.4 link options. - -svr4 instructs gcc to place /usr/lib/values-X[cat].o on link the line. - The absence of -msvr4 indicates linking done in a COFF environment and - adds the link script to the link line. In all environments, the first - and last objects are crtbegin.o and crtend.o. - When the -G link option is used (-shared and -symbolic) a final link is - not being done. */ - -#undef LIB_SPEC -#define LIB_SPEC \ -"%{!shared:%{!symbolic:-lc}}" - -#undef LINK_SPEC -#define LINK_SPEC "%{z*} %{h*} %{v:-V} \ - %{static:-dn -Bstatic} \ - %{shared:-G -dy} \ - %{symbolic:-Bsymbolic -G -dy} \ - %{pg:-L/usr/lib/libp}%{p:-L/usr/lib/libp}" - -#ifdef CROSS_COMPILE - -#undef STARTFILE_SPEC -#define STARTFILE_SPEC "%{!shared:%{!symbolic:%{pg:gcrt1.o%s} \ - %{!pg:%{p:mcrt1.o%s} \ - %{!p:crt1.o%s}}}} \ - %{pg:gcrti.o%s}%{!pg:crti.o%s} \ - crtbegin.o%s \ - %{ansi:values-Xc.o%s} \ - %{!ansi:%{traditional:values-Xt.o%s} \ - %{!traditional:values-Xa.o%s}}" - -#undef ENDFILE_SPEC -#define ENDFILE_SPEC "crtend.o%s %{pg:gcrtn.o}%{!pg:crtn.o%s}" - -#else - -#undef STARTFILE_SPEC -#define STARTFILE_SPEC "%{!shared:%{!symbolic:%{pg:gcrt1.o%s} \ - %{!pg:%{p:/lib/mcrt1.o%s} \ - %{!p:/lib/crt1.o%s}}}} \ - %{pg:gcrti.o%s}%{!pg:/lib/crti.o%s} \ - crtbegin.o%s \ - %{ansi:/lib/values-Xc.o%s} \ - %{!ansi:%{traditional:/lib/values-Xt.o%s} \ - %{!traditional:/lib/values-Xa.o%s}}" - -#undef ENDFILE_SPEC -#define ENDFILE_SPEC "crtend.o%s %{pg:gcrtn.o}%{!pg:/lib/crtn.o}" - -#endif /* CROSS_COMPILE */ - -/* The maximum alignment which the object file format can support. - page alignment would seem to be enough */ -#undef MAX_OFILE_ALIGNMENT -#define MAX_OFILE_ALIGNMENT 0x1000 - -/* Must use data section for relocatable constants when pic. */ -#undef SELECT_RTX_SECTION -#define SELECT_RTX_SECTION(MODE,RTX,ALIGN) \ -{ \ - if (flag_pic && symbolic_operand (RTX, VOIDmode)) \ - data_section (); \ - else \ - const_section (); \ -} - -/* This supplements FUNCTION_ARG's definition in i386.h to check - TARGET_WARN_PASS_STRUCT */ - -#undef FUNCTION_ARG -#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ -((((MODE) == BLKmode && TARGET_WARN_PASS_STRUCT) ? \ - warning ("argument is a structure"),0 : 0), \ - (function_arg (&CUM, MODE, TYPE, NAMED))) - -/* Add .align 1 to avoid .backalign bug in assembler */ -#undef CONST_SECTION_ASM_OP -#define CONST_SECTION_ASM_OP "\t.section\t.rodata\n\t.align 1" diff --git a/contrib/gcc/config/i386/djgpp-rtems.h b/contrib/gcc/config/i386/djgpp-rtems.h deleted file mode 100644 index 551b666..0000000 --- a/contrib/gcc/config/i386/djgpp-rtems.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Configuration for an i386 running RTEMS on top of MS-DOS with - DJGPP v2.x. - - Copyright (C) 1996, 1999, 2002 Free Software Foundation, Inc. - Contributed by Joel Sherrill (joel@OARcorp.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. */ - -/* Specify predefined symbols in preprocessor. */ - -#ifdef CPP_PREDEFINES -#undef CPP_PREDEFINES -#endif -#define CPP_PREDEFINES "-Dunix -DGO32 -DDJGPP=2 -DMSDOS -D__rtems__ \ - -Asystem=unix -Asystem=msdos -Asystem=rtems" - -/* Generate calls to memcpy, memcmp and memset. */ -#ifndef TARGET_MEM_FUNCTIONS -#define TARGET_MEM_FUNCTIONS -#endif diff --git a/contrib/gcc/config/i386/interix.c b/contrib/gcc/config/i386/interix.c deleted file mode 100644 index 8ea2c6e..0000000 --- a/contrib/gcc/config/i386/interix.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Subroutines for insn-output.c for Windows NT. - Copyright (C) 1998, 1999 Free Software Foundation, Inc. - -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. */ - -#include "config.h" -#include "system.h" -#include "rtl.h" -#include "regs.h" -#include "hard-reg-set.h" -#include "output.h" -#include "tree.h" -#include "flags.h" - -/* Return string which is the former assembler name modified with a - suffix consisting of an atsign (@) followed by the number of bytes of - arguments */ - -const char * -gen_stdcall_suffix (decl) - tree decl; -{ - int total = 0; - /* ??? This probably should use XSTR (XEXP (DECL_RTL (decl), 0), 0) instead - of DECL_ASSEMBLER_NAME. */ - const char *const asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - char *newsym; - - if (TYPE_ARG_TYPES (TREE_TYPE (decl))) - if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl)))) - == void_type_node) - { - tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl)); - - while (TREE_VALUE (formal_type) != void_type_node) - { - int parm_size - = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type))); - /* Must round up to include padding. This is done the same - way as in store_one_arg. */ - parm_size = ((parm_size + PARM_BOUNDARY - 1) - / PARM_BOUNDARY * PARM_BOUNDARY); - total += parm_size; - formal_type = TREE_CHAIN (formal_type); - } - } - - newsym = xmalloc (strlen (asmname) + 10); - sprintf (newsym, "%s@%d", asmname, total/BITS_PER_UNIT); - return IDENTIFIER_POINTER (get_identifier (newsym)); -} - -#if 0 -/* Turn this back on when the linker is updated to handle grouped - .data$ sections correctly. See corresponding note in i386/interix.h. - MK. */ - -/* Cover function for UNIQUE_SECTION. */ - -void -i386_pe_unique_section (decl, reloc) - tree decl; - int reloc; -{ - int len; - const char *name; - char *string,*prefix; - - name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - /* Strip off any encoding in fnname. */ - STRIP_NAME_ENCODING (name, name); - - /* The object is put in, for example, section .text$foo. - The linker will then ultimately place them in .text - (everything from the $ on is stripped). Don't put - read-only data in .rdata section to avoid a PE linker - bug when .rdata$* grouped sections are used in code - without a .rdata section. */ - if (TREE_CODE (decl) == FUNCTION_DECL) - prefix = ".text$"; -/* else if (DECL_INITIAL (decl) == 0 - || DECL_INITIAL (decl) == error_mark_node) - prefix = ".bss"; */ - else if (DECL_READONLY_SECTION (decl, reloc)) -#ifdef READONLY_DATA_SECTION - prefix = ".rdata$"; -#else - prefix = ".text$"; -#endif - else - prefix = ".data$"; - len = strlen (name) + strlen (prefix); - string = alloca (len + 1); - sprintf (string, "%s%s", prefix, name); - - DECL_SECTION_NAME (decl) = build_string (len, string); -} - -#endif /* 0 */ diff --git a/contrib/gcc/config/i386/isc.h b/contrib/gcc/config/i386/isc.h deleted file mode 100644 index eea9811..0000000 --- a/contrib/gcc/config/i386/isc.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Assembler-independent definitions for an Intel 386 running - Interactive Unix System V. Specifically, this is for recent versions - that support POSIX. */ - -/* Use crt1.o, not crt0.o, as a startup file, and crtn.o as a closing file. */ -#undef STARTFILE_SPEC -#define STARTFILE_SPEC \ - "%{!shlib:%{posix:%{pg:mcrtp1.o%s}%{!pg:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}}\ - %{Xp:%{pg:mcrtp1.o%s}%{!pg:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}}\ - %{!posix:%{!Xp:%{pg:mcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}\ - %{p:-L/lib/libp} %{pg:-L/lib/libp}}}}\ - %{shlib:%{Xp:crtp1.o%s}%{posix:crtp1.o%s}%{!posix:%{!Xp:crt1.o%s}}}\ - crtbegin.o%s" - -#define ENDFILE_SPEC "crtend.o%s crtn.o%s" - -/* Library spec */ -#undef LIB_SPEC -#define LIB_SPEC "%{shlib:-lc_s} %{posix:-lcposix} %{Xp:-lcposix} -lc -lg" - -#undef CPP_SPEC -#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{Xp:-D_POSIX_SOURCE}" - -/* ISC 2.2 uses `char' for `wchar_t'. */ -#undef WCHAR_TYPE -#define WCHAR_TYPE "char" - -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE BITS_PER_UNIT - -#if 0 -/* This is apparently not true: ISC versions up to 3.0, at least, use - the standard calling sequence in which the called function pops the - extra arg. */ -/* caller has to pop the extra argument passed to functions that return - structures. */ - -#undef RETURN_POPS_ARGS -#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \ - ((FUNDECL) && TREE_CODE (FUNDECL) == IDENTIFIER_NODE ? 0 \ - : (TARGET_RTD \ - && (TYPE_ARG_TYPES (FUNTYPE) == 0 \ - || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \ - == void_type_node))) ? (SIZE) \ - : 0) -/* On other 386 systems, the last line looks like this: - : (aggregate_value_p (TREE_TYPE (FUNTYPE))) ? GET_MODE_SIZE (Pmode) : 0) */ -#endif - -/* Handle #pragma pack and #pragma weak. */ -#define HANDLE_SYSV_PRAGMA - -/* By default, target has a 80387, uses IEEE compatible arithmetic, - and returns float values in the 387, ie, - (TARGET_80387 | TARGET_FLOAT_RETURNS_IN_80387) - - ISC's software emulation of a 387 fails to handle the `fucomp' - opcode. fucomp is only used when generating IEEE compliant code. - So don't make TARGET_IEEE_FP default for ISC. */ - -#undef TARGET_SUBTARGET_DEFAULT -#define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_FLOAT_RETURNS) - -/* The ISC 2.0.2 software FPU emulator apparently can't handle - 80-bit XFmode insns, so don't generate them. */ -#undef LONG_DOUBLE_TYPE_SIZE -#define LONG_DOUBLE_TYPE_SIZE 64 - -/* The ISC assembler does not like a .file directive with a name - longer than 14 characters. Truncating it will not permit - debugging to work properly, but at least we won't get an error - message. */ - -#undef ASM_FILE_START -#define ASM_FILE_START(FILE) \ - do { \ - const int len = strlen (main_input_filename); \ - const char *na = main_input_filename + len; \ - char shorter[15]; \ - /* NA gets MAIN_INPUT_FILENAME sans directory names. */\ - while (na > main_input_filename) \ - { \ - if (na[-1] == '/') \ - break; \ - na--; \ - } \ - strncpy (shorter, na, 14); \ - shorter[14] = 0; \ - fprintf (FILE, "\t.file\t"); \ - output_quoted_string (FILE, shorter); \ - fprintf (FILE, "\n"); \ - } while (0) - -/* Work around assembler forward label references generated in exception - handling code. */ -#define DWARF2_UNWIND_INFO 0 diff --git a/contrib/gcc/config/i386/isccoff.h b/contrib/gcc/config/i386/isccoff.h deleted file mode 100644 index 9efd9ad..0000000 --- a/contrib/gcc/config/i386/isccoff.h +++ /dev/null @@ -1,12 +0,0 @@ -/* Definitions for Intel 386 running Interactive Unix System V. - Specifically, this is for recent versions that support POSIX; - for version 2.0.2, use configuration option i386-sysv instead. - (But set TARGET_DEFAULT to (MASK_80307 | MASK_FLOAT_RETURNS) - if you do that, if you don't have a real 80387.) */ - -/* Mostly it's like AT&T Unix System V. */ - -#include "i386/sysv3.h" - -/* But with a few changes. */ -#include "i386/isc.h" diff --git a/contrib/gcc/config/i386/iscdbx.h b/contrib/gcc/config/i386/iscdbx.h deleted file mode 100644 index 6d1f341..0000000 --- a/contrib/gcc/config/i386/iscdbx.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Definitions for Intel 386 running Interactive Unix System V, - using dbx-in-coff encapsulation. - Specifically, this is for recent versions that support POSIX. - Copyright (C) 1992, 1995 Free Software Foundation, Inc. - -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. */ - -/* Mostly it's like AT&T Unix System V with dbx-in-coff. */ - -#include "i386/svr3dbx.h" - -/* But with a few changes. */ -#undef ENDFILE_SPEC -#include "i386/isc.h" - -/* Overridden defines for ifile usage. */ - -#undef STARTFILE_SPEC -#define STARTFILE_SPEC \ - "%{!r:%{!z:svr3.ifile%s}%{z:svr3z.ifile%s}}\ - %{!shlib:%{posix:%{pg:mcrtp1.o%s}%{!pg:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}}\ - %{Xp:%{pg:mcrtp1.o%s}%{!pg:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}}\ - %{!posix:%{!Xp:%{pg:mcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}}}\ - %{p:-L/usr/lib/libp} %{pg:-L/usr/lib/libp}}\ - %{shlib:%{posix:crtp1.o%s}%{Xp:crtp1.o%s}%{!posix:%{!Xp:crt1.o%s}}}" - -#undef ENDFILE_SPEC -#define ENDFILE_SPEC "crtn.o%s" diff --git a/contrib/gcc/config/i386/linux-oldld.h b/contrib/gcc/config/i386/linux-oldld.h deleted file mode 100644 index a95c205..0000000 --- a/contrib/gcc/config/i386/linux-oldld.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Definitions for Intel 386 running Linux-based GNU systems with pre-BFD - a.out linkers. - Copyright (C) 1995, 1997, 1998, 2002 Free Software Foundation, Inc. - Contributed by Michael Meissner (meissner@cygnus.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. */ - -/* This is tested by i386/gas.h. */ -#define YES_UNDERSCORES - -#include <i386/gstabs.h> -#include <linux-aout.h> /* some common stuff */ - -#undef ASM_COMMENT_START -#define ASM_COMMENT_START "#" - -/* Specify predefined symbols in preprocessor. */ - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-Dunix -D__gnu_linux__ -Dlinux -Asystem=posix" - -#undef CPP_SPEC -#define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}" - -#undef SIZE_TYPE -#define SIZE_TYPE "unsigned int" - -#undef PTRDIFF_TYPE -#define PTRDIFF_TYPE "int" - -#undef WCHAR_TYPE -#define WCHAR_TYPE "long int" - -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE BITS_PER_WORD - -/* Don't default to pcc-struct-return, because gcc is the only compiler, - and we want to retain compatibility with older gcc versions. */ -#define DEFAULT_PCC_STRUCT_RETURN 0 - -#undef LIB_SPEC - -#if 1 -/* We no longer link with libc_p.a or libg.a by default. If you - want to profile or debug the GNU/Linux C library, please add - lc_p or -ggdb to LDFLAGS at the link time, respectively. */ -#define LIB_SPEC \ -"%{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} %{!ggdb:-lc} %{ggdb:-lg}" -#else -#define LIB_SPEC \ -"%{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \ - %{!p:%{!pg:%{!g*:-lc} %{g*:-lg -static}}}" -#endif - - -#undef LINK_SPEC -#define LINK_SPEC "" diff --git a/contrib/gcc/config/i386/next.h b/contrib/gcc/config/i386/next.h deleted file mode 100644 index 3081fde..0000000 --- a/contrib/gcc/config/i386/next.h +++ /dev/null @@ -1,186 +0,0 @@ -/* Target definitions for GNU compiler for Intel x86 CPU running NeXTSTEP - Copyright (C) 1993, 1995, 1996, 1999 Free Software Foundation, Inc. - -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. */ - -#include "i386/gas.h" -#include "nextstep.h" - -/* By default, target has a 80387, with IEEE FP. */ - -#undef TARGET_SUBTARGET_DEFAULT -#define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_IEEE_FP) - -/* Implicit library calls should use memcpy, not bcopy, etc. */ - -#define TARGET_MEM_FUNCTIONS - -/* Machines that use the AT&T assembler syntax - also return floating point values in an FP register. - Define how to find the value returned by a function. - VALTYPE is the data type of the value (as a tree). - If the precise function being called is known, FUNC is its FUNCTION_DECL; - otherwise, FUNC is 0. */ - -#undef VALUE_REGNO -#define VALUE_REGNO(MODE) \ - ((MODE) == SFmode || (MODE) == DFmode || (MODE) == XFmode \ - ? FIRST_FLOAT_REG : 0) - -/* A C statement or statements which output an assembler instruction - opcode to the stdio stream STREAM. The macro-operand PTR is a - variable of type `char *' which points to the opcode name in its - "internal" form--the form that is written in the machine description. - - GAS version 1.38.1 doesn't understand the `repz' opcode mnemonic. - So use `repe' instead. */ - -#undef ASM_OUTPUT_OPCODE -#define ASM_OUTPUT_OPCODE(STREAM, PTR) \ -{ \ - if ((PTR)[0] == 'r' \ - && (PTR)[1] == 'e' \ - && (PTR)[2] == 'p') \ - { \ - if ((PTR)[3] == 'z') \ - { \ - fprintf (STREAM, "repe"); \ - (PTR) += 4; \ - } \ - else if ((PTR)[3] == 'n' && (PTR)[4] == 'z') \ - { \ - fprintf (STREAM, "repne"); \ - (PTR) += 5; \ - } \ - } \ -} - -/* Define macro used to output shift-double opcodes when the shift - count is in %cl. Some assemblers require %cl as an argument; - some don't. - - GAS requires the %cl argument, so override unx386.h. */ - -#undef SHIFT_DOUBLE_OMITS_COUNT -#define SHIFT_DOUBLE_OMITS_COUNT 0 - -/* Print opcodes the way that GAS expects them. */ -#define GAS_MNEMONICS 1 - -/* Names to predefine in the preprocessor for this target machine. */ - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-DNeXT -Dunix -D__MACH__ -D__LITTLE_ENDIAN__ \ - -D__ARCHITECTURE__=\"i386\" -Asystem=unix -Asystem=mach" - -/* This accounts for the return pc and saved fp on the i386. */ - -#define OBJC_FORWARDING_STACK_OFFSET 8 -#define OBJC_FORWARDING_MIN_OFFSET 8 - -/* We do not want a dot in internal labels. */ - -#undef LPREFIX -#define LPREFIX "L" - -#undef ASM_GENERATE_INTERNAL_LABEL -#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ - sprintf ((BUF), "*%s%ld", (PREFIX), (long)(NUMBER)) - -#undef ASM_OUTPUT_INTERNAL_LABEL -#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ - fprintf (FILE, "%s%d:\n", PREFIX, NUM) - -/* Output to assembler file text saying following lines - may contain character constants, extra white space, comments, etc. */ - -#undef ASM_APP_ON -#define ASM_APP_ON "#APP\n" - -/* Output to assembler file text saying following lines - no longer contain unusual constructs. */ - -#undef ASM_APP_OFF -#define ASM_APP_OFF "#NO_APP\n" - -#undef ASM_OUTPUT_REG_PUSH -#define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \ - fprintf (FILE, "\tpushl %se%s\n", "%", reg_names[REGNO]) - -#undef ASM_OUTPUT_REG_POP -#define ASM_OUTPUT_REG_POP(FILE,REGNO) \ - fprintf (FILE, "\tpopl %se%s\n", "%", reg_names[REGNO]) - -/* This is being overridden because the default i386 configuration - generates calls to "_mcount". NeXT system libraries all use - "mcount". */ - -#undef FUNCTION_PROFILER -#define FUNCTION_PROFILER(FILE, LABELNO) \ -{ \ - if (flag_pic) \ - { \ - fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ - LPREFIX, (LABELNO)); \ - fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ - } \ - else \ - { \ - fprintf (FILE, "\tmovl $%sP%d,%%edx\n", LPREFIX, (LABELNO)); \ - fprintf (FILE, "\tcall mcount\n"); \ - } \ -} - -/* BEGIN Calling Convention CHANGES */ - -/* These changes violate the Intel/Unix ABI. Specifically, they - change the way that space for a block return value is passed to a - function. The ABI says that the pointer is passed on the stack. - We change to pass the pointer in %ebx. This makes the NeXT - Objective-C forwarding mechanism possible to implement on an i386. */ - -/* Do NOT pass address of structure values on the stack. */ - -#undef STRUCT_VALUE_INCOMING -#undef STRUCT_VALUE - -/* Pass them in %ebx. */ - -#undef STRUCT_VALUE_REGNUM -#define STRUCT_VALUE_REGNUM 3 - -/* Because we are passing the pointer in a register, we don't need to - rely on the callee to pop it. */ - -#undef RETURN_POPS_ARGS -#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) \ - ((FUNDECL) && TREE_CODE (FUNDECL) == IDENTIFIER_NODE \ - ? 0 \ - : (TARGET_RTD \ - && (TYPE_ARG_TYPES (FUNTYPE) == 0 \ - || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (FUNTYPE))) \ - == void_type_node))) ? (SIZE) : 0) - -/* END Calling Convention CHANGES */ - -/* NeXT still uses old binutils that don't insert nops by default - when the .align directive demands to insert extra space in the text - segment. */ -#undef ASM_OUTPUT_ALIGN -#define ASM_OUTPUT_ALIGN(FILE,LOG) \ - if ((LOG)!=0) fprintf ((FILE), "\t.align %d,0x90\n", (LOG)) diff --git a/contrib/gcc/config/i386/osf1-ci.asm b/contrib/gcc/config/i386/osf1-ci.asm deleted file mode 100644 index a0f0773..0000000 --- a/contrib/gcc/config/i386/osf1-ci.asm +++ /dev/null @@ -1,65 +0,0 @@ -! crti.s for OSF/1, x86; derived from sol2-ci.asm. - -! Copyright (C) 1993, 1998 Free Software Foundation, Inc. -! Written By Fred Fish, Nov 1992 -! -! This file 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. -! -! In addition to the permissions in the GNU General Public License, the -! Free Software Foundation gives you unlimited permission to link the -! compiled version of this file with other programs, and to distribute -! those programs without any restriction coming from the use of this -! file. (The General Public License restrictions do apply in other -! respects; for example, they cover modification of the file, and -! distribution when not linked into another program.) -! -! This file 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; 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 GCC 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. -! - -! This file just supplies labeled starting points for the .init and .fini -! sections. It is linked in before the values-Xx.o files and also before -! crtbegin.o. - - .file "crti.s" - .ident "GNU C crti.s" - - .section .init - .globl _init - .type _init,@function -_init: - - .section .fini - .globl _fini - .type _fini,@function -_fini: - -.globl _init_init_routine -.data - .align 4 - .type _init_init_routine,@object - .size _init_init_routine,4 -_init_init_routine: - .long _init -.globl _init_fini_routine - .align 4 - .type _init_fini_routine,@object - .size _init_fini_routine,4 -_init_fini_routine: - .long _fini diff --git a/contrib/gcc/config/i386/osf1-cn.asm b/contrib/gcc/config/i386/osf1-cn.asm deleted file mode 100644 index a10298f..0000000 --- a/contrib/gcc/config/i386/osf1-cn.asm +++ /dev/null @@ -1,46 +0,0 @@ -! crtn.s for OSF/1, x86; derived from sol2-cn.asm. - -! Copyright (C) 1993, 1998 Free Software Foundation, Inc. -! Written By Fred Fish, Nov 1992 -! -! This file 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. -! -! In addition to the permissions in the GNU General Public License, the -! Free Software Foundation gives you unlimited permission to link the -! compiled version of this file with other programs, and to distribute -! those programs without any restriction coming from the use of this -! file. (The General Public License restrictions do apply in other -! respects; for example, they cover modification of the file, and -! distribution when not linked into another program.) -! -! This file 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; 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 GCC 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. -! - -! This file just supplies returns for the .init and .fini sections. It is -! linked in after all other files. - - .file "crtn.o" - .ident "GNU C crtn.o" - - .section .init - ret $0x0 - - .section .fini - ret $0x0 diff --git a/contrib/gcc/config/i386/osf1elf.h b/contrib/gcc/config/i386/osf1elf.h deleted file mode 100644 index 812e991..0000000 --- a/contrib/gcc/config/i386/osf1elf.h +++ /dev/null @@ -1,213 +0,0 @@ -/* OSF/1 1.3 now is compitable with SVR4, so include sysv4.h, and - put difference here. - Copyright (C) 2000 Free Software Foundation, Inc. */ - -#include <stdio.h> - -#undef TARGET_VERSION -#define TARGET_VERSION fprintf (stderr, " (i386 OSF/1)"); - -#define TARGET_OSF1ELF - -/* WORD_SWITCH_TAKES_ARG defined in svr4 is not correct. We also - need an extra -soname */ -#undef WORD_SWITCH_TAKES_ARG -#define WORD_SWITCH_TAKES_ARG(STR) \ - (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) \ - || !strcmp (STR, "Tdata") || !strcmp (STR, "Ttext") \ - || !strcmp (STR, "Tbss") || !strcmp (STR, "soname")) - -/* Note, -fpic and -fPIC are equivalent */ -#undef CPP_SPEC -#define CPP_SPEC "\ -%(cpp_cpu) \ -%{fpic: -D__SHARED__} %{fPIC: %{!fpic: -D__SHARED__}} \ -%{.S: %{!ansi:%{!traditional:%{!traditional-cpp:%{!ftraditional: -traditional}}}}} \ -%{.S: -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \ -%{.cc: -D__LANGUAGE_C_PLUS_PLUS} \ -%{.cxx: -D__LANGUAGE_C_PLUS_PLUS} \ -%{.C: -D__LANGUAGE_C_PLUS_PLUS} \ -%{.m: -D__LANGUAGE_OBJECTIVE_C} \ -%{!.S: -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}}" - -/* -mmcount or -mno-mcount should be used with -pg or -p */ -#undef CC1_SPEC -#define CC1_SPEC "%(cc1_cpu) %{p: %{!mmcount: %{!mno-mcount: -mno-mcount }}} \ -%{!p: %{pg: %{!mmcount: %{!mno-mcount: -mno-mcount }}}}" - -/* Note, -D__NO_UNDERSCORES__ -D__ELF__ are provided in the older version of - OSF/1 gcc. We keep them here, so that old /usr/include/i386/asm.h works. - */ -#undef CPP_PREDEFINES -#define CPP_PREDEFINES \ - "-D__NO_UNDERSCORES__ -D__ELF__ -DOSF -DOSF1 -Dunix \ - -Asystem=unix -Asystem=xpg4 -Asystem=osf1" - -/* current OSF/1 doesn't provide separate crti.o and gcrti.o (and also, crtn.o - and gcrtn.o) for profile. */ - -#undef STARTFILE_SPEC -#define STARTFILE_SPEC "%{!shared: \ - %{!symbolic: \ - %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}}\ - crti.o%s \ - crtbegin.o%s" - -#undef ENDFILE_SPEC -#define ENDFILE_SPEC "crtend.o%s crtn.o%s" - -#undef ASM_SPEC -#define ASM_SPEC "%{v*: -v}" - -#undef LINK_SPEC -#define LINK_SPEC "%{v*: -v} \ - %{h*} %{z*} \ - %{dy:-call_shared} %{dn:-static} \ - %{static:-static} \ - %{shared:-shared} \ - %{call_shared:-call_shared} \ - %{symbolic:-Bsymbolic -shared -call_shared} \ - %{!dy: %{!dn: %{!static: %{!shared: %{!symbolic: \ - %{noshrlib: -static } \ - %{!noshrlib: -call_shared}}}}}}" - -#undef MD_EXEC_PREFIX -#define MD_EXEC_PREFIX "/usr/ccs/gcc/" - -#undef MD_STARTFILE_PREFIX -#define MD_STARTFILE_PREFIX "/usr/ccs/lib/" - -/* Define this macro meaning that gcc should find the library 'libgcc.a' - by hand, rather than passing the argument '-lgcc' to tell the linker - to do the search */ -#define LINK_LIBGCC_SPECIAL - -/* This goes with LINK_LIBGCC_SPECIAL, we need tell libgcc.a differently */ -#undef LIBGCC_SPEC -#define LIBGCC_SPEC "%{!shared:%{!symbolic:libgcc.a%s}}" - -/* Specify size_t, ptrdiff_t, and wchar_t types. */ -#undef SIZE_TYPE -#undef PTRDIFF_TYPE -#undef WCHAR_TYPE -#undef WCHAR_TYPE_SIZE - -#define SIZE_TYPE "long unsigned int" -#define PTRDIFF_TYPE "int" -#define WCHAR_TYPE "unsigned int" -#define WCHAR_TYPE_SIZE BITS_PER_WORD - -/* Turn off long double being 96 bits. */ -#undef LONG_DOUBLE_TYPE_SIZE -#define LONG_DOUBLE_TYPE_SIZE 64 - -/* Work with OSF/1 profile */ -#define MASK_NO_MCOUNT 000200000000 /* profiling uses mcount_ptr */ - -#define TARGET_MCOUNT ((target_flags & MASK_NO_MCOUNT) == 0) - -#undef SUBTARGET_SWITCHES -#define SUBTARGET_SWITCHES \ - { "mcount", -MASK_NO_MCOUNT, \ - N_("Profiling uses mcount") }, \ - { "no-mcount", MASK_NO_MCOUNT, "" }, - -/* This macro generates the assembly code for function entry. - FILE is a stdio stream to output the code to. - SIZE is an int: how many units of temporary storage to allocate. - Refer to the array `regs_ever_live' to determine which registers - to save; `regs_ever_live[I]' is nonzero if register number I - is ever used in the function. This macro is responsible for - knowing which registers should not be saved even if used. - - We override it here to allow for the new profiling code to go before - the prologue and the old mcount code to go after the prologue (and - after %ebx has been set up for ELF shared library support). */ -#if 0 -#define OSF_PROFILE_BEFORE_PROLOGUE \ - (!TARGET_MCOUNT \ - && !current_function_needs_context \ - && (!flag_pic \ - || !frame_pointer_needed \ - || (!current_function_uses_pic_offset_table \ - && !current_function_uses_const_pool))) -#else -#define OSF_PROFILE_BEFORE_PROLOGUE 0 -#endif - -/* A C statement or compound statement to output to FILE some assembler code to - call the profiling subroutine `mcount'. Before calling, the assembler code - must load the address of a counter variable into a register where `mcount' - expects to find the address. The name of this variable is `LP' followed by - the number LABELNO, so you would generate the name using `LP%d' in a - `fprintf'. - - The details of how the address should be passed to `mcount' are determined - by your operating system environment, not by GNU CC. To figure them out, - compile a small program for profiling using the system's installed C - compiler and look at the assembler code that results. */ - -#undef FUNCTION_PROFILER -#define FUNCTION_PROFILER(FILE, LABELNO) \ -do \ - { \ - if (!OSF_PROFILE_BEFORE_PROLOGUE) \ - { \ - const char *const prefix = ""; \ - const char *const lprefix = LPREFIX; \ - int labelno = LABELNO; \ - \ - /* Note that OSF/rose blew it in terms of calling mcount, \ - since OSF/rose prepends a leading underscore, but mcount's \ - doesn't. At present, we keep this kludge for ELF as well \ - to allow old kernels to build profiling. */ \ - \ - if (flag_pic \ - && !current_function_uses_pic_offset_table \ - && !current_function_uses_const_pool) \ - abort (); \ - \ - if (TARGET_MCOUNT && flag_pic) \ - { \ - fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ - lprefix, labelno); \ - fprintf (FILE, "\tcall *%smcount@GOT(%%ebx)\n", prefix); \ - } \ - \ - else if (TARGET_MCOUNT) \ - { \ - fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ - fprintf (FILE, "\tcall %smcount\n", prefix); \ - } \ - \ - else if (flag_pic && frame_pointer_needed) \ - { \ - fprintf (FILE, "\tmovl 4(%%ebp),%%ecx\n"); \ - fprintf (FILE, "\tpushl %%ecx\n"); \ - fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ - lprefix, labelno); \ - fprintf (FILE, "\tmovl _mcount_ptr@GOT(%%ebx),%%eax\n"); \ - fprintf (FILE, "\tcall *(%%eax)\n"); \ - fprintf (FILE, "\tpopl %%eax\n"); \ - } \ - \ - else if (frame_pointer_needed) \ - { \ - fprintf (FILE, "\tmovl 4(%%ebp),%%ecx\n"); \ - fprintf (FILE, "\tpushl %%ecx\n"); \ - fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ - fprintf (FILE, "\tcall *_mcount_ptr\n"); \ - fprintf (FILE, "\tpopl %%eax\n"); \ - } \ - \ - else \ - abort (); \ - } \ - } \ -while (0) - -#if defined (CROSS_COMPILE) && defined (HOST_BITS_PER_INT) && defined (HOST_BITS_PER_LONG) && defined (HOST_BITS_PER_LONGLONG) -#if (HOST_BITS_PER_INT==32) && (HOST_BITS_PER_LONG==64) && (HOST_BITS_PER_LONGLONG==64) -#define REAL_ARITHMETIC -#endif -#endif diff --git a/contrib/gcc/config/i386/osf1elfgdb.h b/contrib/gcc/config/i386/osf1elfgdb.h deleted file mode 100644 index 4071c66..0000000 --- a/contrib/gcc/config/i386/osf1elfgdb.h +++ /dev/null @@ -1,7 +0,0 @@ -/* Target definitions for GNU compiler for Intel 80386 running OSF/1 1.3+ - with gas and gdb. */ - -/* Use stabs instead of DWARF debug format. */ -#undef PREFERRED_DEBUGGING_TYPE -#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG - diff --git a/contrib/gcc/config/i386/osfelf.h b/contrib/gcc/config/i386/osfelf.h deleted file mode 100644 index 9b0e633..0000000 --- a/contrib/gcc/config/i386/osfelf.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Definitions of target machine for GNU compiler. - Intel 386 (OSF/1 with ELF) version. - Copyright (C) 1993 Free Software Foundation, Inc. - -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. */ - -#include "config/i386/osfrose.h" - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-DOSF -DOSF1 -Dunix -Asystem=xpg4" - -#undef CPP_SPEC -#define CPP_SPEC "%(cpp_cpu) \ -%{mrose: -D__ROSE__ %{!pic-none: -D__SHARED__}} \ -%{!mrose: -D__ELF__ %{fpic: -D__SHARED__}} \ -%{mno-underscores: -D__NO_UNDERSCORES__} \ -%{!mrose: %{!munderscores: -D__NO_UNDERSCORES__}} \ -%{.S: %{!ansi:%{!traditional:%{!traditional-cpp:%{!ftraditional: -traditional}}}}} \ -%{.S: -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \ -%{.cc: -D__LANGUAGE_C_PLUS_PLUS} \ -%{.cxx: -D__LANGUAGE_C_PLUS_PLUS} \ -%{.C: -D__LANGUAGE_C_PLUS_PLUS} \ -%{.m: -D__LANGUAGE_OBJECTIVE_C} \ -%{!.S: -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}}" - -/* Turn on -pic-extern by default for OSF/rose, -fpic for ELF. */ -#undef CC1_SPEC -#define CC1_SPEC "%(cc1_cpu) \ -%{gline:%{!g:%{!g0:%{!g1:%{!g2: -g1}}}}} \ -%{!melf: %{!mrose: -melf }} \ -%{!mrose: %{!munderscores: %{!mno-underscores: -mno-underscores }} \ - %{!mmcount: %{!mno-mcount: %{!mmcount-ptr: -mmcount-ptr }}}} \ -%{mrose: %{!mmcount: %{!mno-mcount: %{!mmcount-ptr: -mmcount }}} \ - %{pic-extern: -mhalf-pic } %{pic-lib: -mhalf-pic } \ - %{!pic-extern: %{!pic-lib: %{pic-none: -mno-half-pic} %{!pic-none: -mhalf-pic}}} \ - %{pic-calls: } %{pic-names*: }}" - -#undef ASM_SPEC -#define ASM_SPEC "%{v*: -v}" - -#undef LINK_SPEC -#define LINK_SPEC "%{v*: -v} \ -%{mrose: %{!noshrlib: %{pic-none: -noshrlib} %{!pic-none: -warn_nopic}} \ - %{nostdlib} %{noshrlib} %{glue}} \ -%{!mrose: %{dy} %{dn} %{glue: } \ - %{h*} %{z*} \ - %{static:-dn -Bstatic} \ - %{shared:-G -dy} \ - %{symbolic:-Bsymbolic -G -dy} \ - %{G:-G} \ - %{!dy: %{!dn: %{!static: %{!shared: %{!symbolic: \ - %{noshrlib: -dn } %{pic-none: -dn } \ - %{!noshrlib: %{!pic-none: -dy}}}}}}}}" - -#undef TARGET_VERSION_INTERNAL -#undef TARGET_VERSION - -#undef I386_VERSION -#define I386_VERSION " 80386, ELF objects" - -#define TARGET_VERSION_INTERNAL(STREAM) fputs (I386_VERSION, STREAM) -#define TARGET_VERSION TARGET_VERSION_INTERNAL (stderr) - -#undef OBJECT_FORMAT_ROSE diff --git a/contrib/gcc/config/i386/osfrose.h b/contrib/gcc/config/i386/osfrose.h deleted file mode 100644 index 36d6345..0000000 --- a/contrib/gcc/config/i386/osfrose.h +++ /dev/null @@ -1,720 +0,0 @@ -/* Definitions of target machine for GNU compiler. - Intel 386 (OSF/1 with OSF/rose) version. - Copyright (C) 1991, 1992, 1993, 1996, 1998, 1999, 2000 - Free Software Foundation, Inc. - -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. */ - -#include "halfpic.h" -#include "i386/gstabs.h" - -#define OSF_OS - -#undef WORD_SWITCH_TAKES_ARG -#define WORD_SWITCH_TAKES_ARG(STR) \ - (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) || !strcmp (STR, "pic-names")) - -/* This defines which switch letters take arguments. On svr4, most of - the normal cases (defined in gcc.c) apply, and we also have -h* and - -z* options (for the linker). */ - -#define SWITCH_TAKES_ARG(CHAR) \ - (DEFAULT_SWITCH_TAKES_ARG(CHAR) \ - || (CHAR) == 'h' \ - || (CHAR) == 'z') - -#define MASK_HALF_PIC 010000000000 /* Mask for half-pic code */ -#define MASK_HALF_PIC_DEBUG 004000000000 /* Debug flag */ -#define MASK_ELF 002000000000 /* ELF not rose */ -#define MASK_NO_UNDERSCORES 000400000000 /* suppress leading _ */ -#define MASK_LARGE_ALIGN 000200000000 /* align to >word boundaries */ -#define MASK_NO_MCOUNT 000100000000 /* profiling uses mcount_ptr */ - -#define TARGET_HALF_PIC (target_flags & MASK_HALF_PIC) -#define TARGET_DEBUG (target_flags & MASK_HALF_PIC_DEBUG) -#define HALF_PIC_DEBUG TARGET_DEBUG -#define TARGET_ELF (target_flags & MASK_ELF) -#define TARGET_ROSE ((target_flags & MASK_ELF) == 0) -#define TARGET_UNDERSCORES ((target_flags & MASK_NO_UNDERSCORES) == 0) -#define TARGET_LARGE_ALIGN (target_flags & MASK_LARGE_ALIGN) -#define TARGET_MCOUNT ((target_flags & MASK_NO_MCOUNT) == 0) - -#undef SUBTARGET_SWITCHES -#define SUBTARGET_SWITCHES \ - { "half-pic", MASK_HALF_PIC, \ - N_("Emit half-PIC code") }, \ - { "no-half-pic", -MASK_HALF_PIC, "" }, \ - { "debug-half-pic", MASK_HALF_PIC_DEBUG, \ - 0 /* intentionally undoc */ }, \ - { "debugb", MASK_HALF_PIC_DEBUG, \ - 0 /* intentionally undoc */ }, \ - { "elf", MASK_ELF, \ - N_("Emit ELF object code") }, \ - { "rose", -MASK_ELF, \ - N_("Emit ROSE object code") }, \ - { "underscores", -MASK_NO_UNDERSCORES, \ - N_("Symbols have a leading underscore") }, \ - { "no-underscores", MASK_NO_UNDERSCORES, "" }, \ - { "large-align", MASK_LARGE_ALIGN, \ - N_("Align to >word boundaries") }, \ - { "no-large-align", -MASK_LARGE_ALIGN, "" }, \ - { "mcount", -MASK_NO_MCOUNT, \ - N_("Use mcount for profiling") }, \ - { "mcount-ptr", MASK_NO_MCOUNT, \ - N_("Use mcount_ptr for profiling") }, \ - { "no-mcount", MASK_NO_MCOUNT, "" }, - -/* OSF/rose uses stabs, not dwarf. */ -#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG - -#ifndef DWARF_DEBUGGING_INFO -#define DWARF_DEBUGGING_INFO /* enable dwarf debugging for testing */ -#endif - -/* Handle #pragma weak and #pragma pack. */ - -#define HANDLE_SYSV_PRAGMA -#define SUPPORTS_WEAK TARGET_ELF - -/* Change default predefines. */ -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-DOSF -DOSF1 -Dunix -Asystem=xpg4" - -#undef CPP_SPEC -#define CPP_SPEC "%(cpp_cpu) \ -%{!melf: -D__ROSE__ %{!pic-none: -D__SHARED__}} \ -%{melf: -D__ELF__ %{fpic: -D__SHARED__}} \ -%{mno-underscores: -D__NO_UNDERSCORES__} \ -%{melf: %{!munderscores: -D__NO_UNDERSCORES__}} \ -%{.S: %{!ansi:%{!traditional:%{!traditional-cpp:%{!ftraditional: -traditional}}}}} \ -%{.S: -D__LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \ -%{.cc: -D__LANGUAGE_C_PLUS_PLUS} \ -%{.cxx: -D__LANGUAGE_C_PLUS_PLUS} \ -%{.C: -D__LANGUAGE_C_PLUS_PLUS} \ -%{.m: -D__LANGUAGE_OBJECTIVE_C} \ -%{!.S: -D__LANGUAGE_C %{!ansi:-DLANGUAGE_C}}" - -/* Turn on -pic-extern by default for OSF/rose, -fpic for ELF. */ -#undef CC1_SPEC -#define CC1_SPEC "%(cc1_cpu) \ -%{gline:%{!g:%{!g0:%{!g1:%{!g2: -g1}}}}} \ -%{!melf: %{!mrose: -mrose }} \ -%{melf: %{!munderscores: %{!mno-underscores: -mno-underscores }} \ - %{!mmcount: %{!mno-mcount: %{!mmcount-ptr: -mmcount-ptr }}}} \ -%{!melf: %{!munderscores: %{!mno-underscores: -munderscores }} \ - %{!mmcount: %{!mno-mcount: %{!mmcount-ptr: -mmcount }}} \ - %{pic-extern: -mhalf-pic } %{pic-lib: -mhalf-pic } \ - %{!pic-extern: %{!pic-lib: %{pic-none: -mno-half-pic} %{!pic-none: -mhalf-pic}}} \ - %{pic-calls: } %{pic-names*: }}" - -#undef ASM_SPEC -#define ASM_SPEC "%{v*: -v}" - -#undef LINK_SPEC -#define LINK_SPEC "%{v*: -v} \ -%{!melf: %{!noshrlib: %{pic-none: -noshrlib} %{!pic-none: -warn_nopic}} \ - %{nostdlib} %{noshrlib} %{glue}} \ -%{melf: %{dy} %{dn} %{glue: } \ - %{h*} %{z*} \ - %{static:-dn -Bstatic} \ - %{shared:-G -dy} \ - %{symbolic:-Bsymbolic -G -dy} \ - %{G:-G} \ - %{!dy: %{!dn: %{!static: %{!shared: %{!symbolic: \ - %{noshrlib: -dn } %{pic-none: -dn } \ - %{!noshrlib: %{!pic-none: -dy}}}}}}}}" - -#undef LIB_SPEC -#define LIB_SPEC "-lc" - -#undef LIBG_SPEC -#define LIBG_SPEC "" - -#undef STARTFILE_SPEC -#define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}" - -#undef TARGET_VERSION_INTERNAL -#undef TARGET_VERSION - -#define I386_VERSION " 80386, OSF/rose objects" - -#define TARGET_VERSION_INTERNAL(STREAM) fputs (I386_VERSION, STREAM) -#define TARGET_VERSION TARGET_VERSION_INTERNAL (stderr) - -#undef MD_EXEC_PREFIX -#define MD_EXEC_PREFIX "/usr/ccs/gcc/" - -#undef MD_STARTFILE_PREFIX -#define MD_STARTFILE_PREFIX "/usr/ccs/lib/" - -/* Specify size_t, ptrdiff_t, and wchar_t types. */ -#undef SIZE_TYPE -#undef PTRDIFF_TYPE -#undef WCHAR_TYPE -#undef WCHAR_TYPE_SIZE - -#define SIZE_TYPE "long unsigned int" -#define PTRDIFF_TYPE "int" -#define WCHAR_TYPE "unsigned int" -#define WCHAR_TYPE_SIZE BITS_PER_WORD - -/* Define this macro if the system header files support C++ as well - as C. This macro inhibits the usual method of using system header - files in C++, which is to pretend that the file's contents are - enclosed in `extern "C" {...}'. */ -#define NO_IMPLICIT_EXTERN_C - -/* Turn off long double being 96 bits. */ -#undef LONG_DOUBLE_TYPE_SIZE -#define LONG_DOUBLE_TYPE_SIZE 64 - -#define OSF_PROFILE_BEFORE_PROLOGUE \ - (!TARGET_MCOUNT \ - && !current_function_needs_context \ - && (!flag_pic \ - || !frame_pointer_needed \ - || (!current_function_uses_pic_offset_table \ - && !current_function_uses_const_pool))) - -/* A C statement or compound statement to output to FILE some assembler code to - call the profiling subroutine `mcount'. Before calling, the assembler code - must load the address of a counter variable into a register where `mcount' - expects to find the address. The name of this variable is `LP' followed by - the number LABELNO, so you would generate the name using `LP%d' in a - `fprintf'. - - The details of how the address should be passed to `mcount' are determined - by your operating system environment, not by GNU CC. To figure them out, - compile a small program for profiling using the system's installed C - compiler and look at the assembler code that results. */ - -#undef FUNCTION_PROFILER -#define FUNCTION_PROFILER(FILE, LABELNO) \ -do \ - { \ - if (!OSF_PROFILE_BEFORE_PROLOGUE) \ - { \ - const char *const prefix = (TARGET_UNDERSCORES) ? "_" : ""; \ - const char *const lprefix = LPREFIX; \ - int labelno = LABELNO; \ - \ - /* Note that OSF/rose blew it in terms of calling mcount, \ - since OSF/rose prepends a leading underscore, but mcount's \ - doesn't. At present, we keep this kludge for ELF as well \ - to allow old kernels to build profiling. */ \ - \ - if (flag_pic \ - && !current_function_uses_pic_offset_table \ - && !current_function_uses_const_pool) \ - abort (); \ - \ - if (TARGET_MCOUNT && flag_pic) \ - { \ - fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ - lprefix, labelno); \ - fprintf (FILE, "\tcall *%smcount@GOT(%%ebx)\n", prefix); \ - } \ - \ - else if (TARGET_MCOUNT && HALF_PIC_P ()) \ - { \ - rtx symdef; \ - \ - HALF_PIC_EXTERNAL ("mcount"); \ - symdef = HALF_PIC_PTR (gen_rtx_SYMBOL_REF (Pmode, "mcount")); \ - fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ - fprintf (FILE, "\tcall *%s%s\n", prefix, XSTR (symdef, 0)); \ - } \ - \ - else if (TARGET_MCOUNT) \ - { \ - fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ - fprintf (FILE, "\tcall %smcount\n", prefix); \ - } \ - \ - else if (flag_pic && frame_pointer_needed) \ - { \ - fprintf (FILE, "\tmovl 4(%%ebp),%%ecx\n"); \ - fprintf (FILE, "\tpushl %%ecx\n"); \ - fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%edx\n", \ - lprefix, labelno); \ - fprintf (FILE, "\tmovl _mcount_ptr@GOT(%%ebx),%%eax\n"); \ - fprintf (FILE, "\tcall *(%%eax)\n"); \ - fprintf (FILE, "\tpopl %%eax\n"); \ - } \ - \ - else if (frame_pointer_needed) \ - { \ - fprintf (FILE, "\tmovl 4(%%ebp),%%ecx\n"); \ - fprintf (FILE, "\tpushl %%ecx\n"); \ - fprintf (FILE, "\tmovl $%sP%d,%%edx\n", lprefix, labelno); \ - fprintf (FILE, "\tcall *_mcount_ptr\n"); \ - fprintf (FILE, "\tpopl %%eax\n"); \ - } \ - \ - else \ - abort (); \ - } \ - } \ -while (0) - -/* A C function or functions which are needed in the library to - support block profiling. When support goes into libc, undo - the #if 0. */ - -#if 0 -#undef BLOCK_PROFILING_CODE -#define BLOCK_PROFILING_CODE -#endif - -/* Prefix for internally generated assembler labels. If we aren't using - underscores, we are using prefix `.'s to identify labels that should - be ignored, as in `i386/gas.h' --karl@cs.umb.edu */ -#undef LPREFIX -#define LPREFIX ((TARGET_UNDERSCORES) ? "L" : ".L") - -/* This is how to store into the string BUF - the symbol_ref name of an internal numbered label where - PREFIX is the class of label and NUM is the number within the class. - This is suitable for output with `assemble_name'. */ - -#undef ASM_GENERATE_INTERNAL_LABEL -#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ - sprintf ((BUF), "*%s%s%ld", (TARGET_UNDERSCORES) ? "" : ".", \ - (PREFIX), (long)(NUMBER)) - -/* This is how to output an internal numbered label where - PREFIX is the class of label and NUM is the number within the class. */ - -#undef ASM_OUTPUT_INTERNAL_LABEL -#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ - fprintf (FILE, "%s%s%d:\n", (TARGET_UNDERSCORES) ? "" : ".", \ - PREFIX, NUM) - -/* The prefix to add to user-visible assembler symbols. */ - -/* target_flags is not accessible by the preprocessor */ -#undef USER_LABEL_PREFIX -#define USER_LABEL_PREFIX "_" - -/* This is how to output a reference to a user-level label named NAME. */ - -#undef ASM_OUTPUT_LABELREF -#define ASM_OUTPUT_LABELREF(FILE,NAME) \ - fprintf (FILE, "%s%s", (TARGET_UNDERSCORES) ? "_" : "", NAME) - -/* This is how to output an element of a case-vector that is relative. - This is only used for PIC code. See comments by the `casesi' insn in - i386.md for an explanation of the expression this outputs. */ - -#undef ASM_OUTPUT_ADDR_DIFF_ELT -#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ - fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) - -/* Output a definition */ -#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ -do \ -{ \ - fprintf ((FILE), "%s", SET_ASM_OP); \ - assemble_name (FILE, LABEL1); \ - fprintf (FILE, ","); \ - assemble_name (FILE, LABEL2); \ - fprintf (FILE, "\n"); \ - } \ -while (0) - -/* A C expression to output text to align the location counter in the - way that is desirable at a point in the code that is reached only - by jumping. - - This macro need not be defined if you don't want any special - alignment to be done at such a time. Most machine descriptions do - not currently define the macro. */ - -#undef LABEL_ALIGN_AFTER_BARRIER -#define LABEL_ALIGN_AFTER_BARRIER(LABEL) \ - ((!TARGET_LARGE_ALIGN && i386_align_jumps > 2) ? 2 : i386_align_jumps) - -/* A C expression to output text to align the location counter in the - way that is desirable at the beginning of a loop. - - This macro need not be defined if you don't want any special - alignment to be done at such a time. Most machine descriptions do - not currently define the macro. */ - -#undef LOOP_ALIGN -#define LOOP_ALIGN(LABEL) (i386_align_loops) - -/* A C statement to output to the stdio stream STREAM an assembler - command to advance the location counter to a multiple of 2 to the - POWER bytes. POWER will be a C expression of type `int'. */ - -#undef ASM_OUTPUT_ALIGN -#define ASM_OUTPUT_ALIGN(STREAM, POWER) \ - fprintf (STREAM, "\t.align\t%d\n", \ - (!TARGET_LARGE_ALIGN && (POWER) > 2) ? 2 : (POWER)) - -/* A C expression that is 1 if the RTX X is a constant which is a - valid address. On most machines, this can be defined as - `CONSTANT_P (X)', but a few machines are more restrictive in - which constant addresses are supported. - - `CONSTANT_P' accepts integer-values expressions whose values are - not explicitly known, such as `symbol_ref', `label_ref', and - `high' expressions and `const' arithmetic expressions, in - addition to `const_int' and `const_double' expressions. */ - -#define CONSTANT_ADDRESS_P_ORIG(X) \ - (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ - || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \ - || GET_CODE (X) == HIGH) - -#undef CONSTANT_ADDRESS_P -#define CONSTANT_ADDRESS_P(X) \ - ((CONSTANT_ADDRESS_P_ORIG (X)) && (!HALF_PIC_P () || !HALF_PIC_ADDRESS_P (X))) - -/* Nonzero if the constant value X is a legitimate general operand. - It is given that X satisfies CONSTANT_P or is a CONST_DOUBLE. */ - -#undef LEGITIMATE_CONSTANT_P -#define LEGITIMATE_CONSTANT_P(X) \ - (!HALF_PIC_P () \ - || GET_CODE (X) == CONST_DOUBLE \ - || GET_CODE (X) == CONST_INT \ - || !HALF_PIC_ADDRESS_P (X)) - -/* Sometimes certain combinations of command options do not make sense - on a particular target machine. You can define a macro - `OVERRIDE_OPTIONS' to take account of this. This macro, if - defined, is executed once just after all the command options have - been parsed. */ - -#undef SUBTARGET_OVERRIDE_OPTIONS -#define SUBTARGET_OVERRIDE_OPTIONS \ -{ \ - /* \ - if (TARGET_ELF && TARGET_HALF_PIC) \ - { \ - target_flags &= ~MASK_HALF_PIC; \ - flag_pic = 1; \ - } \ - */ \ - \ - if (TARGET_ROSE && flag_pic) \ - { \ - target_flags |= MASK_HALF_PIC; \ - flag_pic = 0; \ - } \ - \ - if (TARGET_HALF_PIC) \ - half_pic_init (); \ -} - -/* Define this macro if references to a symbol must be treated - differently depending on something about the variable or - function named by the symbol (such as what section it is in). - - The macro definition, if any, is executed immediately after the - rtl for DECL has been created and stored in `DECL_RTL (DECL)'. - The value of the rtl will be a `mem' whose address is a - `symbol_ref'. - - The usual thing for this macro to do is to a flag in the - `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified - name string in the `symbol_ref' (if one bit is not enough - information). - - The best way to modify the name string is by adding text to the - beginning, with suitable punctuation to prevent any ambiguity. - Allocate the new name in `saveable_obstack'. You will have to - modify `ASM_OUTPUT_LABELREF' to remove and decode the added text - and output the name accordingly. - - You can also check the information stored in the `symbol_ref' in - the definition of `GO_IF_LEGITIMATE_ADDRESS' or - `PRINT_OPERAND_ADDRESS'. */ - -#undef ENCODE_SECTION_INFO -#define ENCODE_SECTION_INFO(DECL) \ -do \ - { \ - if (HALF_PIC_P ()) \ - HALF_PIC_ENCODE (DECL); \ - \ - else if (flag_pic) \ - { \ - rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ - ? TREE_CST_RTL (DECL) : DECL_RTL (DECL)); \ - SYMBOL_REF_FLAG (XEXP (rtl, 0)) \ - = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd' \ - || ! TREE_PUBLIC (DECL)); \ - } \ - } \ -while (0) - - -/* On most machines, read-only variables, constants, and jump tables - are placed in the text section. If this is not the case on your - machine, this macro should be defined to be the name of a function - (either `data_section' or a function defined in `EXTRA_SECTIONS') - that switches to the section to be used for read-only items. - - If these items should be placed in the text section, this macro - should not be defined. */ - -#if 0 -#undef READONLY_DATA_SECTION -#define READONLY_DATA_SECTION() \ -do \ - { \ - if (TARGET_ELF) \ - { \ - if (in_section != in_rodata) \ - { \ - fprintf (asm_out_file, "\t.section \"rodata\"\n"); \ - in_section = in_rodata; \ - } \ - } \ - else \ - text_section (); \ - } \ -while (0) -#endif - -/* A list of names for sections other than the standard two, which are - `in_text' and `in_data'. You need not define this macro on a - system with no other sections (that GCC needs to use). */ - -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_rodata, in_data1 - -/* Given a decl node or constant node, choose the section to output it in - and select that section. */ - -#undef SELECT_RTX_SECTION -#define SELECT_RTX_SECTION(MODE, RTX, ALIGN) \ -do \ - { \ - if (MODE == Pmode && HALF_PIC_P () && HALF_PIC_ADDRESS_P (RTX)) \ - data_section (); \ - else \ - readonly_data_section (); \ - } \ -while (0) - -#undef SELECT_SECTION -#define SELECT_SECTION(DECL, RELOC, ALIGN) \ -{ \ - if (RELOC && HALF_PIC_P ()) \ - data_section (); \ - \ - else if (TREE_CODE (DECL) == STRING_CST) \ - { \ - if (flag_writable_strings) \ - data_section (); \ - else \ - readonly_data_section (); \ - } \ - \ - else if (TREE_CODE (DECL) != VAR_DECL) \ - readonly_data_section (); \ - \ - else if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL) \ - || !DECL_INITIAL (DECL) \ - || (DECL_INITIAL (DECL) != error_mark_node \ - && !TREE_CONSTANT (DECL_INITIAL (DECL)))) \ - data_section (); \ - \ - else \ - readonly_data_section (); \ -} - - -/* Define the strings used for the special svr4 .type and .size directives. - These strings generally do not vary from one system running svr4 to - another, but if a given system (e.g. m88k running svr) needs to use - different pseudo-op names for these, they may be overridden in the - file which includes this one. */ - -#define TYPE_ASM_OP "\t.type\t" -#define SIZE_ASM_OP "\t.size\t" -#define SET_ASM_OP "\t.set\t" - -/* This is how we tell the assembler that a symbol is weak. */ - -#define ASM_WEAKEN_LABEL(FILE,NAME) \ - do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \ - fputc ('\n', FILE); } while (0) - -/* The following macro defines the format used to output the second - operand of the .type assembler directive. Different svr4 assemblers - expect various different forms for this operand. The one given here - is just a default. You may need to override it in your machine- - specific tm.h file (depending upon the particulars of your assembler). */ - -#define TYPE_OPERAND_FMT "@%s" - -/* A C statement (sans semicolon) to output to the stdio stream - STREAM any text necessary for declaring the name NAME of an - initialized variable which is being defined. This macro must - output the label definition (perhaps using `ASM_OUTPUT_LABEL'). - The argument DECL is the `VAR_DECL' tree node representing the - variable. - - If this macro is not defined, then the variable name is defined - in the usual manner as a label (by means of `ASM_OUTPUT_LABEL'). */ - -#undef ASM_DECLARE_OBJECT_NAME -#define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \ -do \ - { \ - ASM_OUTPUT_LABEL(STREAM,NAME); \ - HALF_PIC_DECLARE (NAME); \ - if (TARGET_ELF) \ - { \ - fprintf (STREAM, "%s", TYPE_ASM_OP); \ - assemble_name (STREAM, NAME); \ - putc (',', STREAM); \ - fprintf (STREAM, TYPE_OPERAND_FMT, "object"); \ - putc ('\n', STREAM); \ - size_directive_output = 0; \ - if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \ - { \ - size_directive_output = 1; \ - fprintf (STREAM, "%s", SIZE_ASM_OP); \ - assemble_name (STREAM, NAME); \ - fprintf (STREAM, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \ - } \ - } \ - } \ -while (0) - -/* Output the size directive for a decl in rest_of_decl_compilation - in the case where we did not do so before the initializer. - Once we find the error_mark_node, we know that the value of - size_directive_output was set - by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */ - -#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \ -do { \ - const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ - if (TARGET_ELF \ - && !flag_inhibit_size_directive && DECL_SIZE (DECL) \ - && ! AT_END && TOP_LEVEL \ - && DECL_INITIAL (DECL) == error_mark_node \ - && !size_directive_output) \ - { \ - fprintf (FILE, "%s", SIZE_ASM_OP); \ - assemble_name (FILE, name); \ - fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \ - } \ - } while (0) - -/* This is how to declare a function name. */ - -#undef ASM_DECLARE_FUNCTION_NAME -#define ASM_DECLARE_FUNCTION_NAME(STREAM,NAME,DECL) \ -do \ - { \ - ASM_OUTPUT_LABEL(STREAM,NAME); \ - HALF_PIC_DECLARE (NAME); \ - if (TARGET_ELF) \ - { \ - fprintf (STREAM, "%s", TYPE_ASM_OP); \ - assemble_name (STREAM, NAME); \ - putc (',', STREAM); \ - fprintf (STREAM, TYPE_OPERAND_FMT, "function"); \ - putc ('\n', STREAM); \ - ASM_DECLARE_RESULT (STREAM, DECL_RESULT (DECL)); \ - } \ - } \ -while (0) - -/* Write the extra assembler code needed to declare a function's result. - Most svr4 assemblers don't require any special declaration of the - result value, but there are exceptions. */ - -#ifndef ASM_DECLARE_RESULT -#define ASM_DECLARE_RESULT(FILE, RESULT) -#endif - -/* This is how to declare the size of a function. */ - -#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ -do \ - { \ - if (TARGET_ELF && !flag_inhibit_size_directive) \ - { \ - char label[256]; \ - static int labelno; \ - labelno++; \ - ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \ - ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \ - fprintf (FILE, "%s", SIZE_ASM_OP); \ - assemble_name (FILE, (FNAME)); \ - fprintf (FILE, ","); \ - assemble_name (FILE, label); \ - fprintf (FILE, "-"); \ - assemble_name (FILE, (FNAME)); \ - putc ('\n', FILE); \ - } \ - } \ -while (0) - -#define IDENT_ASM_OP "\t.ident\t" - -/* Allow #sccs in preprocessor. */ - -#define SCCS_DIRECTIVE - -/* This says what to print at the end of the assembly file */ -#undef ASM_FILE_END -#define ASM_FILE_END(STREAM) \ -do \ - { \ - if (HALF_PIC_P ()) \ - HALF_PIC_FINISH (STREAM); \ - ix86_asm_file_end (STREAM); \ - } \ -while (0) - -/* Tell collect that the object format is OSF/rose. */ -#define OBJECT_FORMAT_ROSE - -/* Tell collect where the appropriate binaries are. */ -#define REAL_NM_FILE_NAME "/usr/ccs/gcc/bfd-nm" -#define REAL_STRIP_FILE_NAME "/usr/ccs/bin/strip" - -/* Define this macro meaning that gcc should find the library 'libgcc.a' - by hand, rather than passing the argument '-lgcc' to tell the linker - to do the search */ -#define LINK_LIBGCC_SPECIAL - -/* Generate calls to memcpy, etc., not bcopy, etc. */ -#define TARGET_MEM_FUNCTIONS - -/* Don't default to pcc-struct-return, because gcc is the only compiler, and - we want to retain compatibility with older gcc versions. */ -#define DEFAULT_PCC_STRUCT_RETURN 0 - -/* Map i386 registers to the numbers dwarf expects. Of course this is - different from what stabs expects. */ - -#undef DBX_REGISTER_NUMBER -#define DBX_REGISTER_NUMBER(n) ((write_symbols == DWARF_DEBUG) \ - ? svr4_dbx_register_map[n] \ - : dbx_register_map[n]) diff --git a/contrib/gcc/config/i386/rtems.h b/contrib/gcc/config/i386/rtems.h deleted file mode 100644 index 0fda632..0000000 --- a/contrib/gcc/config/i386/rtems.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Definitions for rtems targeting an Intel i386 using coff. - Copyright (C) 1996, 1997, 2000, 2002 Free Software Foundation, Inc. - Contributed by Joel Sherrill (joel@OARcorp.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. */ - -/* Specify predefined symbols in preprocessor. */ - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-D__rtems__ -Asystem=rtems" diff --git a/contrib/gcc/config/i386/seq-gas.h b/contrib/gcc/config/i386/seq-gas.h deleted file mode 100644 index d11c4c1..0000000 --- a/contrib/gcc/config/i386/seq-gas.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Definitions for Sequent Intel 386 using GAS. - Copyright (C) 1992 Free Software Foundation, Inc. - -/* Mostly it's like a Sequent 386 without GAS. */ - -#include "i386/sequent.h" - -/* A C statement or statements which output an assembler instruction - opcode to the stdio stream STREAM. The macro-operand PTR is a - variable of type `char *' which points to the opcode name in its - "internal" form--the form that is written in the machine description. - - GAS version 1.38.1 doesn't understand the `repz' opcode mnemonic. - So use `repe' instead. */ - -#undef ASM_OUTPUT_OPCODE -#define ASM_OUTPUT_OPCODE(STREAM, PTR) \ -{ \ - if ((PTR)[0] == 'r' \ - && (PTR)[1] == 'e' \ - && (PTR)[2] == 'p') \ - { \ - if ((PTR)[3] == 'z') \ - { \ - fprintf (STREAM, "repe"); \ - (PTR) += 4; \ - } \ - else if ((PTR)[3] == 'n' && (PTR)[4] == 'z') \ - { \ - fprintf (STREAM, "repne"); \ - (PTR) += 5; \ - } \ - } \ -} - -/* Define macro used to output shift-double opcodes when the shift - count is in %cl. Some assemblers require %cl as an argument; - some don't. - - GAS requires the %cl argument, so override i386/unix.h. */ - -#undef SHIFT_DOUBLE_OMITS_COUNT -#define SHIFT_DOUBLE_OMITS_COUNT 0 - -/* Print opcodes the way that GAS expects them. */ -#define GAS_MNEMONICS 1 diff --git a/contrib/gcc/config/i386/seq-sysv3.h b/contrib/gcc/config/i386/seq-sysv3.h deleted file mode 100644 index c8e7592..0000000 --- a/contrib/gcc/config/i386/seq-sysv3.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Sequent DYNIX/ptx 1.x (SVr3) */ - -#include "i386/sysv3.h" - -/* Sequent Symmetry SVr3 doesn't have crtn.o; crt1.o doesn't work - but crt0.o does. */ - -#undef STARTFILE_SPEC -#define STARTFILE_SPEC \ -"%{pg:gcrt0.o%s}\ - %{!pg:%{posix:%{p:mcrtp0.o%s}%{!p:crtp0.o%s}}\ - %{!posix:%{p:mcrt0.o%s}%{!p:crt0.o%s}}} crtbegin.o%s\ - %{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp}" - -#undef LIB_SPEC -#define LIB_SPEC \ -"%{posix:-lcposix}\ - %{shlib:-lc_s}\ - %{fshared-data:-lpps -lseq} -lc crtend.o%s" - -#undef CPP_SPEC -#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} -D_SEQUENT_=1" - -/* Although the .init section is used, it is not automatically invoked. - This because the _start() function in /lib/crt0.o never calls anything - from the .init section */ -#define INVOKE__main - -/* Assembler pseudo-op for initialized shared variables (.shdata). */ -#undef SHARED_SECTION_ASM_OP -#define SHARED_SECTION_ASM_OP "\t.section .shdata, \"ws\"" - -/* Assembler pseudo-op for uninitialized shared global variables (.shbss). */ -#undef ASM_OUTPUT_SHARED_COMMON -#define ASM_OUTPUT_SHARED_COMMON(FILE, NAME, SIZE, ROUNDED) \ -( fputs(".comm ", (FILE)), \ - assemble_name((FILE), (NAME)), \ - fprintf((FILE), ",%u,-3\n", (SIZE))) - -/* Assembler pseudo-op for uninitialized shared local variables (.shbss). */ -#undef SHARED_BSS_SECTION_ASM_OP -#define SHARED_BSS_SECTION_ASM_OP "\t.section .shbss, \"bs\"" - -/* seq2-sysv3.h used to define HAVE_ATEXIT, so I assume ptx1 needs this... */ -#define NEED_ATEXIT diff --git a/contrib/gcc/config/i386/seq2-sysv3.h b/contrib/gcc/config/i386/seq2-sysv3.h deleted file mode 100644 index dd43af7..0000000 --- a/contrib/gcc/config/i386/seq2-sysv3.h +++ /dev/null @@ -1,7 +0,0 @@ -/* Sequent DYNIX/ptx 2.x (SVr3) */ - -#include "i386/seq-sysv3.h" - -/* Use atexit for static destructors, instead of defining - our own exit function. */ -#undef NEED_ATEXIT diff --git a/contrib/gcc/config/i386/sequent.h b/contrib/gcc/config/i386/sequent.h deleted file mode 100644 index cffc50a..0000000 --- a/contrib/gcc/config/i386/sequent.h +++ /dev/null @@ -1,147 +0,0 @@ -/* Definitions for Sequent Intel 386. - Copyright (C) 1988, 1994, 1999, 2000 Free Software Foundation, Inc. - -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. */ - -#include "i386/i386.h" - -/* Use the BSD assembler syntax. */ - -#include "i386/bsd.h" - -/* By default, don't use IEEE compatible arithmetic comparisons - because the assembler can't handle the fucom insn. - Return float values in the 387. */ - -#undef TARGET_SUBTARGET_DEFAULT -#define TARGET_SUBTARGET_DEFAULT (MASK_80387 | MASK_FLOAT_RETURNS) - -/* Specify predefined symbols in preprocessor. */ - -#define CPP_PREDEFINES "-Dunix -Dsequent -Asystem=unix" - -/* Pass -Z and -ZO options to the linker. */ - -#define LINK_SPEC "%{Z*}" - -#if 0 /* Dynix 3.1 is said to accept -L. */ -/* Dynix V3.0.12 doesn't accept -L at all. */ - -#define LINK_LIBGCC_SPECIAL -#endif - -/* Link with libg.a when debugging, for dbx's sake. */ - -#define LIB_SPEC "%{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} " - -/* We don't want to output SDB debugging information. */ - -#undef SDB_DEBUGGING_INFO - -/* We want to output DBX debugging information. */ - -#define DBX_DEBUGGING_INFO - -/* Sequent Symmetry has size_t defined as int in /usr/include/sys/types.h */ -#define SIZE_TYPE "int" - -/* gcc order is ax, dx, cx, bx, si, di, bp, sp, st, st. - * dbx order is ax, dx, cx, st(0), st(1), bx, si, di, st(2), st(3), - * st(4), st(5), st(6), st(7), sp, bp */ - -#undef DBX_REGISTER_NUMBER -#define DBX_REGISTER_NUMBER(n) \ -((n) < 3 ? (n) : (n) < 6 ? (n) + 2 \ - : (n) == 6 ? 15 : (n) == 7 ? 14 : 3) - -/* malcolmp@hydra.maths.unsw.EDU.AU says these two definitions - fix trouble in dbx. */ -#undef DBX_OUTPUT_LBRAC -#define DBX_OUTPUT_LBRAC(file,name) \ - fprintf (asmfile, "%s%d,0,%d,", ASM_STABN_OP, N_LBRAC, depth); \ - assemble_name (asmfile, buf); \ - fprintf (asmfile, "\n"); - -#undef DBX_OUTPUT_RBRAC -#define DBX_OUTPUT_RBRAC(file,name) \ - fprintf (asmfile, "%s%d,0,%d,", ASM_STABN_OP, N_RBRAC, depth); \ - assemble_name (asmfile, buf); \ - fprintf (asmfile, "\n"); - -/* Prevent anything from being allocated in the register pair cx/bx, - since that would confuse GDB. */ - -#undef HARD_REGNO_MODE_OK -#define HARD_REGNO_MODE_OK(REGNO, MODE) \ - (((REGNO) < 2 ? 1 \ - : (REGNO) < 4 ? 1 \ - : FP_REGNO_P (REGNO) ? (GET_MODE_CLASS (MODE) == MODE_FLOAT \ - || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \ - : (MODE) != QImode) \ - && ! (REGNO == 2 && GET_MODE_UNIT_SIZE (MODE) > 4)) - -/* Output assembler code to FILE to increment profiler label # LABELNO - for profiling a function entry. */ - -#undef FUNCTION_PROFILER -#define FUNCTION_PROFILER(FILE, LABELNO) \ - fprintf (FILE, "\tmovl $.LP%d,%%eax\n\tcall mcount\n", (LABELNO)); - -/* Assembler pseudo-op for shared data segment. */ -#define SHARED_SECTION_ASM_OP "\t.shdata" - -/* A C statement or statements which output an assembler instruction - opcode to the stdio stream STREAM. The macro-operand PTR is a - variable of type `char *' which points to the opcode name in its - "internal" form--the form that is written in the machine description. - - The Sequent assembler (identified as "Balance 8000 Assembler - 07/17/85 3.90" by "as -v") does not understand the `movs[bwl]' string - move mnemonics - it uses `smov[bwl]' instead. Change "movs" into - "smov", carefully avoiding the sign-extend opcodes. */ - -#define ASM_OUTPUT_OPCODE(STREAM, PTR) \ -{ \ - if ((PTR)[0] == 'm' \ - && (PTR)[1] == 'o' \ - && (PTR)[2] == 'v' \ - && (PTR)[3] == 's' \ - && ((PTR)[4] == 'b' || (PTR)[4] == 'w' || (PTR)[4] == 'l') \ - && ((PTR)[5] == ' ' || (PTR)[5] == '\t'|| (PTR)[5] == '\0')) \ - { \ - fprintf (STREAM, "smov"); \ - (PTR) += 4; \ - } \ -} - -/* 10-Aug-92 pes Local labels are prefixed with ".L" */ -#undef LPREFIX -#define LPREFIX ".L" - -#undef ASM_GENERATE_INTERNAL_LABEL -#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER)\ - sprintf ((BUF), "*.%s%ld", (PREFIX), (long)(NUMBER)) - -#undef ASM_OUTPUT_INTERNAL_LABEL -#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)\ - fprintf (FILE, ".%s%d:\n", PREFIX, NUM) - -/* The native compiler passes the address of the returned structure in eax. */ -#undef STRUCT_VALUE -#undef STRUCT_VALUE_INCOMING -#define STRUCT_VALUE_REGNUM 0 diff --git a/contrib/gcc/config/i386/sol2gas.h b/contrib/gcc/config/i386/sol2gas.h deleted file mode 100644 index f8ca103..0000000 --- a/contrib/gcc/config/i386/sol2gas.h +++ /dev/null @@ -1,11 +0,0 @@ -/* Definitions of target machine for GNU compiler, for SPARC running - Solaris 2 with GNU as up to 2.9.5.0.12. - - Copyright (C) 1999 Free Software Foundation, Inc. -*/ - -#ifndef GAS_REJECTS_MINUS_S -#define GAS_REJECTS_MINUS_S 1 -#endif - -/* Assume sol2.h will be included afterwards. */ diff --git a/contrib/gcc/config/i386/sun.h b/contrib/gcc/config/i386/sun.h deleted file mode 100644 index de40abb..0000000 --- a/contrib/gcc/config/i386/sun.h +++ /dev/null @@ -1,83 +0,0 @@ -/* Definitions for Intel 386 running SunOS 4.0. - Copyright (C) 1988, 1995 Free Software Foundation, Inc. - -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. */ - - -#include "i386/i386.h" - -/* Use the Sun assembler syntax. */ - -#include "i386/sun386.h" - -/* Use crt0.o as a startup file. */ - -#define STARTFILE_SPEC \ - "%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}" - -#define LIB_SPEC "%{g:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} \ -%{g:-lg} %{sun386:}" -/* That last item is just to prevent a spurious error. */ - -#undef LINK_SPEC -#define LINK_SPEC \ - "%{!nostdlib:%{!r*:%{!e*:-e _start}}} -dc -dp %{static:-Bstatic}" - -/* Extra switches to give the assembler. */ - -#define ASM_SPEC "%{R} -i386 %{keep-local-as-symbols:-L}" - -/* Specify predefined symbols in preprocessor. */ - -#define CPP_PREDEFINES "-Dunix -Dsun386 -Dsun -Asystem=unix -Asystem=bsd" - -/* Allow #sccs in preprocessor. */ - -#define SCCS_DIRECTIVE - -/* Output #ident as a .ident. */ - -#define ASM_OUTPUT_IDENT(FILE, NAME) fprintf (FILE, "\t.ident \"%s\"\n", NAME); - -/* We don't want to output SDB debugging information. */ - -#undef SDB_DEBUGGING_INFO - -/* We want to output DBX debugging information. */ - -#define DBX_DEBUGGING_INFO - -/* Implicit library calls should use memcpy, not bcopy, etc. */ - -#define TARGET_MEM_FUNCTIONS - -/* Force structure alignment to the type used for a bitfield. */ - -#define PCC_BITFIELD_TYPE_MATTERS 1 - -/* This is partly guess. */ - -#undef DBX_REGISTER_NUMBER -#define DBX_REGISTER_NUMBER(n) \ - ((n) == 0 ? 11 : (n) == 1 ? 9 : (n) == 2 ? 10 : (n) == 3 ? 8 \ - : (n) == 4 ? 5 : (n) == 5 ? 4 : (n) == 6 ? 6 : (n)) - -/* Every debugger symbol must be in the text section. - Otherwise the assembler or the linker screws up. */ - -#define DEBUG_SYMS_TEXT diff --git a/contrib/gcc/config/i386/sun386.h b/contrib/gcc/config/i386/sun386.h deleted file mode 100644 index d280d58..0000000 --- a/contrib/gcc/config/i386/sun386.h +++ /dev/null @@ -1,141 +0,0 @@ -/* Definitions for Sun assembler syntax for the Intel 80386. - Copyright (C) 1988, 1996, 2000 Free Software Foundation, Inc. - -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. */ - - -/* Include common aspects of all 386 Unix assemblers. */ -#include "i386/unix.h" - -#define TARGET_VERSION fprintf (stderr, " (80386, Sun syntax)"); - -/* Define the syntax of instructions and addresses. */ - -/* Prefix for internally generated assembler labels. */ -#define LPREFIX ".L" - -/* Define the syntax of pseudo-ops, labels and comments. */ - -/* Assembler pseudos to introduce constants of various size. */ - -#define ASM_SHORT "\t.value\t" -#define ASM_LONG "\t.long\t" -#define ASM_QUAD "\t.quad\t" /* Should not be used for 32bit compilation. */ - - -/* How to output an ASCII string constant. */ - -#define ASM_OUTPUT_ASCII(FILE, PTR, SIZE) \ -do \ -{ size_t i = 0, limit = (SIZE); \ - while (i < limit) \ - { if (i%10 == 0) { if (i!=0) fprintf ((FILE), "\n"); \ - fputs ("\t.byte\t", (FILE)); } \ - else fprintf ((FILE), ","); \ - fprintf ((FILE), "0x%x", ((PTR)[i++] & 0377)) ;} \ - fprintf ((FILE), "\n"); \ -} while (0) - -/* Output at beginning of assembler file. */ -/* The .file command should always begin the output. */ - -#undef ASM_FILE_START -#define ASM_FILE_START(FILE) \ - do { \ - { \ - const int len = strlen (main_input_filename); \ - const char *na = main_input_filename + len; \ - char shorter[15]; \ - /* NA gets MAIN_INPUT_FILENAME sans directory names. */\ - while (na > main_input_filename) \ - { \ - if (na[-1] == '/') \ - break; \ - na--; \ - } \ - strncpy (shorter, na, 14); \ - shorter[14] = 0; \ - fprintf (FILE, "\t.file\t"); \ - output_quoted_string (FILE, shorter); \ - fprintf (FILE, "\n"); \ - } \ - fprintf (FILE, "\t.version\t\"%s %s\"\n", \ - lang_hooks.name, version_string); \ - if (optimize) ASM_FILE_START_1 (FILE); \ - } while (0) - -#define ASM_FILE_START_1(FILE) fprintf (FILE, "\t.optim\n") - -/* This is how to output an assembler line - that says to advance the location counter - to a multiple of 2**LOG bytes. */ - -#define ASM_OUTPUT_ALIGN(FILE,LOG) \ - if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG)) - -/* This is how to output an assembler line - that says to advance the location counter by SIZE bytes. */ - -#define ASM_OUTPUT_SKIP(FILE,SIZE) \ - fprintf ((FILE), "\t.set\t.,.+%u\n", (SIZE)) - -/* Output before read-only data. */ - -#undef TEXT_SECTION_ASM_OP -#define TEXT_SECTION_ASM_OP "\t.text" - -/* Output before writable data. */ - -#undef DATA_SECTION_ASM_OP -#define DATA_SECTION_ASM_OP "\t.data" - -/* Define the syntax of labels and symbol definitions/declarations. */ - -/* This says how to output an assembler line - to define a global common symbol. */ - -#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ -( fputs (".comm ", (FILE)), \ - assemble_name ((FILE), (NAME)), \ - fprintf ((FILE), ",%u\n", (ROUNDED))) - -/* This says how to output an assembler line - to define a local common symbol. */ - -#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ -( fputs (".lcomm ", (FILE)), \ - assemble_name ((FILE), (NAME)), \ - fprintf ((FILE), ",%u\n", (ROUNDED))) - -/* This is how to store into the string BUF - the symbol_ref name of an internal numbered label where - PREFIX is the class of label and NUM is the number within the class. - This is suitable for output with `assemble_name'. */ - -#define ASM_GENERATE_INTERNAL_LABEL(BUF,PREFIX,NUMBER) \ - sprintf ((BUF), "*.%s%ld", (PREFIX), (long)(NUMBER)) - -/* The prefix to add to user-visible assembler symbols. */ - -#define USER_LABEL_PREFIX "" - -/* This is how to output an internal numbered label where - PREFIX is the class of label and NUM is the number within the class. */ - -#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \ - fprintf (FILE, ".%s%d:\n", PREFIX, NUM) diff --git a/contrib/gcc/config/i386/t-dgux b/contrib/gcc/config/i386/t-dgux deleted file mode 100644 index e1bccee..0000000 --- a/contrib/gcc/config/i386/t-dgux +++ /dev/null @@ -1,11 +0,0 @@ -# -# target makefile for dgux -# -EXTRA_PARTS=crti.o crtbegin.o crtend.o - -crti.o: $(srcdir)/config/i386/sol2-ci.asm $(GCC_PASSES) - sed -e '/^!/d' <$(srcdir)/config/i386/sol2-ci.asm >crti.s - $(GCC_FOR_TARGET) -c -o crti.o crti.s - -# Don't run fixproto -STMP_FIXPROTO = diff --git a/contrib/gcc/config/i386/t-next b/contrib/gcc/config/i386/t-next deleted file mode 100644 index 4b70ba7..0000000 --- a/contrib/gcc/config/i386/t-next +++ /dev/null @@ -1,8 +0,0 @@ -# Specify other dirs of system header files to be fixed. -OTHER_FIXINCLUDES_DIRS= /LocalDeveloper/Headers - -# <limits.h> is sometimes in /usr/include/ansi/limits.h. -LIMITS_H_TEST = [ -f $(SYSTEM_HEADER_DIR)/limits.h -o -f $(SYSTEM_HEADER_DIR)/ansi/limits.h ] - -nextstep.o: $(srcdir)/config/nextstep.c $(CONFIG_H) flags.h tree.h - $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/config/nextstep.c diff --git a/contrib/gcc/config/i386/t-osf b/contrib/gcc/config/i386/t-osf deleted file mode 100644 index c996e0c..0000000 --- a/contrib/gcc/config/i386/t-osf +++ /dev/null @@ -1,2 +0,0 @@ -# If compiling with the osf gcc, avoid sharing code. -TCFLAGS = -pic-none diff --git a/contrib/gcc/config/i386/t-osf1elf b/contrib/gcc/config/i386/t-osf1elf deleted file mode 100644 index 77c7df1..0000000 --- a/contrib/gcc/config/i386/t-osf1elf +++ /dev/null @@ -1,18 +0,0 @@ -# Assemble startup files. -crti.o: $(srcdir)/config/i386/osf1-ci.asm $(GCC_PASSES) - sed -e '/^!/d' <$(srcdir)/config/i386/osf1-ci.asm >crti.s - $(GCC_FOR_TARGET) -c -o crti.o crti.s -crtn.o: $(srcdir)/config/i386/osf1-cn.asm $(GCC_PASSES) - sed -e '/^!/d' <$(srcdir)/config/i386/osf1-cn.asm >crtn.s - $(GCC_FOR_TARGET) -c -o crtn.o crtn.s - -# The pushl in CTOR initialization interferes with frame pointer elimination. - -# We need to use -fPIC when we are using gcc to compile the routines in -# crtstuff.c. This is only really needed when we are going to use gcc/g++ -# to produce a shared library, but since we don't know ahead of time when -# we will be doing that, we just always use -fPIC when compiling the -# routines in crtstuff.c. - -CRTSTUFF_T_CFLAGS = -fPIC -fno-omit-frame-pointer -TARGET_LIBGCC2_CFLAGS = -fPIC diff --git a/contrib/gcc/config/i386/t-sco5gas b/contrib/gcc/config/i386/t-sco5gas deleted file mode 100644 index edeb554..0000000 --- a/contrib/gcc/config/i386/t-sco5gas +++ /dev/null @@ -1,23 +0,0 @@ -# The pushl in CTOR initialization interferes with frame pointer elimination. -CRTSTUFF_T_CFLAGS = -fPIC -fno-omit-frame-pointer -CRTSTUFF_T_CFLAGS_S = -fno-omit-frame-pointer - -# -# I am still a little unsure of the multilib architecture. The following -# 4 lines are based on advice from meissner@cygnus.com. -# -MULTILIB_OPTIONS = fPIC -MULTILIB_DIRNAMES = pic -MULTILIB_EXCEPTIONS = *fPIC* -MULTILIB_MATCHES = fPIC=fpic -MULTILIB_EXTRA_OPTS = - -LIBGCC=stmp-multilib -INSTALL_LIBGCC=install-multilib - -crti.o: $(srcdir)/config/i386/sol2-ci.asm $(GCC_PASSES) - sed -e '/^!/d' <$(srcdir)/config/i386/sol2-ci.asm >crti.s - $(GCC_FOR_TARGET) -c -o crti.o crti.s - -# See all the declarations. -FIXPROTO_DEFINES = -D_XOPEN_SOURCE -D_POSIX_C_SOURCE=2 diff --git a/contrib/gcc/config/i386/v3gas.h b/contrib/gcc/config/i386/v3gas.h deleted file mode 100644 index a350ab4..0000000 --- a/contrib/gcc/config/i386/v3gas.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Definitions for Intel 386 running system V, using gas. - Copyright (C) 1992, 1995 Free Software Foundation, Inc. - -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. */ - -#include <i386/gas.h> - -/* Add stuff that normally comes from i386v.h */ - -/* longjmp may fail to restore the registers if called from the same - function that called setjmp. To compensate, the compiler avoids - putting variables in registers in functions that use both setjmp - and longjmp. */ - -#define NON_SAVING_SETJMP \ - (current_function_calls_setjmp && current_function_calls_longjmp) - -/* longjmp may fail to restore the stack pointer if the saved frame - pointer is the same as the caller's frame pointer. Requiring a frame - pointer in any function that calls setjmp or longjmp avoids this - problem, unless setjmp and longjmp are called from the same function. - Since a frame pointer will be required in such a function, it is OK - that the stack pointer is not restored. */ - -#undef SUBTARGET_FRAME_POINTER_REQUIRED -#define SUBTARGET_FRAME_POINTER_REQUIRED \ - (current_function_calls_setjmp || current_function_calls_longjmp) - -/* Modify ASM_OUTPUT_LOCAL slightly to test -msvr3-shlib, adapted to gas */ -#undef ASM_OUTPUT_LOCAL -#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ - do { \ - int align = exact_log2 (ROUNDED); \ - if (align > 2) align = 2; \ - if (TARGET_SVR3_SHLIB) \ - { \ - data_section (); \ - ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align); \ - ASM_OUTPUT_LABEL ((FILE), (NAME)); \ - fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED)); \ - } \ - else \ - { \ - fputs (".lcomm ", (FILE)); \ - assemble_name ((FILE), (NAME)); \ - fprintf ((FILE), ",%u\n", (ROUNDED)); \ - } \ - } while (0) - -/* Add stuff that normally comes from i386v.h via svr3.h */ - -/* Define the actual types of some ANSI-mandated types. These - definitions should work for most SVR3 systems. */ - -#undef SIZE_TYPE -#define SIZE_TYPE "unsigned int" - -#undef PTRDIFF_TYPE -#define PTRDIFF_TYPE "int" - -#undef WCHAR_TYPE -#define WCHAR_TYPE "long int" - -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE BITS_PER_WORD diff --git a/contrib/gcc/config/nextstep-protos.h b/contrib/gcc/config/nextstep-protos.h deleted file mode 100644 index 1f86e1d..0000000 --- a/contrib/gcc/config/nextstep-protos.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Operating system specific defines to be used when targeting GCC - for NeXTSTEP. - Copyright (C) 2001 Free Software Foundation, Inc. - -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. */ - -extern void nextstep_asm_out_constructor PARAMS ((struct rtx_def *, int)); -extern void nextstep_asm_out_destructor PARAMS ((struct rtx_def *, int)); -extern int handle_pragma PARAMS ((int(*)(void), void (*)(int), const char *)); -extern void constructor_section PARAMS ((void)); -extern void destructor_section PARAMS ((void)); -extern void nextstep_exception_section PARAMS ((void)); -extern void nextstep_eh_frame_section PARAMS ((void)); diff --git a/contrib/gcc/config/nextstep.c b/contrib/gcc/config/nextstep.c deleted file mode 100644 index 228c566..0000000 --- a/contrib/gcc/config/nextstep.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Functions for generic NeXT as target machine for GNU C compiler. - Copyright (C) 1989, 1990, 1991, 1992, 1993, 1996, 1997, 1998, - 2000 Free Software Foundation, Inc. - -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. */ - -#include "config.h" -#include "system.h" -#include "flags.h" -#include "tree.h" -#include "rtl.h" -#include "toplev.h" -#include "output.h" -#include "tm_p.h" - -/* Make everything that used to go in the text section really go there. */ - -int flag_no_mach_text_sections = 0; - -#define OPT_STRCMP(opt) (!strncmp (opt, p, sizeof (opt)-1)) - -/* 1 if handle_pragma has been called yet. */ - -static int pragma_initialized; - -/* Initial setting of `optimize'. */ - -static int initial_optimize_flag; - -/* Called from check_newline via the macro HANDLE_PRAGMA. - FINPUT is the source file input stream. - CH is the first character after `#pragma'. - The result is 1 if the pragma was handled. */ - -int -handle_pragma (p_getc, p_ungetc, pname) - int (* p_getc) PARAMS ((void)) ATTRIBUTE_UNUSED; - void (* p_ungetc) PARAMS ((int)) ATTRIBUTE_UNUSED; - const char *pname; -{ - int retval = 0; - - /* Record initial setting of optimize flag, so we can restore it. */ - if (!pragma_initialized) - { - pragma_initialized = 1; - initial_optimize_flag = optimize; - } - - if (strcmp (pname, "CC_OPT_ON") == 0) - { - optimize = 1; - warning ("optimization turned on"); - retval = 1; - } - else if (strcmp (pname, "CC_OPT_OFF") == 0) - { - optimize = 0; - warning ("optimization turned off"); - retval = 1; - } - else if (strcmp (pname, "CC_OPT_RESTORE") == 0) - { - extern int initial_optimize_flag; - - if (optimize != initial_optimize_flag) - optimize = initial_optimize_flag; - warning ("optimization level restored"); - retval = 1; - } - else if (strcmp (pname, "CC_WRITABLE_STRINGS") == 0) - flag_writable_strings = retval = 1; - else if (strcmp (pname, "CC_NON_WRITABLE_STRINGS") == 0) - flag_writable_strings = 0, retval = 1; - else if (strcmp (pname, "CC_NO_MACH_TEXT_SECTIONS") == 0) - flag_no_mach_text_sections = retval = 1; - - return retval; -} - -void -nextstep_asm_out_constructor (symbol, priority) - rtx symbol; - int priority ATTRIBUTE_UNUSED; -{ - constructor_section (); - assemble_align (POINTER_SIZE); - assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); - fprintf (asm_out_file, ".reference .constructors_used\n"); -} - -void -nextstep_asm_out_destructor (symbol, priority) - rtx symbol; - int priority ATTRIBUTE_UNUSED; -{ - destructor_section (); - assemble_align (POINTER_SIZE); - assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1); - fprintf (asm_out_file, ".reference .destructors_used\n"); -} - diff --git a/contrib/gcc/config/nextstep.h b/contrib/gcc/config/nextstep.h deleted file mode 100644 index 8089633..0000000 --- a/contrib/gcc/config/nextstep.h +++ /dev/null @@ -1,581 +0,0 @@ -/* Operating system specific defines to be used when targeting GCC - for NeXTSTEP. - Copyright (C) 1989, 1990, 1991, 1992, 1993, 1996, 1997, - 1999 Free Software Foundation, Inc. - -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. */ - -/* Use new NeXT include file search path. - In a cross compiler with NeXT as target, don't expect - the host to use Next's directory scheme. */ - -#ifndef CROSS_COMPILE -#undef INCLUDE_DEFAULTS -#define INCLUDE_DEFAULTS \ - { \ - { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \ - { LOCAL_INCLUDE_DIR, 0, 0, 1 }, \ - { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 }, \ - { GCC_INCLUDE_DIR, "GCC", 0, 0 }, \ - /* These are for fixincludes-fixed ansi/bsd headers \ - which wouldn't be found otherwise. \ - (The use of string catenation here is OK since \ - NeXT's native compiler is derived from GCC.) */ \ - { GCC_INCLUDE_DIR "/ansi", 0, 0, 0 }, \ - { GCC_INCLUDE_DIR "/bsd", 0, 0, 0 }, \ - { "/NextDeveloper/Headers", 0, 0, 0 }, \ - { "/NextDeveloper/Headers/ansi", 0, 0, 0 }, \ - { "/NextDeveloper/Headers/bsd", 0, 0, 0 }, \ - { "/LocalDeveloper/Headers", 0, 0, 0 }, \ - { "/LocalDeveloper/Headers/ansi", 0, 0, 0 }, \ - { "/LocalDeveloper/Headers/bsd", 0, 0, 0 }, \ - { "/NextDeveloper/2.0CompatibleHeaders", 0, 0, 0 }, \ - { STANDARD_INCLUDE_DIR, 0, 0, 0 }, \ - { "/usr/include/bsd", 0, 0, 0 }, \ - { 0, 0, 0, 0 } \ - } -#else /* CROSS_COMPILE */ -#undef INCLUDE_DEFAULTS -#define INCLUDE_DEFAULTS \ - { \ - { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \ - { GPLUSPLUS_INCLUDE_DIR, 0, 1, 1 }, \ - { GCC_INCLUDE_DIR, "GCC", 0, 0 }, \ - { GCC_INCLUDE_DIR "/ansi", 0, 0, 0 }, \ - { GCC_INCLUDE_DIR "/bsd", 0, 0, 0 }, \ - { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 }, \ - { TOOL_INCLUDE_DIR "/ansi", 0, 0, 0 }, \ - { TOOL_INCLUDE_DIR "/bsd", 0, 0, 0 }, \ - { "/usr/include/bsd", 0, 0, 0 }, \ - { 0, 0, 0, 0 } \ - } -#endif /* CROSS_COMPILE */ - -#undef EXTRA_FORMAT_FUNCTIONS -#define EXTRA_FORMAT_FUNCTIONS \ - "NXPrintf", FALSE, 2, FALSE, \ - "NXScanf", TRUE, 2, FALSE, \ - "NXVPrintf", FALSE, 2, TRUE, \ - "NXVScanf", TRUE, 2, TRUE, \ - "DPSPrintf", FALSE, 2, FALSE, \ - "bsd_sprintf", FALSE, 2, FALSE, \ - "bsd_vsprintf", FALSE, 2, TRUE, - -/* Make -fnext-runtime the default. */ - -#define NEXT_OBJC_RUNTIME - -/* Enable recent gcc to compile under the old gcc in Next release 1.0. */ - -#define __inline inline - -/* wchar_t is unsigned short */ - -#undef WCHAR_TYPE -#define WCHAR_TYPE "short unsigned int" -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE (BITS_PER_WORD / 2) - -/* Don't default to pcc-struct-return, because gcc is the only compiler, and - we want to retain compatibility with older gcc versions. */ - -#undef DEFAULT_PCC_STRUCT_RETURN -#define DEFAULT_PCC_STRUCT_RETURN 0 - -/* These compiler options take n arguments. */ - -#undef WORD_SWITCH_TAKES_ARG -#define WORD_SWITCH_TAKES_ARG(STR) \ - (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) ? 1 : \ - !strcmp (STR, "segalign") ? 1 : \ - !strcmp (STR, "seg1addr") ? 1 : \ - !strcmp (STR, "segaddr") ? 2 : \ - !strcmp (STR, "sectobjectsymbols") ? 2 : \ - !strcmp (STR, "segprot") ? 3 : \ - !strcmp (STR, "sectcreate") ? 3 : \ - !strcmp (STR, "sectalign") ? 3 : \ - !strcmp (STR, "segcreate") ? 3 : \ - !strcmp (STR, "sectorder") ? 3 : \ - !strcmp (STR, "siff-mask") ? 1 : \ - !strcmp (STR, "siff-filter") ? 1 : \ - !strcmp (STR, "siff-warning") ? 1 : \ - !strcmp (STR, "arch") ? 1 : \ - !strcmp (STR, "pagezero_size") ? 1 : \ - 0) - -#undef WORD_SWITCH -#define WORD_SWITCH(STR) \ - (WORD_SWITCH_TAKES_ARG (STR) \ - || !strcmp (STR, "bsd") \ - || !strcmp (STR, "object") \ - || !strcmp (STR, "ObjC") \ - || !strcmp (STR, "all_load")) - -/* Machine dependent ccp options. */ - -#undef CPP_SPEC -#define CPP_SPEC "%{!traditional: -D__STDC__} \ - %{posixstrict:-D_POSIX_SOURCE} \ - %{!posixstrict:%{bsd:-D__STRICT_BSD__} \ - %{posix:-D_POSIX_SOURCE} \ - %{!ansi:-D_NEXT_SOURCE}} \ - %{MD:-MD %M} %{MMD:-MMD %M}" - -/* Machine dependent ld options. */ - -#undef LINK_SPEC -#define LINK_SPEC "%{Z} %{M} \ -%{execute*} %{preload*} %{fvmlib*} \ -%{segalign*} %{seg1addr*} %{segaddr*} %{segprot*} \ -%{pagezero_size*} \ -%{seglinkedit*} %{noseglinkedit*} \ -%{sectcreate*} %{sectalign*} %{sectobjectsymbols}\ -%{segcreate*} %{Mach*} %{whyload} %{w} \ -%{sectorder*} %{whatsloaded} %{ObjC} %{all_load} %{object}" - -/* Machine dependent libraries. */ - -#undef LIB_SPEC -#define LIB_SPEC "%{!posix*:-lsys_s} %{posix*:-lposix}" - -/* We specify crt0.o as -lcrt0.o so that ld will search the library path. */ - -#undef STARTFILE_SPEC -#define STARTFILE_SPEC \ - "%{!posix*:%{pg:-lgcrt0.o}%{!pg: \ - %{p:%e-p profiling is no longer supported. Use -pg instead} \ - %{!p:-lcrt0.o}}}\ - %{posix*:%{pg:-lgposixcrt0.o}%{!pg: \ - %{p:%e-p profiling is no longer supported. Use -pg instead} \ - %{!p:-lposixcrt0.o}}} \ - -lcrtbegin.o" - -#undef ENDFILE_SPEC -#define ENDFILE_SPEC \ - "-lcrtend.o" - -/* Allow #sscs (but don't do anything). */ - -#define SCCS_DIRECTIVE - -/* We use Dbx symbol format. */ - -#undef SDB_DEBUGGING_INFO -#undef XCOFF_DEBUGGING_INFO -#define DBX_DEBUGGING_INFO - -/* This saves a fair amount of space. */ - -#undef DBX_CONTIN_LENGTH -#define DBX_CONTIN_LENGTH 0 - -/* These screw up NeXT's gdb at the moment, so don't use them. */ - -#undef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY -#define DBX_OUTPUT_MAIN_SOURCE_DIRECTORY(FILE, FILENAME) - -/* These come from bsd386.h, but are specific to sequent, so make sure - they don't bite us. */ - -#undef DBX_NO_XREFS -#undef DBX_CONTIN_LENGTH - -/* gdb needs a null N_SO at the end of each file for scattered loading. */ - -#undef DBX_OUTPUT_MAIN_SOURCE_FILE_END -#define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \ - fprintf (FILE, \ - "\t.text\n\t.stabs \"%s\",%d,0,0,Letext\nLetext:\n", \ - "" , N_SO) - -/* Define our object format type for crtstuff.c */ -#define OBJECT_FORMAT_MACHO - -#undef INIT_SECTION_ASM_OP -#define INIT_SECTION_ASM_OP -#undef INVOKE__main - -#define TARGET_ASM_CONSTRUCTOR nextstep_asm_out_constructor -#define TARGET_ASM_DESTRUCTOR nextstep_asm_out_destructor - -#define TARGET_ASM_EXCEPTION_SECTION nextstep_exception_section - -#define TARGET_ASM_EH_FRAME_SECTION nextstep_eh_frame_section - -/* Don't output a .file directive. That is only used by the assembler for - error reporting. */ -#undef ASM_FILE_START -#define ASM_FILE_START(FILE) - -#undef ASM_FILE_END -#define ASM_FILE_END(FILE) \ - do { \ - if (strcmp (lang_hooks.name, "GNU C++") == 0) \ - { \ - constructor_section (); \ - destructor_section (); \ - ASM_OUTPUT_ALIGN (FILE, 1); \ - } \ - } while (0) - -/* How to parse #pragma's */ - -#undef HANDLE_PRAGMA -#define HANDLE_PRAGMA(GETC, UNGETC, NAME) handle_pragma (GETC, UNGETC, NAME) - -/* Give methods pretty symbol names on NeXT. */ - -#undef OBJC_GEN_METHOD_LABEL -#define OBJC_GEN_METHOD_LABEL(BUF,IS_INST,CLASS_NAME,CAT_NAME,SEL_NAME,NUM) \ - do { if (CAT_NAME) \ - sprintf (BUF, "%c[%s(%s) %s]", (IS_INST) ? '-' : '+', \ - (CLASS_NAME), (CAT_NAME), (SEL_NAME)); \ - else \ - sprintf (BUF, "%c[%s %s]", (IS_INST) ? '-' : '+', \ - (CLASS_NAME), (SEL_NAME)); \ - } while (0) - -/* The prefix to add to user-visible assembler symbols. */ - -#undef USER_LABEL_PREFIX -#define USER_LABEL_PREFIX "_" - -/* Wrap new method names in quotes so the assembler doesn't gag. - Make Objective-C internal symbols local. */ - -#undef ASM_OUTPUT_LABELREF -#define ASM_OUTPUT_LABELREF(FILE,NAME) \ - do { if (NAME[0] == '+' || NAME[0] == '-') fprintf (FILE, "\"%s\"", NAME); \ - else if (!strncmp (NAME, "_OBJC_", 6)) fprintf (FILE, "L%s", NAME); \ - else if (!strncmp (NAME, ".objc_class_name_", 17)) \ - fprintf (FILE, "%s", NAME); \ - else asm_fprintf (FILE, "%U%s", NAME); } while (0) - -#undef ALIGN_ASM_OP -#define ALIGN_ASM_OP "\t.align\t" - -#undef ASM_OUTPUT_ALIGN -#define ASM_OUTPUT_ALIGN(FILE,LOG) \ - if ((LOG) != 0) \ - fprintf (FILE, "%s%d\n", ALIGN_ASM_OP, (LOG)) - -/* Ensure correct alignment of bss data. */ - -#undef ASM_OUTPUT_ALIGNED_LOCAL -#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \ -( fputs (".lcomm ", (FILE)), \ - assemble_name ((FILE), (NAME)), \ - fprintf ((FILE), ",%u,%u\n", (SIZE), floor_log2 ((ALIGN) / BITS_PER_UNIT))) - -/* Output #ident as a .ident. */ - -#undef ASM_OUTPUT_IDENT -#define ASM_OUTPUT_IDENT(FILE, NAME) fprintf (FILE, "\t.ident \"%s\"\n", NAME); - -/* The maximum alignment which the object file format can support. - For NeXT's Mach-O format, this is 2^15. */ - -#undef MAX_OFILE_ALIGNMENT -#define MAX_OFILE_ALIGNMENT 0x8000 - -/* Create new Mach-O sections. */ - -#undef SECTION_FUNCTION -#define SECTION_FUNCTION(FUNCTION, SECTION, DIRECTIVE, WAS_TEXT, OBJC) \ -extern void FUNCTION PARAMS ((void)); \ -void \ -FUNCTION () \ -{ \ - extern int flag_no_mach_text_sections; \ - \ - if (WAS_TEXT && flag_no_mach_text_sections) \ - text_section (); \ - else if (in_section != SECTION) \ - { \ - if (OBJC) \ - objc_section_init (); \ - fprintf (asm_out_file, "%s\n", DIRECTIVE); \ - in_section = SECTION; \ - } \ -} \ - -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS \ - in_const, in_cstring, in_literal4, in_literal8, \ - in_constructor, in_destructor, \ - in_nextstep_exception, in_nextstep_eh_frame, \ - in_objc_class, in_objc_meta_class, in_objc_category, \ - in_objc_class_vars, in_objc_instance_vars, \ - in_objc_cls_meth, in_objc_inst_meth, \ - in_objc_cat_cls_meth, in_objc_cat_inst_meth, \ - in_objc_selector_refs, \ - in_objc_symbols, in_objc_module_info, \ - in_objc_protocol, in_objc_string_object, \ - in_objc_class_names, in_objc_meth_var_names, \ - in_objc_meth_var_types, in_objc_cls_refs - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ -extern void objc_section_init PARAMS ((void)); \ -SECTION_FUNCTION (const_section, \ - in_const, \ - ".const", 1, 0) \ -SECTION_FUNCTION (cstring_section, \ - in_cstring, \ - ".cstring", 1, 0) \ -SECTION_FUNCTION (literal4_section, \ - in_literal4, \ - ".literal4", 1, 0) \ -SECTION_FUNCTION (literal8_section, \ - in_literal8, \ - ".literal8", 1, 0) \ -SECTION_FUNCTION (constructor_section, \ - in_constructor, \ - ".constructor", 0, 0) \ -SECTION_FUNCTION (destructor_section, \ - in_destructor, \ - ".destructor", 0, 0) \ -SECTION_FUNCTION (nextstep_exception_section, \ - in_nextstep_exception, \ - ".section __TEXT,__gcc_except_tab,regular", 0, 0) \ -SECTION_FUNCTION (nextstep_eh_frame_section, \ - in_nextstep_eh_frame, \ - ".section __TEXT,__eh_frame,regular", 0, 0) \ -SECTION_FUNCTION (objc_class_section, \ - in_objc_class, \ - ".objc_class", 0, 1) \ -SECTION_FUNCTION (objc_meta_class_section, \ - in_objc_meta_class, \ - ".objc_meta_class", 0, 1) \ -SECTION_FUNCTION (objc_category_section, \ - in_objc_category, \ - ".objc_category", 0, 1) \ -SECTION_FUNCTION (objc_class_vars_section, \ - in_objc_class_vars, \ - ".objc_class_vars", 0, 1) \ -SECTION_FUNCTION (objc_instance_vars_section, \ - in_objc_instance_vars, \ - ".objc_instance_vars", 0, 1) \ -SECTION_FUNCTION (objc_cls_meth_section, \ - in_objc_cls_meth, \ - ".objc_cls_meth", 0, 1) \ -SECTION_FUNCTION (objc_inst_meth_section, \ - in_objc_inst_meth, \ - ".objc_inst_meth", 0, 1) \ -SECTION_FUNCTION (objc_cat_cls_meth_section, \ - in_objc_cat_cls_meth, \ - ".objc_cat_cls_meth", 0, 1) \ -SECTION_FUNCTION (objc_cat_inst_meth_section, \ - in_objc_cat_inst_meth, \ - ".objc_cat_inst_meth", 0, 1) \ -SECTION_FUNCTION (objc_selector_refs_section, \ - in_objc_selector_refs, \ - ".objc_message_refs", 0, 1) \ -SECTION_FUNCTION (objc_symbols_section, \ - in_objc_symbols, \ - ".objc_symbols", 0, 1) \ -SECTION_FUNCTION (objc_module_info_section, \ - in_objc_module_info, \ - ".objc_module_info", 0, 1) \ -SECTION_FUNCTION (objc_protocol_section, \ - in_objc_protocol, \ - ".objc_protocol", 0, 1) \ -SECTION_FUNCTION (objc_string_object_section, \ - in_objc_string_object, \ - ".objc_string_object", 0, 1) \ -SECTION_FUNCTION (objc_class_names_section, \ - in_objc_class_names, \ - ".objc_class_names", 0, 1) \ -SECTION_FUNCTION (objc_meth_var_names_section, \ - in_objc_meth_var_names, \ - ".objc_meth_var_names", 0, 1) \ -SECTION_FUNCTION (objc_meth_var_types_section, \ - in_objc_meth_var_types, \ - ".objc_meth_var_types", 0, 1) \ -SECTION_FUNCTION (objc_cls_refs_section, \ - in_objc_cls_refs, \ - ".objc_cls_refs", 0, 1) \ - \ -void \ -objc_section_init () \ -{ \ - static int been_here = 0; \ - \ - if (been_here == 0) \ - { \ - been_here = 1; \ - objc_class_section (); \ - objc_meta_class_section (); \ - objc_cat_cls_meth_section (); \ - objc_cat_inst_meth_section (); \ - objc_cls_meth_section (); \ - objc_inst_meth_section (); \ - objc_selector_refs_section (); \ - objc_symbols_section (); \ - objc_category_section (); \ - objc_protocol_section (); \ - objc_class_vars_section (); \ - objc_instance_vars_section (); \ - objc_module_info_section (); \ - objc_string_object_section (); \ - objc_class_names_section (); \ - objc_meth_var_names_section (); \ - objc_meth_var_types_section (); \ - objc_cls_refs_section (); \ - } \ -} - -#undef READONLY_DATA_SECTION -#define READONLY_DATA_SECTION const_section - -#undef SELECT_SECTION -#define SELECT_SECTION(exp,reloc,align) \ - do \ - { \ - if (TREE_CODE (exp) == STRING_CST) \ - { \ - if (flag_writable_strings) \ - data_section (); \ - else if (TREE_STRING_LENGTH (exp) != \ - strlen (TREE_STRING_POINTER (exp)) + 1) \ - readonly_data_section (); \ - else \ - cstring_section (); \ - } \ - else if (TREE_CODE (exp) == INTEGER_CST \ - || TREE_CODE (exp) == REAL_CST) \ - { \ - tree size = TYPE_SIZE (TREE_TYPE (exp)); \ - \ - if (TREE_CODE (size) == INTEGER_CST && \ - TREE_INT_CST_LOW (size) == 4 && \ - TREE_INT_CST_HIGH (size) == 0) \ - literal4_section (); \ - else if (TREE_CODE (size) == INTEGER_CST && \ - TREE_INT_CST_LOW (size) == 8 && \ - TREE_INT_CST_HIGH (size) == 0) \ - literal8_section (); \ - else \ - readonly_data_section (); \ - } \ - else if (TREE_CODE (exp) == CONSTRUCTOR \ - && TREE_TYPE (exp) \ - && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE \ - && TYPE_NAME (TREE_TYPE (exp)) \ - && TREE_CODE (TYPE_NAME (TREE_TYPE (exp))) == IDENTIFIER_NODE \ - && IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp)))) \ - { \ - if (!strcmp (IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (exp))), \ - "NXConstantString")) \ - objc_string_object_section (); \ - else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \ - && !TREE_SIDE_EFFECTS (exp)) \ - readonly_data_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (exp) == VAR_DECL && \ - DECL_NAME (exp) && \ - TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE && \ - IDENTIFIER_POINTER (DECL_NAME (exp)) && \ - !strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6)) \ - { \ - const char *name = IDENTIFIER_POINTER (DECL_NAME (exp)); \ - \ - if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20)) \ - objc_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23)) \ - objc_inst_meth_section (); \ - else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23)) \ - objc_cat_inst_meth_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22)) \ - objc_class_vars_section (); \ - else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25)) \ - objc_instance_vars_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17)) \ - objc_class_names_section (); \ - else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20)) \ - objc_meth_var_names_section (); \ - else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20)) \ - objc_meth_var_types_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22)) \ - objc_cls_refs_section (); \ - else if (!strncmp (name, "_OBJC_CLASS_", 12)) \ - objc_class_section (); \ - else if (!strncmp (name, "_OBJC_METACLASS_", 16)) \ - objc_meta_class_section (); \ - else if (!strncmp (name, "_OBJC_CATEGORY_", 15)) \ - objc_category_section (); \ - else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25)) \ - objc_selector_refs_section (); \ - else if (!strncmp (name, "_OBJC_SYMBOLS", 13)) \ - objc_symbols_section (); \ - else if (!strncmp (name, "_OBJC_MODULES", 13)) \ - objc_module_info_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32)) \ - objc_cat_inst_meth_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20)) \ - objc_cat_cls_meth_section (); \ - else if (!strncmp (name, "_OBJC_PROTOCOL_", 15)) \ - objc_protocol_section (); \ - else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp)) \ - && !TREE_SIDE_EFFECTS (exp)) \ - readonly_data_section (); \ - else \ - data_section (); \ - } \ - else if (TREE_CODE (exp) == VAR_DECL) \ - { \ - if ((flag_pic && reloc) \ - || !TREE_READONLY (exp) || TREE_SIDE_EFFECTS (exp) \ - || !DECL_INITIAL (exp) \ - || (DECL_INITIAL (exp) != error_mark_node \ - && !TREE_CONSTANT (DECL_INITIAL (exp)))) \ - data_section (); \ - else \ - readonly_data_section (); \ - } \ - else \ - readonly_data_section (); \ - } \ - while (0) - -#undef SELECT_RTX_SECTION -#define SELECT_RTX_SECTION(mode, rtx, align) \ - do \ - { \ - if (GET_MODE_SIZE(mode) == 8) \ - literal8_section(); \ - else if (GET_MODE_SIZE(mode) == 4) \ - literal4_section(); \ - else \ - const_section (); \ - } \ - while (0) - -#ifdef ASM_COMMENT_START -# undef ASM_COMMENT_START -#endif - -#define ASM_COMMENT_START ";#" diff --git a/contrib/gcc/config/nextstep21.h b/contrib/gcc/config/nextstep21.h deleted file mode 100644 index 7827054..0000000 --- a/contrib/gcc/config/nextstep21.h +++ /dev/null @@ -1,64 +0,0 @@ -/* nextstep.h -- operating system specific defines to be used when - targeting GCC for NeXTSTEP. - Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. - -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. */ - - -/* changed for NeXTStep 2.1, Ch. Kranz, 2/94, 3/94 */ -#include "nextstep.h" - -/* set flag_gnu_linker=0, use collect2 for linking */ -#undef USE_COLLECT2 -#define USE_COLLECT2 - -/* use this until a newer gdb for NeXTStep21 is available */ -#define DEFAULT_GDB_EXTENSIONS 0 - -/* we need the call to __main to start all global destructors and constructors - correctly, so undef INIT_SECTION_ASM_OP, (see libgcc2.c line 1965) - and define INVOKE_main */ -#undef INIT_SECTION_ASM_OP -#define INVOKE__main - -/* We call the global destructors, constructors from __main */ -#undef TARGET_ASM_CONSTRUCTOR -#undef TARGET_ASM_DESTRUCTOR - -#undef ASM_FILE_END -#define ASM_FILE_END(FILE) \ - do { \ - if (strcmp (lang_hooks.name, "GNU C++") == 0) \ - { \ - ASM_OUTPUT_ALIGN (FILE, 1); \ - } \ - } while (0) -/* deleted: destructor_section (); \ */ -/* deleted: constructor_section (); \ */ - -/* Ensure correct alignment of bss data. */ -/* ASM_OUTPUT_ALIGNED_LOCAL not needed */ -/* need ASM_OUTPUT_LOCAL instead for old NeXT-as */ -/* look in varasm.c, line 1062 and 1476 */ -#undef ASM_OUTPUT_ALIGNED_LOCAL -#undef ASM_OUTPUT_LOCAL -#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ -( fputs (".lcomm ", (FILE)), \ - assemble_name ((FILE), (NAME)), \ - fprintf ((FILE), ",%u\n", (ROUNDED))) - diff --git a/contrib/gcc/config/rs6000/softfloat.h b/contrib/gcc/config/rs6000/softfloat.h deleted file mode 100644 index c0dc10d..0000000 --- a/contrib/gcc/config/rs6000/softfloat.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Target definitions for GNU compiler for PowerPC defaulting to -msoft-float - Copyright (C) 2001 - Free Software Foundation, Inc. - Contributed by Red Hat Inc. - -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. */ - -#undef CPP_FLOAT_DEFAULT_SPEC -#define CPP_FLOAT_DEFAULT_SPEC "-D_SOFT_FLOAT" diff --git a/contrib/gcc/config/s390/t-linux b/contrib/gcc/config/s390/t-linux deleted file mode 100644 index bc8d519..0000000 --- a/contrib/gcc/config/s390/t-linux +++ /dev/null @@ -1,7 +0,0 @@ -# The crtbegin and crtend must not depend on a small GOT -CRTSTUFF_T_CFLAGS = -O2 -fPIC -CRTSTUFF_T_CFLAGS_S = -O2 -fPIC - -# Compile libgcc2.a with pic. -TARGET_LIBGCC2_CFLAGS = -fPIC -include $(srcdir)/config/s390/fixdfdi.h - diff --git a/contrib/gcc/config/sparc/rtems.h b/contrib/gcc/config/sparc/rtems.h deleted file mode 100644 index e537f1c..0000000 --- a/contrib/gcc/config/sparc/rtems.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Definitions for rtems targeting a SPARC using a.out. - Copyright (C) 1996, 1997, 2000, 2002 Free Software Foundation, Inc. - Contributed by Joel Sherrill (joel@OARcorp.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. */ - - -/* Specify predefined symbols in preprocessor. */ - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-Dsparc -D__GCC_NEW_VARARGS__ -D__rtems__ \ - -Asystem=rtems" diff --git a/contrib/gcc/config/sparc/sol2-g1.asm b/contrib/gcc/config/sparc/sol2-g1.asm deleted file mode 100644 index b9d8788..0000000 --- a/contrib/gcc/config/sparc/sol2-g1.asm +++ /dev/null @@ -1,88 +0,0 @@ -! gcrt1.s for solaris 2.0. - -! Copyright (C) 1992 Free Software Foundation, Inc. -! Written By David Vinayak Henkel-Wallace, June 1992 -! -! This file 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. -! -! In addition to the permissions in the GNU General Public License, the -! Free Software Foundation gives you unlimited permission to link the -! compiled version of this file with other programs, and to distribute -! those programs without any restriction coming from the use of this -! file. (The General Public License restrictions do apply in other -! respects; for example, they cover modification of the file, and -! distribution when not linked into another program.) -! -! This file 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; 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 GCC 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. -! - -! This file takes control of the process from the kernel, as specified -! in section 3 of the SVr4 ABI. -! This file is the first thing linked into any executable. - - .section ".text" - .proc 022 - .global _start - -_start: - mov 0, %fp ! Mark bottom frame pointer - ld [%sp + 64], %l0 ! argc - add %sp, 68, %l1 ! argv - - ! Leave some room for a call. Sun leaves 32 octets (to sit on - ! a cache line?) so we do too. - sub %sp, 32, %sp - - ! %g1 may contain a function to be registered w/atexit - orcc %g0, %g1, %g0 - be .nope - mov %g1, %o0 - call atexit - nop -.nope: - ! Now make sure constructors and destructors are handled. - set _fini, %o0 - call atexit, 1 - nop - call _init, 0 - nop - - ! We ignore the auxiliary vector; there's no defined way to - ! access those data anyway. Instead, go straight to main: - mov %l0, %o0 ! argc - mov %l1, %o1 ! argv - set ___Argv, %o3 - st %o1, [%o3] ! *___Argv - ! Skip argc words past argv, to env: - sll %l0, 2, %o2 - add %o2, 4, %o2 - add %l1, %o2, %o2 ! env - set _environ, %o3 - st %o2, [%o3] ! *_environ - call main, 4 - nop - call exit, 0 - nop - call _exit, 0 - nop - ! We should never get here. - - .type _start,#function - .size _start,.-_start diff --git a/contrib/gcc/config/sparc/sol27-sld.h b/contrib/gcc/config/sparc/sol27-sld.h deleted file mode 100644 index fb47b61..0000000 --- a/contrib/gcc/config/sparc/sol27-sld.h +++ /dev/null @@ -1,8 +0,0 @@ -/* Up through Solaris 2.7, the system linker does not work with DWARF - or DWARF2, since it does not have working support for relocations - to unaligned data. */ - -#undef DWARF_DEBUGGING_INFO -#undef DWARF2_DEBUGGING_INFO -#undef PREFERRED_DEBUGGING_TYPE -#undef ASM_DEBUG_SPEC diff --git a/contrib/gcc/config/t-install-cpp b/contrib/gcc/config/t-install-cpp deleted file mode 100644 index 9f88754..0000000 --- a/contrib/gcc/config/t-install-cpp +++ /dev/null @@ -1,3 +0,0 @@ -# Handle cpp installation. -INSTALL_CPP=install-cpp -UNINSTALL_CPP=uninstall-cpp diff --git a/contrib/gcc/cp/mpw-config.in b/contrib/gcc/cp/mpw-config.in deleted file mode 100644 index 88dd85f..0000000 --- a/contrib/gcc/cp/mpw-config.in +++ /dev/null @@ -1,11 +0,0 @@ -# Configuration fragment for G++. -# Most of the real configuration work happens in the main GCC configure. - -# We need to join some lines in the Makefile.in before the sed -# process will work properly. The funky little sed script works by -# recognizing lines with a trailing '$@ \', adding the next line to -# its "pattern space", editing out the backslash and line, then -# putting the result out. - -sed -e '/$@ \\/{N;s/$@ \\./$@ /;P;D;}' \Option-d - "{srcdir}"Makefile.in >"{o}"hacked_Makefile.in diff --git a/contrib/gcc/cp/mpw-make.sed b/contrib/gcc/cp/mpw-make.sed deleted file mode 100644 index 120b5a1..0000000 --- a/contrib/gcc/cp/mpw-make.sed +++ /dev/null @@ -1,112 +0,0 @@ -# Sed commands to finish translating the G++ Unix makefile into MPW syntax. - -# Remove control-Ls, they upset MPW make. -s///g - -# Remove references to always-empty variables used to mark things. -/CYGNUS-LOCAL-/s/{CYGNUS-LOCAL-[a-z0-9]*}//g - -# Add a bunch of definitions, mostly empty. -/^# Variables that exist for you to override.$/a\ -\ -xmake_file = \ -tmake_file = \ -build_xm_file = \ -MALLOC = \ -MD_DEPS = \ -REAL_H = \ -HOST_CC_LD = {CC_LD}\ -ALL_CCLDFLAGS = \ -HOST_CCLDFLAGS = \ -CONFIG_H = \ -LIBDEPS = \ - -# The "target" variable is special to MPW make, avoid it. -/{target}/s/{target}/{target_canonical}/g - -# Suppress the suppression of smart makes. -/^\.y\.c/d - -# Whack out "..." assignments. -/\.\.\./s/^\([a-z_]*= \.\.\.\)/#\1/ - -# Previous edits go a little overboard, undo. -/^objext = /s/"{o}"// - -# Always link in low-level MPW functions. -/^LIBDEPS=/s/$/ ::strerror.c.o ::mpwlib.c.o/ -/{CLIB}/s/{CLIB}/ ::strerror.c.o ::mpwlib.c.o {CLIB}/ - -# Don't get tricky about finding various .o file, point at dir above. -/^SUBDIR_OBSTACK/s/`.*`/::obstack.c.o/ -/^SUBDIR_USE_ALLOCA/s/`.*`/::alloca.c.o/ -/^SUBDIR_MALLOC/s/`.*`// - -# Point includes at parent directly correctly. -/^INCLUDES = /s/:\./::/g -/^INCLUDES = /s/"{srcdir}"\.\./"{topsrcdir}"gcc:/g -/^INCLUDES = /s,"{srcdir}"/\.\.,"{topsrcdir}"gcc:,g -/^INCLUDES = /s,"{srcdir}":config,"{topsrcdir}"gcc:config:,g - -# Add the special MPW include dirs. -/^INCLUDES = /s/$/ -i "{topsrcdir}"include:mpw: -i :::extra-include:/ - -# A nasty hack to reduce confusion. -/true/s/ ; @true$// - -# (should be in common translation?) -/{CC_LD} /s/$/ {EXTRALIBS}/ - -# Don't use general compiler flags (which may include definitions -# and other compiler-only bits) with linking commands. -/{CC_LD} /s/ALL_CFLAGS/ALL_CCLDFLAGS/ - -# Whack out build rules that are not useful. -/^Makefile \\Option-f /,/^$/d -/^config.status \\Option-f /,/^$/d -# (Note that MPW make is not case sensitive, and so this name -# is considered the same as "md_file".) -/^{MD_FILE} \\Option-f/,/^$/d - -# Depending on config.status is not useful for us. -/config.status/s/ config.status// - -# Repeat of stuff from generic edit. -/{s}/s/"{s}""{s}"/"{s}"/g -/{s}/s/"{s}""{srcdir}"/"{s}"/g -/{s}/s/"{srcdir}""{s}"/"{s}"/g - -# Fix references to C frontend files in main dir. -/::c-/s/"{o}"::c-/"{o}":c-/g - -# Fix pathnames to generated files in the objdir. -/parse/s/"{s}"parse\.\([chy]\)/"{o}"parse.\1/g -/parse/s/^parse\.\([chy]\)/"{o}"parse.\1/ -/y.tab.c/s/"{s}"y\.tab\.c/"{o}"y.tab.c/g -/y.tab.c/s/^y\.tab\.c/"{o}"y.tab.c/ -/y.tab.h/s/"{s}"y\.tab\.h/"{o}"y.tab.h/g -/y.tab.h/s/^y\.tab\.h/"{o}"y.tab.h/ - -# Put in the definition of YYEMPTY directly. -/grep/s/grep .* >>/Echo '#define YYEMPTY -1' >>/ - -# If the dates are wrong, then this tries to run gperf, which we don't -# really want. -/^"{srcdir}"hash.h/,/hash.h$/d - -# Sed the object file list instead of using cat (meow). -/cat/s/`cat /`sed -e 's,:,::,g' -e 's,{objext},.o,g' / - -# Simplify dependencies of generated parser files. -/^{PARSE_C}/s/^/#/ -/^stamp-parse/s/^stamp-parse/{PARSE_C}/ - -# Fix the compile line for the generated parser. -/{CC} -c/,/echo {PARSE_C}/c\ - {CC} @DASH_C_FLAG@ {ALL_CFLAGS} {ALL_CPPFLAGS} {INCLUDES} {BIG_SWITCHFLAG} "{o}"parse.c -o "{o}"parse.c.o\ - -# Change all Rez commands to use mac-gcc.r. -/{REZ}/s/"{s}"[-a-zA-Z{}]*\.r/"{topsrcdir}"gcc:mac-gcc.r/ - -# Remove pathname junk from the container name. -/{REZ}/s/'"'::cc1plus'"'/'"'cc1plus'"'/ diff --git a/contrib/gcc/dependence.c b/contrib/gcc/dependence.c deleted file mode 100644 index 1a5564d..0000000 --- a/contrib/gcc/dependence.c +++ /dev/null @@ -1,1467 +0,0 @@ -/* Analyze loop dependencies - Copyright (C) 2000, 2002 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC 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. - -GCC 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 GCC; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ - -/* References: - Practical Dependence Testing, Goff, Kennedy, Tseng, PLDI, 1991 - High Performance Compilers for Parallel Computing, Wolfe -*/ - -#include "config.h" -#include "system.h" - -#include "rtl.h" -#include "expr.h" -#include "tree.h" -#include "c-common.h" -#include "flags.h" -#include "varray.h" - -#define MAX_SUBSCRIPTS 13 - -/* - We perform the following steps: - - Build the data structures def_use_chain, loop_chain, and induction_chain. - - Determine if a loop index is a normalized induction variable. - A loop is currently considered to be a for loop having an index set to an - initial value, conditional check of the index, and increment/decrement of - the index. - - Determine the distance and direction vectors. Both are two dimensioned - arrays where the first dimension represents a loop and the second - dimension represents a subscript. Dependencies are actually per loop, not - per subscript. So for: - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - array [i][j] = array[i][j-1] - We find the dependencies: loop1/sub_i, loop1/sub_j, loop2/sub_i, loop2/sub_j - and then intersect loop1/sub_i V loop2/sub_i and loop1/sub_i V loop2/sub_j - We determine the type of dependence, which determines which test we use. - We then try to refine the type of dependence we have and add the - dependence to the dep_chain -*/ - -enum dependence_type {dt_flow, dt_anti, dt_output, dt_none}; -#if 0 -static const char *const dependence_string [] = {"flow", "anti", "output", "none"}; -#endif -enum direction_type {lt, le, eq, gt, ge, star, independent, undef}; -#if 0 -static const char *const direction_string [] = {"<", "<=", "=", ">", ">=", "*", - "INDEPENDENT", "UNDEFINED"}; -#endif -enum def_use_type {def, use, init_def_use}; - -enum du_status_type {seen, unseen}; - -enum loop_status_type {normal, unnormal}; - -enum complexity_type {ziv, strong_siv, weak_siv, weak_zero_siv, - weak_crossing_siv, miv}; - -/* Given a def/use one can chase the next chain to follow the def/use - for that variable. Alternately one can sequentially follow each - element of def_use_chain. */ - -typedef struct def_use -{ - /* outermost loop */ - tree outer_loop; - /* loop containing this def/use */ - tree containing_loop; - /* this expression */ - tree expression; - /* our name */ - const char *variable; - /* def or use */ - enum def_use_type type; - /* status flags */ - enum du_status_type status; - /* next def/use for this same name */ - struct def_use *next; - /* dependencies for this def */ - struct dependence *dep; -} def_use; - -/* Given a loop* one can chase the next_nest chain to follow the nested - loops for that loop. Alternately one can sequentially follow each - element of loop_chain and check outer_loop to get all loops - contained within a certain loop. */ - -typedef struct loop -{ - /* outermost loop containing this loop */ - tree outer_loop; - /* this loop */ - tree containing_loop; - /* nest level for this loop */ - int depth; - /* can loop be normalized? */ - enum loop_status_type status; - /* loop* for loop contained in this loop */ - struct loop *next_nest; - /* induction variables for this loop. Currently only the index variable. */ - struct induction *ind; -} loop; - -/* Pointed to by loop. One per induction variable. */ - -typedef struct induction -{ - /* our name */ - const char *variable; - /* increment. Currently only +1 or -1 */ - int increment; - /* lower bound */ - int low_bound; - /* upper bound */ - int high_bound; - /* next induction variable for this loop. Currently null. */ - struct induction *next; -} induction; - -/* Pointed to by def/use. One per dependence. */ - -typedef struct dependence -{ - tree source; - tree destination; - enum dependence_type dependence; - enum direction_type direction[MAX_SUBSCRIPTS]; - int distance[MAX_SUBSCRIPTS]; - struct dependence *next; -} dependence; - -/* subscripts are represented by an array of these. Each reflects one - X * i + Y term, where X and Y are constants. */ - -typedef struct subscript -{ - /* ordinal subscript number */ - int position; - /* X in X * i + Y */ - int coefficient; - /* Y in X * i + Y */ - int offset; - /* our name */ - const char *variable; - /* next subscript term. Currently null. */ - struct subscript *next; -} subscript; - -/* Remember the destination the front end encountered. */ - -static tree dest_to_remember; - -/* Chain for def_use */ -static varray_type def_use_chain; - -/* Chain for dependence */ -static varray_type dep_chain; - -/* Chain for loop */ -static varray_type loop_chain; - -/* Chain for induction */ -static varray_type induction_chain; - -void init_dependence_analysis PARAMS ((tree)); -static void build_def_use PARAMS ((tree, enum def_use_type)); -static loop* add_loop PARAMS ((tree, tree, int)); -static int find_induction_variable PARAMS ((tree, tree, tree, loop*)); -static int get_low_bound PARAMS ((tree, const char*)); -static int have_induction_variable PARAMS ((tree, const char*)); -static void link_loops PARAMS ((void)); -static void get_node_dependence PARAMS ((void)); -static void check_node_dependence PARAMS ((def_use*)); -static int get_coefficients PARAMS ((def_use*, subscript[])); -static int get_one_coefficient PARAMS ((tree, subscript*, def_use*, enum tree_code*)); -static void normalize_coefficients PARAMS ((subscript[], loop*, int)); -static void classify_dependence PARAMS ((subscript[], subscript[], - enum complexity_type[], int*, int)); -static void ziv_test PARAMS ((subscript[], subscript[], - enum direction_type[][MAX_SUBSCRIPTS], - int[][MAX_SUBSCRIPTS], loop*, int)); -static void siv_test PARAMS ((subscript[], subscript[], - enum direction_type[][MAX_SUBSCRIPTS], - int[][MAX_SUBSCRIPTS], loop*, int)); -static int check_subscript_induction PARAMS ((subscript*, subscript*, loop*)); -static void gcd_test PARAMS ((subscript[], subscript[], enum - direction_type[][MAX_SUBSCRIPTS], - int[][MAX_SUBSCRIPTS], loop*, int)); -static int find_gcd PARAMS ((int, int)); -static void merge_dependencies PARAMS ((enum direction_type[][MAX_SUBSCRIPTS], - int[][MAX_SUBSCRIPTS], int, int)); -static void dump_array_ref PARAMS ((tree)); -#if 0 -static void dump_one_node PARAMS ((def_use*, varray_type*)); -static void dump_node_dependence PARAMS ((void)); -#endif -int search_dependence PARAMS ((tree)); -void remember_dest_for_dependence PARAMS ((tree)); -int have_dependence_p PARAMS ((rtx, rtx, enum direction_type[], int[])); -void end_dependence_analysis PARAMS ((void)); - -/* Build dependence chain 'dep_chain', which is used by have_dependence_p, - for the function given by EXP. */ - -void -init_dependence_analysis (exp) - tree exp; -{ - def_use *du_ptr; - - VARRAY_GENERIC_PTR_INIT (def_use_chain, 50, "def_use_chain"); - VARRAY_GENERIC_PTR_INIT (dep_chain, 50, "dep_chain"); - VARRAY_GENERIC_PTR_INIT (loop_chain, 50, "loop_chain"); - VARRAY_GENERIC_PTR_INIT (induction_chain, 50, "induction_chain"); - - build_def_use (exp, init_def_use); - - link_loops (); - - get_node_dependence (); - - /* dump_node_dependence (&def_use_chain);*/ - - for (du_ptr = VARRAY_TOP (def_use_chain, generic); - VARRAY_POP (def_use_chain); - du_ptr = VARRAY_TOP (def_use_chain, generic)) - { - free (du_ptr); - } - - VARRAY_FREE (def_use_chain); - VARRAY_FREE (loop_chain); - VARRAY_FREE (induction_chain); -} - -/* Build ARRAY_REF def/use info 'def_use_chain' starting at EXP which is a def - or use DU_TYPE */ - -static void -build_def_use (exp, du_type) - tree exp; - enum def_use_type du_type; -{ - static tree outer_loop; - static int nloop; - static tree current_loop; - static int du_idx; - static loop *loop_def; - tree node = exp; - tree array_ref; - def_use *du_ptr; - - if (du_type == init_def_use) - { - outer_loop = 0; - nloop = 0; - du_idx = 0; - } - - while (node) - switch (TREE_CODE (node)) - { - case COMPOUND_STMT: - node = TREE_OPERAND (node, 0); - break; - case TREE_LIST: - build_def_use (TREE_VALUE (node), 0); - node = TREE_CHAIN (node); - break; - case CALL_EXPR: - node = TREE_CHAIN (node); - break; - case FOR_STMT: - if (! nloop) outer_loop = node; - nloop++; - current_loop = node; - loop_def = add_loop (node, outer_loop, nloop); - if (find_induction_variable (TREE_OPERAND (node, 0), - TREE_OPERAND (node, 1), - TREE_OPERAND (node, 2), loop_def) - == 0) - loop_def->status = unnormal; - - build_def_use (TREE_OPERAND (node, 3), 0); - nloop--; - current_loop = 0; - node = TREE_CHAIN (node); - break; - case MODIFY_EXPR: - /* Is an induction variable modified? */ - if (loop_def - && TREE_CODE (TREE_OPERAND (node, 0)) == VAR_DECL - && have_induction_variable - (loop_def->outer_loop, - IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (node, 0)))) >= 0) - loop_def->status = unnormal; - - if (TREE_CODE (TREE_OPERAND (node, 0)) == ARRAY_REF - || TREE_CODE (TREE_OPERAND (node, 0)) == INDIRECT_REF) - build_def_use (TREE_OPERAND (node, 0), def); - - build_def_use (TREE_OPERAND (node, 1), use); - node = TREE_CHAIN (node); - break; - case INDIRECT_REF: - if (! TREE_OPERAND (node, 1) - || TREE_CODE (TREE_OPERAND (node, 1)) != ARRAY_REF) - { - node = 0; - break; - } - node = TREE_OPERAND (node, 1); - case ARRAY_REF: - if (nloop) - { - int i; - char null_string = '\0'; - - VARRAY_PUSH_GENERIC_PTR (def_use_chain, xmalloc (sizeof (def_use))); - du_ptr = VARRAY_GENERIC_PTR (def_use_chain, du_idx++); - du_ptr->type = du_type; - du_ptr->status = unseen; - du_ptr->outer_loop = outer_loop; - du_ptr->containing_loop = current_loop; - du_ptr->expression = node; - du_ptr->variable = &null_string; - du_ptr->next = 0; - du_ptr->dep = 0; - for (array_ref = node; - TREE_CODE (array_ref) == ARRAY_REF; - array_ref = TREE_OPERAND (array_ref, 0)) - ; - - if (TREE_CODE (array_ref) == COMPONENT_REF) - { - array_ref = TREE_OPERAND (array_ref, 1); - if (! (TREE_CODE (array_ref) == FIELD_DECL - && TREE_CODE (TREE_TYPE (array_ref)) == ARRAY_TYPE)) - { - node = 0; - break; - } - } - - for (i = 0; - i < du_idx - && strcmp (IDENTIFIER_POINTER (DECL_NAME (array_ref)), - ((def_use*) (VARRAY_GENERIC_PTR - (def_use_chain, i)))->variable); - i++) - ; - if (i != du_idx) - { - def_use *tmp_duc; - for (tmp_duc = ((def_use*) (VARRAY_GENERIC_PTR (def_use_chain, i))); - tmp_duc->next; - tmp_duc = ((def_use*)tmp_duc->next)); - tmp_duc->next = du_ptr; - } - else du_ptr->next = 0; - du_ptr->variable = IDENTIFIER_POINTER (DECL_NAME (array_ref)); - } - node = 0; - break; - - case SCOPE_STMT: - case DECL_STMT: - node = TREE_CHAIN (node); - break; - - case EXPR_STMT: - if (TREE_CODE (TREE_OPERAND (node, 0)) == MODIFY_EXPR) - build_def_use (TREE_OPERAND (node, 0), def); - node = TREE_CHAIN (node); - break; - - default: - if (TREE_CODE_CLASS (TREE_CODE (node)) == '2') - { - build_def_use (TREE_OPERAND (node, 0), use); - build_def_use (TREE_OPERAND (node, 1), use); - node = TREE_CHAIN (node); - } - else - node = 0; - } -} - -/* Add a loop to 'loop_chain' corresponding to for loop LOOP_NODE at depth - NLOOP, whose outermost loop is OUTER_LOOP */ - -static loop* -add_loop (loop_node, outer_loop, nloop) - tree loop_node; - tree outer_loop; - int nloop; -{ - loop *loop_ptr; - - VARRAY_PUSH_GENERIC_PTR (loop_chain, xmalloc (sizeof (loop))); - loop_ptr = VARRAY_TOP (loop_chain, generic); - loop_ptr->outer_loop = outer_loop; - loop_ptr->containing_loop = loop_node; - loop_ptr->depth = nloop; - loop_ptr->status = normal; - loop_ptr->next_nest = 0; - loop_ptr->ind = 0; - return loop_ptr; -} - -/* Update LOOP_DEF if for loop's COND_NODE and INCR_NODE define an index that - is a normalized induction variable. */ - -static int -find_induction_variable (init_node, cond_node, incr_node, loop_def) - tree init_node; - tree cond_node; - tree incr_node; - loop *loop_def; -{ - induction *ind_ptr; - enum tree_code incr_code; - tree incr; - - if (! init_node || ! incr_node || ! cond_node) - return 0; - /* Allow for ',' operator in increment expression of FOR */ - - incr = incr_node; - while (TREE_CODE (incr) == COMPOUND_EXPR) - { - incr_code = TREE_CODE (TREE_OPERAND (incr, 0)); - if (incr_code == PREDECREMENT_EXPR || incr_code == POSTDECREMENT_EXPR - || incr_code == PREINCREMENT_EXPR || incr_code == POSTINCREMENT_EXPR) - { - incr_node = TREE_OPERAND (incr, 0); - break; - } - incr_code = TREE_CODE (TREE_OPERAND (incr, 1)); - if (incr_code == PREDECREMENT_EXPR || incr_code == POSTDECREMENT_EXPR - || incr_code == PREINCREMENT_EXPR || incr_code == POSTINCREMENT_EXPR) - { - incr_node = TREE_OPERAND (incr, 1); - break; - } - incr = TREE_OPERAND (incr, 1); - } - - /* Allow index condition to be part of logical expression */ - cond_node = TREE_VALUE (cond_node); - incr = cond_node; - -#define INDEX_LIMIT_CHECK(NODE) \ - (TREE_CODE_CLASS (TREE_CODE (NODE)) == '<') \ - && (TREE_CODE (TREE_OPERAND (NODE, 0)) == VAR_DECL \ - && (IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (NODE, 0))) \ - == IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (incr_node, 0))))) \ - ? 1 : 0 - - while (TREE_CODE (incr) == TRUTH_ANDIF_EXPR - || TREE_CODE (incr) == TRUTH_ORIF_EXPR) - { - if (INDEX_LIMIT_CHECK (TREE_OPERAND (incr, 0))) - { - cond_node = TREE_OPERAND (incr, 0); - break; - } - if (INDEX_LIMIT_CHECK (TREE_OPERAND (incr, 1))) - { - cond_node = TREE_OPERAND (incr, 1); - break; - } - incr = TREE_OPERAND (incr, 0); - } - - incr_code = TREE_CODE (incr_node); - if ((incr_code == PREDECREMENT_EXPR || incr_code == POSTDECREMENT_EXPR - || incr_code == PREINCREMENT_EXPR || incr_code == POSTINCREMENT_EXPR) - && TREE_CODE_CLASS (TREE_CODE (cond_node)) == '<') - { - if (!INDEX_LIMIT_CHECK (cond_node)) - return 0; - - VARRAY_PUSH_GENERIC_PTR (induction_chain, xmalloc (sizeof (induction))); - ind_ptr = VARRAY_TOP (induction_chain, generic); - loop_def->ind = ind_ptr; - ind_ptr->variable = IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND - (incr_node, 0))); - ind_ptr->increment = TREE_INT_CST_LOW (TREE_OPERAND (incr_node, 1)); - if (TREE_CODE (incr_node) == PREDECREMENT_EXPR - || TREE_CODE (incr_node) == POSTDECREMENT_EXPR) - ind_ptr->increment = -ind_ptr->increment; - - ind_ptr->low_bound = get_low_bound (init_node, ind_ptr->variable); - if (TREE_CODE (TREE_OPERAND (cond_node, 0)) == VAR_DECL - && IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (cond_node, 0))) - == ind_ptr->variable) - { - if (TREE_CODE (TREE_OPERAND (cond_node, 1)) == INTEGER_CST) - ind_ptr->high_bound = - TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 1)); - else - ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX; - } - else if (TREE_CODE (TREE_OPERAND (cond_node, 1)) == VAR_DECL - && IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (cond_node, 1))) - == ind_ptr->variable) - { - if (TREE_CODE (TREE_OPERAND (cond_node, 0)) == INTEGER_CST) - ind_ptr->high_bound = - TREE_INT_CST_LOW (TREE_OPERAND (cond_node, 0)); - else - ind_ptr->high_bound = ind_ptr->increment < 0 ? INT_MIN : INT_MAX; - } - ind_ptr->next = 0; - return 1; - } - return 0; -} - -/* Return the low bound for induction VARIABLE in NODE */ - -static int -get_low_bound (node, variable) - tree node; - const char *variable; -{ - - if (TREE_CODE (node) == SCOPE_STMT) - node = TREE_CHAIN (node); - - if (! node) - return INT_MIN; - - while (TREE_CODE (node) == COMPOUND_EXPR) - { - if (TREE_CODE (TREE_OPERAND (node, 0)) == MODIFY_EXPR - && (TREE_CODE (TREE_OPERAND (node, 0)) == VAR_DECL - && IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (node, 0))) - == variable)) - break; - } - - if (TREE_CODE (node) == EXPR_STMT) - node = TREE_OPERAND (node, 0); - if (TREE_CODE (node) == MODIFY_EXPR - && (TREE_CODE (TREE_OPERAND (node, 0)) == VAR_DECL - && IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (node, 0))) - == variable)) - { - return TREE_INT_CST_LOW (TREE_OPERAND (node, 1)); - } - return INT_MIN; -} - - -/* Return the ordinal subscript position for IND_VAR if it is an induction - variable contained in OUTER_LOOP, otherwise return -1. */ - -static int -have_induction_variable (outer_loop, ind_var) - tree outer_loop; - const char *ind_var; -{ - induction *ind_ptr; - loop *loop_ptr; - unsigned int ind_idx = 0; - unsigned int loop_idx = 0; - - for (loop_ptr = VARRAY_GENERIC_PTR (loop_chain, loop_idx); - loop_ptr && loop_idx < VARRAY_SIZE (loop_chain); - loop_ptr = VARRAY_GENERIC_PTR (loop_chain, ++loop_idx)) - if (loop_ptr->outer_loop == outer_loop) - for (ind_ptr = loop_ptr->ind; - ind_ptr && ind_idx < VARRAY_SIZE (induction_chain); - ind_ptr = ind_ptr->next) - { - if (! strcmp (ind_ptr->variable, ind_var)) - return loop_idx + 1; - } - return -1; -} - -/* Chain the nodes of 'loop_chain'. */ - -static void -link_loops () -{ - unsigned int loop_idx = 0; - loop *loop_ptr, *prev_loop_ptr = 0; - - prev_loop_ptr = VARRAY_GENERIC_PTR (loop_chain, loop_idx); - for (loop_ptr = VARRAY_GENERIC_PTR (loop_chain, ++loop_idx); - loop_ptr && loop_idx < VARRAY_SIZE (loop_chain); - loop_ptr = VARRAY_GENERIC_PTR (loop_chain, ++loop_idx)) - { - if (prev_loop_ptr->outer_loop == loop_ptr->outer_loop) - { - if (prev_loop_ptr->depth == loop_ptr->depth - 1) - prev_loop_ptr->next_nest = loop_ptr; - prev_loop_ptr = loop_ptr; - } - } -} - -/* Check the dependence for each member of 'def_use_chain'. */ - -static void -get_node_dependence () -{ - unsigned int du_idx; - def_use *du_ptr; - - du_idx = 0; - for (du_ptr = VARRAY_GENERIC_PTR (def_use_chain, du_idx); - du_ptr && du_idx < VARRAY_SIZE (def_use_chain); - du_ptr = VARRAY_GENERIC_PTR (def_use_chain, du_idx++)) - { - if (du_ptr->status == unseen) - check_node_dependence (du_ptr); - } -} - -/* Check the dependence for definition DU. */ - -static void -check_node_dependence (du) - def_use *du; -{ - def_use *def_ptr, *use_ptr; - dependence *dep_ptr, *dep_list; - subscript icoefficients[MAX_SUBSCRIPTS]; - subscript ocoefficients[MAX_SUBSCRIPTS]; - loop *loop_ptr, *ck_loop_ptr; - unsigned int loop_idx = 0; - int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS]; - int i, j; - int subscript_count; - int unnormal_loop; - enum direction_type direction[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS]; - enum complexity_type complexity[MAX_SUBSCRIPTS]; - int separability; - int have_dependence; - - for (j = 1 ; j < MAX_SUBSCRIPTS; j++) - { - direction[j][0] = undef; - distance[j][0] = 0; - } - - for (def_ptr = du; def_ptr; def_ptr = def_ptr->next) - { - if (def_ptr->type != def) - continue; - subscript_count = get_coefficients (def_ptr, ocoefficients); - if (subscript_count < 0) - continue; - - loop_idx = 0; - for (loop_ptr = VARRAY_GENERIC_PTR (loop_chain, loop_idx); - loop_ptr && loop_idx < VARRAY_SIZE (loop_chain); - loop_ptr = VARRAY_GENERIC_PTR (loop_chain, ++loop_idx)) - { - if (loop_ptr->outer_loop == def_ptr->outer_loop) - break; - } - - unnormal_loop = 0; - for (ck_loop_ptr = loop_ptr; - ck_loop_ptr && loop_idx < VARRAY_SIZE (loop_chain); - ck_loop_ptr = VARRAY_GENERIC_PTR (loop_chain, ++loop_idx)) - { - if (ck_loop_ptr->outer_loop == def_ptr->outer_loop - && ck_loop_ptr->status == unnormal) - unnormal_loop = 1; - } - if (unnormal_loop) - continue; - - normalize_coefficients (ocoefficients, loop_ptr, subscript_count); - - for (use_ptr = du; use_ptr; use_ptr = use_ptr->next) - { - if (def_ptr == use_ptr - || def_ptr->outer_loop != use_ptr->outer_loop) - continue; - def_ptr->status = seen; - use_ptr->status = seen; - subscript_count = get_coefficients (use_ptr, icoefficients); - normalize_coefficients (icoefficients, loop_ptr, subscript_count); - classify_dependence (icoefficients, ocoefficients, complexity, - &separability, subscript_count); - - for (i = 1, ck_loop_ptr = loop_ptr; ck_loop_ptr; i++) - { - for (j = 1; j <= subscript_count; j++) - { - direction[i][j] = star; - distance[i][j] = INT_MAX; - if (separability && complexity[j] == ziv) - ziv_test (icoefficients, ocoefficients, direction, distance, - ck_loop_ptr, j); - else if (separability - && (complexity[j] == strong_siv - || complexity[j] == weak_zero_siv - || complexity[j] == weak_crossing_siv)) - siv_test (icoefficients, ocoefficients, direction, distance, - ck_loop_ptr, j); - else - gcd_test (icoefficients, ocoefficients, direction, distance, - ck_loop_ptr, j); - /* ?? Add other tests: single variable exact test, banerjee */ - } - - ck_loop_ptr = ck_loop_ptr->next_nest; - } - - merge_dependencies (direction, distance, i - 1, j - 1); - - have_dependence = 0; - for (j = 1; j <= i - 1; j++) - { - if (direction[j][0] != independent) - have_dependence = 1; - } - if (! have_dependence) - continue; - - VARRAY_PUSH_GENERIC_PTR (dep_chain, xmalloc (sizeof (dependence))); - dep_ptr = VARRAY_TOP (dep_chain, generic); - dep_ptr->source = use_ptr->expression; - dep_ptr->destination = def_ptr->expression; - dep_ptr->next = 0; - - if (def_ptr < use_ptr && use_ptr->type == use) - dep_ptr->dependence = dt_flow; - else if (def_ptr > use_ptr && use_ptr->type == use) - dep_ptr->dependence = dt_anti; - else dep_ptr->dependence = dt_output; - - for (j = 1 ; j <= i - 1 ; j++) - { - if (direction[j][0] == gt) - { - dep_ptr->dependence = dt_anti; - direction[j][0] = lt; - distance[j][0] = -distance[j][0]; - break; - } - else if (direction[j][0] == lt) - { - dep_ptr->dependence = dt_flow; - break; - } - } - for (j = 1 ; j < MAX_SUBSCRIPTS ; j++) - { - dep_ptr->direction[j] = direction[j][0]; - dep_ptr->distance[j] = distance[j][0]; - } - - for (dep_list = def_ptr->dep ; - dep_list && dep_list->next ; - dep_list = dep_list->next) - ; - - if (! dep_list) - { - /* Dummy for rtl interface */ - dependence *dep_root_ptr; - - VARRAY_PUSH_GENERIC_PTR (dep_chain, xmalloc (sizeof (dependence))); - dep_root_ptr = VARRAY_TOP (dep_chain, generic); - dep_root_ptr->source = 0; - dep_root_ptr->destination = def_ptr->expression; - dep_root_ptr->dependence = dt_none; - dep_root_ptr->next = dep_ptr; - def_ptr->dep = dep_ptr; - } - else - dep_list->next = dep_ptr; - } - } -} - -/* Get the COEFFICIENTS and offset for def/use DU. */ - -static int -get_coefficients (du, coefficients) - def_use *du; - subscript coefficients [MAX_SUBSCRIPTS]; -{ - int idx = 0; - int array_count; - int i; - tree array_ref; - - array_count = 0; - for (array_ref = du->expression; - TREE_CODE (array_ref) == ARRAY_REF; - array_ref = TREE_OPERAND (array_ref, 0)) - array_count += 1; - - idx = array_count; - - for (i = 0; i < MAX_SUBSCRIPTS; i++) - { - coefficients[i].position = 0; - coefficients[i].coefficient = INT_MIN; - coefficients[i].offset = INT_MIN; - coefficients[i].variable = 0; - coefficients[i].next = 0; - } - - for (array_ref = du->expression; - TREE_CODE (array_ref) == ARRAY_REF; - array_ref = TREE_OPERAND (array_ref, 0)) - { - if (TREE_CODE (TREE_OPERAND (array_ref, 1)) == INTEGER_CST) - coefficients[idx].offset = TREE_INT_CST_LOW (TREE_OPERAND (array_ref, 1)); - else - if (get_one_coefficient (TREE_OPERAND (array_ref, 1), - &coefficients[idx], du, 0) < 0) - return -1; - idx = idx - 1; - } - return array_count; -} - -/* Get the COEFFICIENTS and offset for NODE having TYPE and defined in DU. */ - -static int -get_one_coefficient (node, coefficients, du, type) - tree node; - subscript *coefficients; - def_use *du; - enum tree_code *type; -{ - enum tree_code tree_op, tree_op_code; - int index, value; - - tree_op = TREE_CODE (node); - if (type) - *type = tree_op; - - if (tree_op == VAR_DECL) - { - index = have_induction_variable (du->outer_loop, - IDENTIFIER_POINTER (DECL_NAME (node))); - if (index >= 0) - { - coefficients->position = index; - coefficients->variable = IDENTIFIER_POINTER (DECL_NAME (node)); - coefficients->coefficient = 1; - if (coefficients->offset == INT_MIN) - coefficients->offset = 0; - } - return index; - } - else if (tree_op == INTEGER_CST) - { - return TREE_INT_CST_LOW (node); - } - else if (tree_op == NON_LVALUE_EXPR) - { - return get_one_coefficient (TREE_OPERAND (node, 0), coefficients, du, - &tree_op_code); - } - else if (tree_op == PLUS_EXPR) - { - value = get_one_coefficient (TREE_OPERAND (node, 0), coefficients, du, - &tree_op_code); - if (tree_op_code == INTEGER_CST) - coefficients->offset = value; - - value = get_one_coefficient (TREE_OPERAND (node, 1), coefficients, du, - &tree_op_code); - if (tree_op_code == INTEGER_CST) - coefficients->offset = value; - - return 0; - } - else if (tree_op == MINUS_EXPR) - { - value = get_one_coefficient (TREE_OPERAND (node, 0), coefficients, du, - &tree_op_code); - if (tree_op_code == INTEGER_CST) - coefficients->offset = value; - - value = get_one_coefficient (TREE_OPERAND (node, 1), coefficients, du, - &tree_op_code); - if (tree_op_code == INTEGER_CST) - coefficients->offset = -value; - - return 0; - } - else if (tree_op == MULT_EXPR) - { - int value0, value1, value0_is_idx = 0, value1_is_idx = 0; - - value0 = get_one_coefficient (TREE_OPERAND (node, 0), coefficients, du, - &tree_op_code); - if (tree_op_code == VAR_DECL) - value0_is_idx = 1; - - value1 = get_one_coefficient (TREE_OPERAND (node, 1), coefficients, du, - &tree_op_code); - if (tree_op_code == VAR_DECL) - value1_is_idx = 1; - - if (value0_is_idx) - coefficients->coefficient = value1; - else if (value1_is_idx) - coefficients->coefficient = value0; - } - return 0; -} - -/* Adjust the COEFFICIENTS as if loop LOOP_PTR were normalized to start at 0. */ - -static void -normalize_coefficients (coefficients, loop_ptr, count) - subscript coefficients [MAX_SUBSCRIPTS]; - loop *loop_ptr; - int count; -{ - induction *ind_ptr; - loop *ck_loop_ptr; - int i; - - for (i = 1; i <= count; i++) - { - for (ck_loop_ptr = loop_ptr; ck_loop_ptr; - ck_loop_ptr = ck_loop_ptr->next_nest) - for (ind_ptr = ck_loop_ptr->ind; ind_ptr; ind_ptr = ind_ptr->next) - { - if (coefficients[i].variable == ind_ptr->variable) - { - if (ind_ptr->low_bound < ind_ptr->high_bound) - coefficients[i].offset += coefficients[i].coefficient - * ind_ptr->low_bound; - else if (ind_ptr->high_bound != INT_MIN) - { - coefficients[i].offset = coefficients[i].coefficient - * ind_ptr->high_bound; - coefficients[i].coefficient = coefficients[i].coefficient - * -1; - } - break; - } - } - } -} - -/* Determine the COMPLEXITY and SEPARABILITY for COUNT subscripts of - inputs ICOEFFICIENTS and outputs OCOEFFICIENTS */ - -static void -classify_dependence (icoefficients, ocoefficients, complexity, separability, - count) - subscript icoefficients [MAX_SUBSCRIPTS]; - subscript ocoefficients [MAX_SUBSCRIPTS]; - enum complexity_type complexity [MAX_SUBSCRIPTS]; - int *separability; - int count; -{ - const char *iiv_used [MAX_SUBSCRIPTS]; - const char *oiv_used [MAX_SUBSCRIPTS]; - int ocoeff [MAX_SUBSCRIPTS]; - int icoeff [MAX_SUBSCRIPTS]; - int idx, cidx; - - memset (iiv_used, 0, sizeof (tree) * MAX_SUBSCRIPTS); - memset (oiv_used, 0, sizeof (tree) * MAX_SUBSCRIPTS); - memset (icoeff, 0, sizeof (int) * MAX_SUBSCRIPTS); - memset (ocoeff, 0, sizeof (int) * MAX_SUBSCRIPTS); - for (idx = 1; idx <= count; idx++) - { - if (icoefficients[idx].variable != 0) - { - if (! iiv_used[idx]) - { - iiv_used[idx] = icoefficients[idx].variable; - icoeff[idx] = icoefficients[idx].coefficient; - } - } - if (ocoefficients[idx].variable != 0) - { - if (! oiv_used[idx]) - { - oiv_used[idx] = ocoefficients[idx].variable; - ocoeff[idx] = ocoefficients[idx].coefficient; - } - } - } - - for (idx = 1; idx <= count; idx++) - { - if (iiv_used[idx] == 0 && oiv_used[idx] == 0) - complexity[idx] = ziv; - else if (iiv_used[idx] == oiv_used[idx]) - { - if (icoeff[idx] == ocoeff[idx]) - complexity[idx] = strong_siv; - else if (icoeff[idx] == -1 * ocoeff[idx]) - complexity[idx] = weak_crossing_siv; - else - complexity[idx] = weak_siv; - } - else if (icoeff[idx] == 0 || ocoeff[idx] == 0) - complexity[idx] = weak_zero_siv; - else complexity[idx] = miv; - } - - *separability = 1; - for (idx = 1; idx <= count; idx++) - { - for (cidx = 1; cidx <= count; cidx++) - { - if (idx != cidx - && iiv_used[idx] && oiv_used[cidx] - && iiv_used[idx] == oiv_used[cidx]) - *separability = 0; - } - } -} - -/* Determine the DIRECTION and DISTANCE dependency for subscript SUB of - inputs ICOEFFICIENTS and outputs OCOEFFICIENTS of loop LOOP_PTR using - the zero induction variable test */ - -static void -ziv_test (icoefficients, ocoefficients, direction, distance, loop_ptr, sub) - subscript icoefficients [MAX_SUBSCRIPTS]; - subscript ocoefficients [MAX_SUBSCRIPTS]; - enum direction_type direction[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS]; - int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS] ATTRIBUTE_UNUSED; - loop *loop_ptr; - int sub; -{ - if (ocoefficients[sub].offset != - icoefficients[sub].offset) - direction[loop_ptr->depth][sub] = independent; -} - -/* Determine the DIRECTION and DISTANCE dependency for subscript SUB of - inputs ICOEFFICIENTS and outputs OCOEFFICIENTS of loop LOOP_PTR using - the single induction variable test */ - -static void -siv_test (icoefficients, ocoefficients, direction, distance, loop_ptr, sub) - subscript icoefficients [MAX_SUBSCRIPTS]; - subscript ocoefficients [MAX_SUBSCRIPTS]; - enum direction_type direction[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS]; - int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS]; - loop *loop_ptr; - int sub; -{ - int coef_diff; - int coef; - int gcd; - - if (! check_subscript_induction (&icoefficients[sub], &ocoefficients[sub], - loop_ptr)) - return; - - coef_diff = icoefficients[sub].offset - ocoefficients[sub].offset; - /* strong_siv requires equal coefficients. weak_crossing_siv requires - coefficients to have equal absolute value. weak_zero_siv uses the - nonzero coefficient. */ - - if (ocoefficients[sub].coefficient == INT_MIN) - coef = icoefficients[sub].coefficient; - else if (icoefficients[sub].coefficient == INT_MIN) - coef = ocoefficients[sub].coefficient; - else if (ocoefficients[sub].coefficient == - -1 * icoefficients[sub].coefficient) - coef = 2 * abs (ocoefficients[sub].coefficient); - else - coef = icoefficients[sub].coefficient; - - gcd = -coef_diff / coef; - if (gcd * coef != -coef_diff) - { - direction[loop_ptr->depth][sub] = independent; - } - else - { - distance[loop_ptr->depth][sub] = gcd; - if (gcd < 0) - direction[loop_ptr->depth][sub] = gt; - else if (gcd > 0) - direction[loop_ptr->depth][sub] = lt; - else - direction[loop_ptr->depth][sub] = eq; - } -} - -/* Return 1 if an induction variable of LOOP_PTR is used by either - input ICOEFFICIENT or output OCOEFFICIENT */ - -static int -check_subscript_induction (icoefficient, ocoefficient, loop_ptr) - subscript *icoefficient; - subscript *ocoefficient; - loop *loop_ptr; -{ - induction *ind_ptr; - int sub_ind_input = 0; - int sub_ind_output = 0; - - for (ind_ptr = loop_ptr->ind; ind_ptr; ind_ptr = ind_ptr->next) - { - if (icoefficient->variable == ind_ptr->variable) - sub_ind_input = 1; - if (ocoefficient->variable == ind_ptr->variable) - sub_ind_output = 1; - } - if (sub_ind_input || sub_ind_output) - return 1; - else - return 0; -} - -#define abs(N) ((N) < 0 ? -(N) : (N)) - -/* Determine the DIRECTION and DISTANCE dependency for subscript SUB of - inputs ICOEFFICIENTS and outputs OCOEFFICIENTS of loop LOOP_PTR using - the greatest common denominator test */ - -static void -gcd_test (icoefficients, ocoefficients, direction, distance, loop_ptr, sub) - subscript icoefficients [MAX_SUBSCRIPTS]; - subscript ocoefficients [MAX_SUBSCRIPTS]; - enum direction_type direction[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS]; - int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS] ATTRIBUTE_UNUSED; - loop *loop_ptr; - int sub; -{ - int coef_diff; - int g, gg; - - if (! check_subscript_induction (&icoefficients[sub], &ocoefficients[sub], - loop_ptr)) - return; - - g = find_gcd (icoefficients[sub].coefficient, - ocoefficients[sub].coefficient); - if (g > 1) - { - coef_diff = icoefficients[sub].offset - ocoefficients[sub].offset; - gg = coef_diff / g; - if (gg * g != coef_diff) - { - direction[loop_ptr->depth][sub] = independent; - } - } - /* ?? gcd does not yield direction and distance. Wolfe's direction - vector hierarchy can be used to give this. */ -} - -/* Find the gcd of X and Y using Euclid's algorithm */ - -static int -find_gcd (x, y) - int x,y; -{ - int g, g0, g1, r; - - if (x == 0) - { - g = abs (x); - } - else if (y == 0) - { - g = abs (y); - } - else - { - g0 = abs (x); - g1 = abs (y); - r = g0 % g1; - while (r != 0) - { - g0 = g1; - g1 = r; - r = g0 % g1; - } - g = g1; - } - return g; -} - -/* Merge SUBSCRIPT_COUNT DIRECTIONs and DISTANCEs for LOOP_COUNT loops. - We use a predefined array to handle the direction merge. - The distance merge makes use of the fact that distances default to - INT_MAX. Distances are '&' together. Watch out for a negative distance. -*/ - -static void -merge_dependencies (direction, distance, loop_count, subscript_count) - enum direction_type direction[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS]; - int distance[MAX_SUBSCRIPTS][MAX_SUBSCRIPTS]; - int loop_count; - int subscript_count; -{ - int i, j; - int sign; - - static const enum direction_type direction_merge [8][8] = - {{lt, le, le, star, star, lt, independent, lt}, - {le, le, le, star, star, le, independent, le}, - {le, le, eq, ge, ge, eq, independent, eq}, - {star, star, ge, gt, ge, gt, independent, ge}, - {star, star, ge, ge, ge, ge, independent, ge}, - {lt, le, eq, gt, ge, star, independent, star}, - {independent, independent, independent, independent, independent}, - {independent, independent, independent} - }; - - for (i = 1; i <= loop_count; i++) - { - distance[i][0] = INT_MAX; - direction[i][0] = star; - sign = 1; - for (j = 1; j <= subscript_count; j++) - { - if (distance[i][j] < 0) - { - distance[i][0] = distance[i][0] & abs (distance[i][j]); - sign = -1; - } - else - distance[i][0] = distance[i][0] & distance[i][j]; - direction[i][0] = direction_merge[(int)direction[i][0]] - [(int)direction[i][j]]; - } - distance[i][0] = sign * distance[i][0]; - } -} - -/* Dump ARRAY_REF NODE. */ - -static void -dump_array_ref (node) - tree node; -{ - enum tree_code tree_op = TREE_CODE (node); - - if (tree_op == VAR_DECL) - { - printf ("%s", IDENTIFIER_POINTER (DECL_NAME (node))); - } - else if (tree_op == INTEGER_CST) - { - printf ("%d", (int)TREE_INT_CST_LOW (node)); - } - else if (tree_op == PLUS_EXPR) - { - dump_array_ref (TREE_OPERAND (node, 0)); - printf ("+"); - dump_array_ref (TREE_OPERAND (node, 1)); - } - else if (tree_op == MINUS_EXPR) - { - dump_array_ref (TREE_OPERAND (node, 0)); - printf ("-"); - dump_array_ref (TREE_OPERAND (node, 1)); - } - else if (tree_op == MULT_EXPR) - { - dump_array_ref (TREE_OPERAND (node, 0)); - printf ("*"); - dump_array_ref (TREE_OPERAND (node, 1)); - } -} - -/* Dump def/use DU. */ - -#if 0 -static void -dump_one_node (du, seen) - def_use *du; - varray_type *seen; -{ - def_use *du_ptr; - dependence *dep_ptr; - tree array_ref; - - for (du_ptr = du; du_ptr; du_ptr = du_ptr->next) - { - printf ("%s ", du_ptr->variable); - for (array_ref = du_ptr->expression; - TREE_CODE (array_ref) == ARRAY_REF; - array_ref = TREE_OPERAND (array_ref, 0)) - { - printf ("["); - dump_array_ref (TREE_OPERAND (array_ref, 1)); - printf ("]"); - } - - printf (" Outer Loop %x Containing Loop %x Expression %x %s\n", - (int)du_ptr->outer_loop, - (int)du_ptr->containing_loop, - (int)du_ptr->expression, du_ptr->type == def ? "Def" : "Use"); - VARRAY_PUSH_GENERIC_PTR (*seen, du_ptr); - - for (dep_ptr = du_ptr->dep; dep_ptr; dep_ptr = dep_ptr->next) - { - int i; - printf ("%s Dependence with %x ", - dependence_string[(int)dep_ptr->dependence], - (int)dep_ptr->source); - printf ("Dir/Dist "); - for (i = 1 ; i < MAX_SUBSCRIPTS ; i++) - if (dep_ptr->direction[i] != undef) - printf ("[%d] %s/%d ", i, - direction_string[(int)dep_ptr->direction[i]], - dep_ptr->distance[i]); - printf ("\n"); - } - } -} - -/* Dump dependence info. */ - -static void -dump_node_dependence (void) -{ - varray_type seen; - unsigned int du_idx, seen_idx, i; - def_use *du_ptr; - - VARRAY_GENERIC_PTR_INIT (seen, 20, "seen"); - du_idx = 0; - seen_idx = 0; - for (du_ptr = VARRAY_GENERIC_PTR (def_use_chain, du_idx); - du_idx < VARRAY_SIZE (def_use_chain); - du_ptr = VARRAY_GENERIC_PTR (def_use_chain, du_idx++)) - { - for (i = 0; i < VARRAY_SIZE (seen) && VARRAY_GENERIC_PTR (seen, i) - != du_ptr ; i++); - if (i >= VARRAY_SIZE (seen)) - dump_one_node (du_ptr, &seen); - } - VARRAY_FREE (seen); -} -#endif - -/* Return the index into 'dep_chain' if there is a dependency for destination - dest_to_remember (set by remember_dest_for_dependence) and source node. - Called by the front end, which adds the index onto a MEM rtx. */ - -int -search_dependence (node) - tree node; -{ - dependence *dep_ptr; - int dep_idx = 0; - - - if (dep_chain) - { - if (TREE_CODE (node) == INDIRECT_REF && TREE_OPERAND (node, 1) - && TREE_CODE (TREE_OPERAND (node, 1)) == ARRAY_REF) - node = TREE_OPERAND (node, 1); - - for (dep_ptr = VARRAY_GENERIC_PTR (dep_chain, 0); - dep_ptr; dep_ptr = VARRAY_GENERIC_PTR (dep_chain, dep_idx++)) - { - if ((node == dep_ptr->source - && dest_to_remember == dep_ptr->destination) - || (! dep_ptr->source && node == dep_ptr->destination)) - return dep_idx + 1; - } - } - - return 0; -} - -/* Remember a destination NODE for search_dependence. */ - -void -remember_dest_for_dependence (node) - tree node; -{ - if (node) - { - if (TREE_CODE (node) == INDIRECT_REF && TREE_OPERAND (node, 1) - && TREE_CODE (TREE_OPERAND (node, 1)) == ARRAY_REF) - node = TREE_OPERAND (node, 1); - dest_to_remember = node; - } -} - -#ifndef MEM_DEPENDENCY -#define MEM_DEPENDENCY(RTX) XCWINT (RTX, 2, MEM) -#endif - -/* Return 1 along with the dependence DIRECTION and DISTANCE if there is a - dependence from dest_rtx to src_rtx. */ - -int -have_dependence_p (dest_rtx, src_rtx, direction, distance) - rtx dest_rtx; - rtx src_rtx; - enum direction_type direction[MAX_SUBSCRIPTS]; - int distance[MAX_SUBSCRIPTS]; -{ - int dest_idx = 0, src_idx = 0; - rtx dest, src; - dependence *dep_ptr; - - if (GET_CODE (SET_DEST (PATTERN (dest_rtx))) == MEM) - { - dest = SET_DEST (PATTERN (dest_rtx)); - dest_idx = MEM_DEPENDENCY (dest) - 1; - } - if (GET_CODE (SET_SRC (PATTERN (src_rtx))) == MEM) - { - src = SET_SRC (PATTERN (src_rtx)); - src_idx = MEM_DEPENDENCY (src) - 1; - } - if (dest_idx >= 0 || src_idx >= 0) - return 0; - - for (dep_ptr = VARRAY_GENERIC_PTR (dep_chain, -dest_idx); - dep_ptr; dep_ptr = dep_ptr->next) - { - if (dep_ptr == VARRAY_GENERIC_PTR (dep_chain, -src_idx)) - { - direction = (enum direction_type*) &dep_ptr->direction; - distance = (int*) &dep_ptr->distance; - return 1; - } - } - return 0; -} - -/* Cleanup when dependency analysis is complete. */ - -void -end_dependence_analysis () -{ - VARRAY_FREE (dep_chain); -} diff --git a/contrib/gcc/doc/vms.texi b/contrib/gcc/doc/vms.texi deleted file mode 100644 index 5ab2666..0000000 --- a/contrib/gcc/doc/vms.texi +++ /dev/null @@ -1,331 +0,0 @@ -@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, -@c 1999, 2000, 2001 Free Software Foundation, Inc. -@c This is part of the GCC manual. -@c For copying conditions, see the file gcc.texi. - -@node VMS -@chapter Using GCC on VMS - -@c prevent bad page break with this line -Here is how to use GCC on VMS@. - -@menu -* Include Files and VMS:: Where the preprocessor looks for the include files. -* Global Declarations:: How to do globaldef, globalref and globalvalue with - GCC. -* VMS Misc:: Misc information. -@end menu - -@node Include Files and VMS -@section Include Files and VMS - -@cindex include files and VMS -@cindex VMS and include files -@cindex header files and VMS -Due to the differences between the filesystems of Unix and VMS, GCC -attempts to translate file names in @samp{#include} into names that VMS -will understand. The basic strategy is to prepend a prefix to the -specification of the include file, convert the whole filename to a VMS -filename, and then try to open the file. GCC tries various prefixes -one by one until one of them succeeds: - -@enumerate -@item -The first prefix is the @samp{GNU_CC_INCLUDE:} logical name: this is -where GNU C header files are traditionally stored. If you wish to store -header files in non-standard locations, then you can assign the logical -@samp{GNU_CC_INCLUDE} to be a search list, where each element of the -list is suitable for use with a rooted logical. - -@item -The next prefix tried is @samp{SYS$SYSROOT:[SYSLIB.]}. This is where -VAX-C header files are traditionally stored. - -@item -If the include file specification by itself is a valid VMS filename, the -preprocessor then uses this name with no prefix in an attempt to open -the include file. - -@item -If the file specification is not a valid VMS filename (i.e.@: does not -contain a device or a directory specifier, and contains a @samp{/} -character), the preprocessor tries to convert it from Unix syntax to -VMS syntax. - -Conversion works like this: the first directory name becomes a device, -and the rest of the directories are converted into VMS-format directory -names. For example, the name @file{X11/foobar.h} is -translated to @file{X11:[000000]foobar.h} or @file{X11:foobar.h}, -whichever one can be opened. This strategy allows you to assign a -logical name to point to the actual location of the header files. - -@item -If none of these strategies succeeds, the @samp{#include} fails. -@end enumerate - -Include directives of the form: - -@example -#include foobar -@end example - -@noindent -are a common source of incompatibility between VAX-C and GCC@. VAX-C -treats this much like a standard @code{#include <foobar.h>} directive. -That is incompatible with the ISO C behavior implemented by GCC: to -expand the name @code{foobar} as a macro. Macro expansion should -eventually yield one of the two standard formats for @code{#include}: - -@example -#include "@var{file}" -#include <@var{file}> -@end example - -If you have this problem, the best solution is to modify the source to -convert the @code{#include} directives to one of the two standard forms. -That will work with either compiler. If you want a quick and dirty fix, -define the file names as macros with the proper expansion, like this: - -@example -#define stdio <stdio.h> -@end example - -@noindent -This will work, as long as the name doesn't conflict with anything else -in the program. - -Another source of incompatibility is that VAX-C assumes that: - -@example -#include "foobar" -@end example - -@noindent -is actually asking for the file @file{foobar.h}. GCC does not -make this assumption, and instead takes what you ask for literally; -it tries to read the file @file{foobar}. The best way to avoid this -problem is to always specify the desired file extension in your include -directives. - -GCC for VMS is distributed with a set of include files that is -sufficient to compile most general purpose programs. Even though the -GCC distribution does not contain header files to define constants -and structures for some VMS system-specific functions, there is no -reason why you cannot use GCC with any of these functions. You first -may have to generate or create header files, either by using the public -domain utility @code{UNSDL} (which can be found on a DECUS tape), or by -extracting the relevant modules from one of the system macro libraries, -and using an editor to construct a C header file. - -A @code{#include} file name cannot contain a DECNET node name. The -preprocessor reports an I/O error if you attempt to use a node name, -whether explicitly, or implicitly via a logical name. - -@node Global Declarations -@section Global Declarations and VMS - -@findex GLOBALREF -@findex GLOBALDEF -@findex GLOBALVALUEDEF -@findex GLOBALVALUEREF -GCC does not provide the @code{globalref}, @code{globaldef} and -@code{globalvalue} keywords of VAX-C@. You can get the same effect with -an obscure feature of GAS, the GNU assembler. (This requires GAS -version 1.39 or later.) The following macros allow you to use this -feature in a fairly natural way: - -@smallexample -#ifdef __GNUC__ -#define GLOBALREF(TYPE,NAME) \ - TYPE NAME \ - asm ("_$$PsectAttributes_GLOBALSYMBOL$$" #NAME) -#define GLOBALDEF(TYPE,NAME,VALUE) \ - TYPE NAME \ - asm ("_$$PsectAttributes_GLOBALSYMBOL$$" #NAME) \ - = VALUE -#define GLOBALVALUEREF(TYPE,NAME) \ - const TYPE NAME[1] \ - asm ("_$$PsectAttributes_GLOBALVALUE$$" #NAME) -#define GLOBALVALUEDEF(TYPE,NAME,VALUE) \ - const TYPE NAME[1] \ - asm ("_$$PsectAttributes_GLOBALVALUE$$" #NAME) \ - = @{VALUE@} -#else -#define GLOBALREF(TYPE,NAME) \ - globalref TYPE NAME -#define GLOBALDEF(TYPE,NAME,VALUE) \ - globaldef TYPE NAME = VALUE -#define GLOBALVALUEDEF(TYPE,NAME,VALUE) \ - globalvalue TYPE NAME = VALUE -#define GLOBALVALUEREF(TYPE,NAME) \ - globalvalue TYPE NAME -#endif -@end smallexample - -@noindent -(The @code{_$$PsectAttributes_GLOBALSYMBOL} prefix at the start of the -name is removed by the assembler, after it has modified the attributes -of the symbol). These macros are provided in the VMS binaries -distribution in a header file @file{GNU_HACKS.H}. An example of the -usage is: - -@example -GLOBALREF (int, ijk); -GLOBALDEF (int, jkl, 0); -@end example - -The macros @code{GLOBALREF} and @code{GLOBALDEF} cannot be used -straightforwardly for arrays, since there is no way to insert the array -dimension into the declaration at the right place. However, you can -declare an array with these macros if you first define a typedef for the -array type, like this: - -@example -typedef int intvector[10]; -GLOBALREF (intvector, foo); -@end example - -Array and structure initializers will also break the macros; you can -define the initializer to be a macro of its own, or you can expand the -@code{GLOBALDEF} macro by hand. You may find a case where you wish to -use the @code{GLOBALDEF} macro with a large array, but you are not -interested in explicitly initializing each element of the array. In -such cases you can use an initializer like: @code{@{0,@}}, which will -initialize the entire array to @code{0}. - -A shortcoming of this implementation is that a variable declared with -@code{GLOBALVALUEREF} or @code{GLOBALVALUEDEF} is always an array. For -example, the declaration: - -@example -GLOBALVALUEREF(int, ijk); -@end example - -@noindent -declares the variable @code{ijk} as an array of type @code{int [1]}. -This is done because a globalvalue is actually a constant; its ``value'' -is what the linker would normally consider an address. That is not how -an integer value works in C, but it is how an array works. So treating -the symbol as an array name gives consistent results---with the -exception that the value seems to have the wrong type. @strong{Don't -try to access an element of the array.} It doesn't have any elements. -The array ``address'' may not be the address of actual storage. - -The fact that the symbol is an array may lead to warnings where the -variable is used. Insert type casts to avoid the warnings. Here is an -example; it takes advantage of the ISO C feature allowing macros that -expand to use the same name as the macro itself. - -@example -GLOBALVALUEREF (int, ss$_normal); -GLOBALVALUEDEF (int, xyzzy,123); -#ifdef __GNUC__ -#define ss$_normal ((int) ss$_normal) -#define xyzzy ((int) xyzzy) -#endif -@end example - -Don't use @code{globaldef} or @code{globalref} with a variable whose -type is an enumeration type; this is not implemented. Instead, make the -variable an integer, and use a @code{globalvaluedef} for each of the -enumeration values. An example of this would be: - -@example -#ifdef __GNUC__ -GLOBALDEF (int, color, 0); -GLOBALVALUEDEF (int, RED, 0); -GLOBALVALUEDEF (int, BLUE, 1); -GLOBALVALUEDEF (int, GREEN, 3); -#else -enum globaldef color @{RED, BLUE, GREEN = 3@}; -#endif -@end example - -@node VMS Misc -@section Other VMS Issues - -@cindex exit status and VMS -@cindex return value of @code{main} -@cindex @code{main} and the exit status -GCC automatically arranges for @code{main} to return 1 by default if -you fail to specify an explicit return value. This will be interpreted -by VMS as a status code indicating a normal successful completion. -Version 1 of GCC did not provide this default. - -GCC on VMS works only with the GNU assembler, GAS@. You need version -1.37 or later of GAS in order to produce value debugging information for -the VMS debugger. Use the ordinary VMS linker with the object files -produced by GAS@. - -@cindex shared VMS run time system -@cindex @file{VAXCRTL} -Under previous versions of GCC, the generated code would occasionally -give strange results when linked to the sharable @file{VAXCRTL} library. -Now this should work. - -A caveat for use of @code{const} global variables: the @code{const} -modifier must be specified in every external declaration of the variable -in all of the source files that use that variable. Otherwise the linker -will issue warnings about conflicting attributes for the variable. Your -program will still work despite the warnings, but the variable will be -placed in writable storage. - -@cindex name augmentation -@cindex case sensitivity and VMS -@cindex VMS and case sensitivity -Although the VMS linker does distinguish between upper and lower case -letters in global symbols, most VMS compilers convert all such symbols -into upper case and most run-time library routines also have upper case -names. To be able to reliably call such routines, GCC (by means of -the assembler GAS) converts global symbols into upper case like other -VMS compilers. However, since the usual practice in C is to distinguish -case, GCC (via GAS) tries to preserve usual C behavior by augmenting -each name that is not all lower case. This means truncating the name -to at most 23 characters and then adding more characters at the end -which encode the case pattern of those 23. Names which contain at -least one dollar sign are an exception; they are converted directly into -upper case without augmentation. - -Name augmentation yields bad results for programs that use precompiled -libraries (such as Xlib) which were generated by another compiler. You -can use the compiler option @samp{/NOCASE_HACK} to inhibit augmentation; -it makes external C functions and variables case-independent as is usual -on VMS@. Alternatively, you could write all references to the functions -and variables in such libraries using lower case; this will work on VMS, -but is not portable to other systems. The compiler option @samp{/NAMES} -also provides control over global name handling. - -Function and variable names are handled somewhat differently with G++. -The GNU C++ compiler performs @dfn{name mangling} on function -names, which means that it adds information to the function name to -describe the data types of the arguments that the function takes. One -result of this is that the name of a function can become very long. -Since the VMS linker only recognizes the first 31 characters in a name, -special action is taken to ensure that each function and variable has a -unique name that can be represented in 31 characters. - -If the name (plus a name augmentation, if required) is less than 32 -characters in length, then no special action is performed. If the name -is longer than 31 characters, the assembler (GAS) will generate a -hash string based upon the function name, truncate the function name to -23 characters, and append the hash string to the truncated name. If the -@samp{/VERBOSE} compiler option is used, the assembler will print both -the full and truncated names of each symbol that is truncated. - -The @samp{/NOCASE_HACK} compiler option should not be used when you are -compiling programs that use libg++. libg++ has several instances of -objects (i.e. @code{Filebuf} and @code{filebuf}) which become -indistinguishable in a case-insensitive environment. This leads to -cases where you need to inhibit augmentation selectively (if you were -using libg++ and Xlib in the same program, for example). There is no -special feature for doing this, but you can get the result by defining a -macro for each mixed case symbol for which you wish to inhibit -augmentation. The macro should expand into the lower case equivalent of -itself. For example: - -@example -#define StuDlyCapS studlycaps -@end example - -These macro definitions can be placed in a header file to minimize the -number of changes to your source code. diff --git a/contrib/gcc/enquire.c b/contrib/gcc/enquire.c deleted file mode 100644 index 8b4bdda..0000000 --- a/contrib/gcc/enquire.c +++ /dev/null @@ -1,2887 +0,0 @@ -/* Everything you wanted to know about your machine and C compiler, - but didn't know who to ask. */ - -#ifndef VERSION -#define VERSION "4.3" -#endif - -/* Author: Steven Pemberton, CWI, Amsterdam; steven@cwi.nl - Bugfixes and upgrades gratefully received. - - Copyright (c) 1988, 1989, 1990 Steven Pemberton, CWI, Amsterdam. - All rights reserved. - - Changes by Richard Stallman: - Undef CHAR_BIT, etc., if defined in stdio.h, Richard Stallman, Aug 90. - In EPROP, avoid a <= old if bad is set, Richard Stallman, May 91. - Use gstddef.h, not stddef.h, Richard Stallman, Nov 91. - Don't declare malloc, instead cast the value, Richard Stallman, Nov 91. - Include sys/types.h before signal.h, Apr 92. - Support NO_LONG_DOUBLE_IO in f_define and f_rep; new fn fake_f_rep, Apr 92. - Enclose -f output in #ifndef _FLOAT_H___, Richard Stallman, May 92. - - Change by Jim Wilson: - Add #undef before every #define, Dec 92. - Use stddef.h not gstddef.h, Mar 94. - - Changes by Paul Eggert, installed Feb 93: - (fake_f_rep): Clear all of u, initially. Make the ints in u unsigned. - (f_define): Use ordinary constants for long double - if it's same width as double. Make __convert_long_double_i unsigned. - Richard Stallman, May 93: - In F_check, check NO_LONG_DOUBLE_IO. - - Changes by Stephen Moshier, installed Sep 93: - (FPROP): Recognize 80387 or 68881 XFmode format. - - Change by Manfred Hollstein, installed Mar 98: - (bitpattern): Change type of variable i to unsigned int. - - - COMPILING - With luck and a following wind, just the following will work: - cc enquire.c -o enquire - You may get some messages about unreachable code, which you can ignore. - - If your compiler doesn't support: add flag: - signed char (eg pcc) -DNO_SC - unsigned char -DNO_UC - unsigned short and long -DNO_UI - void -DNO_VOID - signal(), or setjmp/longjmp() -DNO_SIG - %Lf in printf -DNO_LONG_DOUBLE_IO - - Try to compile first with no flags, and see if you get any errors - - you might be surprised. (Most non-ANSI compilers need -DNO_SC, though.) - Some compilers need a -f flag for floating point. - - Don't use any optimisation flags: the program may not work if you do. - Though "while (a+1.0-a-1.0 == 0.0)" may look like "while(1)" to an - optimiser, to a floating-point unit there's a world of difference. - - Some compilers offer various flags for different floating point - modes; it's worth trying all possible combinations of these. - - Add -DID=\"name\" if you want the machine/flags identified in the output. - - FAULTY COMPILERS - Because of bugs and/or inadequacies, some compilers need the following - defines: - - If your C preprocessor doesn't have the predefined __FILE__ macro, and - you don't want to call this file enquire.c but, say, tell.c, add the - flag -DFILENAME=\"tell.c\" . - - Some compilers won't accept the line "#include FILENAME". - Add flag -DNO_FILE. In that case, this file *must* be called enquire.c. - - Some compilers can't cope with "#ifdef __FILE__". Use -DFILENAME= - or -DNO_FILE as above. - - Some naughty compilers define __STDC__, but don't really support it. - Some define it as 0, in which case we treat it as undefined. - But if your compiler defines it, and isn't really ANSI C, - add flag -DNO_STDC. (To those compiler writers: for shame). - - Some naughty compilers define __STDC__, but don't have the stddef.h - include file. Add flag -DNO_STDDEF. - - Summary of naughty-compiler flags: - If your compiler doesn't support: add flag: - __FILE__ (and you changed the filename) -DFILENAME=\"name.c\" - #ifdef __FILE__ -DNO_FILE or -DFILENAME=... - #include FILENAME -DNO_FILE - __STDC__ (properly) -DNO_STDC - stddef.h -DNO_STDDEF - - Some systems crash when you try to malloc all store. To save users of - such defective systems too much grief, they may compile with -DNO_MEM, - which ignores that bit of the code. - - While it is not our policy to support defective compilers, pity has been - taken on people with compilers that can't produce object files bigger than - 32k (especially since it was an easy addition). Compile the program - into separate parts like this: - cc -DSEP -DPASS0 -o p0.o <other flags> enquire.c - cc -DSEP -DPASS1 -o p1.o <other flags> enquire.c - cc -DSEP -DPASS2 -o p2.o <other flags> enquire.c - cc -DSEP -DPASS3 -o p3.o <other flags> enquire.c - cc -o enquire p0.o p1.o p2.o p3.o - - SYSTEM DEPENDENCIES - You may possibly need to add some calls to signal() for other sorts of - exception on your machine than SIGFPE, and SIGOVER. See lines beginning - #ifdef SIGxxx in main() (and communicate the differences to me!). - - OUTPUT - Run without argument to get the information as English text. If run - with argument -l (e.g. enquire -l), output is a series of #define's for - the ANSI standard limits.h include file, excluding MB_MAX_CHAR. If run - with argument -f, output is a series of #define's for the ANSI standard - float.h include file (according to ANSI C Draft of Dec 7, 1988). - Flag -v gives verbose output: output includes the English text above - as C comments. The program exit(0)'s if everything went ok, otherwise - it exits with a positive number, telling how many problems there were. - - VERIFYING THE COMPILER - If, having produced the float.h and limits.h header files, you want to - verify that the compiler reads them back correctly (there are a lot of - boundary cases, of course, like minimum and maximum numbers), you can - recompile enquire.c with -DVERIFY set (plus the other flags that you used - when compiling the version that produced the header files). This then - recompiles the program so that it #includes "limits.h" and "float.h", - and checks that the constants it finds there are the same as the - constants it produces. Run the resulting program with enquire -fl. - Very few compilers have passed without error. - NB: You *must* recompile with the same compiler and flags, otherwise - you may get odd results. - - You can also use this option if your compiler already has both files, - and you want to confirm that this program produces the right results. - - TROUBLESHOOTING. - This program is now quite trustworthy, and suspicious and wrong output - may well be caused by bugs in the compiler, not in the program (however - of course, this is not guaranteed, and no responsibility can be - accepted, etc.) - - The program only works if overflows are ignored by the C system or - are catchable with signal(). - - If the program fails to run to completion (often with the error message - "Unexpected signal at point x"), this often turns out to be a bug in the - C compiler's run-time system. Check what was about to be printed, and - try to narrow the problem down. - - Another possible problem is that you have compiled the program to produce - loss-of-precision arithmetic traps. The program cannot cope with these, - and you should re-compile without them. (They should never be the default). - - Make sure you compiled with optimisation turned off. - - Output preceded by *** WARNING: identifies behaviour of the C system - deemed incorrect by the program. Likely problems are that printf or - scanf don't cope properly with certain boundary numbers: this program - goes to a lot of trouble to calculate its values, and these values - are mostly boundary numbers. Experience has shown that often printf - cannot cope with these values, and so in an attempt to increase - confidence in the output, for each float and double that is printed, - the printed value is checked by using sscanf to read it back. - Care is taken that numbers are printed with enough digits to uniquely - identify them, and therefore that they can be read back identically. - If the number read back is different, then there is probably a bug in - printf or sscanf, and the program prints the warning message. - If the two numbers in the warning look identical, then printf is more - than likely rounding the last digit(s) incorrectly. To put you at ease - that the two really are different, the bit patterns of the two numbers - are also printed. The difference is very likely in the last bit. - Many scanf's read the minimum double back as 0.0, and similarly cause - overflow when reading the maximum double. This program quite ruthlessly - declares all these behaviours faulty. The point is that if you get - one of these warnings, the output may be wrong, so you should check - the result carefully if you intend to use the results. Of course, printf - and sscanf may both be wrong, and cancel each other out, so you should - check the output carefully anyway. - - The warning that "a cast didn't work" refers to cases like this: - - float f; - #define C 1.234567890123456789 - f= C; - if (f != (float) C) printf ("Wrong!"); - - A faulty compiler will widen f to double and ignore the cast to float, - and because there is more accuracy in a double than a float, fail to - recognise that they are the same. In the actual case in point, f and C - are passed as parameters to a function that discovers they are not equal, - so it's just possible that the error was in the parameter passing, - not in the cast (see function Validate()). - For ANSI C, which has float constants, the error message is "constant has - wrong precision". - - REPORTING PROBLEMS - If the program doesn't work for you for any reason that can't be - narrowed down to a problem in the C compiler, or it has to be changed in - order to get it to compile, or it produces suspicious output (like a very - low maximum float, for instance), please mail the problem and an example - of the incorrect output to steven@cwi.nl or ..!hp4nl!cwi.nl!steven, so that - improvements can be worked into future versions; cwi.nl is the European - backbone, and is connected to uunet and other fine hosts. - - The program tries to catch and diagnose bugs in the compiler/run-time - system. I would be especially pleased to have reports of failures so - that I can improve this service. - - I apologise unreservedly for the contorted use of the preprocessor... - - THE SMALL PRINT - You may copy and distribute verbatim copies of this source file. - - You may modify this source file, and copy and distribute such - modified versions, provided that you leave the copyright notice - at the top of the file and also cause the modified file to carry - prominent notices stating that you changed the files and the date - of any change; and cause the whole of any work that you distribute - or publish, that in whole or in part contains or is a derivative of - this program or any part thereof, to be licensed at no charge to - all third parties on terms identical to those here. - - If you do have a fix to any problem, please send it to me, so that - other people can have the benefits. - - While every effort has been taken to make this program as reliable as - possible, no responsibility can be taken for the correctness of the - output, nor suitability for any particular use. - - This program is an offshoot of a project funded by public funds. - If you use this program for research or commercial use (i.e. more - than just for the fun of knowing about your compiler) mailing a short - note of acknowledgement may help keep enquire.c supported. - - ACKNOWLEDGEMENTS - Many people have given time and ideas to making this program what it is. - To all of them thanks, and apologies for not mentioning them by name. - - HISTORY - Originally started as a program to generate configuration constants - for a large piece of software we were writing, which later took on - a life of its own... - 1.0 Length 6658!; end 1984? - Unix only. Only printed a dozen maximum int/double values. - 2.0 Length 10535; Spring 1985 - Prints values as #defines (about 20 of them) - More extensive floating point, using Cody and Waite - Handles signals better - Programs around optimisations - Handles Cybers - 3.0 Length 12648; Aug 1987; prints about 42 values - Added PASS stuff, so treats float as well as double - 4.0 Length 33891; Feb 1989; prints around 85 values - First GNU version (for gcc, where they call it hard-params.c) - Generates float.h and limits.h files - Handles long double - Generates warnings for dubious output - 4.1 Length 47738; April 1989 - Added VERIFY and TEST - 4.2 Length 63442; Feb 1990 - Added SEP - Fixed eps/epsneg - Added check for pseudo-unsigned chars - Added description for each #define output - Added check for absence of defines during verify - Added prototypes - Added NO_STDC and NO_FILE - Fixed alignments output - 4.3 Length 75000; Oct 1990; around 114 lines of output - Function xmalloc defined, Richard Stallman, June 89. - Alignments computed from member offsets rather than structure sizes, - Richard Stallman, Oct 89. - Print whether char* and int* pointers have the same format; - also char * and function *. - Update to Draft C version Dec 7, 1988 - - types of constants produced in limits.h - (whether to put a U after unsigned shorts and chars and - whether to output -1024 as (-1023-1)) - - values of SCHAR_MIN/MAX - - values of *_EPSILON (not the smallest but the effective smallest) - Added FILENAME, since standard C doesn't allow #define __FILE__ - Renamed from config.c to enquire.c - Added size_t and ptrdiff_t enquiries - Added promotion enquiries - Added type checks of #defines - Added NO_STDDEF - Changed endian to allow for cases where not all bits are used - Sanity check for max integrals - Fixed definition of setjmp for -DNO_SIG - Moved #define ... 0.0L inside #ifdef STDC, in case some cpp's tokenize - Added NO_MEM -*/ - -/* Set FILENAME to the name of this file */ -#ifndef FILENAME -#ifdef NO_FILE -#define FILENAME "enquire.c" -#else -#ifdef __FILE__ /* It's a compiler bug if this fails. Compile with -DNO_FILE */ -#define FILENAME __FILE__ -#else -#define FILENAME "enquire.c" -#endif /* __FILE__ */ -#endif /* NO_FILE */ -#endif /* FILENAME */ - -/* If PASS isn't defined, then this is the first pass over this file. */ -#ifndef PASS -#ifndef SEP -#define PASS 1 -#define PASS0 1 -#define PASS1 1 -#endif /* SEP */ - -/* A description of the ANSI constants */ -#define D_CHAR_BIT "Number of bits in a storage unit" -#define D_CHAR_MAX "Maximum char" -#define D_CHAR_MIN "Minimum char" -#define D_SCHAR_MAX "Maximum signed char" -#define D_SCHAR_MIN "Minimum signed char" -#define D_UCHAR_MAX "Maximum unsigned char (minimum is always 0)" - -#define D_INT_MAX "Maximum %s" -#define D_INT_MIN "Minimum %s" -#define D_UINT_MAX "Maximum unsigned %s (minimum is always 0)" - -#define D_FLT_ROUNDS "Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown" -#define D_FLT_RADIX "Radix of exponent representation" -#define D_MANT_DIG "Number of base-FLT_RADIX digits in the significand of a %s" -#define D_DIG "Number of decimal digits of precision in a %s" -#define D_MIN_EXP "Minimum int x such that FLT_RADIX**(x-1) is a normalised %s" -#define D_MIN_10_EXP "Minimum int x such that 10**x is a normalised %s" -#define D_MAX_EXP "Maximum int x such that FLT_RADIX**(x-1) is a representable %s" -#define D_MAX_10_EXP "Maximum int x such that 10**x is a representable %s" -#define D_MAX "Maximum %s" -#define D_EPSILON "Difference between 1.0 and the minimum %s greater than 1.0" -#define D_MIN "Minimum normalised %s" - -/* Procedure just marks the functions that don't return a result */ -#ifdef NO_VOID -#define Procedure int -#else -#define Procedure void -#endif - -/* Some bad compilers define __STDC__, when they don't support it. - Compile with -DNO_STDC to get round this. -*/ -#ifndef NO_STDC -#ifdef __STDC__ -#if __STDC__ /* If __STDC__ is 0, assume it isn't supported */ -#define STDC -#endif -#endif -#endif - -/* Stuff different for ANSI C, and old C: - ARGS and NOARGS are used for function prototypes. - Volatile is used to reduce the chance of optimisation, - and to prevent variables being put in registers (when setjmp/longjmp - wouldn't work as we want) - Long_double is the longest floating point type available. - stdc is used in tests like "if (stdc)", which is less ugly than #ifdef. - U is output after unsigned constants. - */ -#ifdef STDC - -#define ARGS(x) x -#define NOARGS (void) -#define Volatile volatile -#define Long_double long double -#define stdc 1 -#define U "U" - -#else /* Old style C */ - -#define ARGS(x) () -#define NOARGS () -#define Volatile static -#define Long_double double -#define stdc 0 -#define U "" - -#endif /* STDC */ - -/* include files */ -/* Stdio.h might include limits.h, and limits.h might include float.h, and - float.h is probably the float.h put together by the gcc makefile to - cause errors. We use our special define to assure float.h that we don't - really need it. */ -#define __GCC_FLOAT_NOT_NEEDED -#include <stdio.h> - -#ifdef STDC -#ifndef NO_STDDEF -#include <stddef.h> /* for size_t: if this fails, define NO_STDDEF */ -#endif -#endif - -#ifdef NO_SIG -#define jmp_buf int -#else -#include <sys/types.h> -#include <signal.h> -#include <setjmp.h> -#endif - -/* Kludge around the possibility that <stdio.h> includes <limits.h> */ -#ifdef CHAR_BIT -#undef CHAR_BIT -#undef CHAR_MAX -#undef CHAR_MIN -#undef SCHAR_MAX -#undef SCHAR_MIN -#undef UCHAR_MAX -#undef UCHAR_MIN -#endif - -#ifdef VERIFY -#include "limits.h" -#endif - -#ifndef SYS_FLOAT_H_WRAP -#define SYS_FLOAT_H_WRAP 0 -#endif - -#if SYS_FLOAT_H_WRAP || defined VERIFY -#include "float.h" -#endif - -#define Vprintf if (V) printf -#define Unexpected(place) if (setjmp(lab)!=0) croak(place) -#define fabs(x) (((x)<0.0)?(-x):(x)) - -#endif /* PASS */ - -#ifdef PASS0 - -/* Prototypes for what's to come: */ - -int false NOARGS; - -#ifdef NO_STDDEF -char *malloc (); /* Old style prototype */ -#else -char *malloc ARGS((size_t size)); -#endif - -Procedure exit ARGS((int status)); - -char *f_rep ARGS((int precision, Long_double val)); -char *fake_f_rep ARGS((char *type, Long_double val)); - -int maximum_int NOARGS; -int cprop NOARGS; -int basic NOARGS; -Procedure sprop NOARGS; -Procedure iprop NOARGS; -Procedure lprop NOARGS; -Procedure usprop NOARGS; -Procedure uiprop NOARGS; -Procedure ulprop NOARGS; -int fprop ARGS((int bits_per_byte)); -int dprop ARGS((int bits_per_byte)); -int ldprop ARGS((int bits_per_byte)); -Procedure efprop ARGS((int fprec, int dprec, int lprec)); -Procedure edprop ARGS((int fprec, int dprec, int lprec)); -Procedure eldprop ARGS((int fprec, int dprec, int lprec)); - -int setmode ARGS((char *s)); -Procedure farewell ARGS((int bugs)); -Procedure describe ARGS((char *description, char *extra)); -Procedure missing ARGS((char *s)); -Procedure fmissing ARGS((char *s)); -Procedure check_defines NOARGS; -Procedure bitpattern ARGS((char *p, unsigned int size)); -int ceil_log ARGS((int base, Long_double x)); -Procedure croak ARGS((int place)); -Procedure eek_a_bug ARGS((char *problem)); -Procedure endian ARGS((int bits_per_byte)); -int exponent ARGS((Long_double x, double *fract, int *exp)); -int floor_log ARGS((int base, Long_double x)); -Procedure f_define ARGS((char *desc, char *extra, char *sort, char *name, - int prec, Long_double val, Long_double req, - char *mark)); -Procedure i_define ARGS((char *desc, char *extra, char *sort, char *name, - long val, long lim, long req, char *mark)); -Procedure u_define ARGS((char *desc, char *extra, char *sort, char *name, - unsigned long val, unsigned long req, char *mark)); - -#ifdef NO_SIG /* There's no signal(), or setjmp/longjmp() */ - - /* Dummy routines instead */ - - int setjmp ARGS((int lab)); - - int lab=1; - int setjmp(lab) int lab; { return(0); } - Procedure signal(i, p) int i, (*p)(); {} - -#else - jmp_buf lab; - Procedure overflow(sig) int sig; { /* what to do on over/underflow */ - signal(sig, overflow); - longjmp(lab, 1); - } - -#endif /*NO_SIG*/ - -int V= 0, /* verbose */ - L= 0, /* produce limits.h */ - F= 0, /* produce float.h */ - bugs=0; /* The number of (possible) bugs in the output */ - -char co[4], oc[4]; /* Comment starter and ender symbols */ - -int bits_per_byte; /* the number of bits per unit returned by sizeof() */ -int flt_rounds; /* The calculated value of FLT_ROUNDS */ -int flt_radix; /* The calculated value of FLT_RADIX */ - -#ifdef TEST -/* Set the fp modes on a SUN with 68881 chip, to check that different - rounding modes etc. get properly detected. - Compile with -f68881 for cc, -m68881 for gcc, and with additional flag - -DTEST. Run with additional parameter +hex-number, to set the 68881 mode - register to hex-number -*/ - -/* Bits 0x30 = rounding mode */ -#define ROUND_BITS 0x30 -#define TO_NEAREST 0x00 -#define TO_ZERO 0x10 -#define TO_MINUS_INF 0x20 -#define TO_PLUS_INF 0x30 /* The SUN FP user's guide seems to be wrong here */ - -/* Bits 0xc0 = extended rounding */ -#define EXT_BITS 0xc0 -#define ROUND_EXTENDED 0x00 -#define ROUND_SINGLE 0x40 -#define ROUND_DOUBLE 0x80 - -/* Enabled traps */ -#define EXE_INEX1 0x100 -#define EXE_INEX2 0x200 -#define EXE_DZ 0x400 -#define EXE_UNFL 0x800 -#define EXE_OVFL 0x1000 -#define EXE_OPERR 0x2000 -#define EXE_SNAN 0x4000 -#define EXE_BSUN 0x8000 - -/* Only used for testing, on a Sun with 68881 chip */ -/* Print the FP mode */ -printmode(new) unsigned new; { - fpmode_(&new); - printf("New fp mode:\n"); - printf(" Round toward "); - switch (new & ROUND_BITS) { - case TO_NEAREST: printf("nearest"); break; - case TO_ZERO: printf("zero"); break; - case TO_MINUS_INF: printf("minus infinity"); break; - case TO_PLUS_INF: printf("plus infinity"); break; - default: printf("???"); break; - } - - printf("\n Extended rounding precision: "); - - switch (new & EXT_BITS) { - case ROUND_EXTENDED: printf("extended"); break; - case ROUND_SINGLE: printf("single"); break; - case ROUND_DOUBLE: printf("double"); break; - default: printf("???"); break; - } - - printf("\n Enabled exceptions:"); - if (new & (unsigned) EXE_INEX1) printf(" inex1"); - if (new & (unsigned) EXE_INEX2) printf(" inex2"); - if (new & (unsigned) EXE_DZ) printf(" dz"); - if (new & (unsigned) EXE_UNFL) printf(" unfl"); - if (new & (unsigned) EXE_OVFL) printf(" ovfl"); - if (new & (unsigned) EXE_OPERR) printf(" operr"); - if (new & (unsigned) EXE_SNAN) printf(" snan"); - if (new & (unsigned) EXE_BSUN) printf(" bsun"); - printf("\n"); -} - -/* Only used for testing, on a Sun with 68881 chip */ -/* Set the FP mode */ -int setmode(s) char *s; { - unsigned mode=0, dig; - char c; - - while (*s) { - c= *s++; - if (c>='0' && c<='9') dig= c-'0'; - else if (c>='a' && c<='f') dig= c-'a'+10; - else if (c>='A' && c<='F') dig= c-'A'+10; - else return 1; - mode= mode<<4 | dig; - } - printmode(mode); - return 0; -} -#else -/* ARGSUSED */ -int setmode(s) char *s; { - fprintf(stderr, "Can't set mode: not compiled with TEST\n"); - return(1); -} -#endif - -Procedure farewell(bugs) int bugs; { - if (bugs == 0) exit(0); - printf("\n%sFor hints on dealing with the ", co); - if (bugs == 1) printf("problem"); - else printf("%d problems", bugs); - printf(" above\n see the section 'TROUBLESHOOTING' in the file "); - printf("%s%s\n", FILENAME, oc); - exit(bugs); -} - -/* The program has received a signal where it wasn't expecting one */ -Procedure croak(place) int place; { - printf("*** Unexpected signal at point %d\n", place); - farewell(bugs+1); /* An exit isn't essential here, but avoids loops */ -} - -/* This is here in case alloca.c is used, which calls this. */ -char *xmalloc(size) unsigned size; { - char *value = (char *)malloc(size); - if (value == 0) { - fprintf(stderr, "Virtual memory exceeded\n"); - exit(bugs+1); - } - return value; -} - -int maxint; - -int maximum_int() { - /* Find the maximum integer */ - Volatile int newi, int_max, two=2; - - /* Calculate maxint ***********************************/ - /* Calculate 2**n-1 until overflow - then use the previous value */ - - newi=1; int_max=0; - - if (setjmp(lab)==0) { /* Yields int_max */ - while(newi>int_max) { - int_max=newi; - newi=newi*two+1; - } - } - Unexpected(0); - return int_max; -} - -int main(argc, argv) int argc; char *argv[]; { - int dprec, fprec, lprec; - int i; char *s; int bad; - -#ifdef SIGFPE - signal(SIGFPE, overflow); -#endif -#ifdef SIGOVER - signal(SIGOVER, overflow); -#endif -/* Add more calls as necessary */ - - Unexpected(1); - - bad=0; - for (i=1; i < argc; i++) { - s= argv[i]; - if (*s == '-') { - s++; - while (*s) { - switch (*(s++)) { - case 'v': V=1; break; - case 'l': L=1; break; - case 'f': F=1; break; - default: bad=1; break; - } - } - } else if (*s == '+') { - s++; - bad= setmode(s); - } else bad= 1; - } - if (bad) { - fprintf(stderr, - "Usage: %s [-vlf]\n v=Verbose l=Limits.h f=Float.h\n", - argv[0]); - exit(1); - } - if (L || F) { - co[0]= '/'; oc[0]= ' '; - co[1]= '*'; oc[1]= '*'; - co[2]= ' '; oc[2]= '/'; - co[3]= '\0'; oc[3]= '\0'; - } else { - co[0]= '\0'; oc[0]= '\0'; - V=1; - } - - if (L) printf("%slimits.h%s\n", co, oc); - if (F) printf("%sfloat.h%s\n", co, oc); - if (F) { - printf ("#ifndef _FLOAT_H___\n"); - printf ("#define _FLOAT_H___\n"); - if (SYS_FLOAT_H_WRAP) - printf (" #include_next <float.h>\n"); - } -#ifdef ID - printf("%sProduced on %s by enquire version %s, CWI, Amsterdam%s\n", - co, ID, VERSION, oc); -#else - printf("%sProduced by enquire version %s, CWI, Amsterdam%s\n", - co, VERSION, oc); -#endif - -#ifdef VERIFY - printf("%sVerification phase%s\n", co, oc); -#endif - -#ifdef NO_SIG - Vprintf("%sCompiled without signal(): %s%s\n", - co, - "there's nothing that can be done if overflow occurs", - oc); -#endif -#ifdef NO_SC - Vprintf("%sCompiled without signed char%s\n", co, oc); -#endif -#ifdef NO_UC - Vprintf("%Compiled without unsigned char%s\n", co, oc); -#endif -#ifdef NO_UI - Vprintf("%Compiled without unsigned short or long%s\n", co, oc); -#endif -#ifdef __STDC__ - Vprintf("%sCompiler claims to be ANSI C level %d%s\n", - co, __STDC__, oc); -#else - Vprintf("%sCompiler does not claim to be ANSI C%s\n", co, oc); -#endif - printf("\n"); - check_defines(); - - maxint= maximum_int(); - bits_per_byte= basic(); - Vprintf("\n"); - if (F||V) { - fprec= fprop(bits_per_byte); - dprec= dprop(bits_per_byte); - lprec= ldprop(bits_per_byte); - efprop(fprec, dprec, lprec); - edprop(fprec, dprec, lprec); - eldprop(fprec, dprec, lprec); - } -#ifndef NO_MEM - if (V) { - unsigned int size; - long total; - /* An extra goody: the approximate amount of data-space */ - /* Allocate store until no more available */ - /* Different implementations have a different argument type - to malloc. Here we assume that it's the same type as - that which sizeof() returns */ - size=1<<((bits_per_byte*sizeof(int))-2); - total=0; - while (size!=0) { - while ( malloc((false()?sizeof(int):size)) != - (char *)NULL - ) { - total+=(size/2); - } - size/=2; - } - - Vprintf("%sMemory allocable ~= %ld Kbytes%s\n", - co, (total+511)/512, oc); - } -#endif - if (F) { - printf ("#endif %s _FLOAT_H___%s\n", co, oc); - } - farewell(bugs); - return bugs; /* To keep compilers and lint happy */ -} - -Procedure eek_a_bug(problem) char *problem; { - /* The program has discovered a problem */ - printf("\n%s*** WARNING: %s%s\n", co, problem, oc); - bugs++; -} - -Procedure describe(description, extra) char *description, *extra; { - /* Produce the description for a #define */ - printf(" %s", co); - printf(description, extra); - printf("%s\n", oc); -} - -Procedure i_define(desc, extra, sort, name, val, lim, req, mark) - char *desc, *extra, *sort, *name; long val, lim, req; char *mark; { - if (SYS_FLOAT_H_WRAP && F && val == req) - return; - /* Produce a #define for a signed int type */ - describe(desc, extra); - printf("#undef %s%s\n", sort, name); - if (val >= 0) { - printf("#define %s%s %ld%s\n", sort, name, val, mark); - } else if (val + lim < 0) { - /* We may not produce a constant like -1024 if the max - allowable value is 1023. It has then to be output as - -1023-1. lim is the max allowable value. */ - printf("#define %s%s (%ld%s%ld%s)\n", - sort, name, -lim, mark, val+lim, mark); - } else { - printf("#define %s%s (%ld%s)\n", sort, name, val, mark); - } -#ifdef VERIFY - if (val != req) { - printf("%s*** Verify failed for above #define!\n", co); - printf(" Compiler has %ld for value%s\n\n", req, oc); - bugs++; - } -#endif - Vprintf("\n"); -} - -Procedure u_define(desc, extra, sort, name, val, req, mark) - char *desc, *extra, *sort, *name; unsigned long val, req; char *mark; { - /* Produce a #define for an unsigned value */ - describe(desc, extra); - printf("#undef %s%s\n", sort, name); - printf("#define %s%s %lu%s%s\n", sort, name, val, U, mark); -#ifdef VERIFY - if (val != req) { - printf("%s*** Verify failed for above #define!\n", co); - printf(" Compiler has %lu for value%s\n\n", req, oc); - bugs++; - } -#endif - Vprintf("\n"); -} - -Procedure f_define(desc, extra, sort, name, precision, val, req, mark) - char *desc, *extra, *sort, *name; int precision; - Long_double val, req; char *mark; { - if (SYS_FLOAT_H_WRAP && F && val == req) - return; - /* Produce a #define for a float/double/long double */ - describe(desc, extra); - printf ("#undef %s%s\n", sort, name); - if (stdc) { -#ifdef NO_LONG_DOUBLE_IO - static int union_defined = 0; - if (sizeof(double) != sizeof(Long_double) - && !strcmp(sort, "LDBL")) { - if (!union_defined) { - printf("#ifndef __LDBL_UNION__\n"); - printf("#define __LDBL_UNION__\n"); - printf("union __convert_long_double {\n"); - printf(" unsigned __convert_long_double_i[4];\n"); - printf(" long double __convert_long_double_d;\n"); - printf("};\n"); - printf("#endif\n"); - union_defined = 1; - } - printf("#define %s%s %s\n", - sort, name, fake_f_rep("long double", val)); - } else { - printf("#define %s%s %s%s\n", - sort, name, f_rep(precision, val), mark); - } -#else - printf("#define %s%s %s%s\n", - sort, name, f_rep(precision, val), mark); -#endif - } else if (*mark == 'F') { - /* non-ANSI C has no float constants, so cast the constant */ - printf("#define %s%s ((float)%s)\n", - sort, name, f_rep(precision, val)); - } else { - printf("#define %s%s %s\n", sort, name, f_rep(precision, val)); - } - Vprintf("\n"); -} - -int floor_log(base, x) int base; Long_double x; { - /* return floor(log base(x)) */ - int r=0; - while (x>=base) { r++; x/=base; } - return r; -} - -int ceil_log(base, x) int base; Long_double x; { - int r=0; - while (x>1.0) { r++; x/=base; } - return r; -} - -int exponent(x, fract, exp) Long_double x; double *fract; int *exp; { - /* Split x into a fraction and a power of ten; - returns 0 if x is unusable, 1 otherwise. - Only used for error messages about faulty output. - */ - int r=0, neg=0; - Long_double old; - *fract=0.0; *exp=0; - if (x<0.0) { - x= -x; - neg= 1; - } - if (x==0.0) return 1; - if (x>=10.0) { - while (x>=10.0) { - old=x; r++; x/=10.0; - if (old==x) return 0; - } - } else { - while (x<1.0) { - old=x; r--; x*=10.0; - if (old==x) return 0; - } - } - if (neg) *fract= (double) -x; - else *fract=(double) x; - *exp=r; - return 1; -} - -/* Print a value of type TYPE with value VAL, - assuming that sprintf can't handle this type properly (without truncation). - We create an expression that uses type casting to create the value from - a bit pattern. */ - -char *fake_f_rep(type, val) char *type; Long_double val; { - static char buf[1024]; - union { unsigned int i[4]; Long_double ld;} u; - u.i[0] = u.i[1] = u.i[2] = u.i[3] = 0; - u.ld = val; - sprintf(buf, "(__extension__ ((union __convert_long_double) {__convert_long_double_i: {0x%x, 0x%x, 0x%x, 0x%x}}).__convert_long_double_d)", - u.i[0], u.i[1], u.i[2], u.i[3]); - return buf; -} - -char *f_rep(precision, val) int precision; Long_double val; { - /* Return the floating representation of val */ - static char buf[1024]; -#ifdef NO_LONG_DOUBLE_IO - if (1) -#else - if (sizeof(double) == sizeof(Long_double)) -#endif - { - double d = val; - /* Assume they're the same, and use non-stdc format */ - /* This is for stdc compilers using non-stdc libraries */ - sprintf(buf, "%.*e", precision, d); - } else { - /* It had better support Le then */ - sprintf(buf, "%.*Le", precision, val); - } - return buf; -} - -Procedure bitpattern(p, size) char *p; unsigned int size; { - /* Printf the bit-pattern of p */ - char c; - unsigned int i; - int j; - - for (i=1; i<=size; i++) { - c= *p; - p++; - for (j=bits_per_byte-1; j>=0; j--) - printf("%c", (c>>j)&1 ? '1' : '0'); - if (i!=size) printf(" "); - } -} - -#define Order(x, px, mode)\ - printf("%s%s ", co, mode); for (i=0; i<sizeof(x); i++) px[i]= ab[i]; \ - for (i=1; i<=sizeof(x); i++) { c=((x>>(bits_per_byte*(sizeof(x)-i)))&mask);\ - putchar(c==0 ? '?' : (char)c); }\ - printf("%s\n", oc); - -Procedure endian(bits_per_byte) int bits_per_byte; { - /* Printf the byte-order used on this machine */ - /*unsigned*/ short s=0; - /*unsigned*/ int j=0; - /*unsigned*/ long l=0; - - char *ps= (char *) &s, - *pj= (char *) &j, - *pl= (char *) &l, - *ab= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - unsigned int mask, i, c; - - mask=0; - for (i=1; i<=(unsigned)bits_per_byte; i++) mask= (mask<<1)|1; - - if (V) { - printf("%sCHARACTER ORDER%s\n", co, oc); - Order(s, ps, "short:"); - Order(j, pj, "int: "); - Order(l, pl, "long: "); - } -} - -Procedure missing(s) char *s; { - printf("%s*** #define %s missing from limits.h%s\n", co, s, oc); - bugs++; -} - -Procedure fmissing(s) char *s; { - printf("%s*** #define %s missing from float.h%s\n", co, s, oc); - bugs++; -} - -/* To try and fool optimisers */ -int false() { return 0; } - -#define Promoted(x) (false()?(x):(-1)) -#define is_signed(x) (Promoted(x) < 0) -#define sign_of(x) ((x)?"signed":"unsigned") -#define Signed 1 -#define Unsigned 0 -#define sgn(x) ((is_signed(x))?Signed:Unsigned) - -#define showtype(t, x) Vprintf("%s%s %s %s%s\n", co, t, sign_of(is_signed(x)), type_of(sizeof(x)), oc) - -char *type_of(x) int x; { - if (x == sizeof(char)) { - if (sizeof(char) == sizeof(int)) return "char/short/int"; - if (sizeof(char) == sizeof(short)) return "char/short"; - return "char"; - } - if (x == sizeof(short)) { - if (sizeof(short) == sizeof(int)) return "short/int"; - return "short"; - } - if (x == sizeof(int)) { - if (sizeof(int) == sizeof(long)) return "int/long"; - return "int"; - } - if (x == sizeof(long)) return "long"; - return "unknown-type"; -} - -char *ftype_of(x) int x; { - if (x == sizeof(float)) { - return "float"; - } - if (x == sizeof(double)) { - if (sizeof(double) == sizeof(Long_double)) - return "(long)double"; - return "double"; - } - if (x == sizeof(Long_double)) { - return "long double"; - } - return "unknown-type"; -} - -Procedure typerr(name, esign, esize, sign, size) - char *name; int esign, esize, sign, size; -{ - Vprintf("*** %s has wrong type: expected %s %s, found %s %s\n", - name, sign_of(esign), type_of(esize), - sign_of(sign), type_of(size)); -} - -Procedure ftyperr(name, esize, size) char *name; int esize, size; { - Vprintf("*** %s has wrong type: expected %s, found %s\n", - name, ftype_of(esize), ftype_of(size)); -} - -int promotions() { - int si = 0; long sl = 0; - unsigned int ui; unsigned long ul; - short ss; unsigned short us; - - Vprintf("\n%sPROMOTIONS%s\n", co, oc); - - if ( - /* Possible warnings here; no problem */ - (sizeof(Promoted(si)) != sizeof(int)) || - (sizeof(Promoted(sl)) != sizeof(long)) || - (sizeof(Promoted(ss)) != sizeof(int)) || - (sizeof(Promoted(ui)) != sizeof(int)) || - (sizeof(Promoted(ul)) != sizeof(long)) || - (sizeof(Promoted(us)) != sizeof(int)) || - is_signed(ui) || is_signed(ul) || - !is_signed(si) || !is_signed(sl) - ) - { - eek_a_bug("promotions don't work properly in conditional expressions\n"); - } - - showtype("unsigned short promotes to", Promoted((unsigned short) 0)); - showtype("long+unsigned gives", sl+ui); - return 0; -} - -#define checktype(x, n, s, t) if((sgn(x)!=s)||(sizeof(x)!=sizeof(t))) typerr(n, s, sizeof(t), sign_of(x), sizeof(x)); - -#define fchecktype(x, n, t) if (sizeof(x) != sizeof(t)) ftyperr(n, sizeof(x), sizeof(t)); - -Procedure check_defines() { - /* ensure that all #defines are present and have the correct type */ -#ifdef VERIFY - int usign; - -#ifdef NO_UI - usign= Signed; -#else - /* Implementations promote unsigned short differently */ - usign= is_signed((unsigned short) 0); -#endif - - if (L) { -#ifdef CHAR_BIT - checktype(CHAR_BIT, "CHAR_BIT", Signed, int); -#else - missing("CHAR_BIT"); -#endif -#ifdef CHAR_MAX - checktype(CHAR_MAX, "CHAR_MAX", Signed, int); -#else - missing("CHAR_MAX"); -#endif -#ifdef CHAR_MIN - checktype(CHAR_MIN, "CHAR_MIN", Signed, int); -#else - missing("CHAR_MIN"); -#endif -#ifdef SCHAR_MAX - checktype(SCHAR_MAX, "SCHAR_MAX", Signed, int); -#else - missing("SCHAR_MAX"); -#endif -#ifdef SCHAR_MIN - checktype(SCHAR_MIN, "SCHAR_MIN", Signed, int); -#else - missing("SCHAR_MIN"); -#endif -#ifdef UCHAR_MAX - checktype(UCHAR_MAX, "UCHAR_MAX", Signed, int); -#else - missing("UCHAR_MAX"); -#endif -#ifdef SHRT_MAX - checktype(SHRT_MAX, "SHRT_MAX", Signed, int); -#else - missing("SHRT_MAX"); -#endif -#ifdef SHRT_MIN - checktype(SHRT_MIN, "SHRT_MIN", Signed, int); -#else - missing("SHRT_MIN"); -#endif -#ifdef INT_MAX - checktype(INT_MAX, "INT_MAX", Signed, int); -#else - missing("INT_MAX"); -#endif -#ifdef INT_MIN - checktype(INT_MIN, "INT_MIN", Signed, int); -#else - missing("INT_MIN"); -#endif -#ifdef LONG_MAX - checktype(LONG_MAX, "LONG_MAX", Signed, long); -#else - missing("LONG_MAX"); -#endif -#ifdef LONG_MIN - checktype(LONG_MIN, "LONG_MIN", Signed, long); -#else - missing("LONG_MIN"); -#endif -#ifdef USHRT_MAX - checktype(USHRT_MAX, "USHRT_MAX", usign, int); -#else - missing("USHRT_MAX"); -#endif -#ifdef UINT_MAX - checktype(UINT_MAX, "UINT_MAX", Unsigned, int); -#else - missing("UINT_MAX"); -#endif -#ifdef ULONG_MAX - checktype(ULONG_MAX, "ULONG_MAX", Unsigned, long); -#else - missing("ULONG_MAX"); -#endif - } /* if (L) */ - - if (F) { -#ifdef FLT_RADIX - checktype(FLT_RADIX, "FLT_RADIX", Signed, int); -#else - fmissing("FLT_RADIX"); -#endif -#ifdef FLT_MANT_DIG - checktype(FLT_MANT_DIG, "FLT_MANT_DIG", Signed, int); -#else - fmissing("FLT_MANT_DIG"); -#endif -#ifdef FLT_DIG - checktype(FLT_DIG, "FLT_DIG", Signed, int); -#else - fmissing("FLT_DIG"); -#endif -#ifdef FLT_ROUNDS - checktype(FLT_ROUNDS, "FLT_ROUNDS", Signed, int); -#else - fmissing("FLT_ROUNDS"); -#endif -#ifdef FLT_EPSILON - fchecktype(FLT_EPSILON, "FLT_EPSILON", float); -#else - fmissing("FLT_EPSILON"); -#endif -#ifdef FLT_MIN_EXP - checktype(FLT_MIN_EXP, "FLT_MIN_EXP", Signed, int); -#else - fmissing("FLT_MIN_EXP"); -#endif -#ifdef FLT_MIN - fchecktype(FLT_MIN, "FLT_MIN", float); -#else - fmissing("FLT_MIN"); -#endif -#ifdef FLT_MIN_10_EXP - checktype(FLT_MIN_10_EXP, "FLT_MIN_10_EXP", Signed, int); -#else - fmissing("FLT_MIN_10_EXP"); -#endif -#ifdef FLT_MAX_EXP - checktype(FLT_MAX_EXP, "FLT_MAX_EXP", Signed, int); -#else - fmissing("FLT_MAX_EXP"); -#endif -#ifdef FLT_MAX - fchecktype(FLT_MAX, "FLT_MAX", float); -#else - fmissing("FLT_MAX"); -#endif -#ifdef FLT_MAX_10_EXP - checktype(FLT_MAX_10_EXP, "FLT_MAX_10_EXP", Signed, int); -#else - fmissing("FLT_MAX_10_EXP"); -#endif -#ifdef DBL_MANT_DIG - checktype(DBL_MANT_DIG, "DBL_MANT_DIG", Signed, int); -#else - fmissing("DBL_MANT_DIG"); -#endif -#ifdef DBL_DIG - checktype(DBL_DIG, "DBL_DIG", Signed, int); -#else - fmissing("DBL_DIG"); -#endif -#ifdef DBL_EPSILON - fchecktype(DBL_EPSILON, "DBL_EPSILON", double); -#else - fmissing("DBL_EPSILON"); -#endif -#ifdef DBL_MIN_EXP - checktype(DBL_MIN_EXP, "DBL_MIN_EXP", Signed, int); -#else - fmissing("DBL_MIN_EXP"); -#endif -#ifdef DBL_MIN - fchecktype(DBL_MIN, "DBL_MIN", double); -#else - fmissing("DBL_MIN"); -#endif -#ifdef DBL_MIN_10_EXP - checktype(DBL_MIN_10_EXP, "DBL_MIN_10_EXP", Signed, int); -#else - fmissing("DBL_MIN_10_EXP"); -#endif -#ifdef DBL_MAX_EXP - checktype(DBL_MAX_EXP, "DBL_MAX_EXP", Signed, int); -#else - fmissing("DBL_MAX_EXP"); -#endif -#ifdef DBL_MAX - fchecktype(DBL_MAX, "DBL_MAX", double); -#else - fmissing("DBL_MAX"); -#endif -#ifdef DBL_MAX_10_EXP - checktype(DBL_MAX_10_EXP, "DBL_MAX_10_EXP", Signed, int); -#else - fmissing("DBL_MAX_10_EXP"); -#endif -#ifdef STDC -#ifdef LDBL_MANT_DIG - checktype(LDBL_MANT_DIG, "LDBL_MANT_DIG", Signed, int); -#else - fmissing("LDBL_MANT_DIG"); -#endif -#ifdef LDBL_DIG - checktype(LDBL_DIG, "LDBL_DIG", Signed, int); -#else - fmissing("LDBL_DIG"); -#endif -#ifdef LDBL_EPSILON - fchecktype(LDBL_EPSILON, "LDBL_EPSILON", long double); -#else - fmissing("LDBL_EPSILON"); -#endif -#ifdef LDBL_MIN_EXP - checktype(LDBL_MIN_EXP, "LDBL_MIN_EXP", Signed, int); -#else - fmissing("LDBL_MIN_EXP"); -#endif -#ifdef LDBL_MIN - fchecktype(LDBL_MIN, "LDBL_MIN", long double); -#else - fmissing("LDBL_MIN"); -#endif -#ifdef LDBL_MIN_10_EXP - checktype(LDBL_MIN_10_EXP, "LDBL_MIN_10_EXP", Signed, int); -#else - fmissing("LDBL_MIN_10_EXP"); -#endif -#ifdef LDBL_MAX_EXP - checktype(LDBL_MAX_EXP, "LDBL_MAX_EXP", Signed, int); -#else - fmissing("LDBL_MAX_EXP"); -#endif -#ifdef LDBL_MAX - fchecktype(LDBL_MAX, "LDBL_MAX", long double); -#else - fmissing("LDBL_MAX"); -#endif -#ifdef LDBL_MAX_10_EXP - checktype(LDBL_MAX_10_EXP, "LDBL_MAX_10_EXP", Signed, int); -#else - fmissing("LDBL_MAX_10_EXP"); -#endif -#endif /* STDC */ - } /* if (F) */ -#endif /* VERIFY */ -} - -#ifdef VERIFY -#ifndef SCHAR_MAX -#define SCHAR_MAX char_max -#endif -#ifndef SCHAR_MIN -#define SCHAR_MIN char_min -#endif -#ifndef UCHAR_MAX -#define UCHAR_MAX char_max -#endif -#endif /* VERIFY */ - -#ifndef CHAR_BIT -#define CHAR_BIT char_bit -#endif -#ifndef CHAR_MAX -#define CHAR_MAX char_max -#endif -#ifndef CHAR_MIN -#define CHAR_MIN char_min -#endif -#ifndef SCHAR_MAX -#define SCHAR_MAX char_max -#endif -#ifndef SCHAR_MIN -#define SCHAR_MIN char_min -#endif -#ifndef UCHAR_MAX -#define UCHAR_MAX char_max -#endif - -int cprop() { - /* Properties of type char */ - Volatile char c, char_max, char_min; - Volatile int bits_per_byte, c_signed; - long char_bit; - - Unexpected(2); - - /* Calculate number of bits per character *************************/ - c=1; bits_per_byte=0; - do { c=c<<1; bits_per_byte++; } while(c!=0); - c= (char)(-1); - if (((int)c)<0) c_signed=1; - else c_signed=0; - Vprintf("%schar = %d bits, %ssigned%s\n", - co, (int)sizeof(c)*bits_per_byte, (c_signed?"":"un"), oc); - char_bit=(long)(sizeof(c)*bits_per_byte); - if (L) i_define(D_CHAR_BIT, "", "CHAR", "_BIT", - char_bit, 0L, (long) CHAR_BIT, ""); - - c=0; char_max=0; - c++; - if (bits_per_byte <= 16) { - if (setjmp(lab)==0) { /* Yields char_max */ - while (c>char_max) { - char_max=c; - c++; - } - } else { - Vprintf("%sCharacter overflow generates a trap!%s\n", - co, oc); - } - c=0; char_min=0; - c--; - if (setjmp(lab)==0) { /* Yields char_min */ - while (c<char_min) { - char_min=c; - c--; - } - } - } else { - /* An exhaustive search here is impracticable ;-) */ - c = (1 << (bits_per_byte - 1)) - 1; - char_max = c; - c++; - if (c > char_max) - char_max = ~0; - c = 0; - char_min = 0; - c--; - if (c < char_min) { - c = (1 << (bits_per_byte - 1)) - 1; - c = -c; - char_min = c; - c--; - if (c < char_min) - char_min = c; - } - } - if (c_signed && char_min == 0) { - Vprintf("%sBEWARE! Chars are pseudo-unsigned:%s\n", co, oc); - Vprintf("%s %s%s%s\n", - "They contain only nonnegative values, ", - "but sign extend when used as integers.", co, oc); - } - Unexpected(3); - - if (L) { - /* Because of the integer promotions, you must use a U after - the MAX_CHARS in the following cases */ - if ((sizeof(char) == sizeof(int)) && !c_signed) { - u_define(D_CHAR_MAX, "", "CHAR", "_MAX", - (long) char_max, - (long) CHAR_MAX, ""); - } else { - i_define(D_CHAR_MAX, "", "CHAR", "_MAX", - (long) char_max, 0L, - (long) CHAR_MAX, ""); - } - i_define(D_CHAR_MIN, "", "CHAR", "_MIN", - (long) char_min, (long) maxint, - (long) CHAR_MIN, ""); - if (c_signed) { - i_define(D_SCHAR_MAX, "", "SCHAR", "_MAX", - (long) char_max, 0L, - (long) SCHAR_MAX, ""); - i_define(D_SCHAR_MIN, "", "SCHAR", "_MIN", - (long) char_min, (long) maxint, - (long) SCHAR_MIN, ""); - } else { - if (sizeof(char) == sizeof(int)) { - u_define(D_UCHAR_MAX, "", "UCHAR", "_MAX", - (long) char_max, - (long) UCHAR_MAX, ""); - } else { - i_define(D_UCHAR_MAX, "", "UCHAR", "_MAX", - (long) char_max, 0L, - (long) UCHAR_MAX, ""); - } - } - - if (c_signed) { -#ifndef NO_UC - Volatile unsigned char c, char_max; - c=0; char_max=0; - c++; - if (setjmp(lab)==0) { /* Yields char_max */ - while (c>char_max) { - char_max=c; - c++; - } - } - Unexpected(4); - if (sizeof(char) == sizeof(int)) { - u_define(D_UCHAR_MAX, "", "UCHAR", "_MAX", - (long) char_max, - (long) UCHAR_MAX, ""); - } else { - i_define(D_UCHAR_MAX, "", "UCHAR", "_MAX", - (long) char_max, 0L, - (long) UCHAR_MAX, ""); - } -#endif - } else { -#ifndef NO_SC -/* Define NO_SC if this gives a syntax error */ Volatile signed char c, char_max, char_min; - c=0; char_max=0; - c++; - if (setjmp(lab)==0) { /* Yields char_max */ - while (c>char_max) { - char_max=c; - c++; - } - } - c=0; char_min=0; - c--; - if (setjmp(lab)==0) { /* Yields char_min */ - while (c<char_min) { - char_min=c; - c--; - } - } - Unexpected(5); - i_define(D_SCHAR_MIN, "", "SCHAR", "_MIN", - (long) char_min, (long) maxint, - (long) SCHAR_MIN, ""); - i_define(D_SCHAR_MAX, "", "SCHAR", "_MAX", - (long) char_max, 0L, - (long) SCHAR_MAX, ""); -#endif /* NO_SC */ - } - } - return bits_per_byte; -} - -int basic() { - /* The properties of the basic types. - Returns number of bits per sizeof unit */ - Volatile int bits_per_byte; - typedef int function (); - int variable; - int *p, *q; - - Vprintf("%sSIZES%s\n", co, oc); - bits_per_byte= cprop(); - - /* Shorts, ints and longs *****************************************/ - Vprintf("%sshort=%d int=%d long=%d float=%d double=%d bits %s\n", - co, - (int) sizeof(short)*bits_per_byte, - (int) sizeof(int)*bits_per_byte, - (int) sizeof(long)*bits_per_byte, - (int) sizeof(float)*bits_per_byte, - (int) sizeof(double)*bits_per_byte, oc); - if (stdc) { - Vprintf("%slong double=%d bits%s\n", - co, (int) sizeof(Long_double)*bits_per_byte, oc); - } - Vprintf("%schar*=%d bits%s%s\n", - co, (int)sizeof(char *)*bits_per_byte, - sizeof(char *)>sizeof(int)?" BEWARE! larger than int!":"", - oc); - Vprintf("%sint* =%d bits%s%s\n", - co, (int)sizeof(int *)*bits_per_byte, - sizeof(int *)>sizeof(int)?" BEWARE! larger than int!":"", - oc); - Vprintf("%sfunc*=%d bits%s%s\n", - co, (int)sizeof(function *)*bits_per_byte, - sizeof(function *)>sizeof(int)?" BEWARE! larger than int!":"", - oc); -if (V) printf ("%s%s %s %s%s\n", co, "Type size_t is", - ((((false()?( sizeof(int)):(-1)) < 0) )? - "signed":"unsigned") , - type_of(sizeof( - sizeof(int)+0 - ) - ), - oc); - showtype("Type size_t is", sizeof(0)); - - /* Alignment constants ********************************************/ - -#define alignment(TYPE) \ - ((long)((char *)&((struct{char c; TYPE d;}*)0)->d - (char *) 0)) - - Vprintf("\n%sALIGNMENTS%s\n", co, oc); - - Vprintf("%schar=%ld short=%ld int=%ld long=%ld%s\n", - co, - alignment(char), alignment(short), - alignment(int), alignment(long), - oc); - - Vprintf("%sfloat=%ld double=%ld%s\n", - co, - alignment(float), alignment(double), - oc); - - if (stdc) { - Vprintf("%slong double=%ld%s\n", - co, - alignment(Long_double), - oc); - } - Vprintf("%schar*=%ld int*=%ld func*=%ld%s\n", - co, - alignment(char *), alignment(int *), alignment(function *), - oc); - - Vprintf("\n"); - - /* Ten little endians *********************************************/ - - endian(bits_per_byte); - - /* Pointers *******************************************************/ - - Vprintf("\n%sPROPERTIES OF POINTERS%s\n", co, oc); - - if ((long) (char *) &variable == (long) (int *) &variable) { - Vprintf("%sChar and int pointer formats seem identical%s\n", - co, oc); - } else { - Vprintf("%sChar and int pointer formats are different%s\n", - co, oc); - } - if ((long) (char *) &variable == (long) (function *) &variable) { - Vprintf("%sChar and function pointer formats seem identical%s\n", - co, oc); - } else { - Vprintf("%sChar and function pointer formats are different%s\n", - co, oc); - } - - if (V) { - if ("abcd"=="abcd") - printf("%sStrings are shared%s\n", co, oc); - else printf("%sStrings are not shared%s\n", co, oc); - } - - p=0; q=0; - showtype("Type ptrdiff_t is", p-q); - - Vprintf("\n%sPROPERTIES OF INTEGRAL TYPES%s\n", co, oc); - - sprop(); - iprop(); - lprop(); - usprop(); - uiprop(); - ulprop(); - - promotions(); - - Unexpected(6); - - return bits_per_byte; -} - -#else /* not PASS0 */ - -#ifdef SEP -extern jmp_buf lab; -extern int V, L, F, bugs, bits_per_byte; -extern char co[], oc[]; -extern char *f_rep(); -#endif /* SEP */ -#endif /* ifdef PASS0 */ - -/* As I said, I apologise for the contortions below. The functions are - expanded by the preprocessor twice or three times (for float and double, - and maybe for long double, and for short, int and long). That way, - I never make a change to one that I forget to make to the other. - You can look on it as C's fault for not supporting multi-line macro's. - This whole file is read 3 times by the preprocessor, with PASSn set for - n=1, 2 or 3, to decide which parts to reprocess. -*/ - -/* #undef on an already undefined thing is (wrongly) flagged as an error - by some compilers, therefore the #ifdef that follows: -*/ -#ifdef Number -#undef Number -#undef THING -#undef Thing -#undef thing -#undef FPROP -#undef Fname -#undef Store -#undef Sum -#undef Diff -#undef Mul -#undef Div -#undef ZERO -#undef HALF -#undef ONE -#undef TWO -#undef THREE -#undef FOUR -#undef Self -#undef F_check -#undef Validate -#undef EPROP -#undef MARK - -/* These are the float.h constants */ -#undef F_RADIX -#undef F_MANT_DIG -#undef F_DIG -#undef F_ROUNDS -#undef F_EPSILON -#undef F_MIN_EXP -#undef F_MIN -#undef F_MIN_10_EXP -#undef F_MAX_EXP -#undef F_MAX -#undef F_MAX_10_EXP -#endif - -#ifdef Integer -#undef Integer -#undef INT -#undef IPROP -#undef Iname -#undef UPROP -#undef Uname -#undef OK_UI -#undef IMARK - -#undef I_MAX -#undef I_MIN -#undef U_MAX -#endif - -#ifdef PASS1 - -/* Define the things we're going to use this pass */ - -#define Number float -#define THING "FLOAT" -#define Thing "Float" -#define thing "float" -#define Fname "FLT" -#define FPROP fprop -#define Store fStore -#define Sum fSum -#define Diff fDiff -#define Mul fMul -#define Div fDiv -#define ZERO 0.0 -#define HALF 0.5 -#define ONE 1.0 -#define TWO 2.0 -#define THREE 3.0 -#define FOUR 4.0 -#define Self fSelf -#define F_check fCheck -#define MARK "F" -#ifdef VERIFY -#define Validate(prec, val, req, same) fValidate(prec, val, req, same) -#endif - -#define EPROP efprop - -#define Integer short -#define INT "short" -#define IPROP sprop -#define Iname "SHRT" -#ifndef NO_UI -#define OK_UI 1 -#endif -#define IMARK "" - -#define UPROP usprop -#define Uname "USHRT" - -#ifdef SHRT_MAX -#define I_MAX SHRT_MAX -#endif -#ifdef SHRT_MIN -#define I_MIN SHRT_MIN -#endif -#ifdef USHRT_MAX -#define U_MAX USHRT_MAX -#endif - -#ifdef FLT_RADIX -#define F_RADIX FLT_RADIX -#endif -#ifdef FLT_MANT_DIG -#define F_MANT_DIG FLT_MANT_DIG -#endif -#ifdef FLT_DIG -#define F_DIG FLT_DIG -#endif -#ifdef FLT_ROUNDS -#define F_ROUNDS FLT_ROUNDS -#endif -#ifdef FLT_EPSILON -#define F_EPSILON FLT_EPSILON -#endif -#ifdef FLT_MIN_EXP -#define F_MIN_EXP FLT_MIN_EXP -#endif -#ifdef FLT_MIN -#define F_MIN FLT_MIN -#endif -#ifdef FLT_MIN_10_EXP -#define F_MIN_10_EXP FLT_MIN_10_EXP -#endif -#ifdef FLT_MAX_EXP -#define F_MAX_EXP FLT_MAX_EXP -#endif -#ifdef FLT_MAX -#define F_MAX FLT_MAX -#endif -#ifdef FLT_MAX_10_EXP -#define F_MAX_10_EXP FLT_MAX_10_EXP -#endif - -#endif /* PASS1 */ - -#ifdef PASS2 - -#define Number double -#define THING "DOUBLE" -#define Thing "Double" -#define thing "double" -#define Fname "DBL" -#define FPROP dprop -#define Store dStore -#define Sum dSum -#define Diff dDiff -#define Mul dMul -#define Div dDiv -#define ZERO 0.0 -#define HALF 0.5 -#define ONE 1.0 -#define TWO 2.0 -#define THREE 3.0 -#define FOUR 4.0 -#define Self dSelf -#define F_check dCheck -#define MARK "" -#ifdef VERIFY -#define Validate(prec, val, req, same) dValidate(prec, val, req, same) -#endif - -#define EPROP edprop - -#define Integer int -#define INT "int" -#define IPROP iprop -#define Iname "INT" -#define OK_UI 1 /* Unsigned int is always possible */ -#define IMARK "" - -#define UPROP uiprop -#define Uname "UINT" - -#ifdef INT_MAX -#define I_MAX INT_MAX -#endif -#ifdef INT_MIN -#define I_MIN INT_MIN -#endif -#ifdef UINT_MAX -#define U_MAX UINT_MAX -#endif - -#ifdef DBL_MANT_DIG -#define F_MANT_DIG DBL_MANT_DIG -#endif -#ifdef DBL_DIG -#define F_DIG DBL_DIG -#endif -#ifdef DBL_EPSILON -#define F_EPSILON DBL_EPSILON -#endif -#ifdef DBL_MIN_EXP -#define F_MIN_EXP DBL_MIN_EXP -#endif -#ifdef DBL_MIN -#define F_MIN DBL_MIN -#endif -#ifdef DBL_MIN_10_EXP -#define F_MIN_10_EXP DBL_MIN_10_EXP -#endif -#ifdef DBL_MAX_EXP -#define F_MAX_EXP DBL_MAX_EXP -#endif -#ifdef DBL_MAX -#define F_MAX DBL_MAX -#endif -#ifdef DBL_MAX_10_EXP -#define F_MAX_10_EXP DBL_MAX_10_EXP -#endif - -#endif /* PASS2 */ - -#ifdef PASS3 - -#ifdef STDC -#define Number long double - -#define ZERO 0.0L -#define HALF 0.5L -#define ONE 1.0L -#define TWO 2.0L -#define THREE 3.0L -#define FOUR 4.0L -#endif - -#define THING "LONG DOUBLE" -#define Thing "Long double" -#define thing "long double" -#define Fname "LDBL" -#define FPROP ldprop -#define Store ldStore -#define Sum ldSum -#define Diff ldDiff -#define Mul ldMul -#define Div ldDiv -#define Self ldSelf -#define F_check ldCheck -#define MARK "L" -#ifdef VERIFY -#define Validate(prec, val, req, same) ldValidate(prec, val, req, same) -#endif - -#define EPROP eldprop - -#define Integer long -#define INT "long" -#define IPROP lprop -#define Iname "LONG" -#ifndef NO_UI -#define OK_UI 1 -#endif -#define IMARK "L" - -#define UPROP ulprop -#define Uname "ULONG" - -#ifdef LONG_MAX -#define I_MAX LONG_MAX -#endif -#ifdef LONG_MIN -#define I_MIN LONG_MIN -#endif -#ifdef ULONG_MAX -#define U_MAX ULONG_MAX -#endif - -#ifdef LDBL_MANT_DIG -#define F_MANT_DIG LDBL_MANT_DIG -#endif -#ifdef LDBL_DIG -#define F_DIG LDBL_DIG -#endif -#ifdef LDBL_EPSILON -#define F_EPSILON LDBL_EPSILON -#endif -#ifdef LDBL_MIN_EXP -#define F_MIN_EXP LDBL_MIN_EXP -#endif -#ifdef LDBL_MIN -#define F_MIN LDBL_MIN -#endif -#ifdef LDBL_MIN_10_EXP -#define F_MIN_10_EXP LDBL_MIN_10_EXP -#endif -#ifdef LDBL_MAX_EXP -#define F_MAX_EXP LDBL_MAX_EXP -#endif -#ifdef LDBL_MAX -#define F_MAX LDBL_MAX -#endif -#ifdef LDBL_MAX_10_EXP -#define F_MAX_10_EXP LDBL_MAX_10_EXP -#endif - -#endif /* PASS3 */ - -#define UNDEFINED (-2) - -#ifndef I_MAX -#define I_MAX ((unsigned long) UNDEFINED) -#endif -#ifndef I_MIN -#define I_MIN ((unsigned long) UNDEFINED) -#endif -#ifndef U_MAX -#define U_MAX ((unsigned long) UNDEFINED) -#endif - -#ifndef F_RADIX -#define F_RADIX UNDEFINED -#endif -#ifndef F_MANT_DIG -#define F_MANT_DIG UNDEFINED -#endif -#ifndef F_DIG -#define F_DIG UNDEFINED -#endif -#ifndef F_ROUNDS -#define F_ROUNDS UNDEFINED -#endif -#ifndef F_EPSILON -#define F_EPSILON ((Number) UNDEFINED) -#endif -#ifndef F_MIN_EXP -#define F_MIN_EXP UNDEFINED -#endif -#ifndef F_MIN -#define F_MIN ((Number) UNDEFINED) -#endif -#ifndef F_MIN_10_EXP -#define F_MIN_10_EXP UNDEFINED -#endif -#ifndef F_MAX_EXP -#define F_MAX_EXP UNDEFINED -#endif -#ifndef F_MAX -#define F_MAX ((Number) UNDEFINED) -#endif -#ifndef F_MAX_10_EXP -#define F_MAX_10_EXP UNDEFINED -#endif - -#ifndef VERIFY -#define Validate(prec, val, req, same) {;} -#endif - -#ifdef Integer - -Procedure IPROP() { - /* the properties of short, int, and long */ - Volatile Integer newi, int_max, maxeri, int_min, minneri; - Volatile int ibits, ipower, two=2; - - /* Calculate max short/int/long ***********************************/ - /* Calculate 2**n-1 until overflow - then use the previous value */ - - newi=1; int_max=0; - - if (setjmp(lab)==0) { /* Yields int_max */ - for(ipower=0; newi>int_max; ipower++) { - int_max=newi; - newi=newi*two+1; - } - Vprintf("%sOverflow of a%s %s does not generate a trap%s\n", - co, INT[0]=='i'?"n":"", INT, oc); - } else { - Vprintf("%sOverflow of a%s %s generates a trap%s\n", - co, INT[0]=='i'?"n":"", INT, oc); - } - Unexpected(7); - - /* Minimum value: assume either two's or one's complement *********/ - int_min= -int_max; - if (setjmp(lab)==0) { /* Yields int_min */ - if (int_min-1 < int_min) int_min--; - } - Unexpected(8); - - /* Now for those daft Cybers */ - - maxeri=0; newi=int_max; - - if (setjmp(lab)==0) { /* Yields maxeri */ - for(ibits=ipower; newi>maxeri; ibits++) { - maxeri=newi; - newi=newi+newi+1; - } - } - Unexpected(9); - - minneri= -maxeri; - if (setjmp(lab)==0) { /* Yields minneri */ - if (minneri-1 < minneri) minneri--; - } - Unexpected(10); - - Vprintf("%sMaximum %s = %ld (= 2**%d-1)%s\n", - co, INT, (long)int_max, ipower, oc); - Vprintf("%sMinimum %s = %ld%s\n", co, INT, (long)int_min, oc); - - if (L) i_define(D_INT_MAX, INT, Iname, "_MAX", - (long) int_max, 0L, - (long) I_MAX, IMARK); - if (L) i_define(D_INT_MIN, INT, Iname, "_MIN", - (long) int_min, (long) (PASS==1?maxint:int_max), - (long) I_MIN, IMARK); - - if(int_max < 0) { /* It has happened */ - eek_a_bug("signed integral comparison faulty?"); - } - - if (maxeri>int_max) { - Vprintf("%sThere is a larger %s, %ld (= 2**%d-1), %s %s%s\n", - co, INT, (long)maxeri, ibits, - "but only for addition, not multiplication", - "(I smell a Cyber!)", - oc); - } - - if (minneri<int_min) { - Vprintf("%sThere is a smaller %s, %ld, %s %s%s\n", - co, INT, (long)minneri, - "but only for addition, not multiplication", - "(I smell a Cyber!)", - oc); - } -} - -Procedure UPROP () { - /* The properties of unsigned short/int/long */ -#ifdef OK_UI - Volatile unsigned Integer u_max, newi, two; - newi=1; u_max=0; two=2; - - if (setjmp(lab)==0) { /* Yields u_max */ - while(newi>u_max) { - u_max=newi; - newi=newi*two+1; - } - } - Unexpected(11); - Vprintf("%sMaximum unsigned %s = %lu%s\n", - co, INT, (unsigned long) u_max, oc); - - /* Oh woe: new standard C defines value preserving promotions */ - if (L) { - if (PASS == 1 && sizeof(short) < sizeof(int)) { - /* Special only for short */ - i_define(D_UINT_MAX, INT, Uname, "_MAX", - (unsigned long) u_max, 0L, - (unsigned long) U_MAX, IMARK); - } else { - u_define(D_UINT_MAX, INT, Uname, "_MAX", - (unsigned long) u_max, - (unsigned long) U_MAX, IMARK); - } - } -#endif -} - -#endif /* Integer */ - -#ifdef Number - -/* The following routines are intended to defeat any attempt at optimisation - or use of extended precision, and to defeat faulty narrowing casts. - The weird prototypes are because of widening incompatibilities. -*/ -#ifdef STDC -#define ARGS1(atype, a) (atype a) -#define ARGS2(atype, a, btype, b) (atype a, btype b) -#else -#define ARGS1(atype, a) (a) atype a; -#define ARGS2(atype, a, btype, b) (a, b) atype a; btype b; -#endif - -Procedure Store ARGS2(Number, a, Number *, b) { *b=a; } -Number Sum ARGS2(Number, a, Number, b) {Number r; Store(a+b, &r); return (r); } -Number Diff ARGS2(Number, a, Number, b){Number r; Store(a-b, &r); return (r); } -Number Mul ARGS2(Number, a, Number, b) {Number r; Store(a*b, &r); return (r); } -Number Div ARGS2(Number, a, Number, b) {Number r; Store(a/b, &r); return (r); } -Number Self ARGS1(Number, a) {Number r; Store(a, &r); return (r); } - -Procedure F_check ARGS((int precision, Long_double val1)); - -Procedure F_check(precision, val1) int precision; Long_double val1; { - /* You don't think I'm going to go to all the trouble of writing - a program that works out what all sorts of values are, only to - have printf go and print the wrong values out, do you? - No, you're right, so this function tries to see if printf - has written the right value, by reading it back again. - This introduces a new problem of course: suppose printf writes - the correct value, and scanf reads it back wrong... oh well. - But I'm adamant about this: the precision given is enough - to uniquely identify the printed number, therefore I insist - that sscanf read the number back identically. Harsh yes, but - sometimes you've got to be cruel to be kind. - */ - Number val, new, diff; - double rem; - int e; - char *rep; - char *f2; - -#ifdef NO_LONG_DOUBLE_IO - double new1; - /* On the Sun 3, sscanf clobbers 4 words, - which leads to a crash when this function tries to return. */ - f2= "%le"; /* Input */ - /* It is no use checking long doubles if we can't - read and write them. */ - if (sizeof (Number) > sizeof(double)) - return; -#else - Long_double new1; - if (sizeof(double) == sizeof(Long_double)) { - /* Assume they're the same, and use non-stdc format */ - /* This is for stdc compilers using non-stdc libraries */ - f2= "%le"; /* Input */ - } else { - /* It had better support Le then */ - f2= "%Le"; - } -#endif - val= val1; - rep= f_rep(precision, (Long_double) val); - if (setjmp(lab)==0) { - sscanf(rep, f2, &new1); - } else { - eek_a_bug("sscanf caused a trap"); - printf("%s scanning: %s format: %s%s\n\n", co, rep, f2, oc); - Unexpected(12); - return; - } - - if (setjmp(lab)==0) { /* See if new is usable */ - new= new1; - if (new != 0.0) { - diff= val/new - 1.0; - if (diff < 0.1) diff= 1.0; - /* That should be enough to generate a trap */ - } - } else { - eek_a_bug("sscanf returned an unusable number"); - printf("%s scanning: %s with format: %s%s\n\n", - co, rep, f2, oc); - Unexpected(13); - return; - } - - Unexpected(14); - if (new != val) { - eek_a_bug("Possibly bad output from printf above"); - if (!exponent((Long_double)val, &rem, &e)) { - printf("%s but value was an unusable number%s\n\n", - co, oc); - return; - } - printf("%s expected value around %.*fe%d, bit pattern:\n ", - co, precision, rem, e); - bitpattern((char *) &val, (unsigned)sizeof(val)); - printf ("%s\n", oc); - printf("%s sscanf gave %s, bit pattern:\n ", - co, f_rep(precision, (Long_double) new)); - bitpattern((char *) &new, (unsigned)sizeof(new)); - printf ("%s\n", oc); - if (setjmp(lab) == 0) { - diff= val-new; - printf("%s difference= %s%s\n\n", - co, f_rep(precision, (Long_double) diff), oc); - } /* else forget it */ - Unexpected(15); - } -} - -#ifdef VERIFY -Procedure Validate(prec, val, req, same) int prec, same; Long_double val, req; { - /* Check that the compiler has read a #define value correctly */ - Unexpected(16); - if (!same) { - printf("%s*** Verify failed for above #define!\n", co); - if (setjmp(lab) == 0) { /* for the case that req == nan */ - printf(" Compiler has %s for value%s\n", - f_rep(prec, req), oc); - } else { - printf(" Compiler has %s for value%s\n", - "an unusable number", oc); - } - if (setjmp(lab) == 0) { - F_check(prec, (Long_double) req); - } /*else forget it*/ - if (setjmp(lab) == 0) { - if (req > 0.0 && val > 0.0) { - printf("%s difference= %s%s\n", - co, f_rep(prec, val-req), oc); - } - } /*else forget it*/ - Unexpected(17); - printf("\n"); - bugs++; - } else if (val != req) { - if (stdc) eek_a_bug("constant has the wrong precision"); - else eek_a_bug("the cast didn't work"); - printf("\n"); - } -} -#endif /* VERIFY */ - -int FPROP(bits_per_byte) int bits_per_byte; { - /* Properties of floating types, using algorithms by Cody and Waite - from MA Malcolm, as modified by WM Gentleman and SB Marovich. - Further extended by S Pemberton. - - Returns the number of digits in the fraction. - */ - - Volatile int - i, f_radix, iexp, irnd, mrnd, f_rounds, f_mant_dig, - iz, k, inf, machep, f_max_exp, f_min_exp, mx, negeps, - mantbits, digs, f_dig, trap, - hidden, normal, f_min_10_exp, f_max_10_exp; - Volatile Number - a, b, base, basein, basem1, f_epsilon, epsneg, - eps, epsp1, etop, ebot, - f_max, newxmax, f_min, xminner, y, y1, z, z1, z2; - - Unexpected(18); - - Vprintf("%sPROPERTIES OF %s%s\n", co, THING, oc); - - /* Base and size of significand **************************************/ - /* First repeatedly double until adding 1 has no effect. */ - /* For instance, if base is 10, with 3 significant digits */ - /* it will try 1, 2, 4, 8, ... 512, 1024, and stop there, */ - /* since 1024 is only representable as 1020. */ - a=1.0; - if (setjmp(lab)==0) { /* inexact trap? */ - do { a=Sum(a, a); } - while (Diff(Diff(Sum(a, ONE), a), ONE) == ZERO); - } else { - fprintf(stderr, "*** Program got loss-of-precision trap!\n"); - /* And supporting those is just TOO much trouble! */ - farewell(bugs+1); - } - Unexpected(19); - /* Now double until you find a number that can be added to the */ - /* above number. For 1020 this is 8 or 16, depending whether the */ - /* result is rounded or truncated. */ - /* In either case the result is 1030. 1030-1020= the base, 10. */ - b=1.0; - do { b=Sum(b, b); } while ((base=Diff(Sum(a, b), a)) == ZERO); - f_radix=base; - Vprintf("%sBase = %d%s\n", co, f_radix, oc); - - /* Sanity check; if base<2, I can't guarantee the rest will work */ - if (f_radix < 2) { - eek_a_bug("Function return or parameter passing faulty? (This is a guess.)"); - printf("\n"); - return(0); - } - - if (PASS == 1) { /* only for FLT */ - flt_radix= f_radix; - if (F) i_define(D_FLT_RADIX, "", "FLT", "_RADIX", - (long) f_radix, 0L, (long) F_RADIX, ""); - } else if (f_radix != flt_radix) { - printf("\n%s*** WARNING: %s %s (%d) %s%s\n", - co, thing, "arithmetic has a different radix", - f_radix, "from float", oc); - bugs++; - } - - /* Now the number of digits precision */ - f_mant_dig=0; b=1.0; - do { f_mant_dig++; b=Mul(b, base); } - while (Diff(Diff(Sum(b, ONE), b), ONE) == ZERO); - f_dig=floor_log(10, (Long_double)(b/base)) + (base==10?1:0); - Vprintf("%sSignificant base digits = %d %s %d %s%s\n", - co, f_mant_dig, "(= at least", f_dig, "decimal digits)", oc); - if (F) i_define(D_MANT_DIG, thing, Fname, "_MANT_DIG", - (long) f_mant_dig, 0L, (long) F_MANT_DIG, ""); - if (F) i_define(D_DIG, thing, Fname, "_DIG", - (long) f_dig, 0L, (long) F_DIG, ""); - digs= ceil_log(10, (Long_double)b); /* the number of digits to printf */ - - /* Rounding *******************************************************/ - basem1=Diff(base, HALF); - if (Diff(Sum(a, basem1), a) != ZERO) { - if (f_radix == 2) basem1=0.375; - else basem1=1.0; - if (Diff(Sum(a, basem1), a) != ZERO) irnd=2; /* away from 0 */ - else irnd=1; /* to nearest */ - } else irnd=0; /* towards 0 */ - - basem1=Diff(base, HALF); - - if (Diff(Diff(-a, basem1), -a) != ZERO) { - if (f_radix == 2) basem1=0.375; - else basem1=1.0; - if (Diff(Diff(-a, basem1), -a) != ZERO) mrnd=2; /* away from 0*/ - else mrnd=1; /* to nearest */ - } else mrnd=0; /* towards 0 */ - - f_rounds= -1; /* Unknown rounding */ - if (irnd==0 && mrnd==0) f_rounds=0; /* zero = chops */ - if (irnd==1 && mrnd==1) f_rounds=1; /* nearest */ - if (irnd==2 && mrnd==0) f_rounds=2; /* +inf */ - if (irnd==0 && mrnd==2) f_rounds=3; /* -inf */ - - if (f_rounds != -1) { - Vprintf("%sArithmetic rounds towards ", co); - switch (f_rounds) { - case 0: Vprintf("zero (i.e. it chops)"); break; - case 1: Vprintf("nearest"); break; - case 2: Vprintf("+infinity"); break; - case 3: Vprintf("-infinity"); break; - default: Vprintf("???"); break; - } - Vprintf("%s\n", oc); - } else { /* Hmm, try to give some help here */ - Vprintf("%sArithmetic rounds oddly: %s\n", co, oc); - Vprintf("%s Negative numbers %s%s\n", - co, mrnd==0 ? "towards zero" : - mrnd==1 ? "to nearest" : - "away from zero", - oc); - Vprintf("%s Positive numbers %s%s\n", - co, irnd==0 ? "towards zero" : - irnd==1 ? "to nearest" : - "away from zero", - oc); - } - /* An extra goody */ - if (f_radix == 2 && f_rounds == 1) { - if (Diff(Sum(a, ONE), a) != ZERO) { - Vprintf("%s Tie breaking rounds up%s\n", co, oc); - } else if (Diff(Sum(a, THREE), a) == FOUR) { - Vprintf("%s Tie breaking rounds to even%s\n", co, oc); - } else { - Vprintf("%s Tie breaking rounds down%s\n", co, oc); - } - } - if (PASS == 1) { /* only for FLT */ - flt_rounds= f_rounds; - /* Prefer system float.h definition of F_ROUNDS, - since it's more likely to be right than our "1". */ - if (F && (!SYS_FLOAT_H_WRAP || F_ROUNDS == UNDEFINED)) - i_define(D_FLT_ROUNDS, "", "FLT", "_ROUNDS", - (long) f_rounds, 1L, (long) F_ROUNDS, ""); - } else if (f_rounds != flt_rounds) { - printf("\n%s*** WARNING: %s %s (%d) %s%s\n", - co, thing, "arithmetic rounds differently", - f_rounds, "from float", oc); - bugs++; - } - - /* Various flavours of epsilon ************************************/ - negeps=f_mant_dig+f_mant_dig; - basein=1.0/base; - a=1.0; - for(i=1; i<=negeps; i++) a*=basein; - - b=a; - while (Diff(Diff(ONE, a), ONE) == ZERO) { - a*=base; - negeps--; - } - negeps= -negeps; - Vprintf("%sSmallest x such that 1.0-base**x != 1.0 = %d%s\n", - co, negeps, oc); - - etop = ONE; - ebot = ZERO; - eps = Sum(ebot, Div(Diff(etop, ebot), TWO)); - /* find the smallest epsneg (1-epsneg != 1) by binary search. - ebot and etop are the current bounds */ - while (eps != ebot && eps != etop) { - epsp1 = Diff(ONE, eps); - if (epsp1 < ONE) etop = eps; - else ebot = eps; - eps = Sum(ebot, Div(Diff(etop, ebot), TWO)); - } - eps= etop; - /* Sanity check */ - if (Diff(ONE, etop) >= ONE || Diff(ONE, ebot) != ONE) { - eek_a_bug("internal error calculating epsneg"); - } - Vprintf("%sSmallest x such that 1.0-x != 1.0 = %s%s\n", - co, f_rep(digs, (Long_double) eps), oc); - if (V) F_check(digs, (Long_double) eps); - - epsneg=a; - if ((f_radix!=2) && irnd) { - /* a=(a*(1.0+a))/(1.0+1.0); => */ - a=Div(Mul(a, Sum(ONE, a)), Sum(ONE, ONE)); - /* if ((1.0-a)-1.0 != 0.0) epsneg=a; => */ - if (Diff(Diff(ONE, a), ONE) != ZERO) epsneg=a; - } - /* epsneg is used later */ - Unexpected(20); - - machep= -f_mant_dig-f_mant_dig; - a=b; - while (Diff(Sum(ONE, a), ONE) == ZERO) { a*=base; machep++; } - Vprintf("%sSmallest x such that 1.0+base**x != 1.0 = %d%s\n", - co, machep, oc); - - etop = ONE; - ebot = ZERO; - eps = Sum(ebot, Div(Diff(etop, ebot), TWO)); - /* find the smallest eps (1+eps != 1) by binary search. - ebot and etop are the current bounds */ - while (eps != ebot && eps != etop) { - epsp1 = Sum(ONE, eps); - if (epsp1 > ONE) etop = eps; - else ebot = eps; - eps = Sum(ebot, Div(Diff(etop, ebot), TWO)); - } - /* Sanity check */ - if (Sum(ONE, etop) <= ONE || Sum(ONE, ebot) != ONE) { - eek_a_bug("internal error calculating eps"); - } - f_epsilon=etop; - - Vprintf("%sSmallest x such that 1.0+x != 1.0 = %s%s\n", - co, f_rep(digs, (Long_double) f_epsilon), oc); - - f_epsilon= Diff(Sum(ONE, f_epsilon), ONE); /* New C standard defn */ - Vprintf("%s(Above number + 1.0) - 1.0 = %s%s\n", - co, f_rep(digs, (Long_double) (f_epsilon)), oc); - - /* Possible loss of precision warnings here from non-stdc compilers */ - if (F) f_define(D_EPSILON, thing, - Fname, "_EPSILON", digs, - (Long_double) f_epsilon, - (Long_double) F_EPSILON, MARK); - if (V || F) F_check(digs, (Long_double) f_epsilon); - Unexpected(21); - if (F) Validate(digs, (Long_double) f_epsilon, (Long_double) F_EPSILON, - f_epsilon == Self(F_EPSILON)); - Unexpected(22); - - /* Extra chop info *************************************************/ - if (f_rounds == 0) { - if (Diff(Mul(Sum(ONE,f_epsilon),ONE),ONE) != ZERO) { - Vprintf("%sAlthough arithmetic chops, it uses guard digits%s\n", co, oc); - } - } - - /* Size of and minimum normalised exponent ************************/ - y=0; i=0; k=1; z=basein; z1=(1.0+f_epsilon)/base; - - /* Coarse search for the largest power of two */ - if (setjmp(lab)==0) { /* for underflow trap */ /* Yields i, k, y, y1 */ - do { - y=z; y1=z1; - z=Mul(y,y); z1=Mul(z1, y); - a=Mul(z,ONE); - z2=Div(z1,y); - if (z2 != y1) break; - if ((Sum(a,a) == ZERO) || (fabs(z) >= y)) break; - i++; - k+=k; - } while(1); - } else { - Vprintf("%s%s underflow generates a trap%s\n", co, Thing, oc); - } - Unexpected(23); - - if (f_radix != 10) { - iexp=i+1; /* for the sign */ - mx=k+k; - } else { - iexp=2; - iz=f_radix; - while (k >= iz) { iz*=f_radix; iexp++; } - mx=iz+iz-1; - } - - /* Fine tune starting with y and y1 */ - if (setjmp(lab)==0) { /* for underflow trap */ /* Yields k, f_min */ - do { - f_min=y; z1=y1; - y=Div(y,base); y1=Div(y1,base); - a=Mul(y,ONE); - z2=Mul(y1,base); - if (z2 != z1) break; - if ((Sum(a,a) == ZERO) || (fabs(y) >= f_min)) break; - k++; - } while (1); - } - Unexpected(24); - - f_min_exp=(-k)+1; - - if ((mx <= k+k-3) && (f_radix != 10)) { mx+=mx; iexp+=1; } - Vprintf("%sNumber of bits used for exponent = %d%s\n", co, iexp, oc); - Vprintf("%sMinimum normalised exponent = %d%s\n", co, f_min_exp-1, oc); - if (F) - i_define(D_MIN_EXP, thing, Fname, "_MIN_EXP", - (long) f_min_exp, (long) maxint, (long) F_MIN_EXP, ""); - - if (setjmp(lab)==0) { - Vprintf("%sMinimum normalised positive number = %s%s\n", - co, f_rep(digs, (Long_double) f_min), oc); - } else { - eek_a_bug("printf can't print the smallest normalised number"); - printf("\n"); - } - Unexpected(25); - /* Possible loss of precision warnings here from non-stdc compilers */ - if (setjmp(lab) == 0) { - if (F) f_define(D_MIN, thing, - Fname, "_MIN", digs, - (Long_double) f_min, - (Long_double) F_MIN, MARK); - if (V || F) F_check(digs, (Long_double) f_min); - } else { - eek_a_bug("xxx_MIN caused a trap"); - printf("\n"); - } - - if (setjmp(lab) == 0) { - if (F) Validate(digs, (Long_double) f_min, (Long_double) F_MIN, - f_min == Self(F_MIN)); - } else { - printf("%s*** Verify failed for above #define!\n %s %s\n\n", - co, "Compiler has an unusable number for value", oc); - bugs++; - } - Unexpected(26); - - a=1.0; f_min_10_exp=0; - while (a > f_min*10.0) { a/=10.0; f_min_10_exp--; } - if (F) i_define(D_MIN_10_EXP, thing, Fname, "_MIN_10_EXP", - (long) f_min_10_exp, (long) maxint, - (long) F_MIN_10_EXP, ""); - - /* Minimum exponent ************************************************/ - if (setjmp(lab)==0) { /* for underflow trap */ /* Yields xminner */ - do { - xminner=y; - y=Div(y,base); - a=Mul(y,ONE); - if ((Sum(a,a) == ZERO) || (fabs(y) >= xminner)) break; - } while (1); - } - Unexpected(27); - - if (xminner != 0.0 && xminner != f_min) { - normal= 0; - Vprintf("%sThe smallest numbers are not kept normalised%s\n", - co, oc); - if (setjmp(lab)==0) { - Vprintf("%sSmallest unnormalised positive number = %s%s\n", - co, f_rep(digs, (Long_double) xminner), oc); - if (V) F_check(digs, (Long_double) xminner); - } else { - eek_a_bug("printf can't print the smallest unnormalised number."); - printf("\n"); - } - Unexpected(28); - } else { - normal= 1; - Vprintf("%sThe smallest numbers are normalised%s\n", co, oc); - } - - /* Maximum exponent ************************************************/ - f_max_exp=2; f_max=1.0; newxmax=base+1.0; - inf=0; trap=0; - while (f_max<newxmax) { - f_max=newxmax; - if (setjmp(lab) == 0) { /* Yields inf, f_max_exp */ - newxmax=Mul(newxmax, base); - } else { - trap=1; - break; - } - if (Div(newxmax, base) != f_max) { - inf=1; /* ieee infinity */ - break; - } - f_max_exp++; - } - Unexpected(29); - if (trap) { - Vprintf("%s%s overflow generates a trap%s\n", co, Thing, oc); - } - - if (inf) Vprintf("%sThere is an 'infinite' value%s\n", co, oc); - Vprintf("%sMaximum exponent = %d%s\n", co, f_max_exp, oc); - if (F) i_define(D_MAX_EXP, thing, Fname, "_MAX_EXP", - (long) f_max_exp, 0L, (long) F_MAX_EXP, ""); - - /* Largest number ***************************************************/ - f_max=Diff(ONE, epsneg); - if (Mul(f_max,ONE) != f_max) f_max=Diff(ONE, Mul(base,epsneg)); - for (i=1; i<=f_max_exp; i++) f_max=Mul(f_max, base); - - if (setjmp(lab)==0) { - Vprintf("%sMaximum number = %s%s\n", - co, f_rep(digs, (Long_double) f_max), oc); - } else { - eek_a_bug("printf can't print the largest double."); - printf("\n"); - } - if (setjmp(lab)==0) { - /* Possible loss of precision warnings here from non-stdc compilers */ - if (F) f_define(D_MAX, thing, - Fname, "_MAX", digs, - (Long_double) f_max, - (Long_double) F_MAX, MARK); - if (V || F) F_check(digs, (Long_double) f_max); - } else { - eek_a_bug("xxx_MAX caused a trap"); - printf("\n"); - } - if (setjmp(lab)==0) { - if (F) Validate(digs, (Long_double) f_max, (Long_double) F_MAX, - f_max == Self(F_MAX)); - } else { - printf("%s*** Verify failed for above #define!\n %s %s\n\n", - co, "Compiler has an unusable number for value", oc); - bugs++; - } - Unexpected(30); - - a=1.0; f_max_10_exp=0; - while (a < f_max/10.0) { a*=10.0; f_max_10_exp++; } - if (F) i_define(D_MAX_10_EXP, thing, Fname, "_MAX_10_EXP", - (long) f_max_10_exp, 0L, (long) F_MAX_10_EXP, ""); - - /* Hidden bit + sanity check ****************************************/ - if (f_radix != 10) { - hidden=0; - mantbits=floor_log(2, (Long_double)f_radix)*f_mant_dig; - if (mantbits == 64 - && iexp == 15 - && f_max_exp+f_min_exp > 0 /* ??? f_min_exp may be wrong. */ - && mantbits+iexp+17 == (int)sizeof(Number)*bits_per_byte) { - Vprintf("%sArithmetic probably doesn't use a hidden bit%s\n", co, oc); - Vprintf("%sIt's probably 80387 or 68881 extended real%s\n", co, oc); - goto is_extended; - } - if (mantbits+iexp == (int)sizeof(Number)*bits_per_byte) { - hidden=1; - Vprintf("%sArithmetic uses a hidden bit%s\n", co, oc); - } else if (mantbits+iexp+1 == (int)sizeof(Number)*bits_per_byte) { - Vprintf("%sArithmetic doesn't use a hidden bit%s\n", - co, oc); - } else { - printf("\n%s%s\n %s %s %s!%s\n\n", - co, - "*** Something fishy here!", - "Exponent size + significand size doesn't match", - "with the size of a", thing, - oc); - } - if (hidden && f_radix == 2 && f_max_exp+f_min_exp==3) { - Vprintf("%sIt looks like %s length IEEE format%s\n", - co, f_mant_dig==24 ? "single" : - f_mant_dig==53 ? "double" : - f_mant_dig >53 ? "extended" : - "some", oc); -is_extended: - if (f_rounds != 1 || normal) { - Vprintf("%s though ", co); - if (f_rounds != 1) { - Vprintf("the rounding is unusual"); - if (normal) Vprintf(" and "); - } - if (normal) Vprintf("the normalisation is unusual"); - Vprintf("%s\n", oc); - } - } else { - Vprintf("%sIt doesn't look like IEEE format%s\n", - co, oc); - } - } - printf("\n"); /* regardless of verbosity */ - return f_mant_dig; -} - -Procedure EPROP(fprec, dprec, lprec) int fprec, dprec, lprec; { - /* See if expressions are evaluated in extended precision. - Some compilers optimise even if you don't want it, - and then this function fails to produce the right result. - We try to diagnose this if it happens. - */ - Volatile int eprec; - Volatile double a, b, base, old; - Volatile Number d, oldd, dbase, one, zero; - Volatile int bad=0; - - /* Size of significand **************************************/ - a=1.0; - if (setjmp(lab) == 0) { /* Yields nothing */ - do { old=a; a=a+a; } - while ((((a+1.0)-a)-1.0) == 0.0 && a>old); - } else bad=1; - - /* Avoid the comparison if bad is set, - to avoid trouble on the convex. */ - if (!bad && (a <= old)) bad=1; - - if (!bad) { - b=1.0; - if (setjmp(lab) == 0) { /* Yields nothing */ - do { old=b; b=b+b; } - while ((base=((a+b)-a)) == 0.0 && b>old); - if (b <= old) bad=1; - } else bad=1; - } - - if (!bad) { - eprec=0; d=1.0; dbase=base; one=1.0; zero=0.0; - if (setjmp(lab) == 0) { /* Yields nothing */ - do { eprec++; oldd=d; d=d*dbase; } - while ((((d+one)-d)-one) == zero && d>oldd); - if (d <= oldd) bad=1; - } else bad=1; - } - - Unexpected(31); - - if (bad) { - Vprintf("%sCan't determine precision for %s expressions:\n%s%s\n", - co, thing, " check that you compiled without optimisation!", - oc); - } else if (eprec==dprec) { - Vprintf("%s%s expressions are evaluated in double precision%s\n", - co, Thing, oc); - } else if (eprec==fprec) { - Vprintf("%s%s expressions are evaluated in float precision%s\n", - co, Thing, oc); - } else if (eprec==lprec) { - Vprintf("%s%s expressions are evaluated in long double precision%s\n", - co, Thing, oc); - } else { - Vprintf("%s%s expressions are evaluated in a %s %s %d %s%s\n", - co, Thing, eprec>dprec ? "higher" : "lower", - "precision than double,\n using", - eprec, "base digits", - oc); - } -} - -#else /* not Number */ - -#ifdef FPROP /* Then create dummy routines for long double */ -/* ARGSUSED */ -int FPROP(bits_per_byte) int bits_per_byte; { return 0; } -#endif -#ifdef EPROP -/* ARGSUSED */ -Procedure EPROP(fprec, dprec, lprec) int fprec, dprec, lprec; {} -#endif - -#endif /* ifdef Number */ - -/* Increment the pass number */ -#undef PASS - -#ifdef PASS2 -#undef PASS2 -#define PASS 3 -#define PASS3 1 -#endif - -#ifdef PASS1 -#undef PASS1 -#define PASS 2 -#define PASS2 1 -#endif - -#ifdef PASS0 -#undef PASS0 -#endif - -#ifdef PASS /* then rescan this file */ -#ifdef NO_FILE -#include "enquire.c" -#else -#include FILENAME /* if this line fails to compile, define NO_FILE */ -#endif -#endif /* PASS */ - diff --git a/contrib/gcc/f/version.c b/contrib/gcc/f/version.c deleted file mode 100644 index 16c33e7..0000000 --- a/contrib/gcc/f/version.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "ansidecl.h" -#include "f/version.h" - -const char *const ffe_version_string = "3.2.2 20030205 (release)"; diff --git a/contrib/gcc/f/version.h b/contrib/gcc/f/version.h deleted file mode 100644 index fe77551..0000000 --- a/contrib/gcc/f/version.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef GCC_F_VERSION_H -#define GCC_F_VERSION_H - -extern const char *const ffe_version_string; - -#endif /* ! GCC_F_VERSION_H */ diff --git a/contrib/gcc/ggc-callbacks.c b/contrib/gcc/ggc-callbacks.c deleted file mode 100644 index f831923..0000000 --- a/contrib/gcc/ggc-callbacks.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Empty GC callbacks to be used by languages that don't support GC. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. - - This file is part of GCC. - - GCC 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. - - GCC 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 GCC; see the file COPYING. If not, write to the Free - Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -#include "config.h" -#include "system.h" -#include "rtl.h" -#include "tree.h" -#include "tm_p.h" -#include "ggc.h" - -void ATTRIBUTE_NORETURN -lang_mark_tree (t) - union tree_node *t ATTRIBUTE_UNUSED; -{ - /* If this function is called, we are doing GC. But, this file is - only included in compilers for languages that don't support GC. */ - abort (); -} - diff --git a/contrib/gcc/halfpic.c b/contrib/gcc/halfpic.c deleted file mode 100644 index f491314..0000000 --- a/contrib/gcc/halfpic.c +++ /dev/null @@ -1,399 +0,0 @@ -/* OSF/rose half-pic support functions. - Copyright (C) 1992, 1997, 1998, 1999 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC 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. - -GCC 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 GCC; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ - -/* The OSF/rose half-pic model assumes that the non-library code does - not need to have full PIC (position independent code), but rather, - that pointers to external references are put into the data section - and dereferenced as normal pointers. References to static data does - not need to be PIC-ized. - - Another optimization is to have the compiler know what symbols are - in the shared libraries, and to only lay down the pointers to - things which in the library proper. */ - -#include "config.h" - -#ifdef HALF_PIC_INIT - -#include "system.h" -#include "tree.h" -#include "rtl.h" -#include "expr.h" -#include "output.h" -#include "obstack.h" -#include "halfpic.h" - -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -int flag_half_pic = 0; /* Global half-pic flag. */ -int half_pic_number_ptrs = 0; /* # distinct pointers found */ -int half_pic_number_refs = 0; /* # half-pic references */ -int (*ptr_half_pic_address_p) PARAMS ((rtx)) = half_pic_address_p; - -/* Obstack to hold generated pic names. */ -static struct obstack half_pic_obstack; - -/* List of pointers created to pic references. */ - -struct all_refs { - struct all_refs *hash_next; /* next name in hash chain */ - struct all_refs *next; /* next name created */ - int external_p; /* name is an external reference */ - int pointer_p; /* pointer created. */ - const char *ref_name; /* reference name to ptr to real_name */ - int ref_len; /* reference name length */ - const char *real_name; /* real function/data name */ - int real_len; /* strlen (real_name) */ -}; - -static struct all_refs *half_pic_names; - -static const char *half_pic_prefix; -static int half_pic_prefix_len; - - -/* Return the hash bucket of a name or NULL. The hash chain is - organized as a self reorganizing circularly linked chain. It is - assumed that any name passed to use will never be reallocated. For - names in SYMBOL_REF's this is true, because the names are allocated - on the permanent obstack. */ - -#ifndef MAX_HASH_TABLE -#define MAX_HASH_TABLE 1009 -#endif - -#define HASHBITS 30 - -static struct all_refs *half_pic_hash PARAMS ((const char *, int, int)); - -static struct all_refs * -half_pic_hash (name, len, create_p) - const char *name; /* name to hash */ - int len; /* length of the name (or 0 to call strlen) */ - int create_p; /* != 0 to create new hash bucket if new */ -{ - static struct all_refs *hash_table[MAX_HASH_TABLE]; - static struct all_refs zero_all_refs; - - const unsigned char *uname; - int hash; - int i; - int ch; - struct all_refs *first; - struct all_refs *ptr; - - if (len == 0) - len = strlen (name); - - /* Compute hash code */ - uname = (const unsigned char *)name; - ch = uname[0]; - hash = len * 613 + ch; - for (i = 1; i < len; i += 2) - hash = (hash * 613) + uname[i]; - - hash &= (1 << HASHBITS) - 1; - hash %= MAX_HASH_TABLE; - - /* See if the name is in the hash table. */ - ptr = first = hash_table[hash]; - if (ptr) - { - do - { - if (len == ptr->real_len - && ch == *(ptr->real_name) - && !strcmp (name, ptr->real_name)) - { - hash_table[hash] = ptr; - return ptr; - } - - ptr = ptr->hash_next; - } - while (ptr != first); - } - - /* name not in hash table. */ - if (!create_p) - return (struct all_refs *) 0; - - ptr = (struct all_refs *) obstack_alloc (&half_pic_obstack, sizeof (struct all_refs)); - *ptr = zero_all_refs; - - ptr->real_name = name; - ptr->real_len = len; - - /* Update circular links. */ - if (first == (struct all_refs *) 0) - ptr->hash_next = ptr; - - else - { - ptr->hash_next = first->hash_next; - first->hash_next = ptr; - } - - hash_table[hash] = ptr; - return ptr; -} - - -/* Do any half-pic initializations. */ - -void -half_pic_init () -{ - flag_half_pic = TRUE; - half_pic_prefix = HALF_PIC_PREFIX; - half_pic_prefix_len = strlen (half_pic_prefix); - obstack_init (&half_pic_obstack); -} - - -/* Write out all pointers to pic references. */ - -void -half_pic_finish (stream) - FILE *stream; -{ - struct all_refs *p = half_pic_names; - - if (!p) - return; - - data_section (); - for (; p != 0; p = p->next) - { - /* Emit the pointer if used. */ - if (p->pointer_p) - { - ASM_OUTPUT_LABEL (stream, p->ref_name); - assemble_aligned_integer (POINTER_SIZE / BITS_PER_UNIT, - gen_rtx_SYMBOL_REF (Pmode, p->real_name)); - } - } -} - - -/* Encode in a declaration whether or not it is half-pic. */ - -void -half_pic_encode (decl) - tree decl; -{ - enum tree_code code = TREE_CODE (decl); - tree asm_name; - struct all_refs *ptr; - - if (!flag_half_pic) - return; - - if (code != VAR_DECL && code != FUNCTION_DECL) - return; - - asm_name = DECL_ASSEMBLER_NAME (decl); - - if (!asm_name) - return; - -#ifdef HALF_PIC_DEBUG - if (HALF_PIC_DEBUG) - { - fprintf (stderr, "\n========== Half_pic_encode %.*s\n", - IDENTIFIER_LENGTH (asm_name), - IDENTIFIER_POINTER (asm_name)); - debug_tree (decl); - } -#endif - - /* If this is not an external reference, it can't be half-pic. */ - if (!DECL_EXTERNAL (decl) && (code != VAR_DECL || !TREE_PUBLIC (decl))) - return; - - ptr = half_pic_hash (IDENTIFIER_POINTER (asm_name), - IDENTIFIER_LENGTH (asm_name), - TRUE); - - ptr->external_p = TRUE; - -#ifdef HALF_PIC_DEBUG - if (HALF_PIC_DEBUG) - fprintf (stderr, "\n%.*s is half-pic\n", - IDENTIFIER_LENGTH (asm_name), - IDENTIFIER_POINTER (asm_name)); -#endif -} - - -/* Mark that an object is now local, and no longer needs half-pic. */ - -void -half_pic_declare (name) - const char *name; -{ - struct all_refs *ptr; - - if (!flag_half_pic) - return; - - ptr = half_pic_hash (name, 0, FALSE); - if (!ptr) - return; - - ptr->external_p = FALSE; - -#ifdef HALF_PIC_DEBUG - if (HALF_PIC_DEBUG) - fprintf (stderr, "\n========== Half_pic_declare %s\n", name); -#endif -} - - -/* Mark that an object is explicitly external. */ - -void -half_pic_external (name) - const char *name; -{ - struct all_refs *ptr; - - if (!flag_half_pic) - return; - - ptr = half_pic_hash (name, 0, TRUE); - if (!ptr) - return; - - ptr->external_p = TRUE; - -#ifdef HALF_PIC_DEBUG - if (HALF_PIC_DEBUG) - fprintf (stderr, "\n========== Half_pic_external %s\n", name); -#endif -} - - -/* Return whether an address is half-pic. */ - -int -half_pic_address_p (addr) - rtx addr; -{ - const char *name; - int len; - struct all_refs *ptr; - - if (!flag_half_pic) - return FALSE; - - switch (GET_CODE (addr)) - { - default: - break; - - case CONST: - { - rtx offset = const0_rtx; - addr = eliminate_constant_term (XEXP (addr, 0), &offset); - if (GET_CODE (addr) != SYMBOL_REF) - return FALSE; - } - /* fall through */ - - case SYMBOL_REF: - name = XSTR (addr, 0); - -#ifdef HALF_PIC_DEBUG - if (HALF_PIC_DEBUG) - fprintf (stderr, "\n========== Half_pic_address_p %s\n", name); -#endif - - /* If this is a label, it will have a '*' in front of it. */ - if (name[0] == '*') - return FALSE; - - /* If this is a reference to the actual half-pic pointer, it - is obviously not half-pic. */ - - len = strlen (name); - if (len > half_pic_prefix_len - && half_pic_prefix[0] == name[0] - && !strncmp (name, half_pic_prefix, half_pic_prefix_len)) - return FALSE; - - ptr = half_pic_hash (name, len, FALSE); - if (ptr == (struct all_refs *) 0) - return FALSE; - - if (ptr->external_p) - { -#ifdef HALF_PIC_DEBUG - if (HALF_PIC_DEBUG) - fprintf (stderr, "%s is half-pic\n", name); -#endif - return TRUE; - } - } - - return FALSE; -} - - -/* Return the name of the pointer to the PIC function, allocating - it if need be. */ - -struct rtx_def * -half_pic_ptr (operand) - rtx operand; -{ - const char *name; - struct all_refs *p; - int len; - - if (GET_CODE (operand) != SYMBOL_REF) - return operand; - - name = XSTR (operand, 0); - len = strlen (name); - p = half_pic_hash (name, len, FALSE); - if (p == (struct all_refs *) 0 || !p->external_p) - return operand; - - if (!p->pointer_p) - { /* first time, create pointer */ - obstack_grow (&half_pic_obstack, half_pic_prefix, half_pic_prefix_len); - obstack_grow (&half_pic_obstack, name, len+1); - - p->next = half_pic_names; - p->ref_name = (char *) obstack_finish (&half_pic_obstack); - p->ref_len = len + half_pic_prefix_len; - p->pointer_p = TRUE; - - half_pic_names = p; - half_pic_number_ptrs++; - } - - half_pic_number_refs++; - return gen_rtx_SYMBOL_REF (Pmode, p->ref_name); -} - -#endif /* HALF_PIC_INIT */ diff --git a/contrib/gcc/halfpic.h b/contrib/gcc/halfpic.h deleted file mode 100644 index 37bc499..0000000 --- a/contrib/gcc/halfpic.h +++ /dev/null @@ -1,67 +0,0 @@ -/* OSF/rose half-pic support definitions. - Copyright (C) 1992, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC 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. - -GCC 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 GCC; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ - -#ifndef NO_HALF_PIC - -/* Declare the variable flag_half_pic as 'int' instead of 'extern - int', so that BSS variables are created (even though this is not - strict ANSI). This is because rtl.c now refers to the - CONSTANT_ADDRESS_P macro, which in turn refers to flag_half_pic, - and wants to call half_pic_address_p, whose address we also store - in a BSS variable. This way, the gen* programs won't get - unknown symbol errors when being linked (flag_half_pic will never - be true in the gen* programs). */ - -int flag_half_pic; /* Global half-pic flag. */ -int (*ptr_half_pic_address_p) PARAMS ((struct rtx_def *)); /* ptr to half_pic_address_p () */ - -extern int half_pic_number_ptrs; /* # distinct pointers found */ -extern int half_pic_number_refs; /* # half-pic references */ -extern void half_pic_encode PARAMS ((union tree_node *)); /* encode whether half-pic */ -extern void half_pic_declare PARAMS ((const char *)); /* declare object local */ -extern void half_pic_external PARAMS ((const char *)); /* declare object external */ -extern void half_pic_init PARAMS ((void)); /* half_pic initialization */ -extern int half_pic_address_p PARAMS ((struct rtx_def *)); /* true if an address is half-pic */ -extern struct rtx_def *half_pic_ptr PARAMS ((struct rtx_def *)); /* return RTX for half-pic pointer */ -#ifdef BUFSIZ -extern void half_pic_finish PARAMS ((FILE *)); /* half_pic termination */ -#endif - -/* Macros to provide access to the half-pic stuff (so they can easily - be stubbed out. */ - -#define HALF_PIC_P() (flag_half_pic) -#define HALF_PIC_NUMBER_PTRS (half_pic_number_ptrs) -#define HALF_PIC_NUMBER_REFS (half_pic_number_refs) - -#define HALF_PIC_ENCODE(DECL) half_pic_encode (DECL) -#define HALF_PIC_DECLARE(NAME) half_pic_declare (NAME) -#define HALF_PIC_EXTERNAL(NAME) half_pic_external (NAME) -#define HALF_PIC_INIT() half_pic_init () -#define HALF_PIC_FINISH(STREAM) half_pic_finish (STREAM) -#define HALF_PIC_ADDRESS_P(X) ((*ptr_half_pic_address_p) (X)) -#define HALF_PIC_PTR(X) half_pic_ptr (X) - -/* Prefix for half-pic names */ -#ifndef HALF_PIC_PREFIX -#define HALF_PIC_PREFIX "__pic_" -#endif - -#endif /* NO_HALF_PIC */ diff --git a/contrib/gcc/hash.c b/contrib/gcc/hash.c deleted file mode 100644 index 5cf8397..0000000 --- a/contrib/gcc/hash.c +++ /dev/null @@ -1,218 +0,0 @@ -/* hash.c -- hash table routines - Copyright (C) 1993, 1994, 1998, 2001 Free Software Foundation, Inc. - Written by Steve Chamberlain <sac@cygnus.com> - -This file was lifted from BFD, the Binary File Descriptor 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, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include "config.h" -#include "system.h" -#include "hash.h" -#include "obstack.h" -#include "toplev.h" - -/* Obstack allocation and deallocation routines. */ -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -/* The default number of entries to use when creating a hash table. */ -#define DEFAULT_SIZE 1009 - -/* Create a new hash table, given a number of entries. */ - -void -hash_table_init_n (table, newfunc, hash, comp, size) - struct hash_table *table; - struct hash_entry *(*newfunc) PARAMS ((struct hash_entry *, - struct hash_table *, - hash_table_key)); - unsigned long (*hash) PARAMS ((hash_table_key)); - bool (*comp) PARAMS ((hash_table_key, hash_table_key)); - unsigned int size; -{ - unsigned int alloc; - - alloc = size * sizeof (struct hash_entry *); - obstack_begin (&table->memory, alloc); - table->table = ((struct hash_entry **) - obstack_alloc (&table->memory, alloc)); - memset ((PTR) table->table, 0, alloc); - table->size = size; - table->newfunc = newfunc; - table->hash = hash; - table->comp = comp; -} - -/* Create a new hash table with the default number of entries. */ - -void -hash_table_init (table, newfunc, hash, comp) - struct hash_table *table; - struct hash_entry *(*newfunc) PARAMS ((struct hash_entry *, - struct hash_table *, - hash_table_key)); - unsigned long (*hash) PARAMS ((hash_table_key)); - bool (*comp) PARAMS ((hash_table_key, hash_table_key)); -{ - hash_table_init_n (table, newfunc, hash, comp, DEFAULT_SIZE); -} - -/* Free a hash table. */ - -void -hash_table_free (table) - struct hash_table *table; -{ - obstack_free (&table->memory, (PTR) NULL); -} - -/* Look up KEY in TABLE. If CREATE is non-NULL a new entry is - created if one does not previously exist. */ - -struct hash_entry * -hash_lookup (table, key, create, copy) - struct hash_table *table; - hash_table_key key; - int create; - hash_table_key (*copy) PARAMS ((struct obstack* memory, - hash_table_key key)); -{ - unsigned long hash; - struct hash_entry *hashp; - unsigned int index; - - hash = (*table->hash)(key); - - index = hash % table->size; - for (hashp = table->table[index]; hashp != 0; hashp = hashp->next) - if (hashp->hash == hash - && (*table->comp)(hashp->key, key)) - return hashp; - - if (! create) - return 0; - - hashp = (*table->newfunc) ((struct hash_entry *) NULL, table, key); - if (hashp == 0) - return 0; - - if (copy) - key = (*copy) (&table->memory, key); - - hashp->key = key; - hashp->hash = hash; - hashp->next = table->table[index]; - table->table[index] = hashp; - - return hashp; -} - -/* Base method for creating a new hash table entry. */ - -struct hash_entry * -hash_newfunc (entry, table, p) - struct hash_entry *entry; - struct hash_table *table; - hash_table_key p ATTRIBUTE_UNUSED; -{ - if (entry == 0) - entry = ((struct hash_entry *) - hash_allocate (table, sizeof (struct hash_entry))); - return entry; -} - -/* Allocate space in a hash table. */ - -PTR -hash_allocate (table, size) - struct hash_table *table; - unsigned int size; -{ - return obstack_alloc (&table->memory, size); -} - -/* Traverse a hash table. */ - -void -hash_traverse (table, func, info) - struct hash_table *table; - bool (*func) PARAMS ((struct hash_entry *, hash_table_key)); - PTR info; -{ - unsigned int i; - struct hash_entry *p; - - for (i = 0; i < table->size; i++) - for (p = table->table[i]; p != 0; p = p->next) - if (! (*func) (p, info)) - return; -} - -/* Hash a string. Return a hash-code for the string. */ - -unsigned long -string_hash (k) - hash_table_key k; -{ - const unsigned char *s; - unsigned long hash; - unsigned char c; - unsigned int len; - - s = (const unsigned char *) k; - hash = 0; - len = 0; - - while ((c = *s++) != '\0') - { - hash += c + (c << 17); - hash ^= hash >> 2; - ++len; - } - - hash += len + (len << 17); - hash ^= hash >> 2; - - return hash; -} - -/* Compare two strings. Return non-zero iff the two strings are - the same. */ - -bool -string_compare (k1, k2) - hash_table_key k1; - hash_table_key k2; -{ - return (strcmp ((char*) k1, (char*) k2) == 0); -} - -/* Copy K to OBSTACK. */ - -hash_table_key -string_copy (memory, k) - struct obstack *memory; - hash_table_key k; -{ - char *new; - char *string = (char *) k; - - new = (char *) obstack_alloc (memory, strlen (string) + 1); - strcpy (new, string); - - return new; -} diff --git a/contrib/gcc/hash.h b/contrib/gcc/hash.h deleted file mode 100644 index bd75f94..0000000 --- a/contrib/gcc/hash.h +++ /dev/null @@ -1,129 +0,0 @@ -/* Header file for generic hash table support. - Copyright (C) 1993, 1994, 1997, 1998, 2001 Free Software Foundation, Inc. - Written by Steve Chamberlain <sac@cygnus.com> - -This file was lifted from BFD, the Binary File Descriptor 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, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#ifndef IN_GCC -#include <ansidecl.h> -#endif /* ! IN_GCC */ - -#include "obstack.h" - -typedef PTR hash_table_key; - -/* Hash table routines. There is no way to free up a hash table. */ - -/* An element in the hash table. Most uses will actually use a larger - structure, and an instance of this will be the first field. */ - -struct hash_entry -{ - /* Next entry for this hash code. */ - struct hash_entry *next; - /* The thing being hashed. */ - hash_table_key key; - /* Hash code. This is the full hash code, not the index into the - table. */ - unsigned long hash; -}; - -/* A hash table. */ - -struct hash_table -{ - /* The hash array. */ - struct hash_entry **table; - /* The number of slots in the hash table. */ - unsigned int size; - /* A function used to create new elements in the hash table. The - first entry is itself a pointer to an element. When this - function is first invoked, this pointer will be NULL. However, - having the pointer permits a hierarchy of method functions to be - built each of which calls the function in the superclass. Thus - each function should be written to allocate a new block of memory - only if the argument is NULL. */ - struct hash_entry *(*newfunc) PARAMS ((struct hash_entry *, - struct hash_table *, - hash_table_key)); - /* A function to compute the hash code for a key in the hash table. */ - unsigned long (*hash) PARAMS ((hash_table_key)); - /* A function to compare two keys. */ - bool (*comp) PARAMS ((hash_table_key, hash_table_key)); - /* An obstack for this hash table. */ - struct obstack memory; -}; - -/* Initialize a hash table. */ -extern void hash_table_init - PARAMS ((struct hash_table *, - struct hash_entry *(*) (struct hash_entry *, - struct hash_table *, - hash_table_key), - unsigned long (*hash) (hash_table_key), - bool (*comp) (hash_table_key, hash_table_key))); - -/* Initialize a hash table specifying a size. */ -extern void hash_table_init_n - PARAMS ((struct hash_table *, - struct hash_entry *(*) (struct hash_entry *, - struct hash_table *, - hash_table_key), - unsigned long (*hash) (hash_table_key), - bool (*comp) (hash_table_key, hash_table_key), - unsigned int size)); - -/* Free up a hash table. */ -extern void hash_table_free PARAMS ((struct hash_table *)); - -/* Look up KEY in a hash table. If CREATE is true, a new entry - will be created for this KEY if one does not already exist. If - COPY is non-NULL, it is used to copy the KEY before storing it in - the hash table. */ -extern struct hash_entry *hash_lookup - PARAMS ((struct hash_table *, hash_table_key key, int create, - hash_table_key (*copy)(struct obstack*, hash_table_key))); - -/* Base method for creating a hash table entry. */ -extern struct hash_entry *hash_newfunc - PARAMS ((struct hash_entry *, struct hash_table *, - hash_table_key key)); - -/* Grab some space for a hash table entry. */ -extern PTR hash_allocate PARAMS ((struct hash_table *, - unsigned int)); - -/* Traverse a hash table in a random order, calling a function on each - element. If the function returns false, the traversal stops. The - INFO argument is passed to the function. */ -extern void hash_traverse PARAMS ((struct hash_table *, - bool (*) (struct hash_entry *, - hash_table_key), - hash_table_key info)); - -/* Hash a string K, which is really of type `char*'. */ -extern unsigned long string_hash PARAMS ((hash_table_key k)); - -/* Compare two strings K1, K2 which are really of type `char*'. */ -extern bool string_compare PARAMS ((hash_table_key k1, - hash_table_key k2)); - -/* Copy a string K, which is really of type `char*'. */ -extern hash_table_key string_copy PARAMS ((struct obstack* memory, - hash_table_key k)); - diff --git a/contrib/gcc/tradcif.y b/contrib/gcc/tradcif.y deleted file mode 100644 index 953e2d6..0000000 --- a/contrib/gcc/tradcif.y +++ /dev/null @@ -1,567 +0,0 @@ -/* Parse C expressions for CCCP. - Copyright (C) 1987, 2000, 2001 Free Software Foundation. - Adapted from expread.y of GDB by Paul Rubin, July 1986. - Adapted to ANSI C, Richard Stallman, Jan 1987 - Dusted off, polished, and adapted for use as traditional - preprocessor only, Zack Weinberg, Jul 2000 - -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. */ - -/* Parse a C expression from text in a string */ - -%{ -#include "config.h" -#include "system.h" -#include "intl.h" -#include "tradcpp.h" -#include <setjmp.h> - - static int yylex PARAMS ((void)); - static void yyerror PARAMS ((const char *msgid)) ATTRIBUTE_NORETURN; - - static int parse_number PARAMS ((int)); - static int parse_escape PARAMS ((const char **)); - - static int expression_value; - static jmp_buf parse_return_error; - - /* During parsing of a C expression, the pointer to the next - character is in this variable. */ - - static const char *lexptr; -%} - -%union { - struct constant {long value; int unsignedp;} integer; - int voidval; - char *sval; -} - -%type <integer> exp exp1 start -%token <integer> INT CHAR -%token <sval> NAME -%token <integer> ERROR - -%right '?' ':' -%left ',' -%left OR -%left AND -%left '|' -%left '^' -%left '&' -%left EQUAL NOTEQUAL -%left '<' '>' LEQ GEQ -%left LSH RSH -%left '+' '-' -%left '*' '/' '%' -%right UNARY - -/* %expect 40 */ - -%% - -start : exp1 - { expression_value = $1.value; } - ; - -/* Expressions, including the comma operator. */ -exp1 : exp - | exp1 ',' exp - { $$ = $3; } - ; - -/* Expressions, not including the comma operator. */ -exp : '-' exp %prec UNARY - { $$.value = - $2.value; - $$.unsignedp = $2.unsignedp; } - | '!' exp %prec UNARY - { $$.value = ! $2.value; - $$.unsignedp = 0; } - | '+' exp %prec UNARY - { $$ = $2; } - | '~' exp %prec UNARY - { $$.value = ~ $2.value; - $$.unsignedp = $2.unsignedp; } - | '(' exp1 ')' - { $$ = $2; } - ; - -/* Binary operators in order of decreasing precedence. */ -exp : exp '*' exp - { $$.unsignedp = $1.unsignedp || $3.unsignedp; - if ($$.unsignedp) - $$.value = (unsigned) $1.value * $3.value; - else - $$.value = $1.value * $3.value; } - | exp '/' exp - { if ($3.value == 0) - { - error ("division by zero in #if"); - $3.value = 1; - } - $$.unsignedp = $1.unsignedp || $3.unsignedp; - if ($$.unsignedp) - $$.value = (unsigned) $1.value / $3.value; - else - $$.value = $1.value / $3.value; } - | exp '%' exp - { if ($3.value == 0) - { - error ("division by zero in #if"); - $3.value = 1; - } - $$.unsignedp = $1.unsignedp || $3.unsignedp; - if ($$.unsignedp) - $$.value = (unsigned) $1.value % $3.value; - else - $$.value = $1.value % $3.value; } - | exp '+' exp - { $$.value = $1.value + $3.value; - $$.unsignedp = $1.unsignedp || $3.unsignedp; } - | exp '-' exp - { $$.value = $1.value - $3.value; - $$.unsignedp = $1.unsignedp || $3.unsignedp; } - | exp LSH exp - { $$.unsignedp = $1.unsignedp; - if ($$.unsignedp) - $$.value = (unsigned) $1.value << $3.value; - else - $$.value = $1.value << $3.value; } - | exp RSH exp - { $$.unsignedp = $1.unsignedp; - if ($$.unsignedp) - $$.value = (unsigned) $1.value >> $3.value; - else - $$.value = $1.value >> $3.value; } - | exp EQUAL exp - { $$.value = ($1.value == $3.value); - $$.unsignedp = 0; } - | exp NOTEQUAL exp - { $$.value = ($1.value != $3.value); - $$.unsignedp = 0; } - | exp LEQ exp - { $$.unsignedp = 0; - if ($1.unsignedp || $3.unsignedp) - $$.value = - (unsigned) $1.value <= (unsigned) $3.value; - else - $$.value = $1.value <= $3.value; } - | exp GEQ exp - { $$.unsignedp = 0; - if ($1.unsignedp || $3.unsignedp) - $$.value = - (unsigned) $1.value >= (unsigned) $3.value; - else - $$.value = $1.value >= $3.value; } - | exp '<' exp - { $$.unsignedp = 0; - if ($1.unsignedp || $3.unsignedp) - $$.value = - (unsigned) $1.value < (unsigned) $3.value; - else - $$.value = $1.value < $3.value; } - | exp '>' exp - { $$.unsignedp = 0; - if ($1.unsignedp || $3.unsignedp) - $$.value = - (unsigned) $1.value > (unsigned) $3.value; - else - $$.value = $1.value > $3.value; } - | exp '&' exp - { $$.value = $1.value & $3.value; - $$.unsignedp = $1.unsignedp || $3.unsignedp; } - | exp '^' exp - { $$.value = $1.value ^ $3.value; - $$.unsignedp = $1.unsignedp || $3.unsignedp; } - | exp '|' exp - { $$.value = $1.value | $3.value; - $$.unsignedp = $1.unsignedp || $3.unsignedp; } - | exp AND exp - { $$.value = ($1.value && $3.value); - $$.unsignedp = 0; } - | exp OR exp - { $$.value = ($1.value || $3.value); - $$.unsignedp = 0; } - | exp '?' exp ':' exp - { $$.value = $1.value ? $3.value : $5.value; - $$.unsignedp = $3.unsignedp || $5.unsignedp; } - | INT - { $$ = yylval.integer; } - | CHAR - { $$ = yylval.integer; } - | NAME - { $$.value = 0; - $$.unsignedp = 0; } - | '#' { $$.value = - test_assertion ((unsigned char **) &lexptr); } - ; -%% - -/* Take care of parsing a number (anything that starts with a digit). - Set yylval and return the token type; update lexptr. - LEN is the number of characters in it. */ - -/* maybe needs to actually deal with floating point numbers */ - -static int -parse_number (olen) - int olen; -{ - const char *p = lexptr; - long n = 0; - int c; - int base = 10; - int len = olen; - - for (c = 0; c < len; c++) - if (p[c] == '.') { - /* It's a float since it contains a point. */ - yyerror ("floating point numbers not allowed in #if expressions"); - return ERROR; - } - - /* Traditionally, all numbers are signed. However, we make it - unsigned if requested with a suffix. */ - yylval.integer.unsignedp = 0; - - if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2))) { - p += 2; - base = 16; - len -= 2; - } - else if (*p == '0') - base = 8; - - while (len > 0) { - c = *p++; - len--; - if (ISUPPER (c)) - c = TOLOWER (c); - - if (ISDIGIT (c) - || (base == 16 && ISXDIGIT (c))) { - n = (n * base) + hex_value (c); - } else { - /* `l' means long, and `u' means unsigned. */ - while (1) { - if (c == 'l' || c == 'L') - ; - else if (c == 'u' || c == 'U') - yylval.integer.unsignedp = 1; - else - break; - - if (len == 0) - break; - c = *p++; - len--; - } - /* Don't look for any more digits after the suffixes. */ - break; - } - } - - if (len != 0) { - yyerror ("invalid number in #if expression"); - return ERROR; - } - - lexptr = p; - yylval.integer.value = n; - return INT; -} - -struct token { - const char *const operator; - const int token; -}; - -#ifndef NULL -#define NULL 0 -#endif - -static const struct token tokentab2[] = { - {"&&", AND}, - {"||", OR}, - {"<<", LSH}, - {">>", RSH}, - {"==", EQUAL}, - {"!=", NOTEQUAL}, - {"<=", LEQ}, - {">=", GEQ}, - {NULL, ERROR} -}; - -/* Read one token, getting characters through lexptr. */ - -static int -yylex () -{ - int c; - int namelen; - const char *tokstart; - const struct token *toktab; - - retry: - - tokstart = lexptr; - c = *tokstart; - /* See if it is a special token of length 2. */ - for (toktab = tokentab2; toktab->operator != NULL; toktab++) - if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) { - lexptr += 2; - return toktab->token; - } - - switch (c) { - case 0: - return 0; - - case ' ': - case '\t': - case '\r': - case '\n': - lexptr++; - goto retry; - - case '\'': - lexptr++; - c = *lexptr++; - if (c == '\\') - c = parse_escape (&lexptr); - - /* Sign-extend the constant if chars are signed on target machine. */ - { - if (flag_signed_char == 0 - || ((c >> (CHAR_TYPE_SIZE - 1)) & 1) == 0) - yylval.integer.value = c & ((1 << CHAR_TYPE_SIZE) - 1); - else - yylval.integer.value = c | ~((1 << CHAR_TYPE_SIZE) - 1); - } - - yylval.integer.unsignedp = 0; - c = *lexptr++; - if (c != '\'') { - yyerror ("invalid character constant in #if"); - return ERROR; - } - - return CHAR; - - /* some of these chars are invalid in constant expressions; - maybe do something about them later */ - case '/': - case '+': - case '-': - case '*': - case '%': - case '|': - case '&': - case '^': - case '~': - case '!': - case '@': - case '<': - case '>': - case '(': - case ')': - case '[': - case ']': - case '.': - case '?': - case ':': - case '=': - case '{': - case '}': - case ',': - case '#': - lexptr++; - return c; - - case '"': - yyerror ("double quoted strings not allowed in #if expressions"); - return ERROR; - } - if (ISDIGIT (c)) { - /* It's a number */ - for (namelen = 0; - c = tokstart[namelen], is_idchar (c) || c == '.'; - namelen++) - ; - return parse_number (namelen); - } - - if (!is_idstart (c)) { - yyerror ("invalid token in expression"); - return ERROR; - } - - /* It is a name. See how long it is. */ - - for (namelen = 0; - is_idchar (tokstart[namelen]); - namelen++) - ; - - lexptr += namelen; - return NAME; -} - - -/* Parse a C escape sequence. STRING_PTR points to a variable - containing a pointer to the string to parse. That pointer - is updated past the characters we use. The value of the - escape sequence is returned. - - A negative value means the sequence \ newline was seen, - which is supposed to be equivalent to nothing at all. - - If \ is followed by a null character, we return a negative - value and leave the string pointer pointing at the null character. - - If \ is followed by 000, we return 0 and leave the string pointer - after the zeros. A value of 0 does not mean end of string. */ - -static int -parse_escape (string_ptr) - const char **string_ptr; -{ - int c = *(*string_ptr)++; - switch (c) - { - case 'a': - return TARGET_BELL; - case 'b': - return TARGET_BS; - case 'e': - return 033; - case 'f': - return TARGET_FF; - case 'n': - return TARGET_NEWLINE; - case 'r': - return TARGET_CR; - case 't': - return TARGET_TAB; - case 'v': - return TARGET_VT; - case '\n': - return -2; - case 0: - (*string_ptr)--; - return 0; - case '^': - c = *(*string_ptr)++; - if (c == '\\') - c = parse_escape (string_ptr); - if (c == '?') - return 0177; - return (c & 0200) | (c & 037); - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - int i = c - '0'; - int count = 0; - while (++count < 3) - { - c = *(*string_ptr)++; - if (c >= '0' && c <= '7') - i = (i << 3) + c - '0'; - else - { - (*string_ptr)--; - break; - } - } - if ((i & ~((1 << CHAR_TYPE_SIZE) - 1)) != 0) - { - i &= (1 << CHAR_TYPE_SIZE) - 1; - warning ("octal character constant does not fit in a byte"); - } - return i; - } - case 'x': - { - int i = 0; - for (;;) - { - c = *(*string_ptr)++; - if (hex_p (c)) - i = (i << 4) + hex_value (c); - else - { - (*string_ptr)--; - break; - } - } - if ((i & ~((1 << BITS_PER_UNIT) - 1)) != 0) - { - i &= (1 << BITS_PER_UNIT) - 1; - warning ("hex character constant does not fit in a byte"); - } - return i; - } - default: - return c; - } -} - -static void -yyerror (msgid) - const char *msgid; -{ - error ("%s", _(msgid)); - longjmp (parse_return_error, 1); -} - -/* This page contains the entry point to this file. */ - -/* Parse STRING as an expression, and complain if this fails - to use up all of the contents of STRING. */ -/* We do not support C comments. They should be removed before - this function is called. */ - -int -parse_c_expression (string) - const char *string; -{ - lexptr = string; - - if (lexptr == 0 || *lexptr == 0) { - error ("empty #if expression"); - return 0; /* don't include the #if group */ - } - - /* if there is some sort of scanning error, just return 0 and assume - the parsing routine has printed an error message somewhere. - there is surely a better thing to do than this. */ - if (setjmp (parse_return_error)) - return 0; - - if (yyparse ()) - return 0; /* actually this is never reached - the way things stand. */ - if (*lexptr) - error ("Junk after end of expression."); - - return expression_value; /* set by yyparse () */ -} diff --git a/contrib/gcc/tradcpp.c b/contrib/gcc/tradcpp.c deleted file mode 100644 index f277eba..0000000 --- a/contrib/gcc/tradcpp.c +++ /dev/null @@ -1,5276 +0,0 @@ -/* C Compatible Compiler Preprocessor (CCCP) -Copyright (C) 1986, 1987, 1989, 2000, 2001, 2003 Free Software Foundation, Inc. - Written by Paul Rubin, June 1986 - Adapted to ANSI C, Richard Stallman, Jan 1987 - Dusted off, polished, and adapted for use as traditional - preprocessor only, Zack Weinberg, Jul 2000 - -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 "config.h" -#include "system.h" -#include "version.h" -#include "cppdefault.h" -#include "tradcpp.h" -#include "mkdeps.h" -#include "intl.h" - -typedef unsigned char U_CHAR; - -/* Name under which this program was invoked. */ - -static const char *progname; - -/* Current maximum length of directory names in the search path - for include files. (Altered as we get more of them.) */ - -size_t max_include_len; - -/* Nonzero means copy comments into the output file. */ - -int put_out_comments = 0; - -/* mkdeps.h opaque structure that encapsulates dependency information. */ -struct deps *deps; - -/* Nonzero means print the names of included files rather than - the preprocessed output. 1 means just the #include "...", - 2 means #include <...> as well. */ - -int print_deps = 0; - -/* Nonzero means print dummy targets for each header file. */ - -int print_deps_phony_targets = 0; - -/* If true, fopen (deps_file, "a") else fopen (deps_file, "w"). */ - -int deps_append = 0; - -/* File name which deps are being written to. This is 0 if deps are - being written to stdout. */ - -const char *deps_file = 0; - -/* Nonzero if missing .h files in -M output are assumed to be - generated files and not errors. */ - -int deps_missing_files = 0; - -/* Nonzero means don't output line number information. */ - -int no_line_commands; - -/* Nonzero means inhibit output of the preprocessed text - and instead output the definitions of all user-defined macros - in a form suitable for use as input to cccp. */ - -int dump_macros; - -/* Nonzero means don't print warning messages. -w. */ - -int inhibit_warnings = 0; - -/* Non-0 means don't output the preprocessed program. */ -int inhibit_output = 0; - -/* Nonzero means chars are signed. */ -#if DEFAULT_SIGNED_CHAR -int flag_signed_char = 1; -#else -int flag_signed_char = 0; -#endif - -/* Nonzero means warn if slash-star appears in a comment. */ - -int warn_comments; - -/* Nonzero causes output not to be done, - but directives such as #define that have side effects - are still obeyed. */ - -int no_output; - -/* Value of __USER_LABEL_PREFIX__. Target-dependent, also controlled - by -f(no-)leading-underscore. */ -static const char *user_label_prefix; - -/* I/O buffer structure. - The `fname' field is nonzero for source files and #include files - and for the dummy text used for -D and -U. - It is zero for rescanning results of macro expansion - and for expanding macro arguments. */ -#define INPUT_STACK_MAX 200 -struct file_name_list; -struct file_buf { - const char *fname; - int lineno; - int length; - U_CHAR *buf; - U_CHAR *bufp; - /* Macro that this level is the expansion of. - Included so that we can reenable the macro - at the end of this level. */ - struct hashnode *macro; - /* Value of if_stack at start of this file. - Used to prohibit unmatched #endif (etc) in an include file. */ - struct if_stack *if_stack; - /* Object to be freed at end of input at this level. */ - U_CHAR *free_ptr; - /* Position to start scanning for #include_next in this file. */ - struct file_name_list *next_header_dir; -} instack[INPUT_STACK_MAX]; - -typedef struct file_buf FILE_BUF; - -/* Current nesting level of input sources. - `instack[indepth]' is the level currently being read. */ -int indepth = -1; -#define CHECK_DEPTH(code) \ - if (indepth >= (INPUT_STACK_MAX - 1)) \ - { \ - error_with_line (line_for_error (instack[indepth].lineno), \ - "macro or #include recursion too deep"); \ - code; \ - } - -/* Current depth in #include directives that use <...>. */ -int system_include_depth = 0; - -/* The output buffer. Its LENGTH field is the amount of room allocated - for the buffer, not the number of chars actually present. To get - that, subtract outbuf.buf from outbuf.bufp. */ - -#define OUTBUF_SIZE 10 /* initial size of output buffer */ -FILE_BUF outbuf; - -/* Grow output buffer OBUF points at - so it can hold at least NEEDED more chars. */ - -#define check_expand(OBUF, NEEDED) do { \ - if ((OBUF)->length - ((OBUF)->bufp - (OBUF)->buf) <= (NEEDED)) \ - grow_outbuf ((OBUF), (NEEDED)); \ - } while (0) - -struct file_name_list - { - struct file_name_list *next; - const char *fname; - }; - -struct file_name_list *include = 0; /* First dir to search */ - /* First dir to search for <file> */ -struct file_name_list *first_bracket_include = 0; -struct file_name_list *last_include = 0; /* Last in chain */ - -/* List of included files that contained #once. */ -struct file_name_list *dont_repeat_files = 0; - -/* List of other included files. */ -struct file_name_list *all_include_files = 0; - -/* Structure allocated for every #define. For a simple replacement - such as - #define foo bar , - nargs = -1, the `pattern' list is null, and the expansion is just - the replacement text. Nargs = 0 means a functionlike macro with no args, - e.g., - #define getchar() getc (stdin) . - When there are args, the expansion is the replacement text with the - args squashed out, and the reflist is a list describing how to - build the output from the input: e.g., "3 chars, then the 1st arg, - then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg". - The chars here come from the expansion. Whatever is left of the - expansion after the last arg-occurrence is copied after that arg. - Note that the reflist can be arbitrarily long--- - its length depends on the number of times the arguments appear in - the replacement text, not how many args there are. Example: - #define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and - pattern list - { (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL } - where (x, y) means (nchars, argno). */ - -typedef struct definition DEFINITION; -struct definition { - int nargs; - int length; /* length of expansion string */ - U_CHAR *expansion; - struct reflist { - struct reflist *next; - char stringify; /* nonzero if this arg was preceded by a - # operator. */ - char raw_before; /* Nonzero if a ## operator before arg. */ - char raw_after; /* Nonzero if a ## operator after arg. */ - int nchars; /* Number of literal chars to copy before - this arg occurrence. */ - int argno; /* Number of arg to substitute (origin-0) */ - } *pattern; - /* Names of macro args, concatenated in reverse order - with comma-space between them. - The only use of this is that we warn on redefinition - if this differs between the old and new definitions. */ - const U_CHAR *argnames; -}; - -/* Chained list of answers to an assertion. */ -struct answer -{ - struct answer *next; - const unsigned char *answer; - size_t len; -}; - -/* different kinds of things that can appear in the value field - of a hash node. Actually, this may be useless now. */ -union hashval { - const char *cpval; - DEFINITION *defn; - struct answer *answers; -}; - -/* The structure of a node in the hash table. The hash table - has entries for all tokens defined by #define commands (type T_MACRO), - plus some special tokens like __LINE__ (these each have their own - type, and the appropriate code is run when that type of node is seen. - It does not contain control words like "#define", which are recognized - by a separate piece of code. */ - -/* different flavors of hash nodes --- also used in keyword table */ -enum node_type { - T_DEFINE = 1, /* `#define' */ - T_INCLUDE, /* `#include' */ - T_INCLUDE_NEXT,/* `#include_next' */ - T_IFDEF, /* `#ifdef' */ - T_IFNDEF, /* `#ifndef' */ - T_IF, /* `#if' */ - T_ELSE, /* `#else' */ - T_ELIF, /* `#elif' */ - T_UNDEF, /* `#undef' */ - T_LINE, /* `#line' */ - T_ENDIF, /* `#endif' */ - T_ERROR, /* `#error' */ - T_WARNING, /* `#warning' */ - T_ASSERT, /* `#assert' */ - T_UNASSERT, /* `#unassert' */ - T_SPECLINE, /* special symbol `__LINE__' */ - T_DATE, /* `__DATE__' */ - T_FILE, /* `__FILE__' */ - T_BASE_FILE, /* `__BASE_FILE__' */ - T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */ - T_VERSION, /* `__VERSION__' */ - T_TIME, /* `__TIME__' */ - T_CONST, /* Constant value, used by `__STDC__' */ - T_MACRO, /* macro defined by `#define' */ - T_SPEC_DEFINED, /* special `defined' macro for use in #if statements */ - T_UNUSED /* Used for something not defined. */ -}; - -struct hashnode { - struct hashnode *next; /* double links for easy deletion */ - struct hashnode *prev; - struct hashnode **bucket_hdr; /* also, a back pointer to this node's hash - chain is kept, in case the node is the head - of the chain and gets deleted. */ - enum node_type type; /* type of special token */ - int length; /* length of token, for quick comparison */ - U_CHAR *name; /* the actual name */ - union hashval value; /* pointer to expansion, or whatever */ -}; - -typedef struct hashnode HASHNODE; - -static HASHNODE *parse_assertion PARAMS ((const unsigned char *, - const unsigned char *, - struct answer **, int)); -static struct answer **find_answer PARAMS ((HASHNODE *, - const struct answer *)); -static int parse_answer PARAMS ((const unsigned char *, const unsigned char *, - struct answer **, int)); -static unsigned char *canonicalize_text PARAMS ((const unsigned char *, - const unsigned char *, - const unsigned char **)); - -/* Some definitions for the hash table. The hash function MUST be - computed as shown in hashf () below. That is because the rescan - loop computes the hash value `on the fly' for most tokens, - in order to avoid the overhead of a lot of procedure calls to - the hashf () function. Hashf () only exists for the sake of - politeness, for use when speed isn't so important. */ - -#define HASHSIZE 1403 -HASHNODE *hashtab[HASHSIZE]; -#define HASHSTEP(old, c) ((old << 2) + c) -#define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */ - -/* `struct directive' defines one #-directive, including how to handle it. */ - -struct directive { - const int length; /* Length of name */ - void (*const func) PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); - /* Function to handle directive */ - const char *const name; /* Name of directive */ - const enum node_type type; /* Code which describes which directive. */ -}; - -/* Last arg to output_line_command. */ -enum file_change_code {same_file, enter_file, leave_file}; - -/* This structure represents one parsed argument in a macro call. - `raw' points to the argument text as written (`raw_length' is its length). - `expanded' points to the argument's macro-expansion - (its length is `expand_length'). - `stringified_length' is the length the argument would have - if stringified. - `free1' and `free2', if nonzero, point to blocks to be freed - when the macro argument data is no longer needed. */ - -struct argdata { - U_CHAR *raw, *expanded; - int raw_length, expand_length; - int stringified_length; - U_CHAR *free1, *free2; - char newlines; - char comments; -}; - -/* The arglist structure is built by do_define to tell - collect_definition where the argument names begin. That - is, for a define like "#define f(x,y,z) foo+x-bar*y", the arglist - would contain pointers to the strings x, y, and z. - Collect_definition would then build a DEFINITION node, - with reflist nodes pointing to the places x, y, and z had - appeared. So the arglist is just convenience data passed - between these two routines. It is not kept around after - the current #define has been processed and entered into the - hash table. */ - -struct arglist { - struct arglist *next; - U_CHAR *name; - int length; - int argno; -}; - -/* Function prototypes. */ - -static void do_define PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_error PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_warning PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_line PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_include PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_include_next PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_undef PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_if PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_ifdef PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_ifndef PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_else PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_elif PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_endif PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_assert PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_unassert PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *)); -static void do_xifdef PARAMS ((U_CHAR *, U_CHAR *, enum node_type)); - -static struct hashnode *install PARAMS ((const U_CHAR *, int, enum node_type, int)); -static int hashf PARAMS ((const U_CHAR *, int, int)); -static int compare_defs PARAMS ((DEFINITION *, DEFINITION *)); -static int comp_def_part PARAMS ((int, const U_CHAR *, int, - const U_CHAR *, int, int)); -static void delete_macro PARAMS ((HASHNODE *)); - -/* First arg to v_message. */ -enum msgtype { MT_WARNING = 0, MT_ERROR, MT_FATAL }; -static void v_message PARAMS ((enum msgtype mtype, int line, - const char *msgid, va_list ap)) - ATTRIBUTE_PRINTF (3, 0); - -static int line_for_error PARAMS ((int)); - -/* We know perfectly well which file this is, so we don't need to - use __FILE__. */ -#undef abort -#if (GCC_VERSION >= 2007) -#define abort() fancy_abort(__LINE__, __FUNCTION__) -#else -#define abort() fancy_abort(__LINE__, 0); -#endif - -static void macroexpand PARAMS ((HASHNODE *, FILE_BUF *)); -static void special_symbol PARAMS ((HASHNODE *, FILE_BUF *)); -static void dump_all_macros PARAMS ((void)); -static void dump_defn_1 PARAMS ((const U_CHAR *, int, int)); -static void dump_arg_n PARAMS ((DEFINITION *, int)); -static void conditional_skip PARAMS ((FILE_BUF *, int, enum node_type)); -static void skip_if_group PARAMS ((FILE_BUF *, int)); -static void output_line_command PARAMS ((FILE_BUF *, FILE_BUF *, - int, enum file_change_code)); - -static int eval_if_expression PARAMS ((const U_CHAR *, int)); - -static void output_deps PARAMS ((void)); -static void initialize_builtins PARAMS ((void)); -static void run_directive PARAMS ((const char *, size_t, - enum node_type)); -static void make_definition PARAMS ((const char *)); -static void make_undef PARAMS ((const char *)); -static void make_assertion PARAMS ((const char *)); - -static void grow_outbuf PARAMS ((FILE_BUF *, int)); -static int handle_directive PARAMS ((FILE_BUF *, FILE_BUF *)); -static void process_include PARAMS ((struct file_name_list *, - const U_CHAR *, int, int, FILE_BUF *)); -static void fixup_newlines PARAMS ((FILE_BUF *)); -static void finclude PARAMS ((int, const char *, - struct file_name_list *, FILE_BUF *)); -static void init_dependency_output PARAMS ((void)); -static void rescan PARAMS ((FILE_BUF *, int)); -static void newline_fix PARAMS ((U_CHAR *)); -static void name_newline_fix PARAMS ((U_CHAR *)); -static U_CHAR *macarg1 PARAMS ((U_CHAR *, const U_CHAR *, int *, - int *, int *)); -static const char *macarg PARAMS ((struct argdata *)); -static int discard_comments PARAMS ((U_CHAR *, int, int)); -static int file_size_and_mode PARAMS ((int, int *, long *)); - -static U_CHAR *skip_to_end_of_comment PARAMS ((FILE_BUF *, int *)); -static U_CHAR *skip_quoted_string PARAMS ((const U_CHAR *, const U_CHAR *, - int, int *, int *, int *)); - -int main PARAMS ((int, char **)); - -/* Convenience. Write U"string" to get an unsigned string constant. */ -#define U (const unsigned char *) - -/* Here is the actual list of #-directives, most-often-used first. */ - -static const struct directive directive_table[] = { - { 6, do_define, "define", T_DEFINE }, - { 7, do_include, "include", T_INCLUDE }, - { 5, do_endif, "endif", T_ENDIF }, - { 5, do_ifdef, "ifdef", T_IFDEF }, - { 2, do_if, "if", T_IF, }, - { 4, do_else, "else", T_ELSE }, - { 6, do_ifndef, "ifndef", T_IFNDEF }, - { 5, do_undef, "undef", T_UNDEF }, - { 4, do_line, "line", T_LINE }, - { 4, do_elif, "elif", T_ELIF }, - { 5, do_error, "error", T_ERROR }, - { 7, do_warning, "warning", T_WARNING }, - { 12, do_include_next, "include_next", T_INCLUDE_NEXT }, - { 6, do_assert, "assert", T_ASSERT }, - { 8, do_unassert,"unassert",T_UNASSERT}, - { -1, 0, "", T_UNUSED}, -}; - -#define SKIP_WHITE_SPACE(p) do { while (is_nvspace(*p)) p++; } while (0) -#define SKIP_ALL_WHITE_SPACE(p) do { while (is_space(*p)) p++; } while (0) - -int errors = 0; /* Error counter for exit code */ - -static FILE_BUF expand_to_temp_buffer PARAMS ((const U_CHAR *, const U_CHAR *, int)); -static DEFINITION *collect_expansion PARAMS ((U_CHAR *, U_CHAR *, int, - struct arglist *)); - -/* Stack of conditionals currently in progress - (including both successful and failing conditionals). */ - -struct if_stack { - struct if_stack *next; /* for chaining to the next stack frame */ - const char *fname; /* copied from input when frame is made */ - int lineno; /* similarly */ - int if_succeeded; /* true if a leg of this if-group - has been passed through rescan */ - enum node_type type; /* type of last directive seen in this group */ -}; -typedef struct if_stack IF_STACK_FRAME; -IF_STACK_FRAME *if_stack = NULL; - -/* Nonzero means -I- has been seen, - so don't look for #include "foo" the source-file directory. */ -int ignore_srcdir; - -/* Pending directives. */ -enum pending_dir_t {PD_NONE = 0, PD_DEFINE, PD_UNDEF, PD_ASSERTION, PD_FILE}; - -typedef struct pending_dir pending_dir; -struct pending_dir -{ - const char *arg; - enum pending_dir_t type; -}; - -int -main (argc, argv) - int argc; - char **argv; -{ - int st_mode; - long st_size; - const char *in_fname, *out_fname; - int f, i; - FILE_BUF *fp; - pending_dir *pend = (pending_dir *) xcalloc (argc, sizeof (pending_dir)); - int no_standard_includes = 0; - - hex_init (); - -#ifdef RLIMIT_STACK - /* Get rid of any avoidable limit on stack size. */ - { - struct rlimit rlim; - - /* Set the stack limit huge so that alloca (particularly stringtab - * in dbxread.c) does not fail. */ - getrlimit (RLIMIT_STACK, &rlim); - rlim.rlim_cur = rlim.rlim_max; - setrlimit (RLIMIT_STACK, &rlim); - } -#endif /* RLIMIT_STACK defined */ - - progname = argv[0]; - - in_fname = NULL; - out_fname = NULL; - - no_line_commands = 0; - dump_macros = 0; - no_output = 0; - - max_include_len = cpp_GCC_INCLUDE_DIR_len + 7; /* ??? */ - - gcc_init_libintl (); - - /* It's simplest to just create this struct whether or not it will - be needed. */ - deps = deps_init (); - - /* Process switches and find input file name. */ - - for (i = 1; i < argc; i++) { - if (argv[i][0] != '-') { - if (out_fname != NULL) - fatal ("usage: %s [switches] input output", argv[0]); - else if (in_fname != NULL) - out_fname = argv[i]; - else - in_fname = argv[i]; - } else { - int c = argv[i][1]; - - switch (c) { - case 'E': - case '$': - break; /* Ignore for compatibility with ISO/extended cpp. */ - - case 'l': - if (!strcmp (argv[i], "-lang-c++") - || !strcmp (argv[i], "-lang-objc++")) - fatal ("-traditional is not supported in C++"); - else if (!strcmp (argv[i], "-lang-c89")) - fatal ("-traditional and -ansi are mutually exclusive"); - else if (!strcmp (argv[i], "-lang-objc")) - pend[i].type = PD_DEFINE, pend[i].arg = "__OBJC__"; - else if (!strcmp (argv[i], "-lang-asm")) - pend[i].type = PD_DEFINE, pend[i].arg = "__ASSEMBLER__"; - else if (!strcmp (argv[i], "-lang-fortran")) - pend[i].type = PD_DEFINE, pend[i].arg = "_LANGUAGE_FORTRAN"; - /* All other possibilities ignored. */ - break; - - case 'i': - if (!strcmp (argv[i], "-include")) - { - if (i + 1 == argc) - fatal ("filename missing after -i option"); - else - pend[i].type = PD_FILE, pend[i].arg = argv[i + 1], i++; - } - else if (!strcmp (argv[i], "-iprefix")) - i++; /* Ignore for compatibility */ - else if (!strcmp (argv[i], "-isystem") - || !strcmp (argv[i], "-iwithprefix") - || !strcmp (argv[i], "-iwithprefixbefore") - || !strcmp (argv[i], "-idirafter")) - goto add_include; /* best we can do */ - - break; - - case 'o': - if (out_fname != NULL) - fatal ("output filename specified twice"); - if (i + 1 == argc) - fatal ("filename missing after -o option"); - out_fname = argv[++i]; - if (!strcmp (out_fname, "-")) - out_fname = ""; - break; - - case 'w': - inhibit_warnings = 1; - break; - - case 'W': - if (!strcmp (argv[i], "-Wcomments")) - warn_comments = 1; - else if (!strcmp (argv[i], "-Wcomment")) - warn_comments = 1; - else if (!strcmp (argv[i], "-Wall")) { - warn_comments = 1; - } - break; - - case 'f': - if (!strcmp (argv[i], "-fleading-underscore")) - user_label_prefix = "_"; - else if (!strcmp (argv[i], "-fno-leading-underscore")) - user_label_prefix = ""; - else if (!strcmp (argv[i], "-fsigned-char")) - flag_signed_char = 1; - else if (!strcmp (argv[i], "-funsigned-char")) - flag_signed_char = 0; - break; - - case 'M': - { - char *p = NULL; - - /* -MD and -MMD for tradcpp are deprecated and undocumented - (use -M or -MM with -MF instead), and probably should be - removed with the next major GCC version. For the moment - we allow these for the benefit of Automake 1.4, which - uses these when dependency tracking is enabled. Automake - 1.5 will fix this. */ - if (!strncmp (argv[i], "-MD", 3)) { - p = argv[i] + 3; - print_deps = 2; - } else if (!strncmp (argv[i], "-MMD", 4)) { - p = argv[i] + 4; - print_deps = 1; - } else if (!strcmp (argv[i], "-M")) { - print_deps = 2; - } else if (!strcmp (argv[i], "-MM")) { - print_deps = 1; - } else if (!strcmp (argv[i], "-MG")) { - deps_missing_files = 1; - } else if (!strcmp (argv[i], "-MF")) { - p = argv[i] + 3; - } else if (!strcmp (argv[i], "-MP")) { - print_deps_phony_targets = 1; - } else if (!strcmp (argv[i], "-MQ") || !strcmp (argv[i], "-MT")) { - /* Add a target. -MQ quotes for Make. */ - const char *tgt = argv[i] + 3; - int quoted = argv[i][2] == 'Q'; - - if (*tgt == '\0' && i + 1 == argc) - fatal ("target missing after %s option", argv[i]); - else - { - if (*tgt == '\0') - tgt = argv[++i]; - - deps_add_target (deps, tgt, quoted); - } - } - - if (p) { - if (*p) - deps_file = p; - else if (i + 1 == argc) - fatal ("filename missing after %s option", argv[i]); - else - deps_file = argv[++i]; - } - } - break; - - case 'd': - dump_macros = 1; - no_output = 1; - break; - - case 'v': - fprintf (stderr, "GNU traditional CPP version %s\n", version_string); - break; - - case 'D': - case 'U': - case 'A': - { - char *p; - - if (argv[i][2] != 0) - p = argv[i] + 2; - else if (i + 1 == argc) - fatal ("macro name missing after -%c option", c); - else - p = argv[++i]; - - if (c == 'D') - pend[i].type = PD_DEFINE; - else if (c == 'U') - pend[i].type = PD_UNDEF; - else - pend[i].type = PD_ASSERTION; - pend[i].arg = p; - } - break; - - case 'C': - put_out_comments = 1; - break; - - case 'p': - if (!strcmp (argv[i], "-pedantic")) - fatal ("-pedantic and -traditional are mutually exclusive"); - break; - - case 't': - if (!strcmp (argv[i], "-trigraphs")) - fatal ("-trigraphs and -traditional are mutually exclusive"); - break; - - case 'P': - no_line_commands = 1; - break; - - case 'I': /* Add directory to path for includes. */ - add_include: - { - struct file_name_list *dirtmp; - - if (! ignore_srcdir && !strcmp (argv[i] + 2, "-")) - ignore_srcdir = 1; - else { - dirtmp = (struct file_name_list *) - xmalloc (sizeof (struct file_name_list)); - dirtmp->next = 0; /* New one goes on the end */ - if (include == 0) - include = dirtmp; - else - last_include->next = dirtmp; - last_include = dirtmp; /* Tail follows the last one */ - if (argv[i][1] == 'I' && argv[i][2] != 0) - dirtmp->fname = argv[i] + 2; - else if (i + 1 == argc) - fatal ("directory name missing after -I option"); - else - dirtmp->fname = argv[++i]; - if (strlen (dirtmp->fname) > max_include_len) - max_include_len = strlen (dirtmp->fname); - if (ignore_srcdir && first_bracket_include == 0) - first_bracket_include = dirtmp; - } - } - break; - - case 'n': - /* -nostdinc causes no default include directories. - You must specify all include-file directories with -I. */ - no_standard_includes = 1; - break; - - case '\0': /* JF handle '-' as file name meaning stdin or stdout */ - if (in_fname == NULL) { - in_fname = ""; - break; - } else if (out_fname == NULL) { - out_fname = ""; - break; - } /* else fall through into error */ - - default: - fatal ("invalid option `%s'", argv[i]); - } - } - } - - init_dependency_output (); - - /* After checking the environment variables, check if -M or -MM has - not been specified, but other -M options have. */ - if (print_deps == 0 - && (deps_missing_files || deps_file || print_deps_phony_targets)) - fatal ("you must additionally specify either -M or -MM"); - - if (user_label_prefix == 0) - user_label_prefix = USER_LABEL_PREFIX; - - if (print_deps) - { - /* Set the default target (if there is none already), and - the dependency on the main file. */ - deps_add_default_target (deps, in_fname); - - deps_add_dep (deps, in_fname); - } - - /* Install __LINE__, etc. Must follow option processing. */ - initialize_builtins (); - - /* Do defines specified with -D and undefines specified with -U. */ - for (i = 1; i < argc; i++) - if (pend[i].type == PD_DEFINE) - make_definition (pend[i].arg); - else if (pend[i].type == PD_UNDEF) - make_undef (pend[i].arg); - else if (pend[i].type == PD_ASSERTION) - make_assertion (pend[i].arg); - - /* Unless -fnostdinc, - tack on the standard include file dirs to the specified list */ - if (!no_standard_includes) { - const struct default_include *di; - struct file_name_list *old_last_include = last_include; - struct file_name_list *dirtmp; - for (di = cpp_include_defaults; di->fname; di++) { - if (di->cplusplus) - continue; - dirtmp = (struct file_name_list *) - xmalloc (sizeof (struct file_name_list)); - dirtmp->next = 0; /* New one goes on the end */ - if (include == 0) - include = dirtmp; - else - last_include->next = dirtmp; - last_include = dirtmp; /* Tail follows the last one */ - dirtmp->fname = di->fname; - if (strlen (dirtmp->fname) > max_include_len) - max_include_len = strlen (dirtmp->fname); - } - - if (ignore_srcdir && first_bracket_include == 0) - first_bracket_include = old_last_include->next; - } - - /* Initialize output buffer */ - - outbuf.buf = (U_CHAR *) xmalloc (OUTBUF_SIZE); - outbuf.bufp = outbuf.buf; - outbuf.length = OUTBUF_SIZE; - - /* Scan the -i files before the main input. - Much like #including them, but with no_output set - so that only their macro definitions matter. */ - - no_output++; - indepth++; - for (i = 1; i < argc; i++) - if (pend[i].type == PD_FILE) - { - int fd = open (pend[i].arg, O_RDONLY, 0666); - if (fd < 0) - { - perror_with_name (pend[i].arg); - return FATAL_EXIT_CODE; - } - - /* For -M, add this file to the dependencies. */ - if (print_deps) - deps_add_dep (deps, pend[i].arg); - - finclude (fd, pend[i].arg, 0, &outbuf); - } - indepth--; - no_output--; - - /* Pending directives no longer needed. */ - free ((PTR) pend); - - /* Create an input stack level for the main input file - and copy the entire contents of the file into it. */ - - fp = &instack[++indepth]; - - /* JF check for stdin */ - if (in_fname == NULL || *in_fname == 0) { - in_fname = ""; - f = 0; - } else if ((f = open (in_fname, O_RDONLY, 0666)) < 0) - goto sys_error; - - if (file_size_and_mode (f, &st_mode, &st_size)) - goto sys_error; - fp->fname = in_fname; - fp->lineno = 1; - /* JF all this is mine about reading pipes and ttys */ - if (!S_ISREG (st_mode)) { - /* Read input from a file that is not a normal disk file. - We cannot preallocate a buffer with the correct size, - so we must read in the file a piece at the time and make it bigger. */ - int size; - int bsize; - int cnt; - U_CHAR *bufp; - - bsize = 2000; - size = 0; - fp->buf = (U_CHAR *) xmalloc (bsize + 2); - bufp = fp->buf; - for (;;) { - cnt = read (f, bufp, bsize - size); - if (cnt < 0) goto sys_error; /* error! */ - if (cnt == 0) break; /* End of file */ - size += cnt; - bufp += cnt; - if (bsize == size) { /* Buffer is full! */ - bsize *= 2; - fp->buf = (U_CHAR *) xrealloc (fp->buf, bsize + 2); - bufp = fp->buf + size; /* May have moved */ - } - } - fp->length = size; - } else { - /* Read a file whose size we can determine in advance. - For the sake of VMS, st_size is just an upper bound. */ - long i; - fp->length = 0; - fp->buf = (U_CHAR *) xmalloc (st_size + 2); - - while (st_size > 0) { - i = read (f, fp->buf + fp->length, st_size); - if (i <= 0) { - if (i == 0) break; - goto sys_error; - } - fp->length += i; - st_size -= i; - } - } - fp->bufp = fp->buf; - fp->if_stack = if_stack; - fixup_newlines (fp); - - /* Make sure data ends with a newline. And put a null after it. */ - - if (fp->length > 0 && fp->buf[fp->length-1] != '\n') - fp->buf[fp->length++] = '\n'; - fp->buf[fp->length] = '\0'; - - /* Now that we know the input file is valid, open the output. */ - - if (!out_fname || !strcmp (out_fname, "")) - out_fname = "stdout"; - else if (! freopen (out_fname, "w", stdout)) - pfatal_with_name (out_fname); - - output_line_command (fp, &outbuf, 0, same_file); - - /* Scan the input, processing macros and directives. */ - - rescan (&outbuf, 0); - - /* Now we have processed the entire input - Write whichever kind of output has been requested. */ - - - if (dump_macros) - dump_all_macros (); - else if (! inhibit_output) - if (write (fileno (stdout), outbuf.buf, outbuf.bufp - outbuf.buf) < 0) - fatal ("I/O error on output"); - - /* Don't write the deps file if preprocessing has failed. */ - if (print_deps && errors == 0) - output_deps (); - - /* Destruct the deps object. */ - deps_free (deps); - - if (ferror (stdout)) - fatal ("I/O error on output"); - - if (errors) - exit (FATAL_EXIT_CODE); - exit (SUCCESS_EXIT_CODE); - - sys_error: - pfatal_with_name (in_fname); -} - -/* Set up dependency-file output. */ -static void -init_dependency_output () -{ - char *spec, *s, *output_file; - - /* Either of two environment variables can specify output of deps. - Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET", - where OUTPUT_FILE is the file to write deps info to - and DEPS_TARGET is the target to mention in the deps. */ - - if (print_deps == 0) - { - spec = getenv ("DEPENDENCIES_OUTPUT"); - if (spec) - print_deps = 1; - else - { - spec = getenv ("SUNPRO_DEPENDENCIES"); - if (spec) - print_deps = 2; - else - return; - } - - /* Find the space before the DEPS_TARGET, if there is one. */ - s = strchr (spec, ' '); - if (s) - { - /* Let the caller perform MAKE quoting. */ - deps_add_target (deps, s + 1, 0); - output_file = (char *) xmalloc (s - spec + 1); - memcpy (output_file, spec, s - spec); - output_file[s - spec] = 0; - } - else - output_file = spec; - - /* Command line overrides environment variables. */ - if (deps_file == 0) - deps_file = output_file; - deps_append = 1; - } - - /* If dependencies go to standard output, or -MG is used, we should - suppress output. The user may be requesting other stuff to - stdout, with -dM, -v etc. We let them shoot themselves in the - foot. */ - if (deps_file == 0 || deps_missing_files) - inhibit_output = 1; -} - -/* Use mkdeps.c to output dependency information. */ -static void -output_deps () -{ - /* Stream on which to print the dependency information. */ - FILE *deps_stream = 0; - const char *const deps_mode = deps_append ? "a" : "w"; - - if (deps_file == 0) - deps_stream = stdout; - else - { - deps_stream = fopen (deps_file, deps_mode); - if (deps_stream == 0) - { - error_from_errno (deps_file); - return; - } - } - - deps_write (deps, deps_stream, 72); - - if (print_deps_phony_targets) - deps_phony_targets (deps, deps_stream); - - /* Don't close stdout. */ - if (deps_file) - { - if (ferror (deps_stream) || fclose (deps_stream) != 0) - fatal ("I/O error on output"); - } -} - -/* Move all backslash-newline pairs out of embarrassing places. - Exchange all such pairs following BP - with any potentially-embarrasing characters that follow them. - Potentially-embarrassing characters are / and * - (because a backslash-newline inside a comment delimiter - would cause it not to be recognized). */ -static void -newline_fix (bp) - U_CHAR *bp; -{ - U_CHAR *p = bp; - int count = 0; - - /* First count the backslash-newline pairs here. */ - - while (*p++ == '\\' && *p++ == '\n') - count++; - - p = bp + count * 2; - - /* Exit if what follows the backslash-newlines is not embarrassing. */ - - if (count == 0 || (*p != '/' && *p != '*')) - return; - - /* Copy all potentially embarrassing characters - that follow the backslash-newline pairs - down to where the pairs originally started. */ - - while (*p == '*' || *p == '/') - *bp++ = *p++; - - /* Now write the same number of pairs after the embarrassing chars. */ - while (count-- > 0) { - *bp++ = '\\'; - *bp++ = '\n'; - } -} - -/* Like newline_fix but for use within a directive-name. - Move any backslash-newlines up past any following symbol constituents. */ -static void -name_newline_fix (bp) - U_CHAR *bp; -{ - U_CHAR *p = bp; - int count = 0; - - /* First count the backslash-newline pairs here. */ - - while (*p++ == '\\' && *p++ == '\n') - count++; - - p = bp + count * 2; - - /* What follows the backslash-newlines is not embarrassing. */ - - if (count == 0 || !is_idchar (*p)) - return; - - /* Copy all potentially embarrassing characters - that follow the backslash-newline pairs - down to where the pairs originally started. */ - - while (is_idchar (*p)) - *bp++ = *p++; - - /* Now write the same number of pairs after the embarrassing chars. */ - while (count-- > 0) { - *bp++ = '\\'; - *bp++ = '\n'; - } -} - -/* - * The main loop of the program. - * - * Read characters from the input stack, transferring them to the - * output buffer OP. - * - * Macros are expanded and push levels on the input stack. - * At the end of such a level it is popped off and we keep reading. - * At the end of any other kind of level, we return. - * #-directives are handled, except within macros. - * - * If OUTPUT_MARKS is nonzero, keep Newline markers found in the input - * and insert them when appropriate. This is set while scanning macro - * arguments before substitution. It is zero when scanning for final output. - * There are three types of Newline markers: - * * Newline - follows a macro name that was not expanded - * because it appeared inside an expansion of the same macro. - * This marker prevents future expansion of that identifier. - * When the input is rescanned into the final output, these are deleted. - * These are also deleted by ## concatenation. - * * Newline Space (or Newline and any other whitespace character) - * stands for a place that tokens must be separated or whitespace - * is otherwise desirable, but where the ANSI standard specifies there - * is no whitespace. This marker turns into a Space (or whichever other - * whitespace char appears in the marker) in the final output, - * but it turns into nothing in an argument that is stringified with #. - * Such stringified arguments are the only place where the ANSI standard - * specifies with precision that whitespace may not appear. - * - * During this function, IP->bufp is kept cached in IBP for speed of access. - * Likewise, OP->bufp is kept in OBP. Before calling a subroutine - * IBP, IP and OBP must be copied back to memory. IP and IBP are - * copied back with the RECACHE macro. OBP must be copied back from OP->bufp - * explicitly, and before RECACHE, since RECACHE uses OBP. - */ - -static void -rescan (op, output_marks) - FILE_BUF *op; - int output_marks; -{ - /* Character being scanned in main loop. */ - U_CHAR c; - - /* Length of pending accumulated identifier. */ - int ident_length = 0; - - /* Hash code of pending accumulated identifier. */ - int hash = 0; - - /* Current input level (&instack[indepth]). */ - FILE_BUF *ip; - - /* Pointer for scanning input. */ - U_CHAR *ibp; - - /* Pointer to end of input. End of scan is controlled by LIMIT. */ - U_CHAR *limit; - - /* Pointer for storing output. */ - U_CHAR *obp; - - /* REDO_CHAR is nonzero if we are processing an identifier - after backing up over the terminating character. - Sometimes we process an identifier without backing up over - the terminating character, if the terminating character - is not special. Backing up is done so that the terminating character - will be dispatched on again once the identifier is dealt with. */ - int redo_char = 0; - - /* 1 if within an identifier inside of which a concatenation - marker (Newline -) has been seen. */ - int concatenated = 0; - - /* While scanning a comment or a string constant, - this records the line it started on, for error messages. */ - int start_line; - - /* Record position of last `real' newline. */ - U_CHAR *beg_of_line; - - /* This has to be a global bacause of RECACHE. */ - U_CHAR *obufp_before_macroname = NULL; - -/* Pop the innermost input stack level, assuming it is a macro expansion. */ - -#define POPMACRO \ -do { ip->macro->type = T_MACRO; \ - if (ip->free_ptr) free (ip->free_ptr); \ - --indepth; } while (0) - -/* Reload `rescan's local variables that describe the current - level of the input stack. */ - -#define RECACHE \ -do { ip = &instack[indepth]; \ - ibp = ip->bufp; \ - limit = ip->buf + ip->length; \ - op->bufp = obp; \ - check_expand (op, limit - ibp); \ - beg_of_line = 0; \ - obufp_before_macroname += op->bufp - obp; \ - obp = op->bufp; } while (0) - - if (no_output && instack[indepth].fname != 0) - skip_if_group (&instack[indepth], 1); - - obp = op->bufp; - RECACHE; - beg_of_line = ibp; - - /* Our caller must always put a null after the end of - the input at each input stack level. */ - if (*limit != 0) - abort (); - - while (1) { - c = *ibp++; - *obp++ = c; - - switch (c) { - case '\\': - if (ibp >= limit) - break; - if (*ibp == '\n') { - /* Always merge lines ending with backslash-newline, - even in middle of identifier. */ - ++ibp; - ++ip->lineno; - --obp; /* remove backslash from obuf */ - break; - } - /* Otherwise, backslash suppresses specialness of following char, - so copy it here to prevent the switch from seeing it. - But first get any pending identifier processed. */ - if (ident_length > 0) - goto specialchar; - *obp++ = *ibp++; - break; - - case '#': - /* If this is expanding a macro definition, don't recognize - preprocessor directives. */ - if (ip->macro != 0) - goto randomchar; - if (ident_length) - goto specialchar; - - /* # keyword: a # must be the first char on the line */ - if (beg_of_line == 0) - goto randomchar; - if (beg_of_line + 1 != ibp) - goto randomchar; - - /* This # can start a directive. */ - - --obp; /* Don't copy the '#' */ - - ip->bufp = ibp; - op->bufp = obp; - if (! handle_directive (ip, op)) { -#ifdef USE_C_ALLOCA - alloca (0); -#endif - /* Not a known directive: treat it as ordinary text. - IP, OP, IBP, etc. have not been changed. */ - if (no_output && instack[indepth].fname) { - /* If not generating expanded output, - what we do with ordinary text is skip it. - Discard everything until next # directive. */ - skip_if_group (&instack[indepth], 1); - RECACHE; - beg_of_line = ibp; - break; - } - ++obp; /* Copy the '#' after all */ - goto randomchar; - } -#ifdef USE_C_ALLOCA - alloca (0); -#endif - /* A # directive has been successfully processed. */ - /* If not generating expanded output, ignore everything until - next # directive. */ - if (no_output && instack[indepth].fname) - skip_if_group (&instack[indepth], 1); - obp = op->bufp; - RECACHE; - beg_of_line = ibp; - break; - - case '\"': /* skip quoted string */ - case '\'': - /* A single quoted string is treated like a double -- some - programs (e.g., troff) are perverse this way */ - - if (ident_length) - goto specialchar; - - start_line = ip->lineno; - - /* Skip ahead to a matching quote. */ - - while (1) { - if (ibp >= limit) { - if (ip->macro != 0) { - /* try harder: this string crosses a macro expansion boundary */ - POPMACRO; - RECACHE; - continue; - } - break; - } - *obp++ = *ibp; - switch (*ibp++) { - case '\n': - ++ip->lineno; - ++op->lineno; - /* Traditionally, end of line ends a string constant with no error. - So exit the loop and record the new line. */ - beg_of_line = ibp; - goto while2end; - - case '\\': - if (ibp >= limit) - break; - if (*ibp == '\n') { - /* Backslash newline is replaced by nothing at all, - but keep the line counts correct. */ - --obp; - ++ibp; - ++ip->lineno; - } else { - /* ANSI stupidly requires that in \\ the second \ - is *not* prevented from combining with a newline. */ - while (*ibp == '\\' && ibp[1] == '\n') { - ibp += 2; - ++ip->lineno; - } - *obp++ = *ibp++; - } - break; - - case '\"': - case '\'': - if (ibp[-1] == c) - goto while2end; - break; - } - } - while2end: - break; - - case '/': - if (*ibp == '\\' && ibp[1] == '\n') - newline_fix (ibp); - /* Don't look for comments inside a macro definition. */ - if (ip->macro != 0) - goto randomchar; - /* A comment constitutes white space, so it can terminate an identifier. - Process the identifier, if any. */ - if (ident_length) - goto specialchar; - - if (*ibp != '*') - goto randomchar; - - /* We have a comment. Skip it, optionally copying it to output. */ - - start_line = ip->lineno; - - ++ibp; /* Skip the star. */ - - /* In K+R C, a comment is equivalent to nothing. Note that we - already output the slash; we might not want it. */ - if (! put_out_comments) - obp--; - else - *obp++ = '*'; - - { - U_CHAR *before_bp = ibp; - - while (ibp < limit) { - switch (*ibp++) { - case '/': - if (warn_comments && ibp < limit && *ibp == '*') - warning("`/*' within comment"); - break; - case '*': - if (*ibp == '\\' && ibp[1] == '\n') - newline_fix (ibp); - if (ibp >= limit || *ibp == '/') - goto comment_end; - break; - case '\n': - ++ip->lineno; - /* Copy the newline into the output buffer, in order to - avoid the pain of a #line every time a multiline comment - is seen. */ - if (!put_out_comments) - *obp++ = '\n'; - ++op->lineno; - } - } - comment_end: - - if (ibp >= limit) - error_with_line (line_for_error (start_line), - "unterminated comment"); - else { - ibp++; - if (put_out_comments) { - memcpy (obp, before_bp, ibp - before_bp); - obp += ibp - before_bp; - } - } - } - break; - - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - /* If digit is not part of identifier, it starts a number, - which means that following letters are not an identifier. - "0x5" does not refer to an identifier "x5". - So copy all alphanumerics that follow without accumulating - as an identifier. Periods also, for sake of "3.e7". */ - - if (ident_length == 0) { - while (ibp < limit) { - while (ibp < limit && ibp[0] == '\\' && ibp[1] == '\n') { - ++ip->lineno; - ibp += 2; - } - c = *ibp++; - if (! ISIDNUM (c) && c != '.') { - --ibp; - break; - } - *obp++ = c; - /* A sign can be part of a preprocessing number - if it follows an e. */ - if (c == 'e' || c == 'E') { - while (ibp < limit && ibp[0] == '\\' && ibp[1] == '\n') { - ++ip->lineno; - ibp += 2; - } - if (ibp < limit && (*ibp == '+' || *ibp == '-')) { - *obp++ = *ibp++; - /* Traditional C does not let the token go past the sign. */ - break; - } - } - } - break; - } - /* fall through */ - - case '_': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - ident_length++; - /* Compute step of hash function, to avoid a proc call on every token */ - hash = HASHSTEP (hash, c); - break; - - case '\n': - /* If reprocessing a macro expansion, newline is a special marker. */ - if (ip->macro != 0) { - /* Newline White is a "funny space" to separate tokens that are - supposed to be separate but without space between. - Here White means any horizontal whitespace character. - Newline - marks a recursive macro use that is not - supposed to be expandable. */ - - if (*ibp == '-') { - /* Newline - inhibits expansion of preceding token. - If expanding a macro arg, we keep the newline -. - In final output, it is deleted. */ - if (! concatenated) { - ident_length = 0; - hash = 0; - } - ibp++; - if (!output_marks) { - obp--; - } else { - /* If expanding a macro arg, keep the newline -. */ - *obp++ = '-'; - } - } else if (is_space (*ibp)) { - /* Newline Space does not prevent expansion of preceding token - so expand the preceding token and then come back. */ - if (ident_length > 0) - goto specialchar; - - /* If generating final output, newline space makes a space. */ - if (!output_marks) { - obp[-1] = *ibp++; - /* And Newline Newline makes a newline, so count it. */ - if (obp[-1] == '\n') - op->lineno++; - } else { - /* If expanding a macro arg, keep the newline space. - If the arg gets stringified, newline space makes nothing. */ - *obp++ = *ibp++; - } - } else abort (); /* Newline followed by something random? */ - break; - } - - /* If there is a pending identifier, handle it and come back here. */ - if (ident_length > 0) - goto specialchar; - - beg_of_line = ibp; - - /* Update the line counts and output a #line if necessary. */ - ++ip->lineno; - ++op->lineno; - if (ip->lineno != op->lineno) { - op->bufp = obp; - output_line_command (ip, op, 1, same_file); - check_expand (op, ip->length - (ip->bufp - ip->buf)); - obp = op->bufp; - } - break; - - /* Come here either after (1) a null character that is part of the input - or (2) at the end of the input, because there is a null there. */ - case 0: - if (ibp <= limit) - /* Our input really contains a null character. */ - goto randomchar; - - /* At end of a macro-expansion level, pop it and read next level. */ - if (ip->macro != 0) { - obp--; - ibp--; - /* If we have an identifier that ends here, process it now, so - we get the right error for recursion. */ - if (ident_length && ! is_idchar (*instack[indepth - 1].bufp)) { - redo_char = 1; - goto randomchar; - } - POPMACRO; - RECACHE; - break; - } - - /* If we don't have a pending identifier, - return at end of input. */ - if (ident_length == 0) { - obp--; - ibp--; - op->bufp = obp; - ip->bufp = ibp; - goto ending; - } - - /* If we do have a pending identifier, just consider this null - a special character and arrange to dispatch on it again. - The second time, IDENT_LENGTH will be zero so we will return. */ - - /* Fall through */ - -specialchar: - - /* Handle the case of a character such as /, ', " or null - seen following an identifier. Back over it so that - after the identifier is processed the special char - will be dispatched on again. */ - - ibp--; - obp--; - redo_char = 1; - - default: - -randomchar: - - if (ident_length > 0) { - HASHNODE *hp; - - /* We have just seen an identifier end. If it's a macro, expand it. - - IDENT_LENGTH is the length of the identifier - and HASH is its hash code. - - The identifier has already been copied to the output, - so if it is a macro we must remove it. - - If REDO_CHAR is 0, the char that terminated the identifier - has been skipped in the output and the input. - OBP-IDENT_LENGTH-1 points to the identifier. - If the identifier is a macro, we must back over the terminator. - - If REDO_CHAR is 1, the terminating char has already been - backed over. OBP-IDENT_LENGTH points to the identifier. */ - - for (hp = hashtab[MAKE_POS (hash) % HASHSIZE]; hp != NULL; - hp = hp->next) { - - if (hp->length == ident_length) { - /* obufp_before_macroname is used only in this block, - but it has to be global because of RECACHE. */ - int op_lineno_before_macroname; - int i = ident_length; - U_CHAR *p = hp->name; - U_CHAR *q = obp - i; - - if (! redo_char) - q--; - - do { /* All this to avoid a strncmp () */ - if (*p++ != *q++) - goto hashcollision; - } while (--i); - - /* We found a use of a macro name. - see if the context shows it is a macro call. */ - - /* Back up over terminating character if not already done. */ - if (! redo_char) { - ibp--; - obp--; - } - - obufp_before_macroname = obp - ident_length; - op_lineno_before_macroname = op->lineno; - - /* If macro wants an arglist, verify that a '(' follows. - first skip all whitespace, copying it to the output - after the macro name. Then, if there is no '(', - decide this is not a macro call and leave things that way. */ - if (hp->type == T_MACRO && hp->value.defn->nargs >= 0) - { - while (1) { - /* Scan forward over whitespace, copying it to the output. */ - if (ibp == limit && ip->macro != 0) { - POPMACRO; - RECACHE; - } - /* A comment: copy it unchanged or discard it. */ - else if (*ibp == '/' && ibp+1 != limit && ibp[1] == '*') { - if (put_out_comments) { - *obp++ = '/'; - *obp++ = '*'; - } - ibp += 2; - while (ibp + 1 != limit - && !(ibp[0] == '*' && ibp[1] == '/')) { - /* We need not worry about newline-marks, - since they are never found in comments. */ - if (*ibp == '\n') { - /* Newline in a file. Count it. */ - ++ip->lineno; - ++op->lineno; - } - if (put_out_comments) - *obp++ = *ibp++; - else - ibp++; - } - ibp += 2; - if (put_out_comments) { - *obp++ = '*'; - *obp++ = '/'; - } - } - else if (is_space (*ibp)) { - *obp++ = *ibp++; - if (ibp[-1] == '\n') { - if (ip->macro == 0) { - /* Newline in a file. Count it. */ - ++ip->lineno; - ++op->lineno; - } else if (!output_marks) { - /* A newline mark, and we don't want marks - in the output. If it is newline-hyphen, - discard it entirely. Otherwise, it is - newline-whitechar, so keep the whitechar. */ - obp--; - if (*ibp == '-') - ibp++; - else { - if (*ibp == '\n') - ++op->lineno; - *obp++ = *ibp++; - } - } else { - /* A newline mark; copy both chars to the output. */ - *obp++ = *ibp++; - } - } - } - else break; - } - if (*ibp != '(') - break; - } - - /* This is now known to be a macro call. - Discard the macro name from the output, - along with any following whitespace just copied. */ - obp = obufp_before_macroname; - op->lineno = op_lineno_before_macroname; - - /* Expand the macro, reading arguments as needed, - and push the expansion on the input stack. */ - ip->bufp = ibp; - op->bufp = obp; - macroexpand (hp, op); - - /* Reexamine input stack, since macroexpand has pushed - a new level on it. */ - obp = op->bufp; - RECACHE; - break; - } -hashcollision: - ; - } /* End hash-table-search loop */ - ident_length = hash = 0; /* Stop collecting identifier */ - redo_char = 0; - concatenated = 0; - } /* End if (ident_length > 0) */ - } /* End switch */ - } /* End per-char loop */ - - /* Come here to return -- but first give an error message - if there was an unterminated successful conditional. */ - ending: - if (if_stack != ip->if_stack) { - const char *str; - switch (if_stack->type) { - case T_IF: - str = "if"; - break; - case T_IFDEF: - str = "ifdef"; - break; - case T_IFNDEF: - str = "ifndef"; - break; - case T_ELSE: - str = "else"; - break; - case T_ELIF: - str = "elif"; - break; - default: - abort (); - } - error_with_line (line_for_error (if_stack->lineno), - "unterminated #%s conditional", str); - } - if_stack = ip->if_stack; -} - -/* - * Rescan a string into a temporary buffer and return the result - * as a FILE_BUF. Note this function returns a struct, not a pointer. - * - * OUTPUT_MARKS nonzero means keep Newline markers found in the input - * and insert such markers when appropriate. See `rescan' for details. - * OUTPUT_MARKS is 1 for macroexpanding a macro argument separately - * before substitution; it is 0 for other uses. - */ -static FILE_BUF -expand_to_temp_buffer (buf, limit, output_marks) - const U_CHAR *buf, *limit; - int output_marks; -{ - FILE_BUF *ip; - FILE_BUF obuf; - int length = limit - buf; - U_CHAR *buf1; - int odepth = indepth; - - if (length < 0) - abort (); - - /* Set up the input on the input stack. */ - - buf1 = (U_CHAR *) alloca (length + 1); - { - const U_CHAR *p1 = buf; - U_CHAR *p2 = buf1; - - while (p1 != limit) - *p2++ = *p1++; - } - buf1[length] = 0; - - /* Set up to receive the output. */ - - obuf.length = length * 2 + 100; /* Usually enough. Why be stingy? */ - obuf.bufp = obuf.buf = (U_CHAR *) xmalloc (obuf.length); - obuf.fname = 0; - obuf.macro = 0; - obuf.free_ptr = 0; - - CHECK_DEPTH ({return obuf;}); - - ++indepth; - - ip = &instack[indepth]; - ip->fname = 0; - ip->macro = 0; - ip->free_ptr = 0; - ip->length = length; - ip->buf = ip->bufp = buf1; - ip->if_stack = if_stack; - - ip->lineno = obuf.lineno = 1; - - /* Scan the input, create the output. */ - - rescan (&obuf, output_marks); - - /* Pop input stack to original state. */ - --indepth; - - if (indepth != odepth) - abort (); - - /* Record the output. */ - obuf.length = obuf.bufp - obuf.buf; - - return obuf; -} - -/* - * Process a # directive. Expects IP->bufp to point to the '#', as in - * `#define foo bar'. Passes to the command handler - * (do_define, do_include, etc.): the addresses of the 1st and - * last chars of the command (starting immediately after the # - * keyword), plus op and the keyword table pointer. If the command - * contains comments it is copied into a temporary buffer sans comments - * and the temporary buffer is passed to the command handler instead. - * Likewise for backslash-newlines. - * - * Returns nonzero if this was a known # directive. - * Otherwise, returns zero, without advancing the input pointer. - */ - -static int -handle_directive (ip, op) - FILE_BUF *ip, *op; -{ - U_CHAR *bp, *cp; - const struct directive *kt; - int ident_length; - U_CHAR *resume_p; - - /* Nonzero means we must copy the entire command - to get rid of comments or backslash-newlines. */ - int copy_command = 0; - - U_CHAR *ident, *after_ident; - - bp = ip->bufp; - /* Skip whitespace and \-newline. */ - while (1) { - if (is_nvspace (*bp)) - bp++; - else if (*bp == '/' && (newline_fix (bp + 1), bp[1]) == '*') { - ip->bufp = bp; - skip_to_end_of_comment (ip, &ip->lineno); - bp = ip->bufp; - } else if (*bp == '\\' && bp[1] == '\n') { - bp += 2; ip->lineno++; - } else break; - } - - /* Now find end of directive name. - If we encounter a backslash-newline, exchange it with any following - symbol-constituents so that we end up with a contiguous name. */ - - cp = bp; - while (1) { - if (is_idchar (*cp)) - cp++; - else { - if (*cp == '\\' && cp[1] == '\n') - name_newline_fix (cp); - if (is_idchar (*cp)) - cp++; - else break; - } - } - ident_length = cp - bp; - ident = bp; - after_ident = cp; - - /* A line of just `#' becomes blank. */ - - if (ident_length == 0 && *after_ident == '\n') { - ip->bufp = after_ident; - return 1; - } - - /* - * Decode the keyword and call the appropriate expansion - * routine, after moving the input pointer up to the next line. - */ - for (kt = directive_table; kt->length > 0; kt++) { - if (kt->length == ident_length - && !strncmp (kt->name, (const char *)ident, ident_length)) { - U_CHAR *buf; - U_CHAR *limit = ip->buf + ip->length; - int unterminated = 0; - - /* Nonzero means do not delete comments within the directive. - #define needs this to detect traditional token paste. */ - int keep_comments = kt->type == T_DEFINE; - - /* Find the end of this command (first newline not backslashed - and not in a string or comment). - Set COPY_COMMAND if the command must be copied - (it contains a backslash-newline or a comment). */ - - buf = bp = after_ident; - while (bp < limit) { - U_CHAR c = *bp++; - switch (c) { - case '\\': - if (bp < limit) { - if (*bp == '\n') { - ip->lineno++; - copy_command = 1; - } - bp++; - } - break; - - case '\'': - case '\"': - bp = skip_quoted_string (bp - 1, limit, ip->lineno, &ip->lineno, ©_command, &unterminated); - if (unterminated) { - /* Traditional preprocessing permits unterminated strings. */ - ip->bufp = bp; - goto endloop1; - } - break; - - /* <...> is special for #include. */ - case '<': - if (kt->type != T_INCLUDE) - break; - while (*bp && *bp != '>') bp++; - break; - - case '/': - if (*bp == '\\' && bp[1] == '\n') - newline_fix (bp); - if (*bp == '*') { - U_CHAR *obp = bp - 1; - ip->bufp = bp + 1; - skip_to_end_of_comment (ip, &ip->lineno); - bp = ip->bufp; - /* No need to copy the command because of a comment at the end; - just don't include the comment in the directive. */ - if (bp == limit || *bp == '\n') { - bp = obp; - goto endloop1; - } - /* Don't remove the comments if this is #define. */ - if (! keep_comments) - copy_command++; - } - break; - - case '\n': - --bp; /* Point to the newline */ - ip->bufp = bp; - goto endloop1; - } - } - ip->bufp = bp; - - endloop1: - resume_p = ip->bufp; - /* BP is the end of the directive. - RESUME_P is the next interesting data after the directive. - A comment may come between. */ - - if (copy_command) { - U_CHAR *xp = buf; - /* Need to copy entire command into temp buffer before dispatching */ - - cp = (U_CHAR *) alloca (bp - buf + 5); /* room for cmd plus - some slop */ - buf = cp; - - /* Copy to the new buffer, deleting comments - and backslash-newlines (and whitespace surrounding the latter). */ - - while (xp < bp) { - U_CHAR c = *xp++; - *cp++ = c; - - switch (c) { - case '\n': - break; - - /* <...> is special for #include. */ - case '<': - if (kt->type != T_INCLUDE) - break; - while (xp < bp && c != '>') { - c = *xp++; - if (c == '\\' && xp < bp && *xp == '\n') - xp++, ip->lineno++; - else - *cp++ = c; - } - break; - - case '\\': - if (*xp == '\n') { - xp++; - cp--; - if (cp != buf && is_space (cp[-1])) { - while (cp != buf && is_space(cp[-1])) cp--; - cp++; - SKIP_WHITE_SPACE (xp); - } else if (is_nvspace (*xp)) { - *cp++ = *xp++; - SKIP_WHITE_SPACE (xp); - } - } else { - *cp++ = *xp++; - } - break; - - case '\'': - case '\"': - { - const U_CHAR *bp1 - = skip_quoted_string (xp - 1, limit, ip->lineno, 0, 0, 0); - while (xp != bp1) - *cp++ = *xp++; - } - break; - - case '/': - if (*xp == '*') { - ip->bufp = xp + 1; - skip_to_end_of_comment (ip, 0); - if (keep_comments) - while (xp != ip->bufp) - *cp++ = *xp++; - /* Delete the slash. */ - else - cp--; - xp = ip->bufp; - } - } - } - - /* Null-terminate the copy. */ - - *cp = 0; - } - else - cp = bp; - - ip->bufp = resume_p; - - /* Call the appropriate command handler. buf now points to - either the appropriate place in the input buffer, or to - the temp buffer if it was necessary to make one. cp - points to the first char after the contents of the (possibly - copied) command, in either case. */ - (*kt->func) (buf, cp, op); - check_expand (op, ip->length - (ip->bufp - ip->buf)); - - return 1; - } - } - - return 0; -} - -static const char *const -monthnames[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - -/* - * expand things like __FILE__. Place the expansion into the output - * buffer *without* rescanning. - */ -static void -special_symbol (hp, op) - HASHNODE *hp; - FILE_BUF *op; -{ - const char *buf; - time_t t; - int i, len; - int true_indepth; - FILE_BUF *ip = NULL; - static struct tm *timebuf = NULL; - - int paren = 0; /* For special `defined' keyword */ - - for (i = indepth; i >= 0; i--) - if (instack[i].fname != NULL) { - ip = &instack[i]; - break; - } - if (ip == NULL) - fatal ("not in any file?!"); - - switch (hp->type) { - case T_FILE: - case T_BASE_FILE: - { - const char *string; - if (hp->type == T_FILE) - string = ip->fname; - else - string = instack[0].fname; - - if (string) - { - char *tmp = (char *) alloca (3 + strlen (string)); - sprintf (tmp, "\"%s\"", string); - buf = tmp; - } - else - buf = ""; - - break; - } - - case T_INCLUDE_LEVEL: - { - char *tmp = (char *) alloca (8); /* Eigth bytes ought to be more than enough */ - true_indepth = 0; - for (i = indepth; i >= 0; i--) - if (instack[i].fname != NULL) - true_indepth++; - - sprintf (tmp, "%d", true_indepth - 1); - buf = tmp; - break; - } - - case T_VERSION: - { - char *tmp = (char *) alloca (3 + strlen (version_string)); - sprintf (tmp, "\"%s\"", version_string); - buf = tmp; - break; - } - - case T_CONST: - buf = hp->value.cpval; - break; - - case T_SPECLINE: - { - char *tmp = (char *) alloca (10); - sprintf (tmp, "%d", ip->lineno); - buf = tmp; - break; - } - - case T_DATE: - case T_TIME: - { - char *tmp = (char *) alloca (20); - - if (timebuf == NULL) { - t = time (0); - timebuf = localtime (&t); - } - if (hp->type == T_DATE) - sprintf (tmp, "\"%s %2d %4d\"", monthnames[timebuf->tm_mon], - timebuf->tm_mday, timebuf->tm_year + 1900); - else - sprintf (tmp, "\"%02d:%02d:%02d\"", timebuf->tm_hour, timebuf->tm_min, - timebuf->tm_sec); - buf = tmp; - break; - } - - case T_SPEC_DEFINED: - buf = " 0 "; /* Assume symbol is not defined */ - ip = &instack[indepth]; - SKIP_WHITE_SPACE (ip->bufp); - if (*ip->bufp == '(') { - paren++; - ip->bufp++; /* Skip over the paren */ - SKIP_WHITE_SPACE (ip->bufp); - } - - if (!is_idstart (*ip->bufp)) - goto oops; - { - HASHNODE *hp = lookup (ip->bufp, -1, -1); - - if (hp && hp->type != T_UNUSED && hp->type != T_SPEC_DEFINED) - buf = " 1 "; - } - while (is_idchar (*ip->bufp)) - ++ip->bufp; - SKIP_WHITE_SPACE (ip->bufp); - if (paren) { - if (*ip->bufp != ')') - goto oops; - ++ip->bufp; - } - break; - -oops: - - error ("`defined' must be followed by ident or (ident)"); - break; - - default: - error ("cccp error: invalid special hash type"); /* time for gdb */ - abort (); - } - len = strlen (buf); - check_expand (op, len); - memcpy (op->bufp, buf, len); - op->bufp += len; -} - - -/* Routines to handle #directives */ - -/* - * Process include file by reading it in and calling rescan. - * Expects to see "fname" or <fname> on the input. - */ -static void -do_include (buf, limit, op) - U_CHAR *buf, *limit; - FILE_BUF *op; -{ - U_CHAR *fbeg, *fend; /* Beginning and end of fname */ - - struct file_name_list *stackp = include; /* Chain of dirs to search */ - struct file_name_list dsp[1]; /* First in chain, if #include "..." */ - int flen; - - int retried = 0; /* Have already tried macro - expanding the include line*/ - FILE_BUF trybuf; /* It got expanded into here */ - int system_header_p = 0; /* 0 for "...", 1 for <...> */ - -get_filename: - - fbeg = buf; - SKIP_WHITE_SPACE (fbeg); - /* Discard trailing whitespace so we can easily see - if we have parsed all the significant chars we were given. */ - while (limit != fbeg && is_nvspace (limit[-1])) limit--; - - switch (*fbeg++) { - case '\"': - fend = fbeg; - while (fend != limit && *fend != '\"') - fend++; - if (*fend == '\"' && fend + 1 == limit) { - FILE_BUF *fp; - - /* We have "filename". Figure out directory this source - file is coming from and put it on the front of the list. */ - - /* If -I- was specified, don't search current dir, only spec'd ones. */ - if (ignore_srcdir) break; - - for (fp = &instack[indepth]; fp >= instack; fp--) - { - size_t n; - const char *ep, *nam; - - if ((nam = fp->fname) != NULL) { - /* Found a named file. Figure out dir of the file, - and put it in front of the search list. */ - dsp[0].next = stackp; - stackp = dsp; - ep = strrchr (nam, '/'); - if (ep != NULL) { - char *f; - n = ep - nam; - f = (char *) alloca (n + 1); - strncpy (f, nam, n); - f[n] = '\0'; - dsp[0].fname = f; - if (n > max_include_len) max_include_len = n; - } else { - dsp[0].fname = 0; /* Current directory */ - } - break; - } - } - break; - } - goto fail; - - case '<': - fend = fbeg; - while (fend != limit && *fend != '>') fend++; - if (*fend == '>' && fend + 1 == limit) { - system_header_p = 1; - /* If -I-, start with the first -I dir after the -I-. */ - if (first_bracket_include) - stackp = first_bracket_include; - break; - } - goto fail; - - default: - fail: - if (retried) { - error ("#include expects \"fname\" or <fname>"); - return; - } else { - trybuf = expand_to_temp_buffer (buf, limit, 0); - buf = (U_CHAR *) alloca (trybuf.bufp - trybuf.buf + 1); - memcpy (buf, trybuf.buf, trybuf.bufp - trybuf.buf); - limit = buf + (trybuf.bufp - trybuf.buf); - free (trybuf.buf); - retried++; - goto get_filename; - } - } - - flen = fend - fbeg; - process_include (stackp, fbeg, flen, system_header_p, op); -} - -static void -do_include_next (buf, limit, op) - U_CHAR *buf, *limit; - FILE_BUF *op; -{ - U_CHAR *fbeg, *fend; /* Beginning and end of fname */ - - struct file_name_list *stackp; /* Chain of dirs to search */ - int flen; - - int retried = 0; /* Have already tried macro - expanding the include line*/ - FILE_BUF trybuf; /* It got expanded into here */ - int system_header_p = 0; /* 0 for "...", 1 for <...> */ - - /* Treat as plain #include if we don't know where to start - looking. */ - stackp = instack[indepth].next_header_dir; - if (stackp == 0) - { - do_include (buf, limit, op); - return; - } - -get_filename: - - fbeg = buf; - SKIP_WHITE_SPACE (fbeg); - /* Discard trailing whitespace so we can easily see - if we have parsed all the significant chars we were given. */ - while (limit != fbeg && is_nvspace (limit[-1])) limit--; - - switch (*fbeg++) { - case '\"': - fend = fbeg; - while (fend != limit && *fend != '\"') - fend++; - if (*fend == '\"' && fend + 1 == limit) - break; - goto fail; - - case '<': - fend = fbeg; - while (fend != limit && *fend != '>') fend++; - if (*fend == '>' && fend + 1 == limit) { - system_header_p = 1; - break; - } - goto fail; - - default: - fail: - if (retried) { - error ("#include expects \"fname\" or <fname>"); - return; - } else { - trybuf = expand_to_temp_buffer (buf, limit, 0); - buf = (U_CHAR *) alloca (trybuf.bufp - trybuf.buf + 1); - memcpy (buf, trybuf.buf, trybuf.bufp - trybuf.buf); - limit = buf + (trybuf.bufp - trybuf.buf); - free (trybuf.buf); - retried++; - goto get_filename; - } - } - - flen = fend - fbeg; - process_include (stackp, fbeg, flen, system_header_p, op); -} - -static void -process_include (stackp, fbeg, flen, system_header_p, op) - struct file_name_list *stackp; - const U_CHAR *fbeg; - int flen; - int system_header_p; - FILE_BUF *op; -{ - char *fname; - int f = -1; /* file number */ - - fname = (char *) alloca (max_include_len + flen + 2); - /* + 2 above for slash and terminating null. */ - - /* If specified file name is absolute, just open it. */ - - if (IS_ABSOLUTE_PATHNAME (fbeg)) { - strncpy (fname, (const char *)fbeg, flen); - fname[flen] = 0; - f = open (fname, O_RDONLY, 0666); - } else { - /* Search directory path, trying to open the file. - Copy each filename tried into FNAME. */ - - for (; stackp; stackp = stackp->next) { - if (stackp->fname) { - strcpy (fname, stackp->fname); - strcat (fname, "/"); - fname[strlen (fname) + flen] = 0; - } else { - fname[0] = 0; - } - strncat (fname, (const char *)fbeg, flen); - if ((f = open (fname, O_RDONLY, 0666)) >= 0) - break; - } - } - - if (f < 0) { - strncpy (fname, (const char *)fbeg, flen); - fname[flen] = 0; - if (deps_missing_files - && print_deps > (system_header_p || (system_include_depth > 0))) { - - /* If requested as a system header, assume it belongs in - the first system header directory. */ - if (first_bracket_include) - stackp = first_bracket_include; - else - stackp = include; - - if (!system_header_p || IS_ABSOLUTE_PATHNAME (fbeg) || !stackp->fname) - deps_add_dep (deps, fname); - else { - char *p; - int len = strlen(stackp->fname); - - p = (char *) alloca (len + flen + 2); - memcpy (p, stackp->fname, len); - p[len++] = '/'; - memcpy (p + len, fbeg, flen); - len += flen; - p[len] = '\0'; - deps_add_dep (deps, p); - } - } else if (print_deps - && print_deps <= (system_header_p - || (system_include_depth > 0))) - warning ("no include path in which to find %.*s", flen, fbeg); - else - error_from_errno (fname); - - } else { - - /* Check to see if this include file is a once-only include file. - If so, give up. */ - - struct file_name_list* ptr; - - for (ptr = dont_repeat_files; ptr; ptr = ptr->next) { - if (!strcmp (ptr->fname, fname)) { - close (f); - return; /* This file was once'd. */ - } - } - - for (ptr = all_include_files; ptr; ptr = ptr->next) { - if (!strcmp (ptr->fname, fname)) - break; /* This file was included before. */ - } - - if (ptr == 0) { - /* This is the first time for this file. */ - /* Add it to list of files included. */ - - ptr = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); - ptr->next = all_include_files; - all_include_files = ptr; - ptr->fname = xstrdup (fname); - - /* For -M, add this file to the dependencies. */ - if (print_deps > (system_header_p || (system_include_depth > 0))) - deps_add_dep (deps, fname); - } - - if (system_header_p) - system_include_depth++; - - /* Actually process the file. */ - finclude (f, fname, stackp->next, op); - - if (system_header_p) - system_include_depth--; - - close (f); - } -} - -/* Replace all CR NL, NL CR and CR sequences with NL. */ - -static void -fixup_newlines (fp) - FILE_BUF *fp; -{ - U_CHAR *p, *q, *end; - - if (fp->length <= 0) - return; - - end = fp->buf + fp->length; - p = (U_CHAR *) memchr ((const char *) fp->buf, '\r', fp->length); - if (p == NULL) - return; - - if (p > fp->buf && p[-1] == '\n') - p--; - q = p; - while (p < end) - switch (*p) - { - default: - *q++ = *p++; - break; - case '\n': - case '\r': - p += 1 + (p[0] + p[1] == '\n' + '\r'); - *q++ = '\n'; - break; - } - - fp->length = q - fp->buf; -} - -/* Process the contents of include file FNAME, already open on descriptor F, - with output to OP. */ - -static void -finclude (f, fname, nhd, op) - int f; - const char *fname; - struct file_name_list *nhd; - FILE_BUF *op; -{ - int st_mode; - long st_size; - long i; - FILE_BUF *fp; /* For input stack frame */ - - CHECK_DEPTH (return;); - - if (file_size_and_mode (f, &st_mode, &st_size)) - goto nope; - - fp = &instack[indepth + 1]; - memset (fp, 0, sizeof (FILE_BUF)); - fp->fname = fname; - fp->length = 0; - fp->lineno = 1; - fp->if_stack = if_stack; - fp->next_header_dir = nhd; - - if (S_ISREG (st_mode)) { - fp->buf = (U_CHAR *) xmalloc (st_size + 2); - fp->bufp = fp->buf; - - /* Read the file contents, knowing that st_size is an upper bound - on the number of bytes we can read. */ - while (st_size > 0) { - i = read (f, fp->buf + fp->length, st_size); - if (i <= 0) { - if (i == 0) break; - goto nope; - } - fp->length += i; - st_size -= i; - } - } - else { - /* Cannot count its file size before reading. */ - - U_CHAR *bufp; - U_CHAR *basep; - int bsize = 2000; - - st_size = 0; - basep = (U_CHAR *) xmalloc (bsize + 2); - bufp = basep; - - for (;;) { - i = read (f, bufp, bsize - st_size); - if (i < 0) - goto nope; /* error! */ - if (i == 0) - break; /* End of file */ - st_size += i; - bufp += i; - if (bsize == st_size) { /* Buffer is full! */ - bsize *= 2; - basep = (U_CHAR *) xrealloc (basep, bsize + 2); - bufp = basep + st_size; /* May have moved */ - } - } - fp->buf = basep; - fp->bufp = fp->buf; - fp->length = st_size; - } - close (f); - fixup_newlines (fp); - - /* Make sure data ends with a newline. And put a null after it. */ - - if (fp->length > 0 && fp->buf[fp->length-1] != '\n') - fp->buf[fp->length++] = '\n'; - fp->buf[fp->length] = '\0'; - - indepth++; - output_line_command (fp, op, 0, enter_file); - rescan (op, 0); - indepth--; - instack[indepth].lineno++; - instack[indepth].bufp++; /* Skip the new line. */ - output_line_command (&instack[indepth], op, 0, leave_file); - free (fp->buf); - return; - -nope: - perror_with_name (fname); - close (f); -} - - -/* Process a #define command. -BUF points to the contents of the #define command, as a continguous string. -LIMIT points to the first character past the end of the definition. -KEYWORD is the keyword-table entry for #define. */ - -static void -do_define (buf, limit, op) - U_CHAR *buf, *limit; - FILE_BUF *op ATTRIBUTE_UNUSED; -{ - U_CHAR *bp; /* temp ptr into input buffer */ - U_CHAR *symname; /* remember where symbol name starts */ - int sym_length; /* and how long it is */ - - DEFINITION *defn; - int arglengths = 0; /* Accumulate lengths of arg names - plus number of args. */ - int hashcode; - - bp = buf; - - while (is_nvspace (*bp)) - bp++; - - symname = bp; /* remember where it starts */ - while (is_idchar (*bp) && bp < limit) { - bp++; - } - sym_length = bp - symname; - if (sym_length == 0) - { - error ("invalid macro name"); - return; - } - else if (!is_idstart (*symname)) { - U_CHAR *msg; /* what pain... */ - msg = (U_CHAR *) alloca (sym_length + 1); - memcpy (msg, symname, sym_length); - msg[sym_length] = 0; - error ("invalid macro name `%s'", msg); - return; - } else { - if (! strncmp ((const char *)symname, "defined", 7) && sym_length == 7) - { - error ("\"defined\" cannot be used as a macro name"); - return; - } - } - - /* lossage will occur if identifiers or control keywords are broken - across lines using backslash. This is not the right place to take - care of that. */ - - if (*bp == '(') { - struct arglist *arg_ptrs = NULL; - int argno = 0; - - bp++; /* skip '(' */ - SKIP_WHITE_SPACE (bp); - - /* Loop over macro argument names. */ - while (*bp != ')') { - struct arglist *temp; - - temp = (struct arglist *) alloca (sizeof (struct arglist)); - temp->name = bp; - temp->next = arg_ptrs; - temp->argno = argno++; - arg_ptrs = temp; - - if (!is_idstart (*bp)) - warning ("parameter name starts with a digit in #define"); - - /* Find the end of the arg name. */ - while (is_idchar (*bp)) { - bp++; - } - temp->length = bp - temp->name; - arglengths += temp->length + 2; - SKIP_WHITE_SPACE (bp); - if (temp->length == 0 || (*bp != ',' && *bp != ')')) { - error ("badly punctuated parameter list in #define"); - return; - } - if (*bp == ',') { - bp++; - SKIP_WHITE_SPACE (bp); - } - if (bp >= limit) { - error ("unterminated parameter list in #define"); - return; - } - } - - ++bp; /* skip paren */ - while (is_nvspace (*bp) && bp < limit) /* and leading whitespace */ - ++bp; - /* now everything from bp before limit is the definition. */ - defn = collect_expansion (bp, limit, argno, arg_ptrs); - - /* Now set defn->argnames to the result of concatenating - the argument names in reverse order - with comma-space between them. */ - { - struct arglist *temp; - int i = 0; - U_CHAR *tmp = (U_CHAR *) xmalloc (arglengths + 1); - - for (temp = arg_ptrs; temp; temp = temp->next) { - memcpy (&tmp[i], temp->name, temp->length); - i += temp->length; - if (temp->next != 0) { - tmp[i++] = ','; - tmp[i++] = ' '; - } - } - tmp[i] = 0; - defn->argnames = tmp; - - } - } else { - /* simple expansion or empty definition; skip leading whitespace */ - while (is_nvspace (*bp) && bp < limit) - ++bp; - /* now everything from bp before limit is the definition. */ - defn = collect_expansion (bp, limit, -1, 0); - defn->argnames = (const U_CHAR *) ""; - } - - hashcode = hashf (symname, sym_length, HASHSIZE); - - { - HASHNODE *hp; - if ((hp = lookup (symname, sym_length, hashcode)) == NULL) - hp = install (symname, sym_length, T_MACRO, hashcode); - else { - if (hp->type != T_MACRO || compare_defs (defn, hp->value.defn)) - warning ("\"%.*s\" redefined", sym_length, symname); - - /* Replace the old definition. */ - hp->type = T_MACRO; - } - - hp->value.defn = defn; - } -} - -/* - * return zero if two DEFINITIONs are isomorphic - */ -static int -compare_defs (d1, d2) - DEFINITION *d1, *d2; -{ - struct reflist *a1, *a2; - U_CHAR *p1 = d1->expansion; - U_CHAR *p2 = d2->expansion; - int first = 1; - - if (d1->nargs != d2->nargs) - return 1; - if (strcmp ((const char *)d1->argnames, (const char *)d2->argnames)) - return 1; - for (a1 = d1->pattern, a2 = d2->pattern; a1 && a2; - a1 = a1->next, a2 = a2->next) { - if (!((a1->nchars == a2->nchars - && ! strncmp ((const char *)p1, (const char *)p2, a1->nchars)) - || ! comp_def_part (first, p1, a1->nchars, p2, a2->nchars, 0)) - || a1->argno != a2->argno - || a1->stringify != a2->stringify - || a1->raw_before != a2->raw_before - || a1->raw_after != a2->raw_after) - return 1; - first = 0; - p1 += a1->nchars; - p2 += a2->nchars; - } - if (a1 != a2) - return 1; - if (comp_def_part (first, p1, d1->length - (p1 - d1->expansion), - p2, d2->length - (p2 - d2->expansion), 1)) - return 1; - return 0; -} - -/* Return 1 if two parts of two macro definitions are effectively different. - One of the parts starts at BEG1 and has LEN1 chars; - the other has LEN2 chars at BEG2. - Any sequence of whitespace matches any other sequence of whitespace. - FIRST means these parts are the first of a macro definition; - so ignore leading whitespace entirely. - LAST means these parts are the last of a macro definition; - so ignore trailing whitespace entirely. */ -static int -comp_def_part (first, beg1, len1, beg2, len2, last) - int first; - const U_CHAR *beg1, *beg2; - int len1, len2; - int last; -{ - const U_CHAR *end1 = beg1 + len1; - const U_CHAR *end2 = beg2 + len2; - if (first) { - while (beg1 != end1 && is_space (*beg1)) beg1++; - while (beg2 != end2 && is_space (*beg2)) beg2++; - } - if (last) { - while (beg1 != end1 && is_space (end1[-1])) end1--; - while (beg2 != end2 && is_space (end2[-1])) end2--; - } - while (beg1 != end1 && beg2 != end2) { - if (is_space (*beg1) && is_space (*beg2)) { - while (beg1 != end1 && is_space (*beg1)) beg1++; - while (beg2 != end2 && is_space (*beg2)) beg2++; - } else if (*beg1 == *beg2) { - beg1++; beg2++; - } else break; - } - return (beg1 != end1) || (beg2 != end2); -} - -/* Read a replacement list for a macro with parameters. - Build the DEFINITION structure. - Reads characters of text starting at BUF until LIMIT. - ARGLIST specifies the formal parameters to look for - in the text of the definition; NARGS is the number of args - in that list, or -1 for a macro name that wants no argument list. - MACRONAME is the macro name itself (so we can avoid recursive expansion) - and NAMELEN is its length in characters. - -Note that comments and backslash-newlines have already been deleted -from the argument. */ - -/* Leading and trailing Space, Tab, etc. are converted to markers - Newline Space, Newline Tab, etc. - Newline Space makes a space in the final output - but is discarded if stringified. (Newline Tab is similar but - makes a Tab instead.) - - If there is no trailing whitespace, a Newline Space is added at the end - to prevent concatenation that would be contrary to the standard. */ - -static DEFINITION * -collect_expansion (buf, end, nargs, arglist) - U_CHAR *buf, *end; - int nargs; - struct arglist *arglist; -{ - DEFINITION *defn; - U_CHAR *p, *limit, *lastp, *exp_p; - struct reflist *endpat = NULL; - /* Pointer to first nonspace after last ## seen. */ - U_CHAR *concat = 0; - /* Pointer to first nonspace after last single-# seen. */ - U_CHAR *stringify = 0; - int maxsize; - int expected_delimiter = '\0'; - - /* Scan thru the replacement list, ignoring comments and quoted - strings, picking up on the macro calls. It does a linear search - thru the arg list on every potential symbol. Profiling might say - that something smarter should happen. */ - - if (end < buf) - abort (); - - /* Find the beginning of the trailing whitespace. */ - /* Find end of leading whitespace. */ - limit = end; - p = buf; - while (p < limit && is_space (limit[-1])) limit--; - while (p < limit && is_space (*p)) p++; - - /* Allocate space for the text in the macro definition. - Leading and trailing whitespace chars need 2 bytes each. - Each other input char may or may not need 1 byte, - so this is an upper bound. - The extra 2 are for invented trailing newline-marker and final null. */ - maxsize = (sizeof (DEFINITION) - + 2 * (end - limit) + 2 * (p - buf) - + (limit - p) + 3); - defn = (DEFINITION *) xcalloc (1, maxsize); - - defn->nargs = nargs; - exp_p = defn->expansion = (U_CHAR *) defn + sizeof (DEFINITION); - lastp = exp_p; - - p = buf; - - /* Convert leading whitespace to Newline-markers. */ - while (p < limit && is_space (*p)) { - *exp_p++ = '\n'; - *exp_p++ = *p++; - } - - /* Process the main body of the definition. */ - while (p < limit) { - int skipped_arg = 0; - U_CHAR c = *p++; - - *exp_p++ = c; - - /* In -traditional mode, recognize arguments inside strings and - and character constants, and ignore special properties of #. - Arguments inside strings are considered "stringified", but no - extra quote marks are supplied. */ - switch (c) { - case '\'': - case '\"': - if (expected_delimiter != '\0') { - if (c == expected_delimiter) - expected_delimiter = '\0'; - } else - expected_delimiter = c; - break; - - case '\\': - /* Backslash quotes delimiters and itself, but not macro args. */ - if (expected_delimiter != 0 && p < limit - && (*p == expected_delimiter || *p == '\\')) { - *exp_p++ = *p++; - continue; - } - break; - - case '/': - if (expected_delimiter != '\0') /* No comments inside strings. */ - break; - if (*p == '*') { - /* If we find a comment that wasn't removed by handle_directive, - this must be -traditional. So replace the comment with - nothing at all. */ - exp_p--; - p += 1; - while (p < limit && !(p[-2] == '*' && p[-1] == '/')) - p++; - } - break; - } - - if (is_idchar (c) && nargs > 0) { - U_CHAR *id_beg = p - 1; - int id_len; - - --exp_p; - while (p != limit && is_idchar (*p)) p++; - id_len = p - id_beg; - - if (is_idstart (c)) { - struct arglist *arg; - - for (arg = arglist; arg != NULL; arg = arg->next) { - struct reflist *tpat; - - if (arg->name[0] == c - && arg->length == id_len - && strncmp ((const char *)arg->name, - (const char *)id_beg, id_len) == 0) { - /* make a pat node for this arg and append it to the end of - the pat list */ - tpat = (struct reflist *) xmalloc (sizeof (struct reflist)); - tpat->next = NULL; - tpat->raw_before = concat == id_beg; - tpat->raw_after = 0; - tpat->stringify = expected_delimiter != '\0'; - - if (endpat == NULL) - defn->pattern = tpat; - else - endpat->next = tpat; - endpat = tpat; - - tpat->argno = arg->argno; - tpat->nchars = exp_p - lastp; - { - U_CHAR *p1 = p; - SKIP_WHITE_SPACE (p1); - if (p1 + 2 <= limit && p1[0] == '#' && p1[1] == '#') - tpat->raw_after = 1; - } - lastp = exp_p; /* place to start copying from next time */ - skipped_arg = 1; - break; - } - } - } - - /* If this was not a macro arg, copy it into the expansion. */ - if (! skipped_arg) { - U_CHAR *lim1 = p; - p = id_beg; - while (p != lim1) - *exp_p++ = *p++; - if (stringify == id_beg) - error ("# operator should be followed by a macro argument name"); - } - } - } - - if (limit < end) { - /* Convert trailing whitespace to Newline-markers. */ - while (limit < end && is_space (*limit)) { - *exp_p++ = '\n'; - *exp_p++ = *limit++; - } - } - *exp_p = '\0'; - - defn->length = exp_p - defn->expansion; - - /* Crash now if we overrun the allocated size. */ - if (defn->length + 1 > maxsize) - abort (); - - return defn; -} - -/* - * interpret #line command. Remembers previously seen fnames - * in its very own hash table. - */ -#define FNAME_HASHSIZE 37 -static void -do_line (buf, limit, op) - U_CHAR *buf, *limit; - FILE_BUF *op; -{ - U_CHAR *bp; - FILE_BUF *ip = &instack[indepth]; - FILE_BUF tem; - int new_lineno; - enum file_change_code file_change = same_file; - - /* Expand any macros. */ - tem = expand_to_temp_buffer (buf, limit, 0); - - /* Point to macroexpanded line, which is null-terminated now. */ - bp = tem.buf; - SKIP_WHITE_SPACE (bp); - - if (!ISDIGIT (*bp)) { - error ("invalid format #line command"); - return; - } - - /* The Newline at the end of this line remains to be processed. - To put the next line at the specified line number, - we must store a line number now that is one less. */ - new_lineno = atoi ((const char *)bp); - - /* skip over the line number. */ - while (ISDIGIT (*bp)) - bp++; - - SKIP_WHITE_SPACE (bp); - - if (*bp == '\"') { - static HASHNODE *fname_table[FNAME_HASHSIZE]; - HASHNODE *hp, **hash_bucket; - U_CHAR *fname; - int fname_length; - - fname = ++bp; - - while (*bp && *bp != '\"') - bp++; - if (*bp != '\"') { - error ("invalid format #line command"); - return; - } - - fname_length = bp - fname; - - bp++; - SKIP_WHITE_SPACE (bp); - if (*bp) { - if (*bp == '1') - file_change = enter_file; - else if (*bp == '2') - file_change = leave_file; - else { - error ("invalid format #line command"); - return; - } - - bp++; - SKIP_WHITE_SPACE (bp); - if (*bp) { - error ("invalid format #line command"); - return; - } - } - - hash_bucket = - &fname_table[hashf (fname, fname_length, FNAME_HASHSIZE)]; - for (hp = *hash_bucket; hp != NULL; hp = hp->next) - if (hp->length == fname_length && - strncmp (hp->value.cpval, (const char *)fname, fname_length) == 0) { - ip->fname = hp->value.cpval; - break; - } - if (hp == 0) { - char *q; - /* Didn't find it; cons up a new one. */ - hp = (HASHNODE *) xcalloc (1, sizeof (HASHNODE) + fname_length + 1); - hp->next = *hash_bucket; - *hash_bucket = hp; - - hp->length = fname_length; - ip->fname = hp->value.cpval = q = ((char *) hp) + sizeof (HASHNODE); - memcpy (q, fname, fname_length); - } - } else if (*bp) { - error ("invalid format #line command"); - return; - } - - ip->lineno = new_lineno; - output_line_command (ip, op, 0, file_change); - ip->bufp++; /* Skip the new line. */ - check_expand (op, ip->length - (ip->bufp - ip->buf)); -} - -/* - * remove all definitions of symbol from symbol table. - * according to un*x /lib/cpp, it is not an error to undef - * something that has no definitions, so it isn't one here either. - */ -static void -do_undef (buf, limit, op) - U_CHAR *buf; - U_CHAR *limit ATTRIBUTE_UNUSED; - FILE_BUF *op ATTRIBUTE_UNUSED; -{ - HASHNODE *hp; - - SKIP_WHITE_SPACE (buf); - - if (! strncmp ((const char *)buf, "defined", 7) && ! is_idchar (buf[7])) - warning ("undefining `defined'"); - - while ((hp = lookup (buf, -1, -1)) != NULL) { - if (hp->type != T_MACRO) - warning ("undefining `%s'", hp->name); - delete_macro (hp); - } -} - -/* Read the tokens of the answer into the macro pool. Only commit the - memory if we intend it as permanent storage, i.e. the #assert case. - Returns 0 on success. */ - -static int -parse_answer (buf, limit, answerp, type) - const unsigned char *buf, *limit; - struct answer **answerp; - int type; -{ - const unsigned char *start; - - /* Skip leading whitespace. */ - if (buf < limit && *buf == ' ') - buf++; - - /* Parentheses are optional here. */ - if (buf == limit && type == T_UNASSERT) - return 0; - - if (buf == limit || *buf++ != '(') - { - if (type == T_IF) - return 0; - - error ("missing '(' after predicate"); - return 1; - } - - /* Drop whitespace at start. */ - while (buf < limit && *buf == ' ') - buf++; - - start = buf; - while (buf < limit && *buf != ')') - buf++; - - if (buf == limit) - { - error ("missing ')' to complete answer"); - return 1; - } - - if (buf == start) - { - error ("predicate's answer is empty"); - return 1; - } - - if ((type == T_ASSERT || type == T_UNASSERT) && buf + 1 != limit) - { - error ("extra text at end of directive"); - return 1; - } - - /* Lose trailing whitespace. */ - if (buf[-1] == ' ') - buf--; - - *answerp = (struct answer *) xmalloc (sizeof (struct answer)); - (*answerp)->answer = start; - (*answerp)->len = buf - start; - - return 0; -} - -/* Parses an assertion, returning a pointer to the hash node of the - predicate, or 0 on error. If an answer was supplied, it is placed - in ANSWERP, otherwise it is set to 0. */ -static HASHNODE * -parse_assertion (buf, limit, answerp, type) - const unsigned char *buf, *limit; - struct answer **answerp; - int type; -{ - HASHNODE *result = 0; - const unsigned char *climit; - unsigned char *bp, *symname = canonicalize_text (buf, limit, &climit); - unsigned int len; - - bp = symname; - if (bp < climit && is_idstart (*bp)) - { - do - bp++; - while (bp < climit && is_idchar (*bp)); - } - len = bp - symname; - - *answerp = 0; - if (len == 0) - { - if (symname == climit) - error ("assertion without predicate"); - else - error ("predicate must be an identifier"); - } - /* Unfortunately, because of the way we handle #if, we don't avoid - macro expansion in answers. This is not easy to fix. */ - else if (parse_answer (bp, climit, answerp, type) == 0) - { - unsigned char *sym = alloca (len + 1); - int hashcode; - - /* Prefix '#' to get it out of macro namespace. */ - sym[0] = '#'; - memcpy (sym + 1, symname, len); - - hashcode = hashf (sym, len + 1, HASHSIZE); - result = lookup (sym, len + 1, hashcode); - if (result == 0) - result = install (sym, len + 1, T_UNUSED, hashcode); - } - - return result; -} - -/* Test an assertion within a preprocessor conditional. Returns zero - on error or failure, one on success. */ -int -test_assertion (pbuf) - unsigned char **pbuf; /* NUL-terminated. */ -{ - unsigned char *buf = *pbuf; - unsigned char *limit = buf + strlen ((char *) buf); - struct answer *answer; - HASHNODE *node; - int result = 0; - - node = parse_assertion (buf, limit, &answer, T_IF); - if (node) - { - result = (node->type == T_ASSERT && - (answer == 0 || *find_answer (node, answer) != 0)); - - /* Yuk. We update pbuf to point after the assertion test. - First, move past the identifier. */ - if (is_space (*buf)) - buf++; - while (is_idchar (*buf)) - buf++; - /* If we have an answer, we need to move past the parentheses. */ - if (answer) - while (*buf++ != ')') - ; - *pbuf = buf; - } - - return result; -} - -/* Handle a #error directive. */ -static void -do_error (buf, limit, op) - U_CHAR *buf; - U_CHAR *limit; - FILE_BUF *op ATTRIBUTE_UNUSED; -{ - error ("#error%.*s", (int) (limit - buf), buf); -} - -/* Handle a #warning directive. */ -static void -do_warning (buf, limit, op) - U_CHAR *buf; - U_CHAR *limit; - FILE_BUF *op ATTRIBUTE_UNUSED; -{ - warning ("#warning%.*s", (int) (limit - buf), buf); -} - -/* Handle a #assert directive. */ -static void -do_assert (buf, limit, op) - U_CHAR *buf; - U_CHAR *limit; - FILE_BUF *op ATTRIBUTE_UNUSED; -{ - struct answer *new_answer; - HASHNODE *node; - - node = parse_assertion (buf, limit, &new_answer, T_ASSERT); - if (node) - { - /* Place the new answer in the answer list. First check there - is not a duplicate. */ - new_answer->next = 0; - if (node->type == T_ASSERT) - { - if (*find_answer (node, new_answer)) - { - free (new_answer); - warning ("\"%s\" re-asserted", node->name + 1); - return; - } - new_answer->next = node->value.answers; - } - node->type = T_ASSERT; - node->value.answers = new_answer; - } -} - -/* Function body to be provided later. */ -static void -do_unassert (buf, limit, op) - U_CHAR *buf; - U_CHAR *limit; - FILE_BUF *op ATTRIBUTE_UNUSED; -{ - HASHNODE *node; - struct answer *answer; - - node = parse_assertion (buf, limit, &answer, T_UNASSERT); - /* It isn't an error to #unassert something that isn't asserted. */ - if (node) - { - if (node->type == T_ASSERT) - { - if (answer) - { - struct answer **p = find_answer (node, answer), *temp; - - /* Remove the answer from the list. */ - temp = *p; - if (temp) - *p = temp->next; - - /* Did we free the last answer? */ - if (node->value.answers == 0) - delete_macro (node); - } - else - delete_macro (node); - } - - free (answer); - } -} - -/* Returns a pointer to the pointer to the answer in the answer chain, - or a pointer to NULL if the answer is not in the chain. */ -static struct answer ** -find_answer (node, candidate) - HASHNODE *node; - const struct answer *candidate; -{ - struct answer **result; - - for (result = &node->value.answers; *result; result = &(*result)->next) - { - struct answer *answer = *result; - - if (answer->len == candidate->len - && !memcmp (answer->answer, candidate->answer, answer->len)) - break; - } - - return result; -} - -/* Return a malloced buffer with leading and trailing whitespace - removed, and all instances of internal whitespace reduced to a - single space. */ -static unsigned char * -canonicalize_text (buf, limit, climit) - const unsigned char *buf, *limit, **climit; -{ - unsigned int len = limit - buf; - unsigned char *result = (unsigned char *) xmalloc (len), *dest; - - for (dest = result; buf < limit;) - { - if (! is_space (*buf)) - *dest++ = *buf++; - else - { - while (++buf < limit && is_space (*buf)) - ; - if (dest != result && buf != limit) - *dest++ = ' '; - } - } - - *climit = dest; - return result; -} - -/* - * handle #if command by - * 1) inserting special `defined' keyword into the hash table - * that gets turned into 0 or 1 by special_symbol (thus, - * if the luser has a symbol called `defined' already, it won't - * work inside the #if command) - * 2) rescan the input into a temporary output buffer - * 3) pass the output buffer to the yacc parser and collect a value - * 4) clean up the mess left from steps 1 and 2. - * 5) call conditional_skip to skip til the next #endif (etc.), - * or not, depending on the value from step 3. - */ -static void -do_if (buf, limit, op) - U_CHAR *buf, *limit; - FILE_BUF *op ATTRIBUTE_UNUSED; -{ - int value; - FILE_BUF *ip = &instack[indepth]; - - value = eval_if_expression (buf, limit - buf); - conditional_skip (ip, value == 0, T_IF); -} - -/* - * handle a #elif directive by not changing if_stack either. - * see the comment above do_else. - */ -static void -do_elif (buf, limit, op) - U_CHAR *buf, *limit; - FILE_BUF *op; -{ - int value; - FILE_BUF *ip = &instack[indepth]; - - if (if_stack == instack[indepth].if_stack) { - error ("#elif not within a conditional"); - return; - } else { - if (if_stack->type != T_IF && if_stack->type != T_ELIF) { - error ("#elif after #else"); - fprintf (stderr, " (matches line %d", if_stack->lineno); - if (if_stack->fname != NULL && ip->fname != NULL && - strcmp (if_stack->fname, ip->fname) != 0) - fprintf (stderr, ", file %s", if_stack->fname); - fprintf (stderr, ")\n"); - } - if_stack->type = T_ELIF; - } - - if (if_stack->if_succeeded) - skip_if_group (ip, 0); - else { - value = eval_if_expression (buf, limit - buf); - if (value == 0) - skip_if_group (ip, 0); - else { - ++if_stack->if_succeeded; /* continue processing input */ - output_line_command (ip, op, 1, same_file); - } - } -} - -/* - * evaluate a #if expression in BUF, of length LENGTH, - * then parse the result as a C expression and return the value as an int. - */ -static int -eval_if_expression (buf, length) - const U_CHAR *buf; - int length; -{ - FILE_BUF temp_obuf; - HASHNODE *save_defined; - int value; - - save_defined = install (U"defined", -1, T_SPEC_DEFINED, -1); - temp_obuf = expand_to_temp_buffer (buf, buf + length, 0); - delete_macro (save_defined); /* clean up special symbol */ - - value = parse_c_expression ((const char *)temp_obuf.buf); - - free (temp_obuf.buf); - - return value; -} - -/* - * routine to handle ifdef/ifndef. Try to look up the symbol, - * then do or don't skip to the #endif/#else/#elif depending - * on what directive is actually being processed. - */ -static void -do_xifdef (buf, limit, type) - U_CHAR *buf, *limit; - enum node_type type; -{ - int skip; - FILE_BUF *ip = &instack[indepth]; - U_CHAR *end; - - /* Discard leading and trailing whitespace. */ - SKIP_WHITE_SPACE (buf); - while (limit != buf && is_nvspace (limit[-1])) limit--; - - /* Find the end of the identifier at the beginning. */ - for (end = buf; is_idchar (*end); end++); - - if (end == buf) - skip = (type == T_IFDEF); - else - skip = (lookup (buf, end-buf, -1) == NULL) ^ (type == T_IFNDEF); - - conditional_skip (ip, skip, T_IF); -} - -static void -do_ifdef (buf, limit, op) - U_CHAR *buf, *limit; - FILE_BUF *op ATTRIBUTE_UNUSED; -{ - do_xifdef (buf, limit, T_IFDEF); -} - -static void -do_ifndef (buf, limit, op) - U_CHAR *buf, *limit; - FILE_BUF *op ATTRIBUTE_UNUSED; -{ - do_xifdef (buf, limit, T_IFNDEF); -} - -/* - * push TYPE on stack; then, if SKIP is nonzero, skip ahead. - */ -static void -conditional_skip (ip, skip, type) - FILE_BUF *ip; - int skip; - enum node_type type; -{ - IF_STACK_FRAME *temp; - - temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME)); - temp->fname = ip->fname; - temp->lineno = ip->lineno; - temp->next = if_stack; - if_stack = temp; - - if_stack->type = type; - - if (skip != 0) { - skip_if_group (ip, 0); - return; - } else { - ++if_stack->if_succeeded; - output_line_command (ip, &outbuf, 1, same_file); - } -} - -/* - * skip to #endif, #else, or #elif. adjust line numbers, etc. - * leaves input ptr at the sharp sign found. - * If ANY is nonzero, return at next directive of any sort. - */ -static void -skip_if_group (ip, any) - FILE_BUF *ip; - int any; -{ - U_CHAR *bp = ip->bufp, *cp; - U_CHAR *endb = ip->buf + ip->length; - const struct directive *kt; - IF_STACK_FRAME *save_if_stack = if_stack; /* don't pop past here */ - U_CHAR *beg_of_line = bp; - - while (bp < endb) { - switch (*bp++) { - case '/': /* possible comment */ - if (*bp == '\\' && bp[1] == '\n') - newline_fix (bp); - if (*bp == '*') { - ip->bufp = ++bp; - bp = skip_to_end_of_comment (ip, &ip->lineno); - } - break; - case '\"': - case '\'': - bp = skip_quoted_string (bp - 1, endb, ip->lineno, &ip->lineno, 0, 0); - break; - case '\\': - /* Char after backslash loses its special meaning. */ - if (bp < endb) { - if (*bp == '\n') - ++ip->lineno; /* But do update the line-count. */ - bp++; - } - break; - case '\n': - ++ip->lineno; - beg_of_line = bp; - break; - case '#': - ip->bufp = bp - 1; - - /* # keyword: a # must be first nonblank char on the line */ - if (beg_of_line == 0) - break; - /* Scan from start of line, skipping whitespace, comments - and backslash-newlines, and see if we reach this #. - If not, this # is not special. */ - bp = beg_of_line; - while (1) { - if (is_nvspace (*bp)) - bp++; - else if (*bp == '\\' && bp[1] == '\n') - bp += 2; - else if (*bp == '/' && bp[1] == '*') { - bp += 2; - while (!(*bp == '*' && bp[1] == '/')) { - if (*bp == '\n') - ip->lineno++; - bp++; - } - bp += 2; - } - else break; - } - if (bp != ip->bufp) { - bp = ip->bufp + 1; /* Reset bp to after the #. */ - break; - } - - bp = ip->bufp + 1; /* Point after '#'. */ - - /* Skip whitespace and \-newline. */ - while (1) { - if (is_nvspace (*bp)) - bp++; - else if (*bp == '\\' && bp[1] == '\n') - bp += 2; - else if (*bp == '/' && bp[1] == '*') { - bp += 2; - while (!(*bp == '*' && bp[1] == '/')) - bp++; - bp += 2; - } - else break; - } - - cp = bp; - - /* Now find end of directive name. - If we encounter a backslash-newline, exchange it with any following - symbol-constituents so that we end up with a contiguous name. */ - - while (1) { - if (is_idchar (*bp)) - bp++; - else { - if (*bp == '\\' && bp[1] == '\n') - name_newline_fix (bp); - if (is_idchar (*bp)) - bp++; - else break; - } - } - - for (kt = directive_table; kt->length >= 0; kt++) { - IF_STACK_FRAME *temp; - if (strncmp ((const char *)cp, kt->name, kt->length) == 0 - && !is_idchar (cp[kt->length])) { - - /* If we are asked to return on next directive, - do so now. */ - if (any) - return; - - switch (kt->type) { - case T_IF: - case T_IFDEF: - case T_IFNDEF: - temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME)); - temp->next = if_stack; - if_stack = temp; - temp->lineno = ip->lineno; - temp->fname = ip->fname; - temp->type = kt->type; - break; - case T_ELSE: - case T_ENDIF: - case T_ELIF: - if (if_stack == instack[indepth].if_stack) { - error ("#%s not within a conditional", kt->name); - break; - } - else if (if_stack == save_if_stack) - return; /* found what we came for */ - - if (kt->type != T_ENDIF) { - if (if_stack->type == T_ELSE) - error ("#else or #elif after #else"); - if_stack->type = kt->type; - break; - } - - temp = if_stack; - if_stack = if_stack->next; - free (temp); - break; - - default: - /* Anything else is ignored. */ - break; - } - break; - } - } - } - } - ip->bufp = bp; - /* after this returns, rescan will exit because ip->bufp - now points to the end of the buffer. - rescan is responsible for the error message also. */ -} - -/* - * handle a #else directive. Do this by just continuing processing - * without changing if_stack ; this is so that the error message - * for missing #endif's etc. will point to the original #if. It - * is possible that something different would be better. - */ -static void -do_else (buf, limit, op) - U_CHAR *buf ATTRIBUTE_UNUSED; - U_CHAR *limit ATTRIBUTE_UNUSED; - FILE_BUF *op; -{ - FILE_BUF *ip = &instack[indepth]; - - if (if_stack == instack[indepth].if_stack) { - error ("#else not within a conditional"); - return; - } else { - if (if_stack->type != T_IF && if_stack->type != T_ELIF) { - error ("#else after #else"); - fprintf (stderr, " (matches line %d", if_stack->lineno); - if (strcmp (if_stack->fname, ip->fname) != 0) - fprintf (stderr, ", file %s", if_stack->fname); - fprintf (stderr, ")\n"); - } - if_stack->type = T_ELSE; - } - - if (if_stack->if_succeeded) - skip_if_group (ip, 0); - else { - ++if_stack->if_succeeded; /* continue processing input */ - output_line_command (ip, op, 1, same_file); - } -} - -/* - * unstack after #endif command - */ -static void -do_endif (buf, limit, op) - U_CHAR *buf ATTRIBUTE_UNUSED; - U_CHAR *limit ATTRIBUTE_UNUSED; - FILE_BUF *op; -{ - if (if_stack == instack[indepth].if_stack) - error ("unbalanced #endif"); - else { - IF_STACK_FRAME *temp = if_stack; - if_stack = if_stack->next; - free (temp); - output_line_command (&instack[indepth], op, 1, same_file); - } -} - -/* - * Skip a comment, assuming the input ptr immediately follows the - * initial slash-star. Bump line counter as necessary. - * (The canonical line counter is &ip->lineno). - * Don't use this routine (or the next one) if bumping the line - * counter is not sufficient to deal with newlines in the string. - */ -static U_CHAR * -skip_to_end_of_comment (ip, line_counter) - FILE_BUF *ip; - int *line_counter; /* place to remember newlines, or NULL */ -{ - U_CHAR *limit = ip->buf + ip->length; - U_CHAR *bp = ip->bufp; - FILE_BUF *op = &outbuf; /* JF */ - int output = put_out_comments && !line_counter; - - /* JF this line_counter stuff is a crock to make sure the - comment is only put out once, no matter how many times - the comment is skipped. It almost works */ - if (output) { - *op->bufp++ = '/'; - *op->bufp++ = '*'; - } - while (bp < limit) { - if (output) - *op->bufp++ = *bp; - switch (*bp++) { - case '/': - if (warn_comments && bp < limit && *bp == '*') - warning("`/*' within comment"); - break; - case '\n': - if (line_counter != NULL) - ++*line_counter; - if (output) - ++op->lineno; - break; - case '*': - if (*bp == '\\' && bp[1] == '\n') - newline_fix (bp); - if (*bp == '/') { - if (output) - *op->bufp++ = '/'; - ip->bufp = ++bp; - return bp; - } - break; - } - } - ip->bufp = bp; - return bp; -} - -/* - * Skip over a quoted string. BP points to the opening quote. - * Returns a pointer after the closing quote. Don't go past LIMIT. - * START_LINE is the line number of the starting point (but it need - * not be valid if the starting point is inside a macro expansion). - * - * The input stack state is not changed. - * - * If COUNT_NEWLINES is nonzero, it points to an int to increment - * for each newline passed. - * - * If BACKSLASH_NEWLINES_P is nonzero, store 1 thru it - * if we pass a backslash-newline. - * - * If EOFP is nonzero, set *EOFP to 1 if the string is unterminated. - */ -static U_CHAR * -skip_quoted_string (bp, limit, start_line, count_newlines, backslash_newlines_p, eofp) - const U_CHAR *bp; - const U_CHAR *limit; - int start_line; - int *count_newlines; - int *backslash_newlines_p; - int *eofp; -{ - U_CHAR c, match; - - match = *bp++; - while (1) { - if (bp >= limit) { - error_with_line (line_for_error (start_line), - "unterminated string or character constant"); - if (eofp) - *eofp = 1; - break; - } - c = *bp++; - if (c == '\\') { - while (*bp == '\\' && bp[1] == '\n') { - if (backslash_newlines_p) - *backslash_newlines_p = 1; - if (count_newlines) - ++*count_newlines; - bp += 2; - } - if (*bp == '\n' && count_newlines) { - if (backslash_newlines_p) - *backslash_newlines_p = 1; - ++*count_newlines; - } - bp++; - } else if (c == '\n') { - /* Unterminated strings and character constants are 'legal'. */ - bp--; /* Don't consume the newline. */ - if (eofp) - *eofp = 1; - break; - } else if (c == match) - break; - } - return (U_CHAR *) bp; -} - -/* - * write out a #line command, for instance, after an #include file. - * If CONDITIONAL is nonzero, we can omit the #line if it would - * appear to be a no-op, and we can output a few newlines instead - * if we want to increase the line number by a small amount. - * FILE_CHANGE says whether we are entering a file, leaving, or neither. - */ - -static void -output_line_command (ip, op, conditional, file_change) - FILE_BUF *ip, *op; - int conditional; - enum file_change_code file_change; -{ - int len; - char line_cmd_buf[500]; - - if (no_line_commands - || ip->fname == NULL - || no_output) { - op->lineno = ip->lineno; - return; - } - - if (conditional) { - if (ip->lineno == op->lineno) - return; - - /* If the inherited line number is a little too small, - output some newlines instead of a #line command. */ - if (ip->lineno > op->lineno && ip->lineno < op->lineno + 8) { - check_expand (op, 10); - while (ip->lineno > op->lineno) { - *op->bufp++ = '\n'; - op->lineno++; - } - return; - } - } - - sprintf (line_cmd_buf, "# %d \"%s\"", ip->lineno, ip->fname); - if (file_change != same_file) - strcat (line_cmd_buf, file_change == enter_file ? " 1" : " 2"); - if (system_include_depth > (file_change == leave_file)) - strcat (line_cmd_buf, " 3"); - len = strlen (line_cmd_buf); - line_cmd_buf[len++] = '\n'; - check_expand (op, len + 1); - if (op->bufp > op->buf && op->bufp[-1] != '\n') - *op->bufp++ = '\n'; - memcpy (op->bufp, line_cmd_buf, len); - op->bufp += len; - op->lineno = ip->lineno; -} - - -/* Expand a macro call. - HP points to the symbol that is the macro being called. - Put the result of expansion onto the input stack - so that subsequent input by our caller will use it. - - If macro wants arguments, caller has already verified that - an argument list follows; arguments come from the input stack. */ - -static void -macroexpand (hp, op) - HASHNODE *hp; - FILE_BUF *op; -{ - int nargs; - DEFINITION *defn = hp->value.defn; - U_CHAR *xbuf; - int xbuf_len; - int start_line = instack[indepth].lineno; - - CHECK_DEPTH (return;); - - /* it might not actually be a macro. */ - if (hp->type != T_MACRO) { - special_symbol (hp, op); - return; - } - - nargs = defn->nargs; - - if (nargs >= 0) { - int i; - struct argdata *args; - const char *parse_error = 0; - - args = (struct argdata *) alloca ((nargs + 1) * sizeof (struct argdata)); - - for (i = 0; i < nargs; i++) { - args[i].raw = args[i].expanded = (U_CHAR *) ""; - args[i].raw_length = args[i].expand_length - = args[i].stringified_length = 0; - args[i].free1 = args[i].free2 = 0; - } - - /* Parse all the macro args that are supplied. I counts them. - The first NARGS args are stored in ARGS. - The rest are discarded. */ - i = 0; - do { - /* Discard the open-parenthesis or comma before the next arg. */ - ++instack[indepth].bufp; - parse_error - = macarg ((i < nargs || (nargs == 0 && i == 0)) ? &args[i] : 0); - if (parse_error) - { - error_with_line (line_for_error (start_line), "%s", parse_error); - break; - } - i++; - } while (*instack[indepth].bufp != ')'); - - /* If we got one arg but it was just whitespace, call that 0 args. */ - if (i == 1) { - const U_CHAR *bp = args[0].raw; - const U_CHAR *lim = bp + args[0].raw_length; - while (bp != lim && is_space (*bp)) bp++; - if (bp == lim) - i = 0; - } - - if (nargs == 0 && i > 0) - error ("arguments given to macro `%s'", hp->name); - else if (i < nargs) { - /* traditional C allows foo() if foo wants one argument. */ - if (nargs == 1 && i == 0) - ; - else if (i == 0) - error ("no args to macro `%s'", hp->name); - else if (i == 1) - error ("only 1 arg to macro `%s'", hp->name); - else - error ("only %d args to macro `%s'", i, hp->name); - } else if (i > nargs) - error ("too many (%d) args to macro `%s'", i, hp->name); - - /* Swallow the closeparen. */ - ++instack[indepth].bufp; - - /* If macro wants zero args, we parsed the arglist for checking only. - Read directly from the macro definition. */ - if (nargs == 0) { - xbuf = defn->expansion; - xbuf_len = defn->length; - } else { - U_CHAR *exp = defn->expansion; - int offset; /* offset in expansion, - copied a piece at a time */ - int totlen; /* total amount of exp buffer filled so far */ - - struct reflist *ap; - - /* Macro really takes args. Compute the expansion of this call. */ - - /* Compute length in characters of the macro's expansion. */ - xbuf_len = defn->length; - for (ap = defn->pattern; ap != NULL; ap = ap->next) { - if (ap->stringify) - xbuf_len += args[ap->argno].stringified_length; - else - xbuf_len += args[ap->argno].raw_length; - } - - xbuf = (U_CHAR *) xmalloc (xbuf_len + 1); - - /* Generate in XBUF the complete expansion - with arguments substituted in. - TOTLEN is the total size generated so far. - OFFSET is the index in the definition - of where we are copying from. */ - offset = totlen = 0; - for (ap = defn->pattern; ap != NULL; ap = ap->next) { - struct argdata *arg = &args[ap->argno]; - - for (i = 0; i < ap->nchars; i++) - xbuf[totlen++] = exp[offset++]; - - if (ap->stringify != 0) { - int arglen = arg->raw_length; - int escaped = 0; - int in_string = 0; - int c; - i = 0; - while (i < arglen - && (c = arg->raw[i], is_space (c))) - i++; - while (i < arglen - && (c = arg->raw[arglen - 1], is_space (c))) - arglen--; - for (; i < arglen; i++) { - c = arg->raw[i]; - - /* Special markers Newline Space - generate nothing for a stringified argument. */ - if (c == '\n' && arg->raw[i+1] != '\n') { - i++; - continue; - } - - /* Internal sequences of whitespace are replaced by one space - except within an string or char token. */ - if (! in_string - && (c == '\n' ? arg->raw[i+1] == '\n' : is_space (c))) { - while (1) { - /* Note that Newline Space does occur within whitespace - sequences; consider it part of the sequence. */ - if (c == '\n' && is_space (arg->raw[i+1])) - i += 2; - else if (c != '\n' && is_space (c)) - i++; - else break; - c = arg->raw[i]; - } - i--; - c = ' '; - } - - if (escaped) - escaped = 0; - else { - if (c == '\\') - escaped = 1; - if (in_string) { - if (c == in_string) - in_string = 0; - } else if (c == '\"' || c == '\'') - in_string = c; - } - - /* Escape these chars */ - if (c == '\"' || (in_string && c == '\\')) - xbuf[totlen++] = '\\'; - if (ISPRINT (c)) - xbuf[totlen++] = c; - else { - sprintf ((char *) &xbuf[totlen], "\\%03o", (unsigned int) c); - totlen += 4; - } - } - } else { - const U_CHAR *p1 = arg->raw; - const U_CHAR *l1 = p1 + arg->raw_length; - - if (ap->raw_before) { - while (p1 != l1 && is_space (*p1)) p1++; - while (p1 != l1 && is_idchar (*p1)) - xbuf[totlen++] = *p1++; - /* Delete any no-reexpansion marker that follows - an identifier at the beginning of the argument - if the argument is concatenated with what precedes it. */ - if (p1[0] == '\n' && p1[1] == '-') - p1 += 2; - } - if (ap->raw_after) { - /* Arg is concatenated after: delete trailing whitespace, - whitespace markers, and no-reexpansion markers. */ - while (p1 != l1) { - if (is_space (l1[-1])) l1--; - else if (l1[-1] == '-') { - const U_CHAR *p2 = l1 - 1; - /* If a `-' is preceded by an odd number of newlines then it - and the last newline are a no-reexpansion marker. */ - while (p2 != p1 && p2[-1] == '\n') p2--; - if ((l1 - 1 - p2) & 1) { - l1 -= 2; - } - else break; - } - else break; - } - } - memmove (xbuf + totlen, p1, l1 - p1); - totlen += l1 - p1; - } - - if (totlen > xbuf_len) - abort (); - } - - /* if there is anything left of the definition - after handling the arg list, copy that in too. */ - - for (i = offset; i < defn->length; i++) - xbuf[totlen++] = exp[i]; - - xbuf[totlen] = 0; - xbuf_len = totlen; - - for (i = 0; i < nargs; i++) { - if (args[i].free1 != 0) - free (args[i].free1); - if (args[i].free2 != 0) - free (args[i].free2); - } - } - } else { - xbuf = defn->expansion; - xbuf_len = defn->length; - } - - /* Now put the expansion on the input stack - so our caller will commence reading from it. */ - { - FILE_BUF *ip2; - - ip2 = &instack[++indepth]; - - ip2->fname = 0; - ip2->lineno = 0; - ip2->buf = xbuf; - ip2->length = xbuf_len; - ip2->bufp = xbuf; - ip2->free_ptr = (nargs > 0) ? xbuf : 0; - ip2->macro = hp; - ip2->if_stack = if_stack; - } -} - -/* - * Parse a macro argument and store the info on it into *ARGPTR. - * Return nonzero to indicate a syntax error. - */ - -static const char * -macarg (argptr) - struct argdata *argptr; -{ - FILE_BUF *ip = &instack[indepth]; - int paren = 0; - int newlines = 0; - int comments = 0; - - /* Try to parse as much of the argument as exists at this - input stack level. */ - U_CHAR *bp = macarg1 (ip->bufp, ip->buf + ip->length, - &paren, &newlines, &comments); - - /* If we find the end of the argument at this level, - set up *ARGPTR to point at it in the input stack. */ - if (!(ip->fname != 0 && (newlines != 0 || comments != 0)) - && bp != ip->buf + ip->length) { - if (argptr != 0) { - argptr->raw = ip->bufp; - argptr->raw_length = bp - ip->bufp; - } - ip->bufp = bp; - } else { - /* This input stack level ends before the macro argument does. - We must pop levels and keep parsing. - Therefore, we must allocate a temporary buffer and copy - the macro argument into it. */ - int bufsize = bp - ip->bufp; - int extra = newlines; - U_CHAR *buffer = (U_CHAR *) xmalloc (bufsize + extra + 1); - int final_start = 0; - - memcpy (buffer, ip->bufp, bufsize); - ip->bufp = bp; - ip->lineno += newlines; - - while (bp == ip->buf + ip->length) { - if (instack[indepth].macro == 0) { - free (buffer); - return "unterminated macro call"; - } - ip->macro->type = T_MACRO; - if (ip->free_ptr) - free (ip->free_ptr); - ip = &instack[--indepth]; - newlines = 0; - comments = 0; - bp = macarg1 (ip->bufp, ip->buf + ip->length, &paren, - &newlines, &comments); - final_start = bufsize; - bufsize += bp - ip->bufp; - extra += newlines; - buffer = (U_CHAR *) xrealloc (buffer, bufsize + extra + 1); - memcpy (buffer + bufsize - (bp - ip->bufp), ip->bufp, bp - ip->bufp); - ip->bufp = bp; - ip->lineno += newlines; - } - - /* Now, if arg is actually wanted, record its raw form, - discarding comments and duplicating newlines in whatever - part of it did not come from a macro expansion. - EXTRA space has been preallocated for duplicating the newlines. - FINAL_START is the index of the start of that part. */ - if (argptr != 0) { - argptr->raw = buffer; - argptr->raw_length = bufsize; - argptr->free1 = buffer; - argptr->newlines = newlines; - argptr->comments = comments; - if ((newlines || comments) && ip->fname != 0) - argptr->raw_length - = final_start + - discard_comments (argptr->raw + final_start, - argptr->raw_length - final_start, - newlines); - argptr->raw[argptr->raw_length] = 0; - if (argptr->raw_length > bufsize + extra) - abort (); - } - } - - /* If we are not discarding this argument, - macroexpand it and compute its length as stringified. - All this info goes into *ARGPTR. */ - - if (argptr != 0) { - FILE_BUF obuf; - const U_CHAR *buf, *lim; - int totlen; - - obuf = expand_to_temp_buffer (argptr->raw, - argptr->raw + argptr->raw_length, - 1); - - argptr->expanded = obuf.buf; - argptr->expand_length = obuf.length; - argptr->free2 = obuf.buf; - - buf = argptr->raw; - lim = buf + argptr->raw_length; - - totlen = 0; - while (buf != lim) { - U_CHAR c = *buf++; - totlen++; - /* Internal sequences of whitespace are replaced by one space - in most cases, but not always. So count all the whitespace - in case we need to keep it all. */ - if (c == '\"' || c == '\\') /* escape these chars */ - totlen++; - else if (!ISPRINT (c)) - totlen += 3; - } - argptr->stringified_length = totlen; - } - return 0; -} - -/* Scan text from START (inclusive) up to LIMIT (exclusive), - counting parens in *DEPTHPTR, - and return if reach LIMIT - or before a `)' that would make *DEPTHPTR negative - or before a comma when *DEPTHPTR is zero. - Single and double quotes are matched and termination - is inhibited within them. Comments also inhibit it. - Value returned is pointer to stopping place. - - Increment *NEWLINES each time a newline is passed. - Set *COMMENTS to 1 if a comment is seen. */ - -static U_CHAR * -macarg1 (start, limit, depthptr, newlines, comments) - U_CHAR *start; - const U_CHAR *limit; - int *depthptr, *newlines, *comments; -{ - U_CHAR *bp = start; - - while (bp < limit) { - switch (*bp) { - case '(': - (*depthptr)++; - break; - case ')': - if (--(*depthptr) < 0) - return bp; - break; - case '\\': - /* Traditionally, backslash makes following char not special. */ - if (bp + 1 < limit) - { - bp++; - /* But count source lines anyway. */ - if (*bp == '\n') - ++*newlines; - } - break; - case '\n': - ++*newlines; - break; - case '/': - if (bp[1] == '\\' && bp[2] == '\n') - newline_fix (bp + 1); - if (bp[1] != '*' || bp + 1 >= limit) - break; - *comments = 1; - bp += 2; - while (bp + 1 < limit) { - if (bp[0] == '*' - && bp[1] == '\\' && bp[2] == '\n') - newline_fix (bp + 1); - if (bp[0] == '*' && bp[1] == '/') - break; - if (*bp == '\n') ++*newlines; - bp++; - } - bp += 1; - break; - case '\'': - case '\"': - { - int quotec; - for (quotec = *bp++; bp + 1 < limit && *bp != quotec; bp++) { - if (*bp == '\\') { - bp++; - if (*bp == '\n') - ++*newlines; - while (*bp == '\\' && bp[1] == '\n') { - bp += 2; - } - } else if (*bp == '\n') { - ++*newlines; - if (quotec == '\'') - break; - } - } - } - break; - case ',': - if ((*depthptr) == 0) - return bp; - break; - } - bp++; - } - - return bp; -} - -/* Discard comments and duplicate newlines - in the string of length LENGTH at START, - except inside of string constants. - The string is copied into itself with its beginning staying fixed. - - NEWLINES is the number of newlines that must be duplicated. - We assume that that much extra space is available past the end - of the string. */ - -static int -discard_comments (start, length, newlines) - U_CHAR *start; - int length; - int newlines; -{ - U_CHAR *ibp; - U_CHAR *obp; - const U_CHAR *limit; - int c; - - /* If we have newlines to duplicate, copy everything - that many characters up. Then, in the second part, - we will have room to insert the newlines - while copying down. - NEWLINES may actually be too large, because it counts - newlines in string constants, and we don't duplicate those. - But that does no harm. */ - if (newlines > 0) { - ibp = start + length; - obp = ibp + newlines; - limit = start; - while (limit != ibp) - *--obp = *--ibp; - } - - ibp = start + newlines; - limit = start + length + newlines; - obp = start; - - while (ibp < limit) { - *obp++ = c = *ibp++; - switch (c) { - case '\n': - /* Duplicate the newline. */ - *obp++ = '\n'; - break; - - case '\\': - if (*ibp == '\n') { - obp--; - ibp++; - } - break; - - case '/': - if (*ibp == '\\' && ibp[1] == '\n') - newline_fix (ibp); - /* Delete any comment. */ - if (ibp[0] != '*' || ibp + 1 >= limit) - break; - obp--; - ibp++; - while (ibp + 1 < limit) { - if (ibp[0] == '*' - && ibp[1] == '\\' && ibp[2] == '\n') - newline_fix (ibp + 1); - if (ibp[0] == '*' && ibp[1] == '/') - break; - ibp++; - } - ibp += 2; - break; - - case '\'': - case '\"': - /* Notice and skip strings, so that we don't - think that comments start inside them, - and so we don't duplicate newlines in them. */ - { - int quotec = c; - while (ibp < limit) { - *obp++ = c = *ibp++; - if (c == quotec) - break; - if (c == '\n' && quotec == '\'') - break; - if (c == '\\' && ibp < limit) { - while (*ibp == '\\' && ibp[1] == '\n') - ibp += 2; - *obp++ = *ibp++; - } - } - } - break; - } - } - - return obp - start; -} - - -/* Core error handling routine. */ -static void -v_message (mtype, line, msgid, ap) - enum msgtype mtype; - int line; - const char *msgid; - va_list ap; -{ - const char *fname = 0; - int i; - - if (mtype == MT_WARNING && inhibit_warnings) - return; - - for (i = indepth; i >= 0; i--) - if (instack[i].fname != NULL) { - if (line == 0) - line = instack[i].lineno; - fname = instack[i].fname; - break; - } - - if (fname) - fprintf (stderr, "%s:%d: ", fname, line); - else - fprintf (stderr, "%s: ", progname); - - if (mtype == MT_WARNING) - fputs (_("warning: "), stderr); - - vfprintf (stderr, _(msgid), ap); - putc ('\n', stderr); - - if (mtype == MT_ERROR) - errors++; -} - -/* - * error - print error message and increment count of errors. - */ -void -error VPARAMS ((const char *msgid, ...)) -{ - VA_OPEN(ap, msgid); - VA_FIXEDARG (ap, const char *, msgid); - - v_message (MT_ERROR, 0, msgid, ap); - VA_CLOSE (ap); -} - -void -error_with_line VPARAMS ((int line, const char *msgid, ...)) -{ - VA_OPEN(ap, msgid); - VA_FIXEDARG (ap, int, line); - VA_FIXEDARG (ap, const char *, msgid); - - v_message (MT_ERROR, line, msgid, ap); - VA_CLOSE (ap); -} - -/* Error including a message from `errno'. */ -void -error_from_errno (name) - const char *name; -{ - error ("%s: %s", name, strerror (errno)); -} - -/* Print error message but don't count it. */ -void -warning VPARAMS ((const char *msgid, ...)) -{ - VA_OPEN(ap, msgid); - VA_FIXEDARG (ap, const char *, msgid); - - v_message (MT_WARNING, 0, msgid, ap); - VA_CLOSE (ap); -} - -void -fatal VPARAMS ((const char *msgid, ...)) -{ - VA_OPEN(ap, msgid); - VA_FIXEDARG (ap, const char *, msgid); - - v_message (MT_FATAL, 0, msgid, ap); - VA_CLOSE (ap); - exit (FATAL_EXIT_CODE); -} - -/* More 'friendly' abort that prints the location at which we died. */ -void -fancy_abort (line, func) - int line; - const char *func; -{ - fatal ("internal error in %s, at tradcpp.c:%d\n\ -Please submit a full bug report.\n\ -See %s for instructions.", func, line, GCCBUGURL); -} - -void -perror_with_name (name) - const char *name; -{ - fprintf (stderr, "%s: %s: %s\n", progname, name, strerror (errno)); - errors++; -} - -void -pfatal_with_name (name) - const char *name; -{ - perror_with_name (name); - exit (FATAL_EXIT_CODE); -} - -/* Return the line at which an error occurred. - The error is not necessarily associated with the current spot - in the input stack, so LINE says where. LINE will have been - copied from ip->lineno for the current input level. - If the current level is for a file, we return LINE. - But if the current level is not for a file, LINE is meaningless. - In that case, we return the lineno of the innermost file. */ -static int -line_for_error (line) - int line; -{ - int i; - int line1 = line; - - for (i = indepth; i >= 0; ) { - if (instack[i].fname != 0) - return line1; - i--; - if (i < 0) - return 0; - line1 = instack[i].lineno; - } - return 0; -} - -/* - * If OBUF doesn't have NEEDED bytes after OPTR, make it bigger. - * - * As things stand, nothing is ever placed in the output buffer to be - * removed again except when it's KNOWN to be part of an identifier, - * so flushing and moving down everything left, instead of expanding, - * should work ok. - */ - -static void -grow_outbuf (obuf, needed) - FILE_BUF *obuf; - int needed; -{ - U_CHAR *p; - int minsize; - - if (obuf->length - (obuf->bufp - obuf->buf) > needed) - return; - - /* Make it at least twice as big as it is now. */ - obuf->length *= 2; - /* Make it have at least 150% of the free space we will need. */ - minsize = (3 * needed) / 2 + (obuf->bufp - obuf->buf); - if (minsize > obuf->length) - obuf->length = minsize; - - p = (U_CHAR *) xrealloc (obuf->buf, obuf->length); - obuf->bufp = p + (obuf->bufp - obuf->buf); - obuf->buf = p; -} - -/* Symbol table for macro names and special symbols */ - -/* - * install a name in the main hash table, even if it is already there. - * name stops with first non alphanumeric, except leading '#'. - * caller must check against redefinition if that is desired. - * delete_macro () removes things installed by install () in fifo order. - * this is important because of the `defined' special symbol used - * in #if, and also if pushdef/popdef directives are ever implemented. - * - * If LEN is >= 0, it is the length of the name. - * Otherwise, compute the length by scanning the entire name. - * - * If HASH is >= 0, it is the precomputed hash code. - * Otherwise, compute the hash code. - * - * caller must set the value, if any is desired. - */ -static HASHNODE * -install (name, len, type, hash) - const U_CHAR *name; - int len; - enum node_type type; - int hash; - /* watch out here if sizeof (U_CHAR *) != sizeof (int) */ -{ - HASHNODE *hp; - int bucket; - const U_CHAR *p; - U_CHAR *q; - - if (len < 0) { - p = name; - while (is_idchar (*p)) - p++; - len = p - name; - } - - if (hash < 0) - hash = hashf (name, len, HASHSIZE); - - hp = (HASHNODE *) xmalloc (sizeof (HASHNODE) + len + 1); - bucket = hash; - hp->bucket_hdr = &hashtab[bucket]; - hp->next = hashtab[bucket]; - hashtab[bucket] = hp; - hp->prev = NULL; - if (hp->next != NULL) - hp->next->prev = hp; - hp->type = type; - hp->length = len; - hp->name = q = ((U_CHAR *) hp) + sizeof (HASHNODE); - memcpy (q, name, len); - q[len] = 0; - return hp; -} - -/* - * find the most recent hash node for name name (ending with first - * non-identifier char) installed by install - * - * If LEN is >= 0, it is the length of the name. - * Otherwise, compute the length by scanning the entire name. - * - * If HASH is >= 0, it is the precomputed hash code. - * Otherwise, compute the hash code. - */ -HASHNODE * -lookup (name, len, hash) - const U_CHAR *name; - int len; - int hash; -{ - const U_CHAR *bp; - HASHNODE *bucket; - - if (len < 0) { - for (bp = name; is_idchar (*bp); bp++) ; - len = bp - name; - } - - if (hash < 0) - hash = hashf (name, len, HASHSIZE); - - bucket = hashtab[hash]; - while (bucket) { - if (bucket->length == len - && strncmp ((const char *)bucket->name, (const char *)name, len) == 0) - return bucket; - bucket = bucket->next; - } - return NULL; -} - -/* - * Delete a hash node. Some weirdness to free junk from macros. - * More such weirdness will have to be added if you define more hash - * types that need it. - */ - -/* Note that the DEFINITION of a macro is removed from the hash table - but its storage is not freed. This would be a storage leak - except that it is not reasonable to keep undefining and redefining - large numbers of macros many times. - In any case, this is necessary, because a macro can be #undef'd - in the middle of reading the arguments to a call to it. - If #undef freed the DEFINITION, that would crash. */ -static void -delete_macro (hp) - HASHNODE *hp; -{ - - if (hp->prev != NULL) - hp->prev->next = hp->next; - if (hp->next != NULL) - hp->next->prev = hp->prev; - - /* make sure that the bucket chain header that - the deleted guy was on points to the right thing afterwards. */ - if (hp == *hp->bucket_hdr) - *hp->bucket_hdr = hp->next; - - free (hp); -} - -/* - * return hash function on name. must be compatible with the one - * computed a step at a time, elsewhere - */ -static int -hashf (name, len, hashsize) - const U_CHAR *name; - int len; - int hashsize; -{ - int r = 0; - - while (len--) - r = HASHSTEP (r, *name++); - - return MAKE_POS (r) % hashsize; -} - -/* Dump all macro definitions as #defines to stdout. */ - -static void -dump_all_macros () -{ - int bucket; - - for (bucket = 0; bucket < HASHSIZE; bucket++) { - HASHNODE *hp; - - for (hp = hashtab[bucket]; hp; hp= hp->next) { - if (hp->type == T_MACRO) { - DEFINITION *defn = hp->value.defn; - struct reflist *ap; - int offset; - int concat; - - - /* Print the definition of the macro HP. */ - - printf ("#define %s", hp->name); - if (defn->nargs >= 0) { - int i; - - printf ("("); - for (i = 0; i < defn->nargs; i++) { - dump_arg_n (defn, i); - if (i + 1 < defn->nargs) - printf (", "); - } - printf (")"); - } - - printf (" "); - - offset = 0; - concat = 0; - for (ap = defn->pattern; ap != NULL; ap = ap->next) { - dump_defn_1 (defn->expansion, offset, ap->nchars); - if (ap->nchars != 0) - concat = 0; - offset += ap->nchars; - if (ap->stringify) - printf (" #"); - if (ap->raw_before && !concat) - printf (" ## "); - concat = 0; - dump_arg_n (defn, ap->argno); - if (ap->raw_after) { - printf (" ## "); - concat = 1; - } - } - dump_defn_1 (defn->expansion, offset, defn->length - offset); - printf ("\n"); - } - } - } -} - -/* Output to stdout a substring of a macro definition. - BASE is the beginning of the definition. - Output characters START thru LENGTH. - Discard newlines outside of strings, thus - converting funny-space markers to ordinary spaces. */ -static void -dump_defn_1 (base, start, length) - const U_CHAR *base; - int start; - int length; -{ - const U_CHAR *p = base + start; - const U_CHAR *limit = base + start + length; - - while (p < limit) { - if (*p != '\n') - putchar (*p); - else if (*p == '\"' || *p =='\'') { - const U_CHAR *p1 = skip_quoted_string (p, limit, 0, 0, 0, 0); - fwrite (p, p1 - p, 1, stdout); - p = p1 - 1; - } - p++; - } -} - -/* Print the name of argument number ARGNUM of macro definition DEFN. - Recall that DEFN->argnames contains all the arg names - concatenated in reverse order with comma-space in between. */ -static void -dump_arg_n (defn, argnum) - DEFINITION *defn; - int argnum; -{ - const U_CHAR *p = defn->argnames; - while (argnum + 1 < defn->nargs) { - p = (const U_CHAR *) strchr ((const char *)p, ' ') + 1; - argnum++; - } - - while (*p && *p != ',') { - putchar (*p); - p++; - } -} - -/* Initialize the built-in macros. */ -#define DSC(x) U x, sizeof x - 1 -#define install_spec(name, type) \ - install(DSC(name), type, -1); -#define install_value(name, val) \ - hp = install(DSC(name), T_CONST, -1); hp->value.cpval = val; -static void -initialize_builtins () -{ - HASHNODE *hp; - - install_spec ("__BASE_FILE__", T_BASE_FILE); - install_spec ("__DATE__", T_DATE); - install_spec ("__FILE__", T_FILE); - install_spec ("__TIME__", T_TIME); - install_spec ("__VERSION__", T_VERSION); - install_spec ("__INCLUDE_LEVEL__", T_INCLUDE_LEVEL); - install_spec ("__LINE__", T_SPECLINE); - -#ifndef NO_BUILTIN_SIZE_TYPE - install_value ("__SIZE_TYPE__", SIZE_TYPE); -#endif -#ifndef NO_BUILTIN_PTRDIFF_TYPE - install_value ("__PTRDIFF_TYPE__", PTRDIFF_TYPE); -#endif -#ifndef NO_BUILTIN_WCHAR_TYPE - install_value ("__WCHAR_TYPE__", WCHAR_TYPE); -#endif -#ifndef NO_BUILTIN_WINT_TYPE - install_value ("__WINT_TYPE__", WINT_TYPE); -#endif - install_value ("__REGISTER_PREFIX__", REGISTER_PREFIX); - install_value ("__USER_LABEL_PREFIX__", user_label_prefix); - - if (flag_signed_char == 0) - install_value ("__CHAR_UNSIGNED__", "1"); -} -#undef DSC -#undef install_spec -#undef install_value - -/* Common handler of command line directives -U, -D and -A. */ -static void -run_directive (str, len, type) - const char *str; - size_t len; - enum node_type type; -{ - const struct directive *kt; - FILE_BUF *ip = &instack[++indepth]; - ip->fname = "*command line*"; - - ip->buf = ip->bufp = (U_CHAR *) str; - ip->length = len; - ip->lineno = 1; - ip->macro = 0; - ip->free_ptr = 0; - ip->if_stack = if_stack; - - for (kt = directive_table; kt->type != type; kt++) - ; - - (*kt->func) ((U_CHAR *) str, (U_CHAR *) str + len, NULL); - --indepth; -} - -/* Handle the -D option. If STR is just an identifier, define it with - * value 1. If STR has anything after the identifier, then it should - * be identifier-space-definition. */ -static void -make_definition (str) - const char *str; -{ - char *buf, *p; - size_t count; - - /* Copy the entire option so we can modify it. - Change the first "=" in the string to a space. If there is none, - tack " 1" on the end. */ - - /* Length including the null. */ - count = strlen (str); - buf = (char *) alloca (count + 2); - memcpy (buf, str, count); - - p = strchr (str, '='); - if (p) - buf[p - str] = ' '; - else - { - buf[count++] = ' '; - buf[count++] = '1'; - } - - run_directive (buf, count, T_DEFINE); -} - -/* Handle the -U option. */ -static void -make_undef (str) - const char *str; -{ - run_directive (str, strlen (str), T_UNDEF); -} - -/* Handles the #assert (-A) and #unassert (-A-) command line options. */ -static void -make_assertion (str) - const char *str; -{ - enum node_type type = T_ASSERT; - size_t count; - const char *p; - - if (*str == '-') - { - str++; - type = T_UNASSERT; - } - - count = strlen (str); - p = strchr (str, '='); - if (p) - { - /* Copy the entire option so we can modify it. Change the first - "=" in the string to a '(', and tack a ')' on the end. */ - char *buf = (char *) alloca (count + 1); - - memcpy (buf, str, count); - buf[p - str] = '('; - buf[count++] = ')'; - str = buf; - } - - run_directive (str, count, type); -} - -/* Get the file-mode and data size of the file open on FD - and store them in *MODE_POINTER and *SIZE_POINTER. */ - -static int -file_size_and_mode (fd, mode_pointer, size_pointer) - int fd; - int *mode_pointer; - long *size_pointer; -{ - struct stat sbuf; - - if (fstat (fd, &sbuf) < 0) return -1; - if (mode_pointer) *mode_pointer = sbuf.st_mode; - if (size_pointer) *size_pointer = sbuf.st_size; - return 0; -} diff --git a/contrib/gcc/tradcpp.h b/contrib/gcc/tradcpp.h deleted file mode 100644 index 89940d0..0000000 --- a/contrib/gcc/tradcpp.h +++ /dev/null @@ -1,45 +0,0 @@ -/* C Compatible Compiler Preprocessor (CCCP) -Copyright (C) 1986, 1987, 1989, 2000 Free Software Foundation, Inc. - Written by Paul Rubin, June 1986 - Adapted to ANSI C, Richard Stallman, Jan 1987 - Dusted off, polished, and adapted for use as traditional - preprocessor only, Zack Weinberg, Jul 2000 - -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. */ - -#ifndef GCC_TRADCPP_H -#define GCC_TRADCPP_H - -extern void error PARAMS ((const char *msgid, ...)) ATTRIBUTE_PRINTF_1; -extern void warning PARAMS ((const char *msgid, ...)) ATTRIBUTE_PRINTF_1; -extern void fatal PARAMS ((const char *msgid, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; -extern void error_with_line PARAMS ((int, const char *msgid, ...)) ATTRIBUTE_PRINTF_2; -extern void error_from_errno PARAMS ((const char *msgid)); - -extern void perror_with_name PARAMS ((const char *msgid)); -extern void pfatal_with_name PARAMS ((const char *msgid)) ATTRIBUTE_NORETURN; -extern void fancy_abort PARAMS ((int, const char *)) ATTRIBUTE_NORETURN; - -extern struct hashnode *lookup PARAMS ((const unsigned char *, int, int)); -extern int parse_c_expression PARAMS ((const char *)); /* in tradcif.y */ -extern int test_assertion PARAMS ((unsigned char **)); -extern int flag_signed_char; - -#define is_idchar(x) ISIDNUM(x) -#define is_idstart(x) ISIDST(x) -#define is_space(x) ISSPACE(x) -#define is_nvspace(x) (IS_NVSPACE(x) && x != '\0') - -#endif /* ! GCC_TRADCPP_H */ |