This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Further baby steps toward standalone cpplib
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 13 Jul 2003 10:31:41 -0700
- Subject: Further baby steps toward standalone cpplib
This patch removes the includes of coretypes.h and tm.h from all the
files that are part of cpplib, and addresses the very few remaining
issues that that exposes. Notes:
* cppchar_t is now limited to 32 bits wide. There are a few targets
for which wchar_t can be 64 bits wide - MIPS in certain
configurations - but there is no meaningful interpretation for a
wchar_t value larger than 2^31, so I do not think this is an issue.
The value will still be properly sign- or zero-extended to the full
width of a INTEGER_CST node upon being handed back from cpplib.
* yes, it would be better to find a common place to put gcc_obstack_init
or a similar macro. At present there is no such place. No one uses
the customization capabilities offered by putting gcc_obstack_init
in defaults.h -- I'm thinking a libiberty.h macro xobstack_init that
uses xmalloc and free, but doesn't tweak the allocation size or
anything.
* Renaming scan_out_logical_line and removing uses of uchar from
c-ppoutput.c are not strictly related to this patch.
* cppdefault.c is not part of cpplib, despite the name.
* The GC/PCH interaction with hashtable.c is going to need reworking -
those data structures will not be visible to gengtype once the file
is moved - but that will be the subject of a later patch.
* I believe that DECC auto-defines "VMS", but I can't find
confirmation on the VMS documentation site I have bookmarked. Can
anyone verify this?
Bootstrapped i686-linux.
zw
* Makefile.in (LIBCPP_DEPS): Remove coretypes.h and $(TM_H).
(hashtable.o, line-map.o, mkdeps.o): Likewise, from dependency
list. Move these all together down by cpplib.
* cpplib.h: Don't refer to MAX_WCHAR_TYPE_SIZE when determining
definition of CPPCHAR_SIGNED_T.
* cppcharset.c, cpperror.c, cppexp.c, cppfiles.c, cpphash.c, cppinit.c
* cpplex.c, cpplib.c, cppmacro.c, cpppch.c, cpptrad.c, hashtable.c
* line-map.c, mkdeps.c: Don't include coretypes.h or tm.h.
* cpphash.c (_cpp_init_hashtable): Don't use gcc_obstack_init.
* cppinit.c (cpp_create_reader): Likewise.
* cpphash.h (scan_out_logical_line): Renamed _cpp_scan_out_logical_line.
* cpptrad.c: Likewise. All callers changed.
* cpplib.c: All callers changed.
* c-ppoutput.c: Replace 'uchar' with 'unsigned char' throughout.
* hashtable.h: Define GTY(x) to nothing here too.
===================================================================
Index: Makefile.in
--- Makefile.in 13 Jul 2003 16:52:23 -0000 1.1114
+++ Makefile.in 13 Jul 2003 17:04:45 -0000
@@ -1450,10 +1450,6 @@ ggc-page.o: ggc-page.c $(CONFIG_H) $(SYS
stringpool.o: stringpool.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(GGC_H) gt-stringpool.h
-hashtable.o: hashtable.c hashtable.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(OBSTACK_H)
-
-line-map.o: line-map.c line-map.h intl.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H)
-
ggc-none.o: ggc-none.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(GGC_H)
$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
@@ -2356,7 +2352,7 @@ LIBCPP_OBJS = cpplib.o cpplex.o cppmacro
hashtable.o line-map.o mkdeps.o cpppch.o
LIBCPP_DEPS = $(CPPLIB_H) cpphash.h line-map.h hashtable.h intl.h \
- $(OBSTACK_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H)
+ $(OBSTACK_H) $(CONFIG_H) $(SYSTEM_H)
# Most of the other archives built/used by this makefile are for
# targets. This one is strictly for the host.
@@ -2383,7 +2379,9 @@ cppdefault.o: cppdefault.c $(CONFIG_H) $
$(PREPROCESSOR_DEFINES) \
-c $(srcdir)/cppdefault.c $(OUTPUT_OPTION)
-mkdeps.o: mkdeps.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) mkdeps.h
+mkdeps.o: mkdeps.c $(CONFIG_H) $(SYSTEM_H) mkdeps.h
+hashtable.o: hashtable.c hashtable.h $(CONFIG_H) $(SYSTEM_H) $(OBSTACK_H)
+line-map.o: line-map.c line-map.h intl.h $(CONFIG_H) $(SYSTEM_H)
# Note for the stamp targets, we run the program `true' instead of
# having an empty command (nothing following the semicolon).
===================================================================
Index: c-ppoutput.c
--- c-ppoutput.c 22 Jun 2003 13:41:24 -0000 1.6
+++ c-ppoutput.c 13 Jul 2003 17:04:45 -0000
@@ -42,7 +42,7 @@ static struct
/* General output routines. */
static void scan_translation_unit (cpp_reader *);
static void scan_translation_unit_trad (cpp_reader *);
-static void account_for_newlines (const uchar *, size_t);
+static void account_for_newlines (const unsigned char *, size_t);
static int dump_macro (cpp_reader *, cpp_hashnode *, void *);
static void print_line (const struct line_map *, unsigned int,
@@ -174,7 +174,7 @@ scan_translation_unit (cpp_reader *pfile
/* Adjust print.line for newlines embedded in output. */
static void
-account_for_newlines (const uchar *str, size_t len)
+account_for_newlines (const unsigned char *str, size_t len)
{
while (len--)
if (*str++ == '\n')
===================================================================
Index: cppcharset.c
--- cppcharset.c 12 Jul 2003 22:49:48 -0000 1.10
+++ cppcharset.c 13 Jul 2003 17:04:46 -0000
@@ -20,8 +20,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "cpplib.h"
#include "cpphash.h"
#include "cppucnid.h"
===================================================================
Index: cpperror.c
--- cpperror.c 17 Jun 2003 06:17:41 -0000 1.65
+++ cpperror.c 13 Jul 2003 17:04:46 -0000
@@ -25,8 +25,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "cpplib.h"
#include "cpphash.h"
#include "intl.h"
===================================================================
Index: cppexp.c
--- cppexp.c 17 Jun 2003 06:17:41 -0000 1.140
+++ cppexp.c 13 Jul 2003 17:04:48 -0000
@@ -20,8 +20,6 @@ Boston, MA 02111-1307, USA. */
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "cpplib.h"
#include "cpphash.h"
===================================================================
Index: cppfiles.c
--- cppfiles.c 3 Jul 2003 04:23:55 -0000 1.174
+++ cppfiles.c 13 Jul 2003 17:04:48 -0000
@@ -23,8 +23,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
#include <dirent.h>
-#include "coretypes.h"
-#include "tm.h"
#include "cpplib.h"
#include "cpphash.h"
#include "intl.h"
===================================================================
Index: cpphash.c
--- cpphash.c 17 Jun 2003 06:17:42 -0000 1.123
+++ cpphash.c 13 Jul 2003 17:04:48 -0000
@@ -25,8 +25,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "cpplib.h"
#include "cpphash.h"
@@ -57,7 +55,10 @@ _cpp_init_hashtable (cpp_reader *pfile,
pfile->our_hashtable = 1;
table = ht_create (13); /* 8K (=2^13) entries. */
table->alloc_node = (hashnode (*) (hash_table *)) alloc_node;
- gcc_obstack_init (&pfile->hash_ob);
+
+ _obstack_begin (&pfile->hash_ob, 0, 0,
+ (void *(*) (long)) xmalloc,
+ (void (*) (void *)) free);
}
table->pfile = pfile;
===================================================================
Index: cpphash.h
--- cpphash.h 10 Jul 2003 23:16:31 -0000 1.193
+++ cpphash.h 13 Jul 2003 17:04:49 -0000
@@ -552,7 +552,7 @@ extern void _cpp_do_file_change (cpp_rea
extern void _cpp_pop_buffer (cpp_reader *);
/* In cpptrad.c. */
-extern bool scan_out_logical_line (cpp_reader *, cpp_macro *);
+extern bool _cpp_scan_out_logical_line (cpp_reader *, cpp_macro *);
extern bool _cpp_read_logical_line_trad (cpp_reader *);
extern void _cpp_overlay_buffer (cpp_reader *pfile, const uchar *, size_t);
extern void _cpp_remove_overlay (cpp_reader *);
===================================================================
Index: cppinit.c
--- cppinit.c 11 Jul 2003 08:33:13 -0000 1.286
+++ cppinit.c 13 Jul 2003 17:04:49 -0000
@@ -21,8 +21,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "cpplib.h"
#include "cpphash.h"
#include "mkdeps.h"
@@ -194,7 +192,9 @@ cpp_create_reader (enum c_lang lang, has
_cpp_expand_op_stack (pfile);
/* Initialize the buffer obstack. */
- gcc_obstack_init (&pfile->buffer_ob);
+ _obstack_begin (&pfile->buffer_ob, 0, 0,
+ (void *(*) (long)) xmalloc,
+ (void (*) (void *)) free);
_cpp_init_includes (pfile);
===================================================================
Index: cpplex.c
--- cpplex.c 7 Jul 2003 19:11:55 -0000 1.242
+++ cpplex.c 13 Jul 2003 17:04:56 -0000
@@ -21,8 +21,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "cpplib.h"
#include "cpphash.h"
===================================================================
Index: cpplib.c
--- cpplib.c 12 Jul 2003 22:49:48 -0000 1.344
+++ cpplib.c 13 Jul 2003 17:04:58 -0000
@@ -21,9 +21,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-
#include "cpplib.h"
#include "cpphash.h"
#include "obstack.h"
@@ -280,7 +277,7 @@ prepare_directive_trad (cpp_reader *pfil
|| pfile->directive == &dtable[T_ELIF]);
if (no_expand)
pfile->state.prevent_expansion++;
- scan_out_logical_line (pfile, NULL);
+ _cpp_scan_out_logical_line (pfile, NULL);
if (no_expand)
pfile->state.prevent_expansion--;
pfile->state.skipping = was_skipping;
===================================================================
Index: cpplib.h
--- cpplib.h 11 Jul 2003 08:33:14 -0000 1.260
+++ cpplib.h 13 Jul 2003 17:04:59 -0000
@@ -191,18 +191,18 @@ struct cpp_token
/* A type wide enough to hold any multibyte source character.
cpplib's character constant interpreter requires an unsigned type.
- Also, a typedef for the signed equivalent. */
-#ifndef MAX_WCHAR_TYPE_SIZE
-# define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
-#endif
-#if CHAR_BIT * SIZEOF_INT >= MAX_WCHAR_TYPE_SIZE
+ Also, a typedef for the signed equivalent.
+ The width of this type is capped at 32 bits; there do exist targets
+ where wchar_t is 64 bits, but only in a non-default mode, and there
+ would be no meaningful interpretation for a wchar_t value greater
+ than 2^32 anyway -- the widest wide-character encoding around is
+ ISO 10646, which stops at 2^31. */
+#if CHAR_BIT * SIZEOF_INT >= 32
# define CPPCHAR_SIGNED_T int
+#elif CHAR_BIT * SIZEOF_LONG >= 32
+# define CPPCHAR_SIGNED_T long
#else
-# if CHAR_BIT * SIZEOF_LONG >= MAX_WCHAR_TYPE_SIZE || !HAVE_LONG_LONG
-# define CPPCHAR_SIGNED_T long
-# else
-# define CPPCHAR_SIGNED_T long long
-# endif
+# error "Cannot find a least-32-bit signed integer type"
#endif
typedef unsigned CPPCHAR_SIGNED_T cppchar_t;
typedef CPPCHAR_SIGNED_T cppchar_signed_t;
===================================================================
Index: cppmacro.c
--- cppmacro.c 25 Jun 2003 21:01:10 -0000 1.136
+++ cppmacro.c 13 Jul 2003 17:05:01 -0000
@@ -25,8 +25,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "cpplib.h"
#include "cpphash.h"
===================================================================
Index: cpppch.c
--- cpppch.c 23 Jun 2003 15:27:35 -0000 1.9
+++ cpppch.c 13 Jul 2003 17:05:01 -0000
@@ -17,7 +17,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
#include "cpplib.h"
#include "cpphash.h"
#include "intl.h"
===================================================================
Index: cpptrad.c
--- cpptrad.c 28 Jun 2003 15:16:09 -0000 1.33
+++ cpptrad.c 13 Jul 2003 17:05:02 -0000
@@ -18,8 +18,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "cpplib.h"
#include "cpphash.h"
@@ -305,7 +303,7 @@ _cpp_read_logical_line_trad (cpp_reader
if (pfile->buffer->need_line && !_cpp_get_fresh_line (pfile))
return false;
}
- while (!scan_out_logical_line (pfile, NULL) || pfile->state.skipping);
+ while (!_cpp_scan_out_logical_line (pfile, NULL) || pfile->state.skipping);
return true;
}
@@ -343,7 +341,7 @@ save_argument (struct fun_macro *macro,
MACRO, and we call save_replacement_text() every time we meet an
argument. */
bool
-scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro)
+_cpp_scan_out_logical_line (cpp_reader *pfile, cpp_macro *macro)
{
bool result = true;
cpp_context *context;
@@ -982,7 +980,7 @@ _cpp_create_trad_definition (cpp_reader
if (* CUR (context) == '(')
{
/* Setting macro to NULL indicates an error occurred, and
- prevents unnecessary work in scan_out_logical_line. */
+ prevents unnecessary work in _cpp_scan_out_logical_line. */
if (!scan_parameters (pfile, macro))
macro = NULL;
else
@@ -1000,7 +998,7 @@ _cpp_create_trad_definition (cpp_reader
CPP_OPTION (pfile, discard_comments_in_macro_exp));
pfile->state.prevent_expansion++;
- scan_out_logical_line (pfile, macro);
+ _cpp_scan_out_logical_line (pfile, macro);
pfile->state.prevent_expansion--;
if (!macro)
===================================================================
Index: hashtable.c
--- hashtable.c 6 Jul 2003 06:15:35 -0000 1.10
+++ hashtable.c 13 Jul 2003 17:05:02 -0000
@@ -21,8 +21,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "hashtable.h"
/* The code below is a specialization of Vladimir Makarov's expandable
@@ -63,7 +61,10 @@ ht_create (unsigned int order)
memset (table, 0, sizeof (hash_table));
/* Strings need no alignment. */
- gcc_obstack_init (&table->stack);
+ _obstack_begin (&table->stack, 0, 0,
+ (void *(*) (long)) xmalloc,
+ (void (*) (void *)) free);
+
obstack_alignment_mask (&table->stack) = 0;
table->entries = (hashnode *) xcalloc (nslots, sizeof (hashnode));
===================================================================
Index: hashtable.h
--- hashtable.h 6 Jul 2003 06:15:35 -0000 1.9
+++ hashtable.h 13 Jul 2003 17:05:02 -0000
@@ -19,6 +19,7 @@ Foundation, 59 Temple Place - Suite 330,
#define GCC_HASHTABLE_H
#include "obstack.h"
+#define GTY(x) /* nothing */
/* This is what each hash table entry points to. It may be embedded
deeply within another object. */
===================================================================
Index: line-map.c
--- line-map.c 3 Jul 2003 05:26:30 -0000 1.10
+++ line-map.c 13 Jul 2003 17:05:02 -0000
@@ -22,8 +22,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "line-map.h"
#include "intl.h"
===================================================================
Index: mkdeps.c
--- mkdeps.c 6 Jul 2003 09:56:04 -0000 1.19
+++ mkdeps.c 13 Jul 2003 17:05:02 -0000
@@ -22,8 +22,6 @@ Foundation, 59 Temple Place - Suite 330,
#include "config.h"
#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
#include "mkdeps.h"
/* Keep this structure local to this file, so clients don't find it