Commit ecddfb39 by Mike Stump Committed by Mike Stump

files.c (pchf_adder): Remove.

        * files.c (pchf_adder): Remove.
        (struct pchf_adder_info): Likewise.
        (_cpp_save_file_entries): Write out all files so that #import works.

From-SVN: r94755
parent 996f0578
2005-02-08 Mike Stump <mrs@apple.com>
* g++.dg/pch/import-2.c: New test.
* g++.dg/pch/import-2.hs: New.
* g++.dg/pch/include/import-2a.h: New.
* g++.dg/pch/include/import-2b.h: New.
2005-02-08 Janis Johnson <janis187@us.ibm.com>
* gcc.dg/uninit-4.c: XFAIL bogus warning for powerpc64.
......
/* { dg-options "-I. -I $srcdir/gcc.dg/pch/include" } */
#include "import-2.h"
#import "import-2b.h"
int main(int argc, char **argv) {
return 0;
}
/* { dg-options "-I $srcdir/gcc.dg/pch/include" } */
#import "import-2b.h"
#import "import-2a.h"
2005-02-08 Mike Stump <mrs@apple.com>
* files.c (pchf_adder): Remove.
(struct pchf_adder_info): Likewise.
(_cpp_save_file_entries): Write out all files so that #import works.
2005-01-23 Joseph S. Myers <joseph@codesourcery.com>
* configure: Regenerate.
......
......@@ -173,7 +173,6 @@ static void read_name_map (cpp_dir *dir);
static char *remap_filename (cpp_reader *pfile, _cpp_file *file);
static char *append_file_to_dir (const char *fname, cpp_dir *dir);
static bool validate_pch (cpp_reader *, _cpp_file *file, const char *pchname);
static int pchf_adder (void **slot, void *data);
static int pchf_save_compare (const void *e1, const void *e2);
static int pchf_compare (const void *d_p, const void *e_p);
static bool check_file_against_entries (cpp_reader *, _cpp_file *, bool);
......@@ -1448,38 +1447,54 @@ struct pchf_data {
static struct pchf_data *pchf;
/* Data for pchf_addr. */
struct pchf_adder_info
/* A qsort ordering function for pchf_entry structures. */
static int
pchf_save_compare (const void *e1, const void *e2)
{
cpp_reader *pfile;
struct pchf_data *d;
};
return memcmp (e1, e2, sizeof (struct pchf_entry));
}
/* A hash traversal function to add entries into DATA->D. */
/* Create and write to F a pchf_data structure. */
static int
pchf_adder (void **slot, void *data)
bool
_cpp_save_file_entries (cpp_reader *pfile, FILE *fp)
{
struct file_hash_entry *h = (struct file_hash_entry *) *slot;
struct pchf_adder_info *i = (struct pchf_adder_info *) data;
size_t count = 0;
struct pchf_data *result;
size_t result_size;
_cpp_file *f;
if (h->start_dir != NULL && h->u.file->stack_count != 0)
for (f = pfile->all_files; f; f = f->next_file)
++count;
result_size = (sizeof (struct pchf_data)
+ sizeof (struct pchf_entry) * (count - 1));
result = xcalloc (result_size, 1);
result->count = 0;
result->have_once_only = false;
for (f = pfile->all_files; f; f = f->next_file)
{
struct pchf_data *d = i->d;
_cpp_file *f = h->u.file;
size_t count = d->count++;
size_t count;
/* This should probably never happen, since if a read error occurred
the PCH file shouldn't be written... */
if (f->dont_read || f->err_no)
return 1;
continue;
if (f->stack_count == 0)
continue;
d->entries[count].once_only = f->once_only;
count = result->count++;
result->entries[count].once_only = f->once_only;
/* |= is avoided in the next line because of an HP C compiler bug */
d->have_once_only = d->have_once_only | f->once_only;
result->have_once_only = result->have_once_only | f->once_only;
if (f->buffer_valid)
md5_buffer ((const char *)f->buffer,
f->st.st_size, d->entries[count].sum);
md5_buffer ((const char *)f->buffer,
f->st.st_size, result->entries[count].sum);
else
{
FILE *ff;
......@@ -1487,48 +1502,16 @@ pchf_adder (void **slot, void *data)
if (!open_file (f))
{
open_file_failed (i->pfile, f);
return 0;
open_file_failed (pfile, f);
return false;
}
ff = fdopen (f->fd, "rb");
md5_stream (ff, d->entries[count].sum);
md5_stream (ff, result->entries[count].sum);
fclose (ff);
f->fd = oldfd;
}
d->entries[count].size = f->st.st_size;
result->entries[count].size = f->st.st_size;
}
return 1;
}
/* A qsort ordering function for pchf_entry structures. */
static int
pchf_save_compare (const void *e1, const void *e2)
{
return memcmp (e1, e2, sizeof (struct pchf_entry));
}
/* Create and write to F a pchf_data structure. */
bool
_cpp_save_file_entries (cpp_reader *pfile, FILE *f)
{
size_t count = 0;
struct pchf_data *result;
size_t result_size;
struct pchf_adder_info pai;
count = htab_elements (pfile->file_hash);
result_size = (sizeof (struct pchf_data)
+ sizeof (struct pchf_entry) * (count - 1));
result = xcalloc (result_size, 1);
result->count = 0;
result->have_once_only = false;
pai.pfile = pfile;
pai.d = result;
htab_traverse (pfile->file_hash, pchf_adder, &pai);
result_size = (sizeof (struct pchf_data)
+ sizeof (struct pchf_entry) * (result->count - 1));
......@@ -1536,7 +1519,7 @@ _cpp_save_file_entries (cpp_reader *pfile, FILE *f)
qsort (result->entries, result->count, sizeof (struct pchf_entry),
pchf_save_compare);
return fwrite (result, result_size, 1, f) == 1;
return fwrite (result, result_size, 1, fp) == 1;
}
/* Read the pchf_data structure from F. */
......
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