comparison gcc/c-pch.c @ 63:b7f97abdc517 gcc-4.6-20100522

update gcc from gcc-4.5.0 to gcc-4.6
author ryoma <e075725@ie.u-ryukyu.ac.jp>
date Mon, 24 May 2010 12:47:05 +0900
parents 77e2b8dfacca
children
comparison
equal deleted inserted replaced
56:3c8a44c06a95 63:b7f97abdc517
1 /* Precompiled header implementation for the C languages. 1 /* Precompiled header implementation for the C languages.
2 Copyright (C) 2000, 2002, 2003, 2004, 2005, 2007, 2008, 2009 2 Copyright (C) 2000, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify 7 GCC is free software; you can redistribute it and/or modify
33 #include "ggc.h" 33 #include "ggc.h"
34 #include "langhooks.h" 34 #include "langhooks.h"
35 #include "hosthooks.h" 35 #include "hosthooks.h"
36 #include "target.h" 36 #include "target.h"
37 #include "opts.h" 37 #include "opts.h"
38 #include "timevar.h"
38 39
39 /* This is a list of flag variables that must match exactly, and their 40 /* This is a list of flag variables that must match exactly, and their
40 names for the error message. The possible values for *flag_var must 41 names for the error message. The possible values for *flag_var must
41 fit in a 'signed char'. */ 42 fit in a 'signed char'. */
42 43
132 fatal_error ("can%'t create precompiled header %s: %m", pch_file); 133 fatal_error ("can%'t create precompiled header %s: %m", pch_file);
133 pch_outfile = f; 134 pch_outfile = f;
134 135
135 gcc_assert (memcmp (executable_checksum, no_checksum, 16) != 0); 136 gcc_assert (memcmp (executable_checksum, no_checksum, 16) != 0);
136 137
138 memset (&v, '\0', sizeof (v));
137 v.debug_info_type = write_symbols; 139 v.debug_info_type = write_symbols;
138 { 140 {
139 size_t i; 141 size_t i;
140 for (i = 0; i < MATCH_SIZE; i++) 142 for (i = 0; i < MATCH_SIZE; i++)
141 { 143 {
175 char *buf; 177 char *buf;
176 long asm_file_end; 178 long asm_file_end;
177 long written; 179 long written;
178 struct c_pch_header h; 180 struct c_pch_header h;
179 181
182 timevar_push (TV_PCH_SAVE);
183
180 (*debug_hooks->handle_pch) (1); 184 (*debug_hooks->handle_pch) (1);
181 185
182 cpp_write_pch_deps (parse_in, pch_outfile); 186 cpp_write_pch_deps (parse_in, pch_outfile);
183 187
184 asm_file_end = ftell (asm_out_file); 188 asm_file_end = ftell (asm_out_file);
208 _IOREAD flag. */ 212 _IOREAD flag. */
209 if (fseek (asm_out_file, 0, SEEK_END) != 0) 213 if (fseek (asm_out_file, 0, SEEK_END) != 0)
210 fatal_error ("can%'t seek in %s: %m", asm_file_name); 214 fatal_error ("can%'t seek in %s: %m", asm_file_name);
211 215
212 gt_pch_save (pch_outfile); 216 gt_pch_save (pch_outfile);
217
218 timevar_push (TV_PCH_CPP_SAVE);
213 cpp_write_pch_state (parse_in, pch_outfile); 219 cpp_write_pch_state (parse_in, pch_outfile);
220 timevar_pop (TV_PCH_CPP_SAVE);
214 221
215 if (fseek (pch_outfile, 0, SEEK_SET) != 0 222 if (fseek (pch_outfile, 0, SEEK_SET) != 0
216 || fwrite (get_ident (), IDENT_LENGTH, 1, pch_outfile) != 1) 223 || fwrite (get_ident (), IDENT_LENGTH, 1, pch_outfile) != 1)
217 fatal_error ("can%'t write %s: %m", pch_file); 224 fatal_error ("can%'t write %s: %m", pch_file);
218 225
219 fclose (pch_outfile); 226 fclose (pch_outfile);
227
228 timevar_pop (TV_PCH_SAVE);
220 } 229 }
221 230
222 /* Check the PCH file called NAME, open on FD, to see if it can be 231 /* Check the PCH file called NAME, open on FD, to see if it can be
223 used in this compilation. Return 1 if valid, 0 if the file can't 232 used in this compilation. Return 1 if valid, 0 if the file can't
224 be used now but might be if it's seen later in the compilation, and 233 be used now but might be if it's seen later in the compilation, and
368 struct c_pch_header h; 377 struct c_pch_header h;
369 struct save_macro_data *smd; 378 struct save_macro_data *smd;
370 expanded_location saved_loc; 379 expanded_location saved_loc;
371 bool saved_trace_includes; 380 bool saved_trace_includes;
372 381
382 timevar_push (TV_PCH_RESTORE);
383
373 f = fdopen (fd, "rb"); 384 f = fdopen (fd, "rb");
374 if (f == NULL) 385 if (f == NULL)
375 { 386 {
376 cpp_errno (pfile, CPP_DL_ERROR, "calling fdopen"); 387 cpp_errno (pfile, CPP_DL_ERROR, "calling fdopen");
377 close (fd); 388 close (fd);
378 return; 389 goto end;
379 } 390 }
380 391
381 cpp_get_callbacks (parse_in)->valid_pch = NULL; 392 cpp_get_callbacks (parse_in)->valid_pch = NULL;
382 393
383 if (fread (&h, sizeof (h), 1, f) != 1) 394 if (fread (&h, sizeof (h), 1, f) != 1)
384 { 395 {
385 cpp_errno (pfile, CPP_DL_ERROR, "reading"); 396 cpp_errno (pfile, CPP_DL_ERROR, "reading");
386 fclose (f); 397 fclose (f);
387 return; 398 goto end;
388 } 399 }
389 400
390 if (!flag_preprocess_only) 401 if (!flag_preprocess_only)
391 { 402 {
392 unsigned long written; 403 unsigned long written;
414 425
415 /* Save the location and then restore it after reading the PCH. */ 426 /* Save the location and then restore it after reading the PCH. */
416 saved_loc = expand_location (line_table->highest_line); 427 saved_loc = expand_location (line_table->highest_line);
417 saved_trace_includes = line_table->trace_includes; 428 saved_trace_includes = line_table->trace_includes;
418 429
430 timevar_push (TV_PCH_CPP_RESTORE);
419 cpp_prepare_state (pfile, &smd); 431 cpp_prepare_state (pfile, &smd);
432 timevar_pop (TV_PCH_CPP_RESTORE);
420 433
421 gt_pch_restore (f); 434 gt_pch_restore (f);
422 435
436 timevar_push (TV_PCH_CPP_RESTORE);
423 if (cpp_read_state (pfile, name, f, smd) != 0) 437 if (cpp_read_state (pfile, name, f, smd) != 0)
424 { 438 {
425 fclose (f); 439 fclose (f);
426 return; 440 timevar_pop (TV_PCH_CPP_RESTORE);
427 } 441 goto end;
442 }
443 timevar_pop (TV_PCH_CPP_RESTORE);
444
428 445
429 fclose (f); 446 fclose (f);
430 447
431 line_table->trace_includes = saved_trace_includes; 448 line_table->trace_includes = saved_trace_includes;
432 cpp_set_line_map (pfile, line_table); 449 cpp_set_line_map (pfile, line_table);
434 451
435 /* Give the front end a chance to take action after a PCH file has 452 /* Give the front end a chance to take action after a PCH file has
436 been loaded. */ 453 been loaded. */
437 if (lang_post_pch_load) 454 if (lang_post_pch_load)
438 (*lang_post_pch_load) (); 455 (*lang_post_pch_load) ();
456
457 end:
458 timevar_pop (TV_PCH_RESTORE);
439 } 459 }
440 460
441 /* Indicate that no more PCH files should be read. */ 461 /* Indicate that no more PCH files should be read. */
442 462
443 void 463 void