aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog19
-rw-r--r--gcc/Makefile.in9
-rw-r--r--gcc/cppdefault.c72
-rw-r--r--gcc/cppdefault.h106
-rw-r--r--gcc/cppinit.c133
5 files changed, 215 insertions, 124 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8c4b344..d7e95ee 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,22 @@
+2000-07-06 Zack Weinberg <zack@wolery.cumb.org>
+
+ * cppinit.c: Include cppdefault.h. Refer to
+ cpp_GCC_INCLUDE_DIR and cpp_GCC_INCLUDE_DIR_len, not directly
+ to GCC_INCLUDE_DIR and its length.
+ (SIZE_TYPE, PTRDIFF_TYPE, WCHAR_TYPE,
+ USER_LABEL_PREFIX, REGISTER_PREFIX, struct default_include,
+ STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT): Move to
+ cppdefault.h.
+ (include_defaults_array): Move to cppdefault.c.
+
+ * cppdefault.h: New file.
+ * cppdefault.c: New file.
+
+ * Makefile.in (LIBCPP_OBJS): Add cppdefault.o.
+ (cppinit.o): Don't apply $(PREPROCESSOR_DEFINES) to this file.
+ (cppdefault.o): New rule; apply $(PREPROCESSOR_DEFINES) to
+ this file.
+
Thu Jul 6 18:30:36 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* reload.c (push_reload): When seeing if can reuse a register,
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 6ec96db..3391132 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1778,7 +1778,7 @@ PREPROCESSOR_DEFINES = \
-DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\"
LIBCPP_OBJS = cpplib.o cpphash.o cpperror.o cppexp.o cppfiles.o \
- cppinit.o cppulp.o cpplex.o mkdeps.o \
+ cppinit.o cppulp.o cpplex.o cppdefault.o mkdeps.o \
prefix.o version.o mbchar.o @extra_cpp_objs@
LIBCPP_DEPS = cpplib.h cpphash.h intl.h system.h
@@ -1804,12 +1804,13 @@ cpplex.o: cpplex.c $(CONFIG_H) $(LIBCPP_DEPS)
cpplib.o: cpplib.c $(CONFIG_H) $(LIBCPP_DEPS) $(OBSTACK_H)
cpphash.o: cpphash.c $(CONFIG_H) $(LIBCPP_DEPS) $(OBSTACK_H) $(HASHTAB_H)
cppfiles.o: cppfiles.c $(CONFIG_H) $(LIBCPP_DEPS) $(SPLAY_TREE_H) mkdeps.h
+cppinit.o: cppinit.c $(CONFIG_H) $(LIBCPP_DEPS) cppdefault.h \
+ mkdeps.h prefix.h output.h version.h
-cppinit.o: cppinit.c $(CONFIG_H) $(LIBCPP_DEPS) \
- mkdeps.h prefix.h output.h Makefile version.h
+cppdefault.o: cppdefault.c $(CONFIG_H) system.h cppdefault.h Makefile
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$(PREPROCESSOR_DEFINES) \
- -c `echo $(srcdir)/cppinit.c | sed 's,^\./,,'`
+ -c `echo $(srcdir)/cppdefault.c | sed 's,^\./,,'`
mkdeps.o: mkdeps.c $(CONFIG_H) system.h mkdeps.h
diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c
new file mode 100644
index 0000000..7a4ec0c
--- /dev/null
+++ b/gcc/cppdefault.c
@@ -0,0 +1,72 @@
+/* CPP Library.
+ Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000 Free Software Foundation, Inc.
+ Contributed by Per Bothner, 1994-95.
+ Based on CCCP program by Paul Rubin, June 1986
+ Adapted to ANSI C, Richard Stallman, Jan 1987
+
+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. */
+
+/* This file contains data definitions shared between cpplib and
+ tradcpp. */
+
+#include "config.h"
+#include "system.h"
+#include "cppdefault.h"
+
+const struct default_include cpp_include_defaults[]
+#ifdef INCLUDE_DEFAULTS
+= INCLUDE_DEFAULTS;
+#else
+= {
+#ifdef GPLUSPLUS_INCLUDE_DIR
+ /* Pick up GNU C++ specific include files. */
+ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },
+#endif
+#ifdef LOCAL_INCLUDE_DIR
+ /* /usr/local/include comes before the fixincluded header files. */
+ { LOCAL_INCLUDE_DIR, 0, 0, 1 },
+#endif
+#ifdef GCC_INCLUDE_DIR
+ /* This is the dir for fixincludes and for gcc's private headers. */
+ { GCC_INCLUDE_DIR, "GCC", 0, 0 },
+#endif
+#ifdef CROSS_INCLUDE_DIR
+ /* One place the target system's headers might be. */
+ { CROSS_INCLUDE_DIR, "GCC", 0, 0 },
+#endif
+#ifdef TOOL_INCLUDE_DIR
+ /* Another place the target system's headers might be. */
+ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 },
+#endif
+#ifdef SYSTEM_INCLUDE_DIR
+ /* Some systems have an extra dir of include files. */
+ { SYSTEM_INCLUDE_DIR, 0, 0, 0 },
+#endif
+#ifdef STANDARD_INCLUDE_DIR
+ /* /usr/include comes dead last. */
+ { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0 },
+#endif
+ { 0, 0, 0, 0 }
+ };
+#endif /* no INCLUDE_DEFAULTS */
+
+#ifdef GCC_INCLUDE_DIR
+const char cpp_GCC_INCLUDE_DIR[] = GCC_INCLUDE_DIR;
+const size_t cpp_GCC_INCLUDE_DIR_len = sizeof GCC_INCLUDE_DIR - 8;
+#else
+const char cpp_GCC_INCLUDE_DIR[] = "";
+const size_t cpp_GCC_INCLUDE_DIR_len = 0;
+#endif
diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h
new file mode 100644
index 0000000..58ff939
--- /dev/null
+++ b/gcc/cppdefault.h
@@ -0,0 +1,106 @@
+/* CPP Library.
+ Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000 Free Software Foundation, Inc.
+ Contributed by Per Bothner, 1994-95.
+ Based on CCCP program by Paul Rubin, June 1986
+ Adapted to ANSI C, Richard Stallman, Jan 1987
+
+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_CPPDEFAULT__
+#define __GCC_CPPDEFAULT__
+
+/* This header contains declarations and/or #defines for all the
+ hard-wired defaults in cpp. Note it's used by both cpplib and
+ tradcpp. */
+
+#ifndef STANDARD_INCLUDE_DIR
+#define STANDARD_INCLUDE_DIR "/usr/include"
+#endif
+
+#ifndef STANDARD_INCLUDE_COMPONENT
+#define STANDARD_INCLUDE_COMPONENT 0
+#endif
+
+#ifdef CROSS_COMPILE
+#undef LOCAL_INCLUDE_DIR
+#undef SYSTEM_INCLUDE_DIR
+#undef STANDARD_INCLUDE_DIR
+#else
+#undef CROSS_INCLUDE_DIR
+#endif
+
+/* We let tm.h override the types used here, to handle trivial differences
+ such as the choice of unsigned int or long unsigned int for size_t.
+ When machines start needing nontrivial differences in the size type,
+ it would be best to do something here to figure out automatically
+ from other information what type to use. */
+
+/* The string value for __SIZE_TYPE__. */
+
+#ifndef SIZE_TYPE
+#define SIZE_TYPE "long unsigned int"
+#endif
+
+/* The string value for __PTRDIFF_TYPE__. */
+
+#ifndef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "long int"
+#endif
+
+/* The string value for __WCHAR_TYPE__. */
+
+#ifndef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+#endif
+
+/* The string value for __USER_LABEL_PREFIX__ */
+
+#ifndef USER_LABEL_PREFIX
+#define USER_LABEL_PREFIX ""
+#endif
+
+/* The string value for __REGISTER_PREFIX__ */
+
+#ifndef REGISTER_PREFIX
+#define REGISTER_PREFIX ""
+#endif
+
+/* This is the default list of directories to search for include files.
+ It may be overridden by the various -I and -ixxx options.
+
+ #include "file" looks in the same directory as the current file,
+ then this list.
+ #include <file> just looks in this list.
+
+ All these directories are treated as `system' include directories
+ (they are not subject to pedantic warnings in some cases). */
+
+struct default_include
+{
+ const char *fname; /* The name of the directory. */
+ const char *component; /* The component containing the directory
+ (see update_path in prefix.c) */
+ int cplusplus; /* Only look here if we're compiling C++. */
+ int cxx_aware; /* Includes in this directory don't need to
+ be wrapped in extern "C" when compiling
+ C++. */
+};
+
+extern const struct default_include cpp_include_defaults[];
+extern const char cpp_GCC_INCLUDE_DIR[];
+extern const size_t cpp_GCC_INCLUDE_DIR_len;
+
+#endif /* cppdefault.h */
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index c60db8b..8785a7b 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -28,6 +28,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "intl.h"
#include "version.h"
#include "mkdeps.h"
+#include "cppdefault.h"
/* Predefined symbols, built-in macros, and the default include path. */
@@ -46,116 +47,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define INO_T_EQ(a, b) ((a) == (b))
#endif
-#ifndef STANDARD_INCLUDE_DIR
-#define STANDARD_INCLUDE_DIR "/usr/include"
-#endif
-
-/* We let tm.h override the types used here, to handle trivial differences
- such as the choice of unsigned int or long unsigned int for size_t.
- When machines start needing nontrivial differences in the size type,
- it would be best to do something here to figure out automatically
- from other information what type to use. */
-
-/* The string value for __SIZE_TYPE__. */
-
-#ifndef SIZE_TYPE
-#define SIZE_TYPE "long unsigned int"
-#endif
-
-/* The string value for __PTRDIFF_TYPE__. */
-
-#ifndef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "long int"
-#endif
-
-/* The string value for __WCHAR_TYPE__. */
-
-#ifndef WCHAR_TYPE
-#define WCHAR_TYPE "int"
-#endif
-
-/* The string value for __USER_LABEL_PREFIX__ */
-
-#ifndef USER_LABEL_PREFIX
-#define USER_LABEL_PREFIX ""
-#endif
-
-/* The string value for __REGISTER_PREFIX__ */
-
-#ifndef REGISTER_PREFIX
-#define REGISTER_PREFIX ""
-#endif
-
-/* This is the default list of directories to search for include files.
- It may be overridden by the various -I and -ixxx options.
-
- #include "file" looks in the same directory as the current file,
- then this list.
- #include <file> just looks in this list.
-
- All these directories are treated as `system' include directories
- (they are not subject to pedantic warnings in some cases). */
-
-struct default_include
-{
- const char *fname; /* The name of the directory. */
- const char *component; /* The component containing the directory
- (see update_path in prefix.c) */
- int cplusplus; /* Only look here if we're compiling C++. */
- int cxx_aware; /* Includes in this directory don't need to
- be wrapped in extern "C" when compiling
- C++. */
-};
-
-#ifndef STANDARD_INCLUDE_COMPONENT
-#define STANDARD_INCLUDE_COMPONENT 0
-#endif
-
-#ifdef CROSS_COMPILE
-#undef LOCAL_INCLUDE_DIR
-#undef SYSTEM_INCLUDE_DIR
-#undef STANDARD_INCLUDE_DIR
-#else
-#undef CROSS_INCLUDE_DIR
-#endif
-
-static const struct default_include include_defaults_array[]
-#ifdef INCLUDE_DEFAULTS
-= INCLUDE_DEFAULTS;
-#else
-= {
-#ifdef GPLUSPLUS_INCLUDE_DIR
- /* Pick up GNU C++ specific include files. */
- { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 },
-#endif
-#ifdef LOCAL_INCLUDE_DIR
- /* /usr/local/include comes before the fixincluded header files. */
- { LOCAL_INCLUDE_DIR, 0, 0, 1 },
-#endif
-#ifdef GCC_INCLUDE_DIR
- /* This is the dir for fixincludes and for gcc's private headers. */
- { GCC_INCLUDE_DIR, "GCC", 0, 0 },
-#endif
-#ifdef CROSS_INCLUDE_DIR
- /* One place the target system's headers might be. */
- { CROSS_INCLUDE_DIR, "GCC", 0, 0 },
-#endif
-#ifdef TOOL_INCLUDE_DIR
- /* Another place the target system's headers might be. */
- { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1 },
-#endif
-#ifdef SYSTEM_INCLUDE_DIR
- /* Some systems have an extra dir of include files. */
- { SYSTEM_INCLUDE_DIR, 0, 0, 0 },
-#endif
-#ifdef STANDARD_INCLUDE_DIR
- /* /usr/include comes dead last. */
- { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0 },
-#endif
- { 0, 0, 0, 0 }
- };
-#endif /* no INCLUDE_DEFAULTS */
-
/* Internal structures and prototypes. */
/* A `struct pending_option' remembers one -D, -A, -U, -include, or -imacros
@@ -785,18 +676,18 @@ initialize_standard_includes (pfile)
/* Search "translated" versions of GNU directories.
These have /usr/local/lib/gcc... replaced by specd_prefix. */
- if (specd_prefix != 0)
+ if (specd_prefix != 0 && cpp_GCC_INCLUDE_DIR_len)
{
- char *default_prefix = (char *) alloca (sizeof GCC_INCLUDE_DIR - 7);
/* Remove the `include' from /usr/local/lib/gcc.../include.
GCC_INCLUDE_DIR will always end in /include. */
- int default_len = sizeof GCC_INCLUDE_DIR - 8;
+ int default_len = cpp_GCC_INCLUDE_DIR_len;
+ char *default_prefix = (char *) alloca (default_len + 1);
int specd_len = strlen (specd_prefix);
- memcpy (default_prefix, GCC_INCLUDE_DIR, default_len);
+ memcpy (default_prefix, cpp_GCC_INCLUDE_DIR, default_len);
default_prefix[default_len] = '\0';
- for (p = include_defaults_array; p->fname; p++)
+ for (p = cpp_include_defaults; p->fname; p++)
{
/* Some standard dirs are only for C++. */
if (!p->cplusplus
@@ -823,7 +714,7 @@ initialize_standard_includes (pfile)
}
/* Search ordinary names for GNU include directories. */
- for (p = include_defaults_array; p->fname; p++)
+ for (p = cpp_include_defaults; p->fname; p++)
{
/* Some standard dirs are only for C++. */
if (!p->cplusplus
@@ -1697,12 +1588,14 @@ handle_option (pfile, argc, argv)
memcpy (fname, CPP_OPTION (pfile, include_prefix), ipl);
memcpy (fname + ipl, arg, len + 1);
}
- else
+ else if (cpp_GCC_INCLUDE_DIR_len)
{
- fname = xmalloc (sizeof GCC_INCLUDE_DIR - 8 + len);
- memcpy (fname, GCC_INCLUDE_DIR, sizeof GCC_INCLUDE_DIR - 9);
- memcpy (fname + sizeof GCC_INCLUDE_DIR - 9, arg, len + 1);
+ fname = xmalloc (cpp_GCC_INCLUDE_DIR_len + len + 1);
+ memcpy (fname, cpp_GCC_INCLUDE_DIR, cpp_GCC_INCLUDE_DIR_len);
+ memcpy (fname + cpp_GCC_INCLUDE_DIR_len, arg, len + 1);
}
+ else
+ fname = xstrdup (arg);
append_include_chain (pfile, CPP_OPTION (pfile, pending), fname,
opt_code == OPT_iwithprefix ? SYSTEM: BRACKET, 0);