Commit 8643e92d by Geoffrey Keating Committed by Geoffrey Keating

c-pch.c: Include langhooks.h.

	* c-pch.c: Include langhooks.h.
	(IDENT_LENGTH): New.
	(get_ident): New.
	(pch_ident): Delete.
	(pch_init): Use get_ident, IDENT_LENGTH.
	(c_common_valid_pch): Likewise.  Also, use actual language
	in warning message.
	* Makefile.in (c-pch.o): Add langhooks.h to dependencies.

	* objc/config-lang.in (gtfiles): Add objc-act.c.  Remove duplicate
	c-parse.in.
	* objc/Make-lang.in (objc/objc-act.o): Add dependency on
	gt-objc-objc-act.h.
	(gt-objc-objc-act.h): New rule.
	* objc/lang-specs.h: Support PCH.
	* objc/objc-act.c: Include gt-objc-objc-act.h.
	(objc_add_static_instance): Move num_static_inst out, mark for PCH.
	(build_selector_reference_decl): Move idx out, mark for PCH.
	(build_class_reference_decl): Likewise.
	(build_objc_string_decl): Move *_idx out, mark for PCH.
	(build_tmp_function_decl): Move xxx out, mark for PCH.

From-SVN: r63924
parent 7f3d8013
2003-03-06 Geoffrey Keating <geoffk@apple.com>
* c-pch.c: Include langhooks.h.
(IDENT_LENGTH): New.
(get_ident): New.
(pch_ident): Delete.
(pch_init): Use get_ident, IDENT_LENGTH.
(c_common_valid_pch): Likewise. Also, use actual language
in warning message.
* Makefile.in (c-pch.o): Add langhooks.h to dependencies.
* objc/config-lang.in (gtfiles): Add objc-act.c. Remove duplicate
c-parse.in.
* objc/Make-lang.in (objc/objc-act.o): Add dependency on
gt-objc-objc-act.h.
(gt-objc-objc-act.h): New rule.
* objc/lang-specs.h: Support PCH.
* objc/objc-act.c: Include gt-objc-objc-act.h.
(objc_add_static_instance): Move num_static_inst out, mark for PCH.
(build_selector_reference_decl): Move idx out, mark for PCH.
(build_class_reference_decl): Likewise.
(build_objc_string_decl): Move *_idx out, mark for PCH.
(build_tmp_function_decl): Move xxx out, mark for PCH.
2003-03-06 Dale Johannesen <dalej@apple.com>
* config/rs6000/rs6000.c (rs6000_binds_local_p): Consider
......
......@@ -1300,7 +1300,7 @@ c-dump.o : c-dump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(C_TREE_H) tree-dump.h
c-pch.o : c-pch.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(CPPLIB_H) $(TREE_H) \
c-common.h output.h toplev.h c-pragma.h $(GGC_H) debug.h
c-common.h output.h toplev.h c-pragma.h $(GGC_H) debug.h langhooks.h
# Language-independent files.
......
......@@ -29,19 +29,42 @@ Boston, MA 02111-1307, USA. */
#include "debug.h"
#include "c-pragma.h"
#include "ggc.h"
#include "langhooks.h"
struct c_pch_header
{
unsigned long asm_size;
};
static const char pch_ident[8] = "gpchC010";
#define IDENT_LENGTH 8
static FILE *pch_outfile;
extern char *asm_file_name;
static long asm_file_startpos;
static const char * get_ident PARAMS((void));
static const char *
get_ident()
{
static char result[IDENT_LENGTH];
static const char template[IDENT_LENGTH] = "gpch.010";
memcpy (result, template, IDENT_LENGTH);
if (strcmp (lang_hooks.name, "GNU C") == 0)
result[4] = 'C';
else if (strcmp (lang_hooks.name, "GNU C++") == 0)
result[4] = '+';
else if (strcmp (lang_hooks.name, "GNU Objective-C") == 0)
result[4] = 'o';
else if (strcmp (lang_hooks.name, "GNU Objective-C++") == 0)
result[4] = 'O';
else
abort ();
return result;
}
void
pch_init ()
{
......@@ -58,7 +81,7 @@ pch_init ()
fatal_io_error ("can't open %s", pch_file);
pch_outfile = f;
if (fwrite (pch_ident, sizeof (pch_ident), 1, f) != 1)
if (fwrite (get_ident(), IDENT_LENGTH, 1, f) != 1)
fatal_io_error ("can't write to %s", pch_file);
/* We need to be able to re-read the output. */
......@@ -122,7 +145,8 @@ c_common_valid_pch (pfile, name, fd)
{
int sizeread;
int result;
char ident[sizeof (pch_ident)];
char ident[IDENT_LENGTH];
const char *pch_ident;
if (! allow_pch)
return 2;
......@@ -130,16 +154,17 @@ c_common_valid_pch (pfile, name, fd)
/* Perform a quick test of whether this is a valid
precompiled header for C. */
sizeread = read (fd, ident, sizeof (pch_ident));
sizeread = read (fd, ident, IDENT_LENGTH);
if (sizeread == -1)
{
fatal_io_error ("can't read %s", name);
return 2;
}
else if (sizeread != sizeof (pch_ident))
else if (sizeread != IDENT_LENGTH)
return 2;
if (memcmp (ident, pch_ident, sizeof (pch_ident)) != 0)
pch_ident = get_ident();
if (memcmp (ident, pch_ident, IDENT_LENGTH) != 0)
{
if (cpp_get_options (pfile)->warn_invalid_pch)
{
......@@ -150,7 +175,8 @@ c_common_valid_pch (pfile, name, fd)
"%s: not compatible with this GCC version", name);
else if (memcmp (ident, pch_ident, 4) == 0)
/* It's a PCH for the wrong language. */
cpp_error (pfile, DL_WARNING, "%s: not for C language", name);
cpp_error (pfile, DL_WARNING, "%s: not for %s", name,
lang_hooks.name);
else
/* Not any kind of PCH. */
cpp_error (pfile, DL_WARNING, "%s: not a PCH file", name);
......
......@@ -71,7 +71,7 @@ objc/objc-act.o : objc/objc-act.c \
$(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) $(EXPR_H) \
$(TARGET_H) $(C_TREE_H) diagnostic.h toplev.h flags.h objc/objc-act.h \
input.h function.h output.h debug.h langhooks.h $(LANGHOOKS_DEF_H) \
gtype-objc.h
gt-objc-objc-act.h gtype-objc.h
po-generated: $(parsedir)/objc/objc-parse.c
$(parsedir)/objc/objc-parse.c : $(parsedir)/objc/objc-parse.y
......@@ -92,6 +92,7 @@ $(parsedir)/objc/objc-parse.y: $(srcdir)/c-parse.in
$(SHELL) $(srcdir)/move-if-change tmp-objc-prs.y $(parsedir)/objc/objc-parse.y
gtype-objc.h : s-gtype ; @true
gt-objc-objc-act.h : s-gtype ; @true
#
# Build hooks:
......
......@@ -34,4 +34,4 @@ stagestuff=""
target_libs=target-libobjc
gtfiles="\$(srcdir)/objc/objc-act.h \$(srcdir)/c-parse.in \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-objc-common.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-pragma.c \$(srcdir)/c-parse.in"
gtfiles="\$(srcdir)/objc/objc-act.h \$(srcdir)/c-parse.in \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-objc-common.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-pragma.c \$(srcdir)/objc/objc-act.c"
......@@ -24,8 +24,6 @@ Boston, MA 02111-1307, USA. */
{".m", "@objective-c", 0},
{"@objective-c",
/* cc1obj has an integrated ISO C preprocessor. We should invoke the
external preprocessor if -save-temps or -traditional is given. */
"%{E|M|MM:%(trad_capable_cpp)\
-lang-objc %(cpp_options) %(cpp_debug_options)}\
%{!E:%{!M:%{!MM:\
......@@ -40,3 +38,17 @@ Boston, MA 02111-1307, USA. */
{"@objc-cpp-output",
"%{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{gen-decls}\
%{!fsyntax-only:%(invoke_as)}}}}", 0},
{"@objective-c-header",
"%{E|M|MM:%(trad_capable_cpp)\
-lang-objc %(cpp_options) %(cpp_debug_options)}\
%{!E:%{!M:%{!MM:\
%{traditional|ftraditional|traditional-cpp:\
%eGNU Objective C no longer supports traditional compilation}\
%{save-temps:cc1obj -E %(cpp_options) %b.mi \n\
cc1obj -fpreprocessed %b.mi %(cc1_options) %{gen-decls}\
-o %g.s %{!o*:--output-pch=%i.pch}\
%W{o*:--output-pch=%*}%V}\
%{!save-temps:\
cc1obj %(cpp_unique_options) %(cc1_options) %{gen-decls}\
-o %g.s %{!o*:--output-pch=%i.pch}\
%W{o*:--output-pch=%*}%V}}}}", 0},
......@@ -1361,11 +1361,11 @@ build_objc_string_object (strings)
/* Declare a static instance of CLASS_DECL initialized by CONSTRUCTOR. */
static GTY(()) int num_static_inst;
static tree
objc_add_static_instance (constructor, class_decl)
tree constructor, class_decl;
{
static int num_static_inst;
tree *chain, decl;
char buf[256];
......@@ -1983,14 +1983,14 @@ generate_strings ()
}
}
static GTY(()) int selector_reference_idx;
static tree
build_selector_reference_decl ()
{
tree decl, ident;
char buf[256];
static int idx = 0;
sprintf (buf, "_OBJC_SELECTOR_REFERENCES_%d", idx++);
sprintf (buf, "_OBJC_SELECTOR_REFERENCES_%d", selector_reference_idx++);
ident = get_identifier (buf);
......@@ -2198,14 +2198,14 @@ build_selector_reference (ident)
build_int_2 (index, 0)));
}
static GTY(()) int class_reference_idx;
static tree
build_class_reference_decl ()
{
tree decl, ident;
char buf[256];
static int idx = 0;
sprintf (buf, "_OBJC_CLASS_REFERENCES_%d", idx++);
sprintf (buf, "_OBJC_CLASS_REFERENCES_%d", class_reference_idx++);
ident = get_identifier (buf);
......@@ -2326,15 +2326,16 @@ add_objc_string (ident, section)
return build_unary_op (ADDR_EXPR, decl, 1);
}
static GTY(()) int class_names_idx;
static GTY(()) int meth_var_names_idx;
static GTY(()) int meth_var_types_idx;
static tree
build_objc_string_decl (section)
enum string_section section;
{
tree decl, ident;
char buf[256];
static int class_names_idx = 0;
static int meth_var_names_idx = 0;
static int meth_var_types_idx = 0;
if (section == class_names)
sprintf (buf, "_OBJC_CLASS_NAME_%d", class_names_idx++);
......@@ -2927,11 +2928,11 @@ generate_method_descriptors (protocol)
/* Generate a temporary FUNCTION_DECL node to be used in
hack_method_prototype below. */
static GTY(()) int build_tmp_function_decl_xxx;
static tree
build_tmp_function_decl ()
{
tree decl_specs, expr_decl, parms;
static int xxx = 0;
char buffer[80];
/* struct objc_object *objc_xxx (id, SEL, ...); */
......@@ -2953,7 +2954,7 @@ build_tmp_function_decl ()
poplevel (0, 0, 0);
decl_specs = build_tree_list (NULL_TREE, objc_object_reference);
sprintf (buffer, "__objc_tmp_%x", xxx++);
sprintf (buffer, "__objc_tmp_%x", build_tmp_function_decl_xxx++);
expr_decl = build_nt (CALL_EXPR, get_identifier (buffer), parms, NULL_TREE);
expr_decl = build1 (INDIRECT_REF, NULL_TREE, expr_decl);
......@@ -8561,4 +8562,5 @@ lookup_objc_ivar (id)
return 0;
}
#include "gt-objc-objc-act.h"
#include "gtype-objc.h"
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