Commit f8ed6dc5 by Jeremie Salvucci Committed by Basile Starynkevitch

gengtype.c: Include getopt.h and version.h.

2010-10-14  Jeremie Salvucci  <jeremie.salvucci@free.fr>
	    Basile Starynkevitch  <basile@starynkevitch.net>

	* gcc/gengtype.c:  Include getopt.h and version.h.

	(lang_bitmap, struct outf, outf_p)
	(get_output_file_with_visibility, oprintf): Definitions moved to
	gengtype.h
	(output_files, header_file, srcdir, srcdir_len, this_file)
	(do_dump): No more static variables.
	(do_debug): New.
	(dbgprint_count_type_at): Added new function.
	(gengtype_long_options): New.
	(print_usage, print_version, parse_program_options): New.
	(main): Call parse_program_options, and removed old option
	handling code.  Added some debug output.

	* gcc/gengtype.h:  Updated copyright year.
	(lang_bitmap, struct outf, outf_p, header_file, oprintf)
	(get_output_file_with_visibility, srcdir, srcdir_len, do_dump):
	Moved from gengtype.c to here.
	(do_debug, read_state_filename, write_state_filename): New
	variables. (DBGPRINTF, DBGPRINT_COUNT_TYPE): New macros.

	* gcc/Makefile.in:
	(REVISION): Always defined.
	(version.o): Removed ifdef REVISION_c.
	(s-gtype): Pass arguments to build/gengtype program.
	(build/version.o): Added building rule.
	(build/gengtype$(build_exeext)): Added build/version.o.


Co-Authored-By: Basile Starynkevitch <basile@starynkevitch.net>

From-SVN: r165470
parent 560d6bd5
2010-10-14 Jeremie Salvucci <jeremie.salvucci@free.fr>
Basile Starynkevitch <basile@starynkevitch.net>
* gengtype.c: Include getopt.h and version.h.
(lang_bitmap, struct outf, outf_p)
(get_output_file_with_visibility, oprintf): Definitions moved to
gengtype.h
(output_files, header_file, srcdir, srcdir_len, this_file)
(do_dump): No more static variables.
(do_debug): New.
(dbgprint_count_type_at): Added new function.
(gengtype_long_options): New.
(print_usage, print_version, parse_program_options): New.
(main): Call parse_program_options, and removed old option
handling code. Added some debug output.
* gengtype.h: Updated copyright year.
(lang_bitmap, struct outf, outf_p, header_file, oprintf)
(get_output_file_with_visibility, srcdir, srcdir_len, do_dump):
Moved from gengtype.c to here.
(do_debug, read_state_filename, write_state_filename): New
variables. (DBGPRINTF, DBGPRINT_COUNT_TYPE): New macros.
* Makefile.in:
(REVISION): Always defined.
(version.o): Removed ifdef REVISION_c.
(s-gtype): Pass arguments to build/gengtype program.
(build/version.o): Added building rule.
(build/gengtype$(build_exeext)): Added build/version.o.
2010-10-14 Iain Sandoe <iains@gcc.gnu.org>
Partial merge of 'ObjC GC' from FSF apple 'trunk' branch.
......@@ -837,6 +837,7 @@ DATESTAMP_c := $(shell cat $(DATESTAMP))
ifeq (,$(wildcard $(REVISION)))
REVISION_c :=
REVISION :=
else
REVISION_c := $(shell cat $(REVISION))
endif
......@@ -2249,11 +2250,7 @@ gcc-options.o: options.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) opts.h intl
dumpvers: dumpvers.c
ifdef REVISION_c
version.o: version.c version.h $(REVISION) $(DATESTAMP) $(BASEVER) $(DEVPHASE)
else
version.o: version.c version.h $(DATESTAMP) $(BASEVER) $(DEVPHASE)
endif
$(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
-DBASEVER=$(BASEVER_s) -DDATESTAMP=$(DATESTAMP_s) \
-DREVISION=$(REVISION_s) \
......@@ -3807,7 +3804,7 @@ s-gtyp-input: Makefile
s-gtype: build/gengtype$(build_exeext) $(filter-out [%], $(GTFILES)) \
gtyp-input.list
$(RUN_GEN) build/gengtype$(build_exeext) $(srcdir) gtyp-input.list
$(RUN_GEN) build/gengtype$(build_exeext) -S $(srcdir) -I gtyp-input.list
$(STAMP) s-gtype
generated_files = config.h tm.h $(TM_P_H) $(TM_H) multilib.h \
......@@ -3827,6 +3824,16 @@ build/%.o : # dependencies provided by explicit rule later
$(COMPILER_FOR_BUILD) -c $(BUILD_COMPILERFLAGS) $(BUILD_CPPFLAGS) \
-o $@ $<
## build/version.o is compiled by the $(COMPILER_FOR_BUILD) but needs
## several C macro definitions, just like version.o
build/version.o: version.c version.h \
$(REVISION) $(DATESTAMP) $(BASEVER) $(DEVPHASE)
$(COMPILER_FOR_BUILD) -c $(BUILD_COMPILERFLAGS) $(BUILD_CPPFLAGS) \
-DBASEVER=$(BASEVER_s) -DDATESTAMP=$(DATESTAMP_s) \
-DREVISION=$(REVISION_s) \
-DDEVPHASE=$(DEVPHASE_s) -DPKGVERSION=$(PKGVERSION_s) \
-DBUGURL=$(BUGURL_s) -o $@ $<
# Header dependencies for the programs that generate source code.
# These are library modules...
build/errors.o : errors.c $(BCONFIG_H) $(SYSTEM_H) errors.h
......@@ -3936,7 +3943,8 @@ genprog = $(genprogerr) check checksum condmd
build/genautomata$(build_exeext) : BUILD_LIBS += -lm
# These programs are not linked with the MD reader.
build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o
build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o \
build/version.o
# Rule for the generator programs:
$(genprog:%=build/gen%$(build_exeext)): build/gen%$(build_exeext): build/gen%.o $(BUILD_LIBDEPS)
......
/* Process source files and output type information.
Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004, 2007, 2008, 2010
Free Software Foundation, Inc.
This file is part of GCC.
......@@ -20,6 +21,10 @@
#ifndef GCC_GENGTYPE_H
#define GCC_GENGTYPE_H
/* Sets of accepted source languages like C, C++, Ada... are
represented by a bitmap. */
typedef unsigned lang_bitmap;
/* A file position, mostly for error messages.
The FILE element may be compared using pointer equality. */
struct fileloc
......@@ -38,14 +43,50 @@ typedef struct options *options_p;
extern int lexer_toplevel_done;
extern struct fileloc lexer_line;
/* Structure representing an output file. */
struct outf
{
struct outf *next;
const char *name;
size_t buflength;
size_t bufused;
char *buf;
};
typedef struct outf *outf_p;
/* The list of output files. */
extern outf_p output_files;
/* The output header file that is included into pretty much every
source file. */
extern outf_p header_file;
/* Print, like fprintf, to O. No-op if O is NULL. */
void
oprintf (outf_p o, const char *S, ...)
ATTRIBUTE_PRINTF_2;
/* An output file, suitable for definitions, that can see declarations
made in INPUT_FILE and is linked into every language that uses
INPUT_FILE. May return NULL in plugin mode. */
extern outf_p get_output_file_with_visibility (const char *input_file);
/* Source directory. */
extern const char *srcdir; /* (-S) program argument. */
/* Length of srcdir name. */
extern size_t srcdir_len;
/* Variable used for reading and writing the state. */
extern const char *read_state_filename; /* (-r) program argument. */
extern const char *write_state_filename; /* (-w) program argument. */
/* Print an error message. */
extern void error_at_line
(const struct fileloc *pos, const char *msg, ...) ATTRIBUTE_PRINTF_2;
/* Like asprintf, but calls fatal() on out of memory. */
extern char *
xasprintf (const char *, ...)
ATTRIBUTE_PRINTF_1;
extern char *xasprintf (const char *, ...) ATTRIBUTE_PRINTF_1;
/* Constructor routines for types. */
extern void do_typedef (const char *s, type_p t, struct fileloc *pos);
......@@ -117,4 +158,28 @@ enum
a meaningful value to be printed. */
FIRST_TOKEN_WITH_VALUE = PARAM_IS
};
/* For debugging purposes we provide two flags. */
/* Dump everything to understand gengtype's state. Might be useful to
gengtype users. */
extern int do_dump; /* (-d) program argument. */
/* Trace the execution by many DBGPRINTF (with the position inside
gengtype source code). Only useful to debug gengtype itself. */
extern int do_debug; /* (-D) program argument. */
#if ENABLE_CHECKING
#define DBGPRINTF(Fmt,...) do {if (do_debug) \
fprintf (stderr, "%s:%d: " Fmt "\n", \
lbasename (__FILE__),__LINE__, ##__VA_ARGS__);} while (0)
void dbgprint_count_type_at (const char *, int, const char *, type_p);
#define DBGPRINT_COUNT_TYPE(Msg,Ty) do {if (do_debug) \
dbgprint_count_type_at (__FILE__, __LINE__, Msg, Ty);}while (0)
#else
#define DBGPRINTF(Fmt,...) do {/*nodbgrintf*/} while (0)
#define DBGPRINT_COUNT_TYPE(Msg,Ty) do{/*nodbgprint_count_type*/}while (0)
#endif /*ENABLE_CHECKING */
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment